Просмотр исходного кода

[用户ID同步][修复]:baseinfo与c_user ID同步,同时更新user_tag

release_toaliyun_real
Stormeye.Wu 7 лет назад
Родитель
Сommit
0c7c8e1502
9 измененных файлов: 142 добавлений и 83 удалений
  1. +2
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserBasicInfoController.java
  2. +3
    -2
      mallinkCApi/src/main/java/com/iformall/controller/BaseController.java
  3. +19
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/CUserTagVo.java
  4. +3
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java
  5. +1
    -5
      mallinkService/src/main/java/com/iformall/mapper/WxTagsMapper.java
  6. +9
    -2
      mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java
  7. +26
    -10
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java
  8. +71
    -62
      mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml
  9. +8
    -0
      mallinkService/src/main/resources/mapper/WxTagsMapper.xml

+ 2
- 2
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();
}



+ 3
- 2
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);
}
}
}

+ 19
- 0
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;
}
}

+ 3
- 0
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<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> findCUserByTags(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId);

void updateNewId(CUserTagVo record);
}

+ 1
- 5
mallinkService/src/main/java/com/iformall/mapper/WxTagsMapper.java Просмотреть файл

@@ -12,10 +12,6 @@ public interface WxTagsMapper extends CommonMapper<WxTags, String> {
List<WxTags> findType1Value();
List<WxTags> findType2Value(String type1);

WxTags getByName(String name);
}

+ 9
- 2
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);

/**
* 保存或更新实体


+ 26
- 10
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<WxCUserBasicInfo> 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());
}




+ 71
- 62
mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml Просмотреть файл

@@ -1,90 +1,99 @@
<?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.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`
</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 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
where cut.id = cu.id
and JSON_CONTAINS(tags,#{tagIds} )
and cut.tenant_id = #{tenantId};
</select>

<select id ="findByTags" resultType="java.lang.Long">
<select id="findByTags" resultType="java.lang.Long">
select user_id from wx_c_user_tags cut
where JSON_CONTAINS(tags,#{tagIds} )
and cut.tenant_id = #{tenantId};
</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
where cut.user_id = cu.id
and JSON_CONTAINS(tags,#{tagIds} )
and cut.tenant_id = #{tenantId};
</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>

+ 8
- 0
mallinkService/src/main/resources/mapper/WxTagsMapper.xml Просмотреть файл

@@ -67,4 +67,12 @@
</if>
</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>

Загрузка…
Отмена
Сохранить