您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇内容主要讲解“什么是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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。