您好,登錄后才能下訂單哦!
本篇內容主要講解“什么是mybatis一對多處理”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“什么是mybatis一對多處理”吧!
一個機構下有多個套餐
package com.kcallme.kangkangapi.commonapi.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; import java.util.List; /** * <p> * 體檢機構 * </p> * * @author Auto-generator * @since 2021-04-14 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("k_kangkang_org") public class Org extends Model<Org> { private static final long serialVersionUID = 1L; /** * 主鍵 */ private String id; /** * 康康每個機構唯一編號 */ private String hospId; /** * 機構名稱 */ private String hospName; /** * 機構圖片 */ private String hospImage; /** * 機構logo圖片 */ @TableField(exist = false) private String hospLogoImage; /** * 溫馨提示 */ private String hospNotice; /** * 乘車信息 */ private String hospBus; /** * 機構地址 */ private String hospAddress; /** * 描述 */ private String hospDescription; /** * 工作時間 */ private String hospWorkTime; /** * 機構緯度 */ private String hospLat; /** * 機構經度 */ private String hospLng; /** * 機構類型名稱 */ private String hospRank; /** * 機構類型編號 */ private String hospRankCode; /** * 機構服務 */ private String hospService; /** * 機構所在省份編號 */ private String provenceCode; /** * 機構所在省份名稱 */ private String provenceName; /** * 機構所在城市編號 */ private String cityCode; /** * 機構所在城市名稱 */ private String cityName; /** * 機構所在區域編號 */ private String areaCode; /** * 機構所在區域名稱 */ private String areaName; /** * 1 上線 0 下線 */ private Integer isOnline; /** * 支付類型 1 在線支付 0 線下支付 */ private Integer payType; /** * 創建時間 */ private Date createTime; /** * 更新時間 */ private Date updateTime; /** * 1 刪除 0 正常 */ private Integer isDel; /** * 此機構和康康網的結算折扣 */ private Float kkzk; /** * 排期JSON */ private String scheduleK; /** * 提前幾天 */ private Integer advanceDay; /** * 套餐 */ @TableField(exist = false) private List<KPackage> packageList; /** * 根據用戶給定的經緯度計算距離 */ @TableField(exist = false) private double juli; @Override protected Serializable pkVal() { return this.id; } } package com.kcallme.kangkangapi.commonapi.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import java.io.Serializable; import java.util.Date; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; /** * <p> * 體檢套餐 * </p> * * @author Auto-generator * @since 2021-04-14 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @TableName("k_kangkang_package") public class KPackage extends Model<KPackage> { private static final long serialVersionUID = 1L; /** * 主鍵 */ private String id; /** * 套餐大類型集合 */ private String packageCat; /** * 是否為康康套餐 */ private Integer isKktc; /** * 套餐ID */ private String packageId; /** * 套餐名稱 */ private String packageName; /** * 套餐編號 */ private String packageCode; /** * 醫院編號 */ private String hospId; /** * 出售價格 */ private Integer sealPrice; /** * 原價 */ private Integer originalPrice; /** * 注意事項 */ private String attention; /** * 圖片路徑 */ private String packageImage; /** * 套餐小類型 */ private String packageType; /** * 套餐性別 1 男 2 女 0 通用 */ private Integer packageSex; /** * 檢查意義 */ private String jcyy; /** * 預約可選婚姻狀態(0 已婚 1 未婚 2 不限) */ private Integer tchyzt; /** * 套餐內容 */ private String packageContent; /** * 1 正常 */ private Integer isOnline; /** * 1 刪除 */ private Integer isDel; /** * */ private Date createTime; private Date updateTime; /** * 支付類型 1 在線支付 0 線下支付 */ private Integer payType; /** * 叩我價格 */ @TableField(exist = false) private Integer kCallMePrice; @TableField(exist = false) private Org org; @Override protected Serializable pkVal() { return this.id; } }
orgMapper.xml 定義
<mapper namespace="com.kcallme.kangkangapi.commonapi.mapper.OrgMapper"> <!-- 通用查詢映射結果 --> <resultMap id="BaseResultMap" type="com.kcallme.kangkangapi.commonapi.entity.Org"> <result column="id" property="id" /> <result column="hosp_id" property="hospId" /> <result column="hosp_name" property="hospName" /> <result column="hosp_image" property="hospImage" /> <result column="hosp_notice" property="hospNotice" /> <result column="hosp_bus" property="hospBus" /> <result column="hosp_address" property="hospAddress" /> <result column="hosp_description" property="hospDescription" /> <result column="hosp_work_time" property="hospWorkTime" /> <result column="hosp_lat" property="hospLat" /> <result column="hosp_lng" property="hospLng" /> <result column="hosp_rank" property="hospRank" /> <result column="hosp_rank_code" property="hospRankCode" /> <result column="hosp_service" property="hospService" /> <result column="provence_code" property="provenceCode" /> <result column="provence_name" property="provenceName" /> <result column="city_code" property="cityCode" /> <result column="city_name" property="cityName" /> <result column="area_code" property="areaCode" /> <result column="area_name" property="areaName" /> <result column="is_online" property="isOnline" /> <result column="pay_type" property="payType" /> <result column="create_time" property="createTime" /> <result column="update_time" property="updateTime" /> <result column="is_del" property="isDel" /> <result column="kkzk" property="kkzk" /> <result column="schedule_k" property="scheduleK" /> <result column="advance_day" property="advanceDay" /> <result column="juli" property="juli" /> <collection property="packageList" column="{hosp_id=hosp_id,packageType=packageType,sex=sex,min=min,max=max}" select="queryPackagesByHospId" javaType="ArrayList" ofType="java.util.HashMap"/> </resultMap> <resultMap id="KPackageResMap" type="com.kcallme.kangkangapi.commonapi.entity.KPackage"> <id column="k_id" property="id" /> <result column="package_type" property="packageType"/> <result column="package_name" property="packageName"/> <result column="package_code" property="packageCode"/> <result column="package_id" property="packageId"/> <result column="seal_price" property="sealPrice"/> <result column="original_price" property="originalPrice"/> <result column="package_image" property="packageImage"/> </resultMap> <select id="queryForOrgAndPackage" resultMap="BaseResultMap" parameterType="java.util.Map"> select DISTINCT(k1.hosp_id), k1.id,k1.hosp_name,k1.hosp_image,k1.hosp_address,k1.hosp_work_time,k1.hosp_lat,k1.hosp_lng,k1.hosp_rank,k1.city_code,k1.city_name,k1.area_code,k1.area_name, (st_distance(point(k1.hosp_lng,k1.hosp_lat),point(#{lng},#{lat}))*111195/1000 ) as juli, #{packageType} as packageType, #{sex} as sex , #{min} as `min`, #{max} as `max` from k_kangkang_org k1 left join k_kangkang_package k2 on k1.hosp_id = k2.hosp_id where k1.is_del=0 and k1.hosp_lat is not null and k2.is_del=0 <if test="cityCode!=null"> and k1.city_code=#{cityCode} </if> <if test="orgRank!=null"> and k1.hosp_rank=#{orgRank} </if> <if test="areaCode!=null"> and k1.area_code=#{areaCode} </if> <if test="orgId!=null"> and k1.hosp_id=#{orgId} </if> <if test="isHot!=null"> and k1.is_hot=#{isHot} </if> <if test="packageType!=null and packageType!=''"> and k2.package_type like CONCAT('%', #{packageType},'%') </if> <if test="sex!=null and sex!=''"> and k2.package_sex=#{sex} </if> <if test="min!=null and min!=''"> and k2.seal_price <![CDATA[>=]]> #{min} </if> <if test="max!=null and max!=''"> and k2.seal_price <![CDATA[<=]]> #{max} </if> order by juli asc </select> <select id="queryPackagesByHospId" parameterType="map" resultMap="KPackageResMap"> select k2.id as k_id,k2.package_type,k2.package_name,k2.package_code,k2.seal_price,k2.original_price,k2.package_image,k2.package_id from k_kangkang_package k2 where k2.is_del=0 and k2.hosp_id = #{hosp_id} <if test="packageType!=null and packageType!=''"> and k2.package_type like CONCAT('%', #{packageType},'%') </if> <if test="sex!=null and sex!=''"> and k2.package_sex=#{sex} </if> <if test="min!=null and min!=''"> and k2.seal_price <![CDATA[>=]]> #{min} </if> <if test="max!=null and max!=''"> and k2.seal_price <![CDATA[<=]]> #{max} </if> </select> </mapper>
到此,相信大家對“什么是mybatis一對多處理”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。