| @@ -84,7 +84,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| wxCUserBasicInfo.setPhone(wxCUser.getPhone()); | wxCUserBasicInfo.setPhone(wxCUser.getPhone()); | ||||
| wxCUserBasicInfo.setTenantId(wxCUser.getTenantId()); | wxCUserBasicInfo.setTenantId(wxCUser.getTenantId()); | ||||
| wxCUserBasicInfo.setNickName(wxCUser.getNickName()); | wxCUserBasicInfo.setNickName(wxCUser.getNickName()); | ||||
| wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); | |||||
| wxCUserBasicInfoService.save(wxCUserBasicInfo); | |||||
| } | } | ||||
| @@ -120,7 +120,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| wxCUserTagsService.saveOrUpdate(record); | wxCUserTagsService.saveOrUpdate(record); | ||||
| wxCUserBasicInfo.setTagId(record.getId()); | wxCUserBasicInfo.setTagId(record.getId()); | ||||
| } | } | ||||
| wxCUserBasicInfoService.saveOrUpdate(wxCUserBasicInfo); | |||||
| wxCUserBasicInfoService.update(wxCUserBasicInfo); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -120,10 +120,11 @@ public class BaseController { | |||||
| if (basicInfo.getPoins() == null) { | if (basicInfo.getPoins() == null) { | ||||
| basicInfo.setPoins(user.getScore()); | basicInfo.setPoins(user.getScore()); | ||||
| } | } | ||||
| wxCUserBasicInfoService.saveOrUpdate(basicInfo); | |||||
| wxCUserBasicInfoService.updateObj(basicInfo, user.getId()); | |||||
| } else { | } else { | ||||
| Date cur = new Date(); | Date cur = new Date(); | ||||
| WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); | WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); | ||||
| basicInfo.setId(user.getId()); | |||||
| basicInfo.setTenantId(user.getTenantId()); | basicInfo.setTenantId(user.getTenantId()); | ||||
| basicInfo.setPhone(phone); | basicInfo.setPhone(phone); | ||||
| basicInfo.setNickName(user.getNickName()); | basicInfo.setNickName(user.getNickName()); | ||||
| @@ -131,7 +132,7 @@ public class BaseController { | |||||
| basicInfo.setPoins(user.getScore()); | basicInfo.setPoins(user.getScore()); | ||||
| basicInfo.setCreateDate(cur); | basicInfo.setCreateDate(cur); | ||||
| basicInfo.setUpdateDate(cur); | basicInfo.setUpdateDate(cur); | ||||
| wxCUserBasicInfoService.saveOrUpdate(basicInfo); | |||||
| wxCUserBasicInfoService.save(basicInfo); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -4,6 +4,7 @@ import java.util.List; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxCUserTags; | import com.iformall.domain.po.WxCUserTags; | ||||
| import com.iformall.domain.vo.CUserTagVo; | |||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | ||||
| @@ -17,4 +18,6 @@ public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | |||||
| List<Long> findByTags(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId); | List<Long> findByTags(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId); | ||||
| List<Long> findCUserByTags(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId); | List<Long> findCUserByTags(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId); | ||||
| void updateNewId(CUserTagVo record); | |||||
| } | } | ||||
| @@ -12,10 +12,6 @@ public interface WxTagsMapper extends CommonMapper<WxTags, String> { | |||||
| List<WxTags> findType1Value(); | List<WxTags> findType1Value(); | ||||
| List<WxTags> findType2Value(String type1); | List<WxTags> findType2Value(String type1); | ||||
| WxTags getByName(String name); | |||||
| } | } | ||||
| @@ -31,11 +31,18 @@ public interface WxCUserBasicInfoService { | |||||
| WxCUserBasicInfo getById(Long id); | WxCUserBasicInfo getById(Long id); | ||||
| /** | /** | ||||
| * 保存或更新实体 | |||||
| * 保存实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void save(WxCUserBasicInfo record); | |||||
| /** | |||||
| * 更新实体 | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| void saveOrUpdate(WxCUserBasicInfo record); | |||||
| void update(WxCUserBasicInfo record); | |||||
| /** | /** | ||||
| * 保存或更新实体 | * 保存或更新实体 | ||||
| @@ -11,10 +11,15 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | 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.CUserBaseVo; | ||||
| import com.iformall.domain.vo.CUserTagVo; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | import com.iformall.mapper.WxCUserBasicInfoMapper; | ||||
| import com.iformall.mapper.WxCUserMapper; | import com.iformall.mapper.WxCUserMapper; | ||||
| import com.iformall.mapper.WxCUserTagsMapper; | |||||
| import com.iformall.mapper.WxTagsMapper; | |||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import org.apache.commons.io.FileUtils; | import org.apache.commons.io.FileUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -37,12 +42,18 @@ import java.util.UUID; | |||||
| @Service | @Service | ||||
| public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | ||||
| @Autowired | |||||
| WxCUserTagsMapper wxCUserTagsMapper; | |||||
| @Autowired | @Autowired | ||||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | ||||
| @Autowired | @Autowired | ||||
| WxCUserMapper wxCUserMapper; | WxCUserMapper wxCUserMapper; | ||||
| @Autowired | |||||
| WxTagsMapper wxTagsMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); | ||||
| @@ -67,19 +78,24 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| } | } | ||||
| @Override | @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 | @Override | ||||
| public void updateObj(WxCUserBasicInfo record, Long newId) { | 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(); | CUserBaseVo userBaseVo = new CUserBaseVo(); | ||||
| org.springframework.beans.BeanUtils.copyProperties(record, userBaseVo); | org.springframework.beans.BeanUtils.copyProperties(record, userBaseVo); | ||||
| userBaseVo.setNewId(newId); | userBaseVo.setNewId(newId); | ||||
| @@ -176,7 +192,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| addrCellTwo.setCellValue(entity.getAddress()); | addrCellTwo.setCellValue(entity.getAddress()); | ||||
| updateDateCellTwo.setCellValue(sdf.format(entity.getUpdateDate())); | updateDateCellTwo.setCellValue(sdf.format(entity.getUpdateDate())); | ||||
| createDateCellTwo.setCellValue(sdf.format(entity.getCreateDate())); | createDateCellTwo.setCellValue(sdf.format(entity.getCreateDate())); | ||||
| tagCellTwo.setCellValue(entity.getTagNames()); | |||||
| } | } | ||||
| @@ -1,90 +1,99 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?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"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.iformall.mapper.WxCUserTagsMapper"> | <mapper namespace="com.iformall.mapper.WxCUserTagsMapper"> | ||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserTags"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||||
| <result column="tags" jdbcType="VARCHAR" property="tags" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserTags"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||||
| <result column="tags" jdbcType="VARCHAR" property="tags"/> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`user_id`,`tags`,`create_date`,`update_date` | `id`,`tenant_id`,`user_id`,`tags`,`create_date`,`update_date` | ||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and `user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != tags "> | |||||
| and `tags` like concat('%', #{tags},'%') | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserTags" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_c_user_tags | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| <select id ="findCountByTags" resultType="java.lang.Long"> | |||||
| select count(user_id) from wx_c_user_tags cut | |||||
| where JSON_CONTAINS(tags,#{tagIds} ) | |||||
| and cut.tenant_id = #{tenantId}; | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` like concat('%', #{tenantId},'%') | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and `user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != tags "> | |||||
| and `tags` like concat('%', #{tags},'%') | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserTags" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_c_user_tags | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <select id="findCountByTags" resultType="java.lang.Long"> | |||||
| select count(user_id) from wx_c_user_tags cut | |||||
| where JSON_CONTAINS(tags,#{tagIds} ) | |||||
| and cut.tenant_id = #{tenantId}; | |||||
| </select> | </select> | ||||
| <select id ="findCUserCountByTags" resultType="java.lang.Long"> | |||||
| <select id="findCUserCountByTags" resultType="java.lang.Long"> | |||||
| select count(user_id) from wx_c_user_tags cut, wx_c_user cu | select count(user_id) from wx_c_user_tags cut, wx_c_user cu | ||||
| where cut.id = cu.id | where cut.id = cu.id | ||||
| and JSON_CONTAINS(tags,#{tagIds} ) | and JSON_CONTAINS(tags,#{tagIds} ) | ||||
| and cut.tenant_id = #{tenantId}; | and cut.tenant_id = #{tenantId}; | ||||
| </select> | </select> | ||||
| <select id ="findByTags" resultType="java.lang.Long"> | |||||
| <select id="findByTags" resultType="java.lang.Long"> | |||||
| select user_id from wx_c_user_tags cut | select user_id from wx_c_user_tags cut | ||||
| where JSON_CONTAINS(tags,#{tagIds} ) | where JSON_CONTAINS(tags,#{tagIds} ) | ||||
| and cut.tenant_id = #{tenantId}; | and cut.tenant_id = #{tenantId}; | ||||
| </select> | </select> | ||||
| <select id ="findCUserByTags" resultType="java.lang.Long"> | |||||
| <select id="findCUserByTags" resultType="java.lang.Long"> | |||||
| select user_id from wx_c_user_tags cut, wx_c_user cu | select user_id from wx_c_user_tags cut, wx_c_user cu | ||||
| where cut.user_id = cu.id | where cut.user_id = cu.id | ||||
| and JSON_CONTAINS(tags,#{tagIds} ) | and JSON_CONTAINS(tags,#{tagIds} ) | ||||
| and cut.tenant_id = #{tenantId}; | and cut.tenant_id = #{tenantId}; | ||||
| </select> | </select> | ||||
| <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserTagVo"> | |||||
| update wx_c_user_tags | |||||
| set user_id=#{newUserId} | |||||
| where tenant_id=#{tenantId} | |||||
| and user_id = #{userId} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -67,4 +67,12 @@ | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="getByName" parameterType="String" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns"/> | |||||
| from wx_tags where 1=1 | |||||
| <if test="_parameter!= null and _parameter!= ''"> | |||||
| and `name` like concat('%', #{name},'%') | |||||
| </if> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||