Commit eb28b23b by 徐高华

修改链接

parent f3797a47
......@@ -2,6 +2,9 @@ package com.gic.haoban.manage.service.dao.mapper.hm;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO;
import com.gic.haoban.manage.service.entity.hm.TabHmLinkChat;
/**
......@@ -14,52 +17,13 @@ import com.gic.haoban.manage.service.entity.hm.TabHmLinkChat;
* @CopyRight
*/
public interface HmLinkChatMapper {
/**
* 新增
* @Title: insert
* @Description: TODO
* @Param @param TabHaobanHmLinkChat
*/
public int insert(TabHmLinkChat tabHaobanHmLinkChat) ;
/**
* 通过主键删除
* @Title: delete
* @Description: TODO
* @Param @param id
* @Throws
*/
public int deleteByPrimaryKey(Long linkChatId) ;
/**
* 更新
* @Title: update
* @Description: TODO
* @Param @param TabHaobanHmLinkChat
* @Throws
*/
public int updateByPrimaryKey(TabHmLinkChat tabHaobanHmLinkChat) ;
/**
* 通过主键查询
* @Title: selectById
* @Description: TODO
* @Param @param id
* @Param @return
* @Return TabHaobanHmLinkChat
* @Throws
*/
public TabHmLinkChat selectByPrimaryKey(Long linkChatId) ;
/**
* 通过条件查询
* @Title: listAll
* @Description: TODO
* @Param @param TabHaobanHmLinkChat
* @Param @return
* @Return List
* @Throws
*/
public List<TabHmLinkChat> listAll(TabHmLinkChat tabHaobanHmLinkChat) ;
public int insert(TabHmLinkChat tabHaobanHmLinkChat);
public int delete(@Param("linkId") Long linkId, @Param("idList") List<Long> idList);
public int update(TabHmLinkChat entity);
public List<HmLinkChatDTO> listByLinkId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId, @Param("linkId") Long linkId);
}
\ No newline at end of file
package com.gic.haoban.manage.service.service.hm.impl;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO;
import com.gic.haoban.manage.service.dao.mapper.hm.HmLinkChatMapper;
import com.gic.haoban.manage.service.entity.hm.TabHmLinkChat;
import com.gic.haoban.manage.service.service.hm.HmLinkChatService;
@Service("hmLinkChatService")
public class HmLinkChatServiceImpl implements HmLinkChatService{
public class HmLinkChatServiceImpl implements HmLinkChatService {
@Autowired
private HmLinkChatMapper hmLinkChatMapper;
@Override
public List<HmLinkChatDTO> listByLinkId(String wxEnterpriseId, String enterpriseId, Long linkId) {
// TODO Auto-generated method stub
return null;
return this.hmLinkChatMapper.listByLinkId(wxEnterpriseId, enterpriseId, linkId);
}
@Override
public int save(Long linkId, List<HmLinkChatDTO> list) {
List<HmLinkChatDTO> updateList = list.stream().filter(dto -> null != dto.getChatHmId())
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(updateList)) {
List<Long> notDelIdList = updateList.stream().map(dto -> dto.getChatHmId()).collect(Collectors.toList());
this.hmLinkChatMapper.delete(linkId, notDelIdList);
for (HmLinkChatDTO item : updateList) {
TabHmLinkChat entity = EntityUtil.changeEntityByJSON(TabHmLinkChat.class, item);
this.hmLinkChatMapper.update(entity);
}
}
List<HmLinkChatDTO> addList = list.stream().filter(dto -> null != dto.getChatHmId())
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(addList)) {
for (HmLinkChatDTO dto : addList) {
TabHmLinkChat entity = EntityUtil.changeEntityByJSON(TabHmLinkChat.class, dto);
entity.setChatHmId(UniqueIdUtils.uniqueLong());
this.hmLinkChatMapper.insert(entity);
}
}
return 0;
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.hm.HmLinkChatMapper">
<resultMap type="com.gic.haoban.manage.service.entity.hm.TabHmLinkChat" id="result-map-tabHaobanHmLinkChat">
<result column="link_chat_id" property="linkChatId"/>
<result column="wx_enterprise_id" property="wxEnterpriseId"/>
<result column="filter_json" property="filterJson"/>
<result column="chat_hm_id" property="chatHmId"/>
<result column="enterprise_id" property="enterpriseId"/>
<result column="member_type" property="memberType"/>
<result column="sort_num" property="sortNum"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="delete_flag" property="deleteFlag"/>
</resultMap>
<sql id="Base_Column_List">
link_chat_id,
wx_enterprise_id,
filter_json,
chat_hm_id,
enterprise_id,
member_type,
sort_num,
create_time,
update_time,
delete_flag
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLinkChat" useGeneratedKeys="true" keyProperty="id">
<![CDATA[
INSERT INTO tab_haoban_hm_link_chat(
link_chat_id,
wx_enterprise_id,
filter_json,
chat_hm_id,
enterprise_id,
member_type,
sort_num,
create_time,
update_time,
delete_flag
)VALUES(
#{linkChatId,jdbcType=BIGINT},
#{wxEnterpriseId,jdbcType=CHAR},
#{filterJson,jdbcType=VARCHAR},
#{chatHmId,jdbcType=BIGINT},
#{enterpriseId,jdbcType=CHAR},
#{memberType,jdbcType=INTEGER},
#{sortNum,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},
#{deleteFlag,jdbcType=INTEGER}
)
]]>
</insert>
<!-- =====================删除==================== -->
<delete id="deleteByPrimaryKey" parameterType="long">
UPDATE tab_haoban_hm_link_chat SET delete_flag = 1 WHERE link_chat_id = #{linkChatId}
</delete>
<!-- ==================更新 ========== -->
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLinkChat">
<![CDATA[
UPDATE tab_haoban_hm_link_chat SET
link_chat_id=#{linkChatId,jdbcType=BIGINT},
wx_enterprise_id=#{wxEnterpriseId,jdbcType=CHAR},
filter_json=#{filterJson,jdbcType=VARCHAR},
chat_hm_id=#{chatHmId,jdbcType=BIGINT},
enterprise_id=#{enterpriseId,jdbcType=CHAR},
member_type=#{memberType,jdbcType=INTEGER},
sort_num=#{sortNum,jdbcType=INTEGER},
create_time=#{createTime,jdbcType=TIMESTAMP},
update_time=#{updateTime,jdbcType=TIMESTAMP},
delete_flag=#{deleteFlag,jdbcType=INTEGER}
link_chat_id = #{linkChatId}
]]>
</update>
<!-- ============ 查询=============-->
<select id="selectById" parameterType="long" resultMap="result-map-tabHaobanHmLinkChat">
SELECT * FROM tab_haoban_hm_link_chat WHERE link_chat_id = #{linkChatId}
</select>
<select id="listAll" parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLinkChat" resultMap="result-map-tabHaobanHmLinkChat">
select * from tab_haoban_hm_link_chat
</select>
<resultMap type="com.gic.haoban.manage.service.entity.hm.TabHmLinkChat"
id="result-map-tabHaobanHmLinkChat">
<result column="link_chat_id" property="linkChatId" />
<result column="wx_enterprise_id" property="wxEnterpriseId" />
<result column="filter_json" property="filterJson" />
<result column="chat_hm_id" property="chatHmId" />
<result column="enterprise_id" property="enterpriseId" />
<result column="member_type" property="memberType" />
<result column="sort_num" property="sortNum" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="delete_flag" property="deleteFlag" />
<result column="link_id" property="linkId" />
</resultMap>
<sql id="Base_Column_List">
link_chat_id,
wx_enterprise_id,
filter_json,
chat_hm_id,
enterprise_id,
member_type,
sort_num,
create_time,
update_time,
delete_flag , link_id
</sql>
<!-- ===================== 新增 ======================== -->
<insert id="insert"
parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLinkChat">
<![CDATA[
INSERT INTO tab_haoban_hm_link_chat(
link_chat_id,
wx_enterprise_id,
filter_json,
chat_hm_id,
enterprise_id,
member_type,
sort_num,
create_time,
update_time,
delete_flag , link_id
)VALUES(
#{linkChatId},
#{wxEnterpriseId},
#{filterJson},
#{chatHmId},
#{enterpriseId},
#{memberType},
#{sortNum},
now(),
now(),
0 ,
#{linkId}
)
]]>
</insert>
<!-- =====================删除==================== -->
<update id="delete">
UPDATE tab_haoban_hm_link_chat SET delete_flag = 1 WHERE link_id =
{linkId}
<if test="null != idList and idList.size > 0">
and link_chat_id in
<foreach collection="idList" item="item" separator="," index="index"
close=")" open="(">
#{item}
</foreach>
</if>
</update>
<!-- ==================更新 ========== -->
<update id="update"
parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLinkChat">
<![CDATA[
UPDATE tab_haoban_hm_link_chat SET
filter_json=#{filterJson},
chat_hm_id=#{chatHmId},
member_type=#{memberType},
sort_num=#{sortNum},
update_time=now()
where link_chat_id = #{linkChatId}
]]>
</update>
<select id="listByLinkId" resultType="com.gic.haoban.manage.api.dto.hm.HmLinkChatDTO">
select
link_chat_id hmChatId ,
filter_json filter_json ,
chat_hm_id chat_hm_id,
member_type memberType
from tab_haoban_hm_link_chat where link_id = #{linkId} and wx_enterprise_id = #{wxEnterpriseId} and enterprise_id = #{enterpriseId}
</select>
</mapper>
\ No newline at end of file
......@@ -160,17 +160,23 @@ public class HmLinkController {
if(StringUtils.isEmpty(dto.getName())) {
return RestResponse.failure("9999", "链接名称不能为空") ;
}
if(StringUtils.isEmpty(dto.getMemberLabelId())) {
return RestResponse.failure("9999", "链接标签不能为空") ;
}
if(null == dto.getPageId()) {
return RestResponse.failure("9999", "请选择落地页模板") ;
}
if(null == dto.getLinkType()) {
return RestResponse.failure("9999", "请选择链接类型") ;
}
if(StringUtils.isEmpty(dto.getStoreRuleJson()) || StringUtils.isEmpty(dto.getCustomRuleJson())) {
return RestResponse.failure("9999", "请选择分配规则") ;
if(dto.getLinkType()==HmLinkTypeEnum.CHAT_HM_LINK_TYPE.getLinkType()) {
if(null == dto.getOtherChatHmId()) {
return RestResponse.failure("9999", "其他可入群不能为空") ;
}
}else {
if(StringUtils.isEmpty(dto.getMemberLabelId())) {
return RestResponse.failure("9999", "链接标签不能为空") ;
}
if(null == dto.getLinkType()) {
return RestResponse.failure("9999", "请选择链接类型") ;
}
if(StringUtils.isEmpty(dto.getStoreRuleJson()) || StringUtils.isEmpty(dto.getCustomRuleJson())) {
return RestResponse.failure("9999", "请选择分配规则") ;
}
}
return RestResponse.successResult() ;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment