diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java index 966e449d0..a1e738000 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java @@ -84,7 +84,7 @@ public class WxCUserBasicInfoController extends BaseController { wxCUserBasicInfo.setPhone(wxCUser.getPhone()); wxCUserBasicInfo.setTenantId(wxCUser.getTenantId()); wxCUserBasicInfo.setNickName(wxCUser.getNickName()); - wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); + wxCUserBasicInfoService.save(wxCUserBasicInfo); } @@ -120,7 +120,7 @@ public class WxCUserBasicInfoController extends BaseController { wxCUserTagsService.saveOrUpdate(record); wxCUserBasicInfo.setTagId(record.getId()); } - wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); + wxCUserBasicInfoService.update(wxCUserBasicInfo); return new ResultData(); } diff --git a/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java b/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java index db061003a..2bdb76ad0 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/BaseController.java @@ -120,10 +120,11 @@ public class BaseController { if (basicInfo.getPoins() == null) { basicInfo.setPoins(user.getScore()); } - wxCUserBasicInfoService.saveOrUpdate(basicInfo); + wxCUserBasicInfoService.updateObj(basicInfo, user.getId()); } else { Date cur = new Date(); WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); + basicInfo.setId(user.getId()); basicInfo.setTenantId(user.getTenantId()); basicInfo.setPhone(phone); basicInfo.setNickName(user.getNickName()); @@ -131,7 +132,7 @@ public class BaseController { basicInfo.setPoins(user.getScore()); basicInfo.setCreateDate(cur); basicInfo.setUpdateDate(cur); - wxCUserBasicInfoService.saveOrUpdate(basicInfo); + wxCUserBasicInfoService.save(basicInfo); } } } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/CUserTagVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/CUserTagVo.java new file mode 100644 index 000000000..08fbc0dfc --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/CUserTagVo.java @@ -0,0 +1,19 @@ +package com.iformall.domain.vo; + +import com.iformall.domain.po.WxCUserTags; + +/** + * Created by syf on 2018/8/30. + */ +public class CUserTagVo extends WxCUserTags { + + private Long newUserId; + + public Long getNewUserId() { + return newUserId; + } + + public void setNewUserId(Long newUserId) { + this.newUserId = newUserId; + } +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java index cdc77ace9..814f82b58 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java @@ -4,6 +4,7 @@ import java.util.List; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxCUserTags; +import com.iformall.domain.vo.CUserTagVo; import org.apache.ibatis.annotations.Param; public interface WxCUserTagsMapper extends CommonMapper { @@ -17,4 +18,6 @@ public interface WxCUserTagsMapper extends CommonMapper { List findByTags(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId); List findCUserByTags(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId); + + void updateNewId(CUserTagVo record); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxTagsMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxTagsMapper.java index 20bce2763..0722db80a 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxTagsMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxTagsMapper.java @@ -12,10 +12,6 @@ public interface WxTagsMapper extends CommonMapper { List findType1Value(); List findType2Value(String type1); - - - - - + WxTags getByName(String name); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java index a7b052b90..da15a4028 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java @@ -31,11 +31,18 @@ public interface WxCUserBasicInfoService { WxCUserBasicInfo getById(Long id); /** - * 保存或更新实体 + * 保存实体 + * + * @param record + */ + void save(WxCUserBasicInfo record); + + /** + * 更新实体 * * @param record */ - void saveOrUpdate(WxCUserBasicInfo record); + void update(WxCUserBasicInfo record); /** * 保存或更新实体 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index 01a73040a..fcd333172 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -11,10 +11,15 @@ import com.iformall.common.ResultData; import com.iformall.domain.dto.WxCUserBasicInfoDto; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxCUserBasicInfo; +import com.iformall.domain.po.WxCUserTags; +import com.iformall.domain.po.WxTags; import com.iformall.domain.vo.CUserBaseVo; +import com.iformall.domain.vo.CUserTagVo; import com.iformall.exception.MallinkException; import com.iformall.mapper.WxCUserBasicInfoMapper; import com.iformall.mapper.WxCUserMapper; +import com.iformall.mapper.WxCUserTagsMapper; +import com.iformall.mapper.WxTagsMapper; import com.iformall.service.WxCUserBasicInfoService; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; @@ -37,12 +42,18 @@ import java.util.UUID; @Service public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { + @Autowired + WxCUserTagsMapper wxCUserTagsMapper; + @Autowired WxCUserBasicInfoMapper wxCUserBasicInfoMapper; @Autowired WxCUserMapper wxCUserMapper; + @Autowired + WxTagsMapper wxTagsMapper; + @Override public PageInfo listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); @@ -67,19 +78,24 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { } @Override - public void saveOrUpdate(WxCUserBasicInfo record) { - if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); - final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); - wxCUserBasicInfoMapper.insertSelective(record); - } else { - wxCUserBasicInfoMapper.updateByPrimaryKeySelective(record); - } + public void save(WxCUserBasicInfo record) { + wxCUserBasicInfoMapper.insertSelective(record); + } + + @Override + public void update(WxCUserBasicInfo record) { + wxCUserBasicInfoMapper.updateByPrimaryKeySelective(record); } @Override public void updateObj(WxCUserBasicInfo record, Long newId) { + // update c_user_tags + CUserTagVo userTagVo = new CUserTagVo(); + userTagVo.setTenantId(record.getTenantId()); + userTagVo.setUserId(record.getId()); + userTagVo.setNewUserId(newId); + wxCUserTagsMapper.updateNewId(userTagVo); + // base info CUserBaseVo userBaseVo = new CUserBaseVo(); org.springframework.beans.BeanUtils.copyProperties(record, userBaseVo); userBaseVo.setNewId(newId); @@ -176,7 +192,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { addrCellTwo.setCellValue(entity.getAddress()); updateDateCellTwo.setCellValue(sdf.format(entity.getUpdateDate())); createDateCellTwo.setCellValue(sdf.format(entity.getCreateDate())); - + tagCellTwo.setCellValue(entity.getTagNames()); } diff --git a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml index f864bf760..d94c9f5f4 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml @@ -1,90 +1,99 @@ - - - - - - - - - - + + + + + + + + + + `id`,`tenant_id`,`user_id`,`tags`,`create_date`,`update_date` - - where 1 = 1 - - - and `id` = #{id} - - - - - and `tenant_id` like concat('%', #{tenantId},'%') - - - - - and `user_id` = #{userId} - - - - - and `tags` like concat('%', #{tags},'%') - - - - - and `create_date` = #{createDate} - - - - - and `update_date` = #{updateDate} - - - - and id in - - #{idItem} - - - order by ${sortColumns} - - - + + where 1 = 1 + + and `id` = #{id} - + select + + from wx_c_user_tags + + + + + - select count(user_id) from wx_c_user_tags cut, wx_c_user cu where cut.id = cu.id and JSON_CONTAINS(tags,#{tagIds} ) and cut.tenant_id = #{tenantId}; - select user_id from wx_c_user_tags cut where JSON_CONTAINS(tags,#{tagIds} ) and cut.tenant_id = #{tenantId}; - select user_id from wx_c_user_tags cut, wx_c_user cu where cut.user_id = cu.id and JSON_CONTAINS(tags,#{tagIds} ) and cut.tenant_id = #{tenantId}; + + update wx_c_user_tags + set user_id=#{newUserId} + where tenant_id=#{tenantId} + and user_id = #{userId} + + diff --git a/mallinkService/src/main/resources/mapper/WxTagsMapper.xml b/mallinkService/src/main/resources/mapper/WxTagsMapper.xml index 21ef420a6..16023eca7 100644 --- a/mallinkService/src/main/resources/mapper/WxTagsMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxTagsMapper.xml @@ -67,4 +67,12 @@ + +