Commit b246f1cf by danmo

员工活码列表查询sql调整,添加条件查询

1 parent 67e6bec0
...@@ -59,5 +59,11 @@ public class WeEmpleCode extends BaseEntity ...@@ -59,5 +59,11 @@ public class WeEmpleCode extends BaseEntity
/** 二维码链接 */ /** 二维码链接 */
private String qrCode; private String qrCode;
/** 使用员工姓名 */
@TableField(exist = false)
private String useUserName;
/** 使用员工手机号 */
@TableField(exist = false)
private String mobile;
} }
...@@ -39,8 +39,7 @@ public class WeEmpleCodeUseScop ...@@ -39,8 +39,7 @@ public class WeEmpleCodeUseScop
private Integer delFlag=new Integer(0); private Integer delFlag=new Integer(0);
/** 活码使用人员名称 */ /** 活码使用人员名称 */
@TableField(exist = false) private String businessName;
private String userUserName;
/** 活码使用人员手机号 */ /** 活码使用人员手机号 */
@TableField(exist = false) @TableField(exist = false)
......
...@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 员工活码Service业务层处理 * 员工活码Service业务层处理
...@@ -55,7 +56,21 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp ...@@ -55,7 +56,21 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
*/ */
@Override @Override
public List<WeEmpleCode> selectWeEmpleCodeList(WeEmpleCode weEmpleCode) { public List<WeEmpleCode> selectWeEmpleCodeList(WeEmpleCode weEmpleCode) {
return this.baseMapper.selectWeEmpleCodeList(weEmpleCode); List<WeEmpleCode> weEmpleCodeList = this.baseMapper.selectWeEmpleCodeList(weEmpleCode);
if (weEmpleCodeList !=null){
weEmpleCodeList.forEach(empleCode ->{
List<WeEmpleCodeUseScop> weEmpleCodeUseScopList = empleCode.getWeEmpleCodeUseScops();
if (CollectionUtil.isNotEmpty(weEmpleCodeUseScopList)){
String useUserName = weEmpleCodeUseScopList.stream().map(WeEmpleCodeUseScop::getBusinessName)
.collect(Collectors.joining(","));
empleCode.setUseUserName(useUserName);
String mobile = weEmpleCodeUseScopList.stream().map(WeEmpleCodeUseScop::getMobile)
.collect(Collectors.joining(","));
empleCode.setMobile(mobile);
}
});
}
return weEmpleCodeList;
} }
/** /**
......
...@@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="qrCode" column="qr_code" /> <result property="qrCode" column="qr_code" />
<collection property="weEmpleCodeUseScops" ofType="com.linkwechat.wecom.domain.WeEmpleCodeUseScop"> <collection property="weEmpleCodeUseScops" ofType="com.linkwechat.wecom.domain.WeEmpleCodeUseScop">
<result property="businessId" column="business_id" /> <result property="businessId" column="business_id" />
<result property="userUserName" column="user_name" /> <result property="businessName" column="business_ame" />
<result property="mobile" column="mobile" /> <result property="mobile" column="mobile" />
</collection> </collection>
<collection property="weEmpleCodeTags" ofType="com.linkwechat.wecom.domain.WeEmpleCodeTag"> <collection property="weEmpleCodeTags" ofType="com.linkwechat.wecom.domain.WeEmpleCodeTag">
...@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wecode.config_id, wecode.config_id,
wecode.qr_code, wecode.qr_code,
wecusn.business_id, wecusn.business_id,
wecusn.user_name, wecusn.business_name,
wecusn.mobile, wecusn.mobile,
wect.tag_id, wect.tag_id,
wect.tag_name wect.tag_name
...@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
we_emple_code wecode we_emple_code wecode
left join ( left join (
SELECT SELECT
wecus.emple_code_id, wecus.business_id, wu.user_name,wu.mobile wecus.emple_code_id, wecus.business_id, wecus.business_name,wu.mobile
FROM FROM
we_emple_code_use_scop wecus we_emple_code_use_scop wecus
LEFT JOIN we_user wu ON LEFT JOIN we_user wu ON
...@@ -66,11 +66,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -66,11 +66,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWeEmpleCodeList" parameterType="WeEmpleCode" resultMap="WeEmpleCodeResult"> <select id="selectWeEmpleCodeList" parameterType="WeEmpleCode" resultMap="WeEmpleCodeResult">
<include refid="selectWeEmpleCodeLsit"/> <include refid="selectWeEmpleCodeLsit"/>
<where> <where>
<if test="codeType != null "> and code_type = #{codeType}</if> <if test="codeType != null "> and wecode.code_type = #{codeType}</if>
<if test="isJoinConfirmFriends != null "> and is_join_confirm_friends = #{isJoinConfirmFriends}</if> <if test="isJoinConfirmFriends != null "> and wecode.is_join_confirm_friends = #{isJoinConfirmFriends}</if>
<if test="activityScene != null and activityScene != ''"> and activity_scene = #{activityScene}</if> <if test="activityScene != null and activityScene != ''">
<if test="welcomeMsg != null "> and welcome_msg = #{welcomeMsg}</if> and wecode.activity_scene like concat('%', #{activityScene}, '%')
</if>
<if test="welcomeMsg != null "> and wecode.welcome_msg = #{welcomeMsg}</if>
<if test="createBy != null and createBy !=''">
AND wecode.create_by like concat('%', #{createBy}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wecode.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wecode.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
<if test="mobile != null and mobile !=''">
AND wecusn.mobile like concat('%', #{mobile}, '%')
</if>
<if test="useUserName != null and useUserName !=''">
AND wecusn.business_name like concat('%', #{useUserName}, '%')
</if>
</where> </where>
</select> </select>
......
...@@ -9,7 +9,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -9,7 +9,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="empleCodeId" column="emple_code_id" /> <result property="empleCodeId" column="emple_code_id" />
<result property="businessId" column="business_id" /> <result property="businessId" column="business_id" />
<result property="delFlag" column="del_flag" /> <result property="delFlag" column="del_flag" />
<result property="userUserName" column="user_name"/> <result property="businessName" column="business_name"/>
<result property="mobile" column="mobile"/>
</resultMap> </resultMap>
<sql id="selectWeEmpleCodeUseScopVo"> <sql id="selectWeEmpleCodeUseScopVo">
...@@ -18,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -18,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWeEmpleCodeUseScopListById" parameterType="Long" resultMap="WeEmpleCodeUseScopResult"> <select id="selectWeEmpleCodeUseScopListById" parameterType="Long" resultMap="WeEmpleCodeUseScopResult">
SELECT SELECT
wecus.id, wecus.emple_code_id,wecus.business_id,wu.user_name wecus.id, wecus.emple_code_id,wecus.business_id,wecus.business_name,wu.mobile
FROM FROM
we_emple_code_use_scop wecus we_emple_code_use_scop wecus
LEFT JOIN we_user wu ON wu.user_id = wecus.business_id LEFT JOIN we_user wu ON wu.user_id = wecus.business_id
...@@ -38,12 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -38,12 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="id != null">id,</if> <if test="id != null">id,</if>
<if test="empleCodeId != null">emple_code_id,</if> <if test="empleCodeId != null">emple_code_id,</if>
<if test="businessId != null">business_id,</if> <if test="businessId != null">business_id,</if>
<if test="businessName != null">business_name,</if>
<if test="delFlag != null">del_flag,</if> <if test="delFlag != null">del_flag,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
<if test="empleCodeId != null">#{empleCodeId},</if> <if test="empleCodeId != null">#{empleCodeId},</if>
<if test="businessId != null">#{businessId},</if> <if test="businessId != null">#{businessId},</if>
<if test="businessName != null">#{businessName},</if>
<if test="delFlag != null">#{delFlag},</if> <if test="delFlag != null">#{delFlag},</if>
</trim> </trim>
</insert> </insert>
...@@ -53,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -53,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="empleCodeId != null">emple_code_id = #{empleCodeId},</if> <if test="empleCodeId != null">emple_code_id = #{empleCodeId},</if>
<if test="businessId != null">business_id = #{businessId},</if> <if test="businessId != null">business_id = #{businessId},</if>
<if test="businessName != null">business_name = #{businessName},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if> <if test="delFlag != null">del_flag = #{delFlag},</if>
</trim> </trim>
where id = #{id} where id = #{id}
...@@ -70,10 +74,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -70,10 +74,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<insert id="batchInsetWeEmpleCodeUseScop"> <insert id="batchInsetWeEmpleCodeUseScop">
insert into we_emple_code_use_scop (id,emple_code_id,business_id,del_flag) insert into we_emple_code_use_scop (id,emple_code_id,business_id,business_name,del_flag)
values values
<foreach collection="weEmpleCodeUseScops" item="scop" index="index" separator=","> <foreach collection="weEmpleCodeUseScops" item="scop" index="index" separator=",">
(#{scop.id},#{scop.empleCodeId},#{scop.businessId},#{scop.delFlag}) (#{scop.id},#{scop.empleCodeId},#{scop.businessId},#{scop.businessName},#{scop.delFlag})
</foreach> </foreach>
</insert> </insert>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!