Commit 1d11aa68 by 徐高华

链接

parent 2c400c28
...@@ -2,6 +2,8 @@ package com.gic.haoban.manage.service.dao.mapper.hm; ...@@ -2,6 +2,8 @@ package com.gic.haoban.manage.service.dao.mapper.hm;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.hm.TabHmLink; import com.gic.haoban.manage.service.entity.hm.TabHmLink;
/** /**
...@@ -15,12 +17,6 @@ import com.gic.haoban.manage.service.entity.hm.TabHmLink; ...@@ -15,12 +17,6 @@ import com.gic.haoban.manage.service.entity.hm.TabHmLink;
*/ */
public interface HmLinkMapper { public interface HmLinkMapper {
/**
* 新增
* @Title: insert
* @Description: TODO
* @Param @param TabHaobanHmLink
*/
public int insert(TabHmLink link); public int insert(TabHmLink link);
/** /**
...@@ -30,7 +26,7 @@ public interface HmLinkMapper { ...@@ -30,7 +26,7 @@ public interface HmLinkMapper {
* @Param @param TabHaobanHmLink * @Param @param TabHaobanHmLink
* @Throws * @Throws
*/ */
public int updateByPrimaryKey(TabHmLink tabHaobanHmLink); public int update(TabHmLink link);
/** /**
* 通过主键查询 * 通过主键查询
...@@ -43,14 +39,6 @@ public interface HmLinkMapper { ...@@ -43,14 +39,6 @@ public interface HmLinkMapper {
*/ */
public TabHmLink selectById(Long linkId); public TabHmLink selectById(Long linkId);
/** public List<TabHmLink> listForSms(@Param("wxEnterpriseId") String wxEnterpriseId,
* 通过条件查询 @Param("enterpriseId") String enterpriseId, @Param("linkName") String linkName);
* @Title: listAll
* @Description: TODO
* @Param @param TabHaobanHmLink
* @Param @return
* @Return List
* @Throws
*/
public List<TabHmLink> listAll(TabHmLink tabHaobanHmLink);
} }
\ No newline at end of file
...@@ -9,9 +9,9 @@ import com.gic.haoban.manage.service.entity.hm.TabHmLink; ...@@ -9,9 +9,9 @@ import com.gic.haoban.manage.service.entity.hm.TabHmLink;
public interface HmLinkService { public interface HmLinkService {
public TabHmLink getByLinkId(Long linkId); public TabHmLink getByLinkId(Long linkId);
public List<HmLinkDTO> listForSms(String wxEnterpriseId, String enterprieId) ;
public HmLinkDTO saveLink(HmLinkDTO dto , List<HmLinkStoreDTO> stoerList); public List<HmLinkDTO> listForSms(String wxEnterpriseId, String enterprieId, String linkName);
public HmLinkDTO saveLink(HmLinkDTO dto, List<HmLinkStoreDTO> stoerList);
} }
package com.gic.haoban.manage.service.service.hm.impl; package com.gic.haoban.manage.service.service.hm.impl;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -22,7 +20,6 @@ public class HmLinkServiceImpl implements HmLinkService { ...@@ -22,7 +20,6 @@ public class HmLinkServiceImpl implements HmLinkService {
@Autowired @Autowired
private HmLinkMapper linkMapper; private HmLinkMapper linkMapper;
@Autowired @Autowired
private HmLinkStoreService hmLinkStoreService; private HmLinkStoreService hmLinkStoreService;
...@@ -30,11 +27,11 @@ public class HmLinkServiceImpl implements HmLinkService { ...@@ -30,11 +27,11 @@ public class HmLinkServiceImpl implements HmLinkService {
public TabHmLink getByLinkId(Long linkId) { public TabHmLink getByLinkId(Long linkId) {
return this.linkMapper.selectById(linkId); return this.linkMapper.selectById(linkId);
} }
@Override @Override
public List<HmLinkDTO> listForSms(String wxEnterpriseId, String enterprieId) { public List<HmLinkDTO> listForSms(String wxEnterpriseId, String enterpriseId, String linkName) {
// TODO Auto-generated method stub List<TabHmLink> list = this.linkMapper.listForSms(wxEnterpriseId, enterpriseId, linkName);
return null; return EntityUtil.changeEntityListByJSON(HmLinkDTO.class, list);
} }
@Override @Override
...@@ -42,19 +39,16 @@ public class HmLinkServiceImpl implements HmLinkService { ...@@ -42,19 +39,16 @@ public class HmLinkServiceImpl implements HmLinkService {
public HmLinkDTO saveLink(HmLinkDTO dto, List<HmLinkStoreDTO> storeList) { public HmLinkDTO saveLink(HmLinkDTO dto, List<HmLinkStoreDTO> storeList) {
// 新增 // 新增
Long linkId = dto.getLinkId(); Long linkId = dto.getLinkId();
TabHmLink entity = EntityUtil.changeEntityByJSON(TabHmLink.class, dto);
if (null == linkId) { if (null == linkId) {
linkId = UniqueIdUtils.uniqueLong(); linkId = UniqueIdUtils.uniqueLong();
dto.setLinkId(linkId);
StringBuilder sb = new StringBuilder("LJ").append("0").append(dto.getLinkType()).append(linkId); StringBuilder sb = new StringBuilder("LJ").append("0").append(dto.getLinkType()).append(linkId);
dto.setLinkId(linkId);
dto.setLinkCode(sb.toString()); dto.setLinkCode(sb.toString());
dto.setStatusFlag(1); dto.setStatusFlag(1);
Date now = new Date();
dto.setCreateTime(now);
dto.setUpdateTime(now);
TabHmLink entity = EntityUtil.changeEntityByJSON(TabHmLink.class, dto);
this.linkMapper.insert(entity); this.linkMapper.insert(entity);
} else { } else {
this.linkMapper.update(entity);
} }
this.hmLinkStoreService.saveStore(linkId, storeList); this.hmLinkStoreService.saveStore(linkId, storeList);
return dto; return dto;
......
package com.gic.haoban.manage.service.service.hm.impl; package com.gic.haoban.manage.service.service.hm.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;import java.util.stream.Collector; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
...@@ -32,6 +33,7 @@ public class HmLinkStoreServiceImpl implements HmLinkStoreService { ...@@ -32,6 +33,7 @@ public class HmLinkStoreServiceImpl implements HmLinkStoreService {
} }
@Override @Override
@Transactional
public int saveStore(Long linkId, List<HmLinkStoreDTO> thisList) { public int saveStore(Long linkId, List<HmLinkStoreDTO> thisList) {
if (CollectionUtils.isEmpty(thisList)) { if (CollectionUtils.isEmpty(thisList)) {
this.hmLinkStoreMapper.deleteByLinkId(linkId); this.hmLinkStoreMapper.deleteByLinkId(linkId);
...@@ -51,13 +53,13 @@ public class HmLinkStoreServiceImpl implements HmLinkStoreService { ...@@ -51,13 +53,13 @@ public class HmLinkStoreServiceImpl implements HmLinkStoreService {
addList.add(EntityUtil.changeEntityByJSON(TabHmLinkStore.class, dto)); addList.add(EntityUtil.changeEntityByJSON(TabHmLinkStore.class, dto));
} }
} }
List<String> thisStoreIdList = thisList.stream().map(dto->dto.getStoreId()).collect(Collectors.toList()) ; List<String> thisStoreIdList = thisList.stream().map(dto -> dto.getStoreId()).collect(Collectors.toList());
for(TabHmLinkStore item : oldList) { for (TabHmLinkStore item : oldList) {
if(!thisStoreIdList.contains(item.getStoreId())) { if (!thisStoreIdList.contains(item.getStoreId())) {
delIdList.add(item.getId()) ; delIdList.add(item.getId());
} }
} }
if(CollectionUtils.isNotEmpty(addList)) { if (CollectionUtils.isNotEmpty(addList)) {
for (TabHmLinkStore item : addList) { for (TabHmLinkStore item : addList) {
item.setId(UniqueIdUtils.uniqueLong()); item.setId(UniqueIdUtils.uniqueLong());
item.setLinkId(linkId); item.setLinkId(linkId);
...@@ -66,8 +68,8 @@ public class HmLinkStoreServiceImpl implements HmLinkStoreService { ...@@ -66,8 +68,8 @@ public class HmLinkStoreServiceImpl implements HmLinkStoreService {
} }
this.hmLinkStoreMapper.insertBatch(addList); this.hmLinkStoreMapper.insertBatch(addList);
} }
if(CollectionUtils.isNotEmpty(delIdList)) { if (CollectionUtils.isNotEmpty(delIdList)) {
this.hmLinkStoreMapper.deleteById(delIdList) ; this.hmLinkStoreMapper.deleteById(delIdList);
} }
return count; return count;
} }
......
...@@ -29,7 +29,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService { ...@@ -29,7 +29,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
@Override @Override
public List<HmLinkDTO> listForSms(String wxEnterpriseId, String enterprieId, String linkName) { public List<HmLinkDTO> listForSms(String wxEnterpriseId, String enterprieId, String linkName) {
return null; return this.hmLinkService.listForSms(wxEnterpriseId, enterprieId,linkName);
} }
@Override @Override
......
...@@ -80,8 +80,8 @@ ...@@ -80,8 +80,8 @@
#{creatorName,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR},
#{modifierId,jdbcType=VARCHAR}, #{modifierId,jdbcType=VARCHAR},
#{modifierName,jdbcType=VARCHAR}, #{modifierName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, now(),
#{updateTime,jdbcType=TIMESTAMP}, now(),
#{storeRuleJson,jdbcType=VARCHAR}, #{storeRuleJson,jdbcType=VARCHAR},
#{customRuleJson,jdbcType=VARCHAR}, #{customRuleJson,jdbcType=VARCHAR},
#{memberLabelId,jdbcType=VARCHAR}, #{memberLabelId,jdbcType=VARCHAR},
...@@ -91,30 +91,21 @@ ...@@ -91,30 +91,21 @@
</insert> </insert>
<!-- ==================更新 ========== --> <!-- ==================更新 ========== -->
<update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLink"> <update id="update" parameterType="com.gic.haoban.manage.service.entity.hm.TabHmLink">
<![CDATA[ <![CDATA[
UPDATE tab_haoban_hm_link SET UPDATE tab_haoban_hm_link SET
link_id=#{linkId,jdbcType=BIGINT}, name=#{name,jdbcType=VARCHAR},
link_code=#{linkCode,jdbcType=VARCHAR}, remark=#{remark,jdbcType=VARCHAR},
link_type=#{linkType,jdbcType=INTEGER}, welcome_id=#{welcomeId,jdbcType=VARCHAR},
wx_enterprise_id=#{wxEnterpriseId,jdbcType=CHAR}, page_id=#{pageId,jdbcType=BIGINT},
enterprise_id=#{enterpriseId,jdbcType=CHAR}, modifier_id=#{modifierId,jdbcType=VARCHAR},
name=#{name,jdbcType=VARCHAR}, modifier_name=#{modifierName,jdbcType=VARCHAR},
remark=#{remark,jdbcType=VARCHAR}, update_time=now(),
welcome_id=#{welcomeId,jdbcType=VARCHAR}, store_rule_json=#{storeRuleJson,jdbcType=VARCHAR},
page_id=#{pageId,jdbcType=BIGINT}, custom_rule_json=#{customRuleJson,jdbcType=VARCHAR},
creator_id=#{creatorId,jdbcType=VARCHAR}, member_label_id=#{memberLabelId,jdbcType=VARCHAR}
creator_name=#{creatorName,jdbcType=VARCHAR}, WHERE link_id = #{linkId}
modifier_id=#{modifierId,jdbcType=VARCHAR}, ]]>
modifier_name=#{modifierName,jdbcType=VARCHAR},
create_time=#{createTime,jdbcType=TIMESTAMP},
update_time=#{updateTime,jdbcType=TIMESTAMP},
store_rule_json=#{storeRuleJson,jdbcType=VARCHAR},
custom_rule_json=#{customRuleJson,jdbcType=VARCHAR},
member_label_id=#{memberLabelId,jdbcType=VARCHAR},
status_flag=#{statusFlag,jdbcType=INTEGER}
link_id = #{linkId}
]]>
</update> </update>
<!-- ============ 查询=============--> <!-- ============ 查询=============-->
...@@ -122,4 +113,13 @@ ...@@ -122,4 +113,13 @@
SELECT * FROM tab_haoban_hm_link WHERE link_id = #{linkId} SELECT * FROM tab_haoban_hm_link WHERE link_id = #{linkId}
</select> </select>
<select id="listForSms" resultMap="result-map-tabHaobanHmLink">
select <include refid="Base_Column_List" /> from tab_haoban_hm_link where wx_enterprise_id=#{wxEnterpriseId} and enterprise_id=#{enterpriseId}
<if test="null != linkName">
and name like '%${linkName}%'
</if>
and status_flag = 1
limit 20
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
id in <foreach collection="list" item="item" separator="," open="(" close=")" > id in <foreach collection="list" item="item" separator="," open="(" close=")" >
#{item} #{item}
</foreach> </foreach>
status_flag = 1 and status_flag = 1
</delete> </delete>
......
...@@ -54,8 +54,9 @@ public class HmLinkTest { ...@@ -54,8 +54,9 @@ public class HmLinkTest {
@Test @Test
public void saveLink() { public void saveLink() {
HmLinkDTO dto = new HmLinkDTO() ; HmLinkDTO dto = new HmLinkDTO() ;
dto.setLinkId(417044789037756417L);
dto.setLinkType(1); dto.setLinkType(1);
dto.setName("打的费"); dto.setName("打的费2");
dto.setCreatorId("creatorid"); dto.setCreatorId("creatorid");
dto.setCreatorName("创建人"); dto.setCreatorName("创建人");
dto.setModifierId("xiugren"); dto.setModifierId("xiugren");
...@@ -69,6 +70,8 @@ public class HmLinkTest { ...@@ -69,6 +70,8 @@ public class HmLinkTest {
dto.setStoreRuleJson("{}"); dto.setStoreRuleJson("{}");
dto.setMemberLabelId("MEML"); dto.setMemberLabelId("MEML");
this.hmLinkApiService.save(dto,null) ; this.hmLinkApiService.save(dto,null) ;
System.out.println(this.hmLinkApiService.listForSms("111", "2222", "打的费")); ;
} }
......
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