提交 ca73dcfd 编写于 作者: 水库浪子

标签接口重构

上级 9ace5515
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import java.util.List;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -39,36 +37,15 @@ public class WeTagGroupController extends BaseController ...@@ -39,36 +37,15 @@ public class WeTagGroupController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('wecom:group:list')") @PreAuthorize("@ss.hasPermi('wecom:group:list')")
@GetMapping("/list") @GetMapping("/list")
public AjaxResult list() public TableDataInfo list(WeTagGroup weTagGroup)
{ {
startPage();
return AjaxResult.success( return getDataTable(
weTagGroupService.selectWeTagGroupList(new WeTagGroup()) weTagGroupService.selectWeTagGroupList(weTagGroup)
); );
} }
/**
* 导出标签组列表
*/
@PreAuthorize("@ss.hasPermi('wecom:group:export')")
@Log(title = "标签组", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WeTagGroup weTagGroup)
{
List<WeTagGroup> list = weTagGroupService.selectWeTagGroupList(weTagGroup);
ExcelUtil<WeTagGroup> util = new ExcelUtil<WeTagGroup>(WeTagGroup.class);
return util.exportExcel(list, "group");
}
/**
* 获取标签组详细信息
*/
@PreAuthorize("@ss.hasPermi('wecom:group:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(weTagGroupService.selectWeTagGroupById(id));
}
/** /**
* 新增标签组 * 新增标签组
......
...@@ -26,7 +26,7 @@ public class BaseEntity implements Serializable ...@@ -26,7 +26,7 @@ public class BaseEntity implements Serializable
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime=new Date();
/** 更新者 */ /** 更新者 */
private String updateBy; private String updateBy;
......
...@@ -2,7 +2,6 @@ package com.linkwechat.wecom.mapper; ...@@ -2,7 +2,6 @@ package com.linkwechat.wecom.mapper;
import java.util.List; import java.util.List;
import com.linkwechat.wecom.domain.WeTag; import com.linkwechat.wecom.domain.WeTag;
import org.apache.ibatis.annotations.Param;
/** /**
* 企业微信标签Mapper接口 * 企业微信标签Mapper接口
...@@ -66,5 +65,13 @@ public interface WeTagMapper ...@@ -66,5 +65,13 @@ public interface WeTagMapper
* @param weTags * @param weTags
* @return * @return
*/ */
public int batchInsetWeTag(@Param("weTags") List<WeTag> weTags); public int batchInsetWeTag(List<WeTag> weTags);
/**
* 标签批量更新
* @param weTags
* @return
*/
public int batchUpdateWeTag(List<WeTag> weTags);
} }
...@@ -83,9 +83,18 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService ...@@ -83,9 +83,18 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int updateWeTagGroup(WeTagGroup weTagGroup) public int updateWeTagGroup(WeTagGroup weTagGroup)
{ {
return weTagGroupMapper.updateWeTagGroup(weTagGroup); int returnCode = weTagGroupMapper.updateWeTagGroup(weTagGroup);
if(returnCode>0){
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
weTagMapper.batchUpdateWeTag(weTags);
}
}
return returnCode;
} }
/** /**
......
...@@ -8,6 +8,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -8,6 +8,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" /> <result property="id" column="id" />
<result property="gourpName" column="gourp_name" /> <result property="gourpName" column="gourp_name" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<collection property="weTags" column="weTags.id" ofType="com.linkwechat.wecom.domain.WeTag">
<id property="id" column="tagId"/>
<result property="groupId" column="group_id" />
<result property="name" column="name" />
</collection>
</resultMap> </resultMap>
<sql id="selectWeTagGroupVo"> <sql id="selectWeTagGroupVo">
...@@ -15,10 +20,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -15,10 +20,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<select id="selectWeTagGroupList" parameterType="WeTagGroup" resultMap="WeTagGroupResult"> <select id="selectWeTagGroupList" parameterType="WeTagGroup" resultMap="WeTagGroupResult">
<include refid="selectWeTagGroupVo"/> SELECT
<where> wtg.*,
wt.id as tagId,
wt.group_id,
wt.name
FROM
we_tag_group wtg
INNER JOIN we_tag wt ON wtg.id = wt.group_id
where
wtg.status=0 and wt.status=0
<if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if> <if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if>
</where>
</select> </select>
<select id="selectWeTagGroupById" parameterType="Long" resultMap="WeTagGroupResult"> <select id="selectWeTagGroupById" parameterType="Long" resultMap="WeTagGroupResult">
...@@ -53,11 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -53,11 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from we_tag_group where id = #{id} delete from we_tag_group where id = #{id}
</delete> </delete>
<delete id="deleteWeTagGroupByIds" parameterType="String"> <update id="deleteWeTagGroupByIds" parameterType="String">
delete from we_tag_group where id in update we_tag_group set status=1
where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </update>
</mapper> </mapper>
\ No newline at end of file
...@@ -67,11 +67,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -67,11 +67,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsetWeTag" > <insert id="batchInsetWeTag" >
insert into person (id, group_id, name, create_time) insert into we_tag (id, group_id, name, create_time)
values values
<foreach collection="tags" item="tag" index="index" separator=","> <foreach collection="list" item="tag" index="index" separator=",">
(#{tag.id},#{tag.groupId},#{tag.name},#{tag.createTime}) (#{tag.id},#{tag.groupId},#{tag.name},#{tag.createTime})
</foreach> </foreach>
</insert> </insert>
<update id="batchUpdateWeTag">
update we_tag set
name=
<foreach collection="list" item="tag" index="index"
separator=" " open="case id" close="end">
when #{tag.id} then #{tag.name}
</foreach>
,status=
<foreach collection="list" item="tag" index="index"
separator=" " open="case id" close="end">
when #{tag.id} then #{tag.status}
</foreach>
where id in
<foreach collection="list" item="tag" index="index"
separator="," open="(" close=")">
#{tag.id}
</foreach>
</update>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册