提交 2df0f5ce 作者: zhenjie

用户信息获取渠道信息

上级 4ca4cfef
......@@ -9,6 +9,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @author: zj
......@@ -54,4 +55,6 @@ public class UserAccountSimpleDTO implements Serializable {
private String companyName;
@ApiModelProperty(value = "合作标签")
private String tagName;
@ApiModelProperty(value = "用户合作标签")
private List<CooperationTagVO> cooperationTagVOS;
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @author: zj
......@@ -65,4 +66,6 @@ public class UserAccountVO implements Serializable {
private String tagName;
@ApiModelProperty(value = "是否删除")
private Integer deleted;
@ApiModelProperty(value = "用户合作标签")
private List<CooperationTagVO> cooperationTagVOS;
}
package com.mmc.iuav.user.model.vo;
import com.mmc.iuav.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.security.PrivateKey;
import java.util.Set;
/**
* @author: zj
* @Date: 2023/6/28 15:59
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserCooperationTagVO implements Serializable {
private static final long serialVersionUID = 7899913481538765762L;
@ApiModelProperty(value = "用户id")
@NotNull(message = "用户id不能为空",groups = {Update.class})
private Integer userAccountId;
@ApiModelProperty(value = "合作标签id")
private Set<Integer> cooperationTagIds;
}
package com.mmc.iuav.user.controller;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.group.Update;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.model.vo.UserCooperationTagVO;
import com.mmc.iuav.user.service.CooperationService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Set;
/**
* @author: zj
......@@ -50,9 +53,9 @@ public class CooperationController extends BaseController{
@ApiOperation(value = "后台设置小程序用户标签")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("changeUserTag")
public ResultBody changeUserTag(@RequestParam("userAccountId") Integer userAccountId, @RequestParam("cooperationTagId") Integer cooperationTagId) {
return cooperationService.changeUserTag(userAccountId, cooperationTagId);
@PostMapping("changeUserTag")
public ResultBody changeUserTag(@Validated(Update.class) @RequestBody UserCooperationTagVO userCooperationTagVO) {
return cooperationService.changeUserTag(userCooperationTagVO);
}
@ApiOperation(value = "获取合作渠道标签", hidden = true)
......
......@@ -6,6 +6,7 @@ import com.mmc.iuav.user.entity.UserTagDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Set;
/**
* @author: zj
......@@ -39,11 +40,11 @@ public interface CooperationDao {
void updateUserApplyTag(UserApplyTagDO userApplyTagDO);
/**
* 根据用户id查询渠道登记
* 根据用户id查询合作标签信息
* @param userAccountId
* @return
*/
UserTagDO getUserTag(Integer userAccountId);
List<CooperationTagDO> listUserCooperationTag(Integer userAccountId);
/**
* 用户设置渠道等级
......@@ -63,4 +64,24 @@ public interface CooperationDao {
* @return
*/
CooperationTagDO getTagById(Integer id);
/**
* 删除用户原来的标签
* @param userAccountId
*/
void removeUserTag(Integer userAccountId);
/**
* 添加用户合作加盟标签
* @param userAccountId
* @param cooperationTagIds
*/
void batchInsertUserTag(Integer userAccountId, Set<Integer> cooperationTagIds);
/**
* 根据用户id查询用户拥有的合作标签
* @param uIds
* @return
*/
List<CooperationTagDO> listUserCooperationTagByUIds(List<Integer> uIds);
}
......@@ -23,6 +23,8 @@ public class CooperationTagDO implements Serializable {
private String tagDescription;
private Date createTime;
private Integer userAccountId;
public CooperationTagVO buildCooperationTagVO(){
return CooperationTagVO.builder()
.id(id)
......
......@@ -3,8 +3,10 @@ package com.mmc.iuav.user.service;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.model.vo.UserCooperationTagVO;
import java.util.List;
import java.util.Set;
/**
* @author: zj
......@@ -26,11 +28,10 @@ public interface CooperationService {
/**
* 后台用户设置小程序用户等级标签
* @param userAccountId
* @param cooperationTagId
* @param userCooperationTagVO
* @return
*/
ResultBody changeUserTag(Integer userAccountId, Integer cooperationTagId);
ResultBody changeUserTag(UserCooperationTagVO userCooperationTagVO);
/**
* 根据ID查询标签信息
......
......@@ -10,11 +10,15 @@ import com.mmc.iuav.user.entity.UserApplyTagDO;
import com.mmc.iuav.user.entity.UserTagDO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.model.vo.UserCooperationTagVO;
import com.mmc.iuav.user.service.CooperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
......@@ -54,19 +58,15 @@ public class CooperationServiceImpl implements CooperationService {
return ResultBody.success();
}
@Transactional
@Override
public ResultBody changeUserTag(Integer userAccountId, Integer cooperationTagId) {
UserTagDO userTagDO = cooperationDao.getUserTag(userAccountId);
if (userTagDO == null){
//直接插入
userTagDO = new UserTagDO();
userTagDO.setUserAccountId(userAccountId);
userTagDO.setCooperationTagId(cooperationTagId);
cooperationDao.insertUserTag(userTagDO);
public ResultBody changeUserTag(UserCooperationTagVO userCooperationTagVO) {
// 删除原来的
cooperationDao.removeUserTag(userCooperationTagVO.getUserAccountId());
// 添加新的
if (!CollectionUtils.isEmpty(userCooperationTagVO.getCooperationTagIds())){
cooperationDao.batchInsertUserTag(userCooperationTagVO.getUserAccountId(), userCooperationTagVO.getCooperationTagIds());
}
//修改渠道等级
userTagDO.setCooperationTagId(cooperationTagId);
cooperationDao.updateUserTag(userTagDO);
return ResultBody.success();
}
......
......@@ -14,9 +14,7 @@ import com.mmc.iuav.user.entity.UserTagDO;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
import com.mmc.iuav.user.model.qo.BUserAccountQO;
import com.mmc.iuav.user.model.qo.UserAccountQO;
import com.mmc.iuav.user.model.vo.BUserAccountVO;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.model.vo.*;
import com.mmc.iuav.user.mq.MqProducer;
import com.mmc.iuav.user.service.CompanyAuthService;
import com.mmc.iuav.user.service.UserAccountService;
......@@ -81,9 +79,10 @@ public class UserAccountServiceImpl implements UserAccountService {
}else {
userAccountVO.setCompanyAuthStatus(0);
}
UserTagDO userTag = cooperationDao.getUserTag(userAccountId);
if (userTag != null){
userAccountVO.setCooperationTagId(userTag.getCooperationTagId());
List<CooperationTagDO> cooperationTagDOS = cooperationDao.listUserCooperationTag(userAccountId);
if (!CollectionUtils.isEmpty(cooperationTagDOS)) {
List<CooperationTagVO> cooperationTags = cooperationTagDOS.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
userAccountVO.setCooperationTagVOS(cooperationTags);
}
return userAccountVO;
}
......@@ -109,9 +108,10 @@ public class UserAccountServiceImpl implements UserAccountService {
}else {
userAccountSimpleDTO.setCompanyAuthStatus(0);
}
UserTagDO userTag = cooperationDao.getUserTag(userAccountId);
if (userTag != null){
userAccountSimpleDTO.setCooperationTagId(userTag.getCooperationTagId());
List<CooperationTagDO> cooperationTagDOS = cooperationDao.listUserCooperationTag(userAccountId);
if (!CollectionUtils.isEmpty(cooperationTagDOS)){
List<CooperationTagVO> cooperationTags = cooperationTagDOS.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
userAccountSimpleDTO.setCooperationTagVOS(cooperationTags);
}
return userAccountSimpleDTO;
}
......@@ -181,9 +181,28 @@ public class UserAccountServiceImpl implements UserAccountService {
return null;
}
List<UserAccountSimpleDTO> accountSimpleDTOS = list.stream().map(UserAccountDO::buildUserAccountSimpleDTO).collect(Collectors.toList());
//设置用户的渠道等级
buildCooperationTagVO(accountSimpleDTOS);
return accountSimpleDTOS;
}
public void buildCooperationTagVO(List<UserAccountSimpleDTO> accountSimpleDTOS){
List<Integer> uIds = accountSimpleDTOS.stream().map(UserAccountSimpleDTO::getId).collect(Collectors.toList());
//设置用户的渠道等级
List<CooperationTagDO> cooperationTagDOS = cooperationDao.listUserCooperationTagByUIds(uIds);
if (!CollectionUtils.isEmpty(cooperationTagDOS)){
Map<Integer, List<CooperationTagDO>> userTagsMap = cooperationTagDOS.stream().collect(Collectors.groupingBy(CooperationTagDO::getUserAccountId));
for (UserAccountSimpleDTO simpleDTO : accountSimpleDTOS) {
List<CooperationTagDO> tagDOS = userTagsMap.get(simpleDTO.getId());
if (!CollectionUtils.isEmpty(tagDOS)){
List<CooperationTagVO> cooperationTagVOS = tagDOS.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
simpleDTO.setCooperationTagVOS(cooperationTagVOS);
}
}
}
}
@Override
public ResultBody updateBAccount(BUserAccountVO bUserAccountVO) {
// 判断账号是否重复
......@@ -251,6 +270,8 @@ public class UserAccountServiceImpl implements UserAccountService {
List<UserAccountDO> userAccountDOS = userServiceDao.listUserAccountByIds(ids);
if (!CollectionUtils.isEmpty(userAccountDOS)){
List<UserAccountSimpleDTO> userAccountSimpleDTOS = userAccountDOS.stream().map(UserAccountDO::buildUserAccountSimpleDTO).collect(Collectors.toList());
//设置用户的渠道等级
buildCooperationTagVO(userAccountSimpleDTOS);
return userAccountSimpleDTOS;
}
return null;
......@@ -261,6 +282,8 @@ public class UserAccountServiceImpl implements UserAccountService {
List<UserAccountDO> userAccountDOS = userServiceDao.feignListRcdUserInfo(userIds);
if (!CollectionUtils.isEmpty(userAccountDOS)){
List<UserAccountSimpleDTO> userAccountSimpleDTOS = userAccountDOS.stream().map(UserAccountDO::buildUserAccountSimpleDTO).collect(Collectors.toList());
//设置用户的渠道等级
buildCooperationTagVO(userAccountSimpleDTOS);
return userAccountSimpleDTOS;
}
return null;
......@@ -279,7 +302,13 @@ public class UserAccountServiceImpl implements UserAccountService {
public UserAccountSimpleDTO feignGetUserRcdInfo(Integer userAccountId) {
UserAccountDO rcdAccountDO = userServiceDao.getUserRcdByAccountId(userAccountId);
if (rcdAccountDO != null){
return rcdAccountDO.buildUserAccountSimpleDTO();
List<CooperationTagDO> cooperationTagDOS = cooperationDao.listUserCooperationTag(userAccountId);
UserAccountSimpleDTO userAccountSimpleDTO = rcdAccountDO.buildUserAccountSimpleDTO();
if (!CollectionUtils.isEmpty(cooperationTagDOS)){
List<CooperationTagVO> cooperationTagVOS = cooperationTagDOS.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
userAccountSimpleDTO.setCooperationTagVOS(cooperationTagVOS);
}
return userAccountSimpleDTO;
}
return null;
}
......@@ -293,8 +322,18 @@ public class UserAccountServiceImpl implements UserAccountService {
int pageNo = param.getPageNo();
param.buildCurrentPage();
List<UserAccountDO> userAccountDOList = userServiceDao.listAppUser(param);
List<Integer> uIds = userAccountDOList.stream().map(UserAccountDO::getId).collect(Collectors.toList());
List<CooperationTagDO> cooperationTagDOS = cooperationDao.listUserCooperationTagByUIds(uIds);
Map<Integer, List<CooperationTagDO>> userTagsMap = cooperationTagDOS.stream().collect(Collectors.groupingBy(CooperationTagDO::getUserAccountId));
List<UserAccountDO> res = buildTagInfo(userAccountDOList);
List<UserAccountVO> userAccountVOS = res.stream().map(UserAccountDO::buildUserAccountVO).collect(Collectors.toList());
for (UserAccountVO userAccountVO : userAccountVOS) {
List<CooperationTagDO> userCooperationTagDOS = userTagsMap.get(userAccountVO.getId());
if (!CollectionUtils.isEmpty(userCooperationTagDOS)){
List<CooperationTagVO> cooperationTagVOS = userCooperationTagDOS.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
userAccountVO.setCooperationTagVOS(cooperationTagVOS);
}
}
return ResultBody.success(PageResult.buildPage(pageNo, param.getPageSize(), count, userAccountVOS));
}
......
......@@ -14,6 +14,14 @@
values(#{userAccountId}, #{cooperationTagId}, NOW());
</insert>
<insert id="batchInsertUserTag">
insert into user_tag(user_account_id, cooperation_tag_id, create_time) values
<foreach item="d" index="index" collection="cooperationTagIds"
separator=",">
(#{userAccountId}, #{d}, NOW())
</foreach>
</insert>
<update id="updateUserApplyTag" parameterType="com.mmc.iuav.user.entity.UserApplyTagDO">
UPDATE user_apply_tag
<set>
......@@ -43,6 +51,10 @@
update user_tag set cooperation_tag_id = #{cooperationTagId} where id = #{id}
</update>
<update id="removeUserTag">
update user_tag set is_deleted = 1 where user_account_id = #{userAccountId} and is_deleted = 0
</update>
<select id="listTags" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
select id, tag_name, tag_img, tag_description, create_time from cooperation_tag where is_deleted = 0
</select>
......@@ -53,13 +65,22 @@
where user_account_id = #{userAccountId} and is_deleted = 0
</select>
<select id="getUserTag" resultType="com.mmc.iuav.user.entity.UserTagDO">
select id, user_account_id, cooperation_tag_id,is_deleted as deleted, create_time, update_time
from user_tag
where user_account_id = #{userAccountId} and is_deleted = 0
<select id="listUserCooperationTag" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
select ct.id,ct.tag_name from cooperation_tag ct LEFT JOIN user_tag ut ON ct.id = ut.cooperation_tag_id
where ct.is_deleted = 0 and ut.is_deleted = 0 and ut.user_account_id = #{userAccountId}
</select>
<select id="getTagById" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
select id, tag_name, tag_img, tag_description, create_time from cooperation_tag where id = #{id} and is_deleted = 0
</select>
<select id="listUserCooperationTagByUIds" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
select ct.id,ct.tag_name,ut.user_account_id from cooperation_tag ct LEFT JOIN user_tag ut ON ct.id = ut.cooperation_tag_id
where ct.is_deleted = 0 and ut.is_deleted = 0
<if test="uIds != null">
<foreach collection="uIds" item="userAccountId" separator="," open=" and ut.user_account_id in (" close=")">
#{userAccountId}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -133,8 +133,8 @@
<select id="feignListUserAccount" resultType="com.mmc.iuav.user.entity.UserAccountDO" parameterType="com.mmc.iuav.user.model.qo.UserAccountQO">
select ua.id, ua.account_no, ua.uid, ua.phone_num, ua.user_name, ua.nick_name, ua.user_img, ua.open_id, ua.union_id, ua.user_sex, ua.email, ua.source, ua.account_status, ua.remark,
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ut.cooperation_tag_id, ca.auth_status as companyAuthStatus
from user_account ua left join user_tag ut on ua.id = ut.user_account_id left join company_auth ca on ua.id = ca.user_account_id
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ca.auth_status as companyAuthStatus
from user_account ua left join company_auth ca on ua.id = ca.user_account_id
where ua.is_deleted = 0
<if test=" userIds != null ">
<foreach collection="userIds" item="id" open="and ua.id in (" close=")" separator=",">
......@@ -223,8 +223,8 @@
<select id="listUserAccountByIds" resultType="com.mmc.iuav.user.entity.UserAccountDO">
select ua.id, ua.account_no, ua.uid, ua.phone_num, ua.user_name, ua.nick_name, ua.user_img, ua.open_id, ua.union_id, ua.user_sex, ua.email, ua.source, ua.account_status, ua.remark,
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ut.cooperation_tag_id, ca.auth_status as companyAuthStatus, ca.company_name
from user_account ua left join user_tag ut on ua.id = ut.user_account_id left join company_auth ca on ua.id = ca.user_account_id
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ca.auth_status as companyAuthStatus, ca.company_name
from user_account ua left join company_auth ca on ua.id = ca.user_account_id
where ua.is_deleted = 0
<if test=" userIds != null ">
<foreach collection="userIds" item="id" open="and ua.id in (" close=")" separator=",">
......@@ -235,8 +235,8 @@
<select id="feignListRcdUserInfo" resultType="com.mmc.iuav.user.entity.UserAccountDO">
select ua.id, ua.account_no, ua.uid, ua.phone_num, ua.user_name, ua.nick_name, ua.user_img, ua.open_id, ua.union_id, ua.user_sex, ua.email, ua.source, ua.account_status, ua.remark,
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ut.cooperation_tag_id, ca.auth_status as companyAuthStatus, ca.company_name
from user_rcd ur inner join user_account ua on ua.id = ur.rcd_user_id left join user_tag ut on ua.id = ut.user_account_id left join company_auth ca on ua.id = ca.user_account_id
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ca.auth_status as companyAuthStatus, ca.company_name
from user_rcd ur inner join user_account ua on ua.id = ur.rcd_user_id left join company_auth ca on ua.id = ca.user_account_id
where ua.is_deleted = 0
<if test=" userIds != null ">
<foreach collection="userIds" item="id" open="and ur.user_account_id in (" close=")" separator=",">
......@@ -247,8 +247,8 @@
<select id="getUserRcdByAccountId" resultType="com.mmc.iuav.user.entity.UserAccountDO">
select ua.id, ua.account_no, ua.uid, ua.phone_num, ua.user_name, ua.nick_name, ua.user_img, ua.open_id, ua.union_id, ua.user_sex, ua.email, ua.source, ua.account_status, ua.remark,
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ut.cooperation_tag_id, ca.auth_status as companyAuthStatus, ca.company_name
from user_rcd ur inner join user_account ua on ua.id = ur.rcd_user_id left join user_tag ut on ua.id = ut.user_account_id left join company_auth ca on ua.id = ca.user_account_id
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ca.auth_status as companyAuthStatus, ca.company_name
from user_rcd ur inner join user_account ua on ua.id = ur.rcd_user_id left join company_auth ca on ua.id = ca.user_account_id
where ua.is_deleted = 0 and ur.user_account_id = #{userAccountId}
</select>
......@@ -290,8 +290,8 @@
<select id="listAppUser" resultType="com.mmc.iuav.user.entity.UserAccountDO" parameterType="com.mmc.iuav.user.model.qo.UserAccountQO">
select ua.id, ua.account_no, ua.uid, ua.phone_num, ua.user_name, ua.nick_name, ua.user_img, ua.open_id, ua.union_id, ua.user_sex, ua.email, ua.source, ua.account_status, ua.remark,
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, ut.cooperation_tag_id, IFNULL(ca.auth_status, 0) as companyAuthStatus, ca.company_name
from user_account ua left join user_tag ut on ua.id = ut.user_account_id left join company_auth ca on ua.id = ca.user_account_id
ua.port_type, ua.is_deleted as deleted, ua.create_time, ua.update_time, IFNULL(ca.auth_status, 0) as companyAuthStatus, ca.company_name
from user_account ua left join company_auth ca on ua.id = ca.user_account_id
where
ua.is_deleted = 0 and ua.port_type = 100
<if test="phoneNum != null and phoneNum != '' ">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论