|
|
@@ -8,11 +8,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="tagId" column="tag_id" />
|
|
|
<result property="companyId" column="company_id" />
|
|
|
<result property="tag" column="tag" />
|
|
|
+ <result property="status" column="status" />
|
|
|
+ <result property="tagType" column="tag_type" />
|
|
|
<result property="createTime" column="create_time" />
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectCompanyTagVo">
|
|
|
- select tag_id, company_id, tag, create_time from company_tag
|
|
|
+ select tag_id, company_id, tag, status, tag_type, create_time from company_tag
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectCompanyTagList" parameterType="CompanyTag" resultMap="CompanyTagResult">
|
|
|
@@ -20,6 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<where>
|
|
|
<if test="companyId != null "> and company_id = #{companyId}</if>
|
|
|
<if test="tag != null and tag != ''"> and tag = #{tag}</if>
|
|
|
+ <if test="status != null "> and status = #{status}</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
@@ -98,11 +101,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="companyId != null">company_id,</if>
|
|
|
<if test="tag != null">tag,</if>
|
|
|
+ <if test="status != null">status,</if>
|
|
|
+ <if test="tagType != null">tag_type,</if>
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="companyId != null">#{companyId},</if>
|
|
|
<if test="tag != null">#{tag},</if>
|
|
|
+ <if test="status != null">#{status},</if>
|
|
|
+ <if test="tagType != null">#{tagType},</if>
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
</trim>
|
|
|
</insert>
|
|
|
@@ -112,6 +119,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="companyId != null">company_id = #{companyId},</if>
|
|
|
<if test="tag != null">tag = #{tag},</if>
|
|
|
+ <if test="status != null">status = #{status},</if>
|
|
|
+ <if test="tagType != null">tag_type = #{tagType},</if>
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
</trim>
|
|
|
where tag_id = #{tagId}
|
|
|
@@ -128,4 +137,169 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</foreach>
|
|
|
</delete>
|
|
|
|
|
|
+ <select id="selectCompanyTagManageList" resultType="com.fs.company.vo.CompanyTagManageVO">
|
|
|
+ select
|
|
|
+ ct.tag_id as tagId,
|
|
|
+ ct.tag as tagName,
|
|
|
+ ifnull(ct.status, 0) as status,
|
|
|
+ ifnull(ct.tag_type, 0) as tagType,
|
|
|
+ ct.create_time as createTime,
|
|
|
+ (
|
|
|
+ select count(distinct upt_count.user_company_user_id)
|
|
|
+ from fs_user_project_tag upt_count
|
|
|
+ inner join fs_user_company_user fucu_count on fucu_count.id = upt_count.user_company_user_id
|
|
|
+ inner join fs_user fu_count on fu_count.user_id = fucu_count.user_id and fu_count.is_del = 0
|
|
|
+ where upt_count.tag_id = ct.tag_id
|
|
|
+ <if test="param.companyId != null">
|
|
|
+ and fucu_count.company_id = #{param.companyId}
|
|
|
+ </if>
|
|
|
+ ) as userCount,
|
|
|
+ (
|
|
|
+ select group_concat(distinct cu_name.nick_name order by cu_name.nick_name separator ',')
|
|
|
+ from fs_user_project_tag upt_name
|
|
|
+ inner join fs_user_company_user fucu_name on fucu_name.id = upt_name.user_company_user_id
|
|
|
+ inner join fs_user fu_name on fu_name.user_id = fucu_name.user_id and fu_name.is_del = 0
|
|
|
+ left join company_user cu_name on cu_name.user_id = fucu_name.company_user_id
|
|
|
+ where upt_name.tag_id = ct.tag_id
|
|
|
+ <if test="param.companyId != null">
|
|
|
+ and fucu_name.company_id = #{param.companyId}
|
|
|
+ </if>
|
|
|
+ ) as companyUserNames,
|
|
|
+ case when count(upt.id) = 0 then true else false end as canDelete
|
|
|
+ from company_tag ct
|
|
|
+ left join fs_user_project_tag upt on upt.tag_id = ct.tag_id
|
|
|
+ left join fs_user_company_user fucu on fucu.id = upt.user_company_user_id
|
|
|
+ left join company_user cu on cu.user_id = fucu.company_user_id
|
|
|
+ <where>
|
|
|
+ <if test="param.companyId != null">
|
|
|
+ and ct.company_id = #{param.companyId}
|
|
|
+ </if>
|
|
|
+ <if test="param.tagName != null and param.tagName != ''">
|
|
|
+ and ct.tag like concat('%', #{param.tagName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="param.status != null">
|
|
|
+ and ifnull(ct.status, 0) = #{param.status}
|
|
|
+ </if>
|
|
|
+ <if test="param.projectId != null">
|
|
|
+ and fucu.project_id = #{param.projectId}
|
|
|
+ </if>
|
|
|
+ <if test="param.employeeName != null and param.employeeName != ''">
|
|
|
+ and cu.nick_name like concat('%', #{param.employeeName}, '%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ group by ct.tag_id
|
|
|
+ order by ct.create_time desc, ct.tag_id desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="countCompanyTagUsed" resultType="int">
|
|
|
+ select count(1)
|
|
|
+ from fs_user_project_tag upt
|
|
|
+ inner join fs_user_company_user fucu on fucu.id = upt.user_company_user_id
|
|
|
+ where upt.tag_id = #{tagId}
|
|
|
+ <if test="companyId != null">
|
|
|
+ and fucu.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectCompanyTagMemberExportList" resultType="com.fs.store.vo.h5.FsUserPageListExportVO">
|
|
|
+ select
|
|
|
+ fu.user_id as userId,
|
|
|
+ fucu.project_id as projectId,
|
|
|
+ fu.nick_name as nickname,
|
|
|
+ fu.phone as phone,
|
|
|
+ fcc.watch_course_count as watchCourseCount,
|
|
|
+ fcc.miss_course_count as missCourseCount,
|
|
|
+ fcc.part_course_count as partCourseCount,
|
|
|
+ fucu.status as status,
|
|
|
+ fcc.status as courseCountStatus,
|
|
|
+ tag_names.tag as tag,
|
|
|
+ fcc.last_watch_date as lastWatchDate,
|
|
|
+ fucu.update_time as createTime,
|
|
|
+ fucu.remark as remark,
|
|
|
+ cu.nick_name as companyUserNickName,
|
|
|
+ fu.integral as integral,
|
|
|
+ if(fu.pay_count > 0, 1, 0) as isBuy,
|
|
|
+ fu.source as source,
|
|
|
+ fu.login_device as loginDevice,
|
|
|
+ fu.app_create_time as appCreateTime,
|
|
|
+ case when (fu.app_create_time is not null or fu.source is not null and fu.source != '' or fu.login_device is not null and fu.login_device != '') then 1 else 0 end as isDownloadApp
|
|
|
+ from (select distinct user_company_user_id from fs_user_project_tag where tag_id = #{tagId}) upt
|
|
|
+ inner join fs_user_company_user fucu on fucu.id = upt.user_company_user_id
|
|
|
+ inner join fs_user fu on fu.user_id = fucu.user_id and fu.is_del = 0
|
|
|
+ left join company_user cu on cu.user_id = fucu.company_user_id
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ user_id,
|
|
|
+ project_id,
|
|
|
+ max(watch_course_count) as watch_course_count,
|
|
|
+ max(miss_course_count) as miss_course_count,
|
|
|
+ max(part_course_count) as part_course_count,
|
|
|
+ max(status) as status,
|
|
|
+ max(last_watch_date) as last_watch_date
|
|
|
+ from fs_user_course_count
|
|
|
+ group by user_id, project_id
|
|
|
+ ) fcc on fcc.user_id = fucu.user_id and fcc.project_id = fucu.project_id
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ upt_inner.user_company_user_id,
|
|
|
+ group_concat(ct.tag order by ct.tag_id separator ',') as tag
|
|
|
+ from fs_user_project_tag upt_inner
|
|
|
+ inner join company_tag ct on ct.tag_id = upt_inner.tag_id
|
|
|
+ group by upt_inner.user_company_user_id
|
|
|
+ ) tag_names on tag_names.user_company_user_id = fucu.id
|
|
|
+ where 1 = 1
|
|
|
+ <if test="companyId != null">
|
|
|
+ and fucu.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ order by fucu.update_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectCompanyTagMemberList" resultType="com.fs.store.vo.h5.FsUserPageListExportVO">
|
|
|
+ select
|
|
|
+ fu.user_id as userId,
|
|
|
+ fucu.project_id as projectId,
|
|
|
+ fu.nick_name as nickname,
|
|
|
+ fu.phone as phone,
|
|
|
+ fucu.status as status,
|
|
|
+ tag_names.tag as tag,
|
|
|
+ fucu.update_time as createTime,
|
|
|
+ fucu.remark as remark,
|
|
|
+ cu.nick_name as companyUserNickName,
|
|
|
+ fu.integral as integral,
|
|
|
+ if(fu.pay_count > 0, 1, 0) as isBuy,
|
|
|
+ fu.source as source,
|
|
|
+ fu.login_device as loginDevice,
|
|
|
+ fu.app_create_time as appCreateTime,
|
|
|
+ case when (fu.app_create_time is not null or fu.source is not null and fu.source != '' or fu.login_device is not null and fu.login_device != '') then 1 else 0 end as isDownloadApp
|
|
|
+ from (select distinct user_company_user_id from fs_user_project_tag where tag_id = #{tagId}) upt
|
|
|
+ inner join fs_user_company_user fucu on fucu.id = upt.user_company_user_id
|
|
|
+ inner join fs_user fu on fu.user_id = fucu.user_id and fu.is_del = 0
|
|
|
+ left join company_user cu on cu.user_id = fucu.company_user_id
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ upt_inner.user_company_user_id,
|
|
|
+ group_concat(ct.tag order by ct.tag_id separator ',') as tag
|
|
|
+ from fs_user_project_tag upt_inner
|
|
|
+ inner join company_tag ct on ct.tag_id = upt_inner.tag_id
|
|
|
+ group by upt_inner.user_company_user_id
|
|
|
+ ) tag_names on tag_names.user_company_user_id = fucu.id
|
|
|
+ where 1 = 1
|
|
|
+ <if test="companyId != null">
|
|
|
+ and fucu.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ order by fucu.update_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectEnabledTagIds" resultType="java.lang.Long">
|
|
|
+ select tag_id
|
|
|
+ from company_tag
|
|
|
+ where ifnull(status, 0) = 0
|
|
|
+ <if test="tagIds != null and tagIds.size() > 0">
|
|
|
+ and tag_id in
|
|
|
+ <foreach item="tagId" collection="tagIds" open="(" separator="," close=")">
|
|
|
+ #{tagId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|