Merge remote-tracking branch 'origin/cc_partner_init' into cc_partner_init

This commit is contained in:
zhangchenbiao
2024-03-29 12:01:15 +08:00
26 changed files with 881 additions and 10 deletions

View File

@@ -0,0 +1,58 @@
package com.cool.store.enums;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* describe:
*
* @author zhouyiping
* @date 2020/10/13
*/
public enum AuthRoleEnum {
/**
* 全企业数据
*/
ALL("all", "全企业数据"),
/**
* 所在组织架构包含下级
*/
INCLUDE_SUBORDINATE("include_subordinate","所在组织架构包含下级"),
// /**
// * 所在的组织架构不包含下级
// */
NOT_INCLUDE_SUBORDINATE("not_include_subordinate","所在的组织架构不包含下级"),
/**
* 仅自己的数据
*/
PERSONAL("personal","仅自己的数据");
private String code;
private String msg;
protected static final Map<String, AuthRoleEnum> map = Arrays.stream(values()).collect(
Collectors.toMap(AuthRoleEnum::getCode, Function.identity()));
AuthRoleEnum(String code, String msg){
this.code=code;
this.msg=msg;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
public static AuthRoleEnum getByCode(String code) {
return map.get(code);
}
}

View File

@@ -0,0 +1,44 @@
package com.cool.store.enums;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author zyp
*/
public enum UserAuthMappingTypeEnum {
/**
* 区域
*/
REGION("region","区域"),
/**
* 门店
*/
STORE("store","门店");
private String code;
private String desc;
public static final Map<String, UserAuthMappingTypeEnum> map = Arrays.stream(values()).collect(
Collectors.toMap(UserAuthMappingTypeEnum::getCode, Function.identity()));
UserAuthMappingTypeEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static UserAuthMappingTypeEnum getByCode(String code) {
return map.get(code);
}
}

View File

@@ -27,6 +27,13 @@ public class RegionAreaConfigDao {
regionAreaConfigMapper.deleteRegionAreaConfigByRegionId(regionId); regionAreaConfigMapper.deleteRegionAreaConfigByRegionId(regionId);
} }
public void deleteByWantShopAreaIds(List<Long> wantShopAreaIds) {
if (CollectionUtils.isEmpty(wantShopAreaIds)) {
return;
}
regionAreaConfigMapper.deleteByWantShopAreaIds(wantShopAreaIds);
}
public void batchInsertOrUpdateRegionAreaConfig(List<RegionAreaConfigDO> regionAreaConfigList) { public void batchInsertOrUpdateRegionAreaConfig(List<RegionAreaConfigDO> regionAreaConfigList) {
if (CollectionUtils.isEmpty(regionAreaConfigList)) { if (CollectionUtils.isEmpty(regionAreaConfigList)) {
return; return;
@@ -41,6 +48,13 @@ public class RegionAreaConfigDao {
return regionAreaConfigMapper.listAreaByRegionId(regionId); return regionAreaConfigMapper.listAreaByRegionId(regionId);
} }
public List<RegionAreaConfigDO> listAreaByRegionIdList(List<Long> regionIdList){
if (CollectionUtils.isEmpty(regionIdList)) {
return Collections.emptyList();
}
return regionAreaConfigMapper.listAreaByRegionIdList(regionIdList);
}
public Long getByWantShopAreaId(Long wantShopAreaId){ public Long getByWantShopAreaId(Long wantShopAreaId){
if (wantShopAreaId == null) { if (wantShopAreaId == null) {
return 0L; return 0L;

View File

@@ -1,6 +1,5 @@
package com.cool.store.dao; package com.cool.store.dao;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.RegionNode; import com.cool.store.dto.RegionNode;
import com.cool.store.entity.RegionDO; import com.cool.store.entity.RegionDO;
import com.cool.store.mapper.RegionMapper; import com.cool.store.mapper.RegionMapper;
@@ -8,11 +7,13 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -172,5 +173,8 @@ public class RegionDao {
return regionMapper.getRegionByParentIds(regionIdList); return regionMapper.getRegionByParentIds(regionIdList);
} }
public List<RegionDO> listByThirdRegionType(Long parentId, String thirdRegionType) {
return regionMapper.listByThirdRegionType(parentId, thirdRegionType);
}
} }

View File

@@ -41,10 +41,15 @@ public interface RegionAreaConfigMapper {
void deleteRegionAreaConfigByRegionId(@Param("regionId") Long regionId); void deleteRegionAreaConfigByRegionId(@Param("regionId") Long regionId);
void deleteByWantShopAreaIds(@Param("wantShopAreaIds") List<Long> wantShopAreaIds);
void batchInsertOrUpdateRegionAreaConfig(@Param("regionAreaConfigList") List<RegionAreaConfigDO> regionAreaConfigList); void batchInsertOrUpdateRegionAreaConfig(@Param("regionAreaConfigList") List<RegionAreaConfigDO> regionAreaConfigList);
List<RegionAreaConfigDO> listAreaByRegionId(@Param("regionId") Long regionId); List<RegionAreaConfigDO> listAreaByRegionId(@Param("regionId") Long regionId);
Long getByWantShopAreaId(@Param("wantShopAreaId") Long wantShopAreaId); Long getByWantShopAreaId(@Param("wantShopAreaId") Long wantShopAreaId);
List<RegionAreaConfigDO> listAreaByRegionIdList(@Param("regionIdList") List<Long> regionIdList);
} }

View File

@@ -94,4 +94,7 @@ public interface RegionMapper {
List<RegionDO> getRegionByParentIds(@Param("regionIdList") List<String> regionIdList); List<RegionDO> getRegionByParentIds(@Param("regionIdList") List<String> regionIdList);
List<RegionDO> listByThirdRegionType(@Param("parentId")Long parentId, @Param("thirdRegionType")String thirdRegionType);
} }

View File

@@ -0,0 +1,107 @@
package com.cool.store.mapper;
import com.cool.store.entity.UserAuthMappingDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 人员权限映射表
*
* @author zyp
* @Description 人员权限映射
*/
@Mapper
public interface UserAuthMappingMapper {
/**
* 根据UserId获取权限
* @param userId
* @return
*/
List<UserAuthMappingDO> listUserAuthMappingByUserId(@Param("userId") String userId);
/**
* 根据UserId和权限来源获取权限
* @param userId
* @param source
* @return
*/
List<UserAuthMappingDO> listByUserIdAndSource( @Param("userId") String userId, @Param("source") String source);
/**
* 查询用户区域
* @param userList
* @return
*/
List<UserAuthMappingDO> listUserAuthMappingByUserIdList(@Param("userList") List<String> userList);
List<UserAuthMappingDO> listUserAuthMappingByMappingList(@Param("mappingIdList") List<String> mappingIdList,
@Param("type") String type);
/**
*查询不包含可视化范围的区域人员
* @param mappingIdList
* @return
*/
List<UserAuthMappingDO> listUserAuthMappingByAuth(@Param("type") String type,
@Param("mappingIdList") List<String> mappingIdList,
@Param("positionType")String positionType,
@Param("notRoleAuth")String notRoleAuth);
List<UserAuthMappingDO> listUserAuthMappingByUserList(@Param("userIdList") List<String> userIdList);
List<UserAuthMappingDO> listUserAuthMappingByUserAndType(@Param("userId") String userId,
@Param("type") String type);
/**
* 根据用户id获得权限映射信息主键列表
* @param userId
* @return: java.util.List<java.lang.Long>
* @Author: xugangkun
* @Date: 2021/3/25 14:24
*/
List<Long> selectIdsByUserId( @Param("userId") String userId);
List<Long> selectIdsByUserIds( @Param("userIds") List<String> userIds);
UserAuthMappingDO getUserAuthByUserIdAndMappingId(
@Param("userId") String userId,
@Param("mappingId") String mappingId,
@Param("type") String type);
/**
* 分页订正 门店类型的权限
* @param enterpriseId
* @return
*/
List<UserAuthMappingDO> listStoreAuthByEid(@Param("enterpriseId") String enterpriseId);
List<UserAuthMappingDO> getAllAuthMapping(@Param("enterpriseId") String enterpriseId);
List<String> getUserIdsByMappingIds(@Param("mappingIdList") List<String> mappingIdList);
List<UserAuthMappingDO> getUserAuthByMappingIds(@Param("mappingIdList") List<String> mappingIdList);
List<String> getMappingIdsByUserId(@Param("userId")String userId);
List<String> getRegionIdByUserId(@Param("userId") String userId);
/**
* 根据UserId和权限来源获取权限
* @param userIdList
* @param source
* @return
*/
List<UserAuthMappingDO> listByUserIdListAndSource(@Param("userIdList") List<String> userIdList, @Param("source") String source);
List<UserAuthMappingDO> getAllByUserIds(@Param("userIdsByRoleIdList") List<String> userIdsByRoleIdList);
}

View File

@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="com.cool.store.entity.RegionAreaConfigDO"> <resultMap id="BaseResultMap" type="com.cool.store.entity.RegionAreaConfigDO">
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="region_id" jdbcType="BIGINT" property="regionId" /> <result column="region_id" jdbcType="BIGINT" property="regionId" />
<result column="region_path" jdbcType="VARCHAR" property="regionPath" />
<result column="want_shop_area_id" jdbcType="BIGINT" property="wantShopAreaId" /> <result column="want_shop_area_id" jdbcType="BIGINT" property="wantShopAreaId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
@@ -12,7 +13,7 @@
<result column="deleted" jdbcType="BIT" property="deleted" /> <result column="deleted" jdbcType="BIT" property="deleted" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, region_id, want_shop_area_id, create_time, update_time, create_user_id, update_user_id, id, region_id, region_path, want_shop_area_id, create_time, update_time, create_user_id, update_user_id,
deleted deleted
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@@ -34,6 +35,9 @@
<if test="regionId != null"> <if test="regionId != null">
region_id, region_id,
</if> </if>
<if test="regionPath != null">
region_path,
</if>
<if test="wantShopAreaId != null"> <if test="wantShopAreaId != null">
want_shop_area_id, want_shop_area_id,
</if> </if>
@@ -57,6 +61,9 @@
<if test="regionId != null"> <if test="regionId != null">
#{regionId,jdbcType=BIGINT}, #{regionId,jdbcType=BIGINT},
</if> </if>
<if test="regionPath != null">
#{regionPath,jdbcType=VARCHAR},
</if>
<if test="wantShopAreaId != null"> <if test="wantShopAreaId != null">
#{wantShopAreaId,jdbcType=BIGINT}, #{wantShopAreaId,jdbcType=BIGINT},
</if> </if>
@@ -83,6 +90,9 @@
<if test="regionId != null"> <if test="regionId != null">
region_id = #{regionId,jdbcType=BIGINT}, region_id = #{regionId,jdbcType=BIGINT},
</if> </if>
<if test="regionPath != null">
region_path = #{regionPath,jdbcType=VARCHAR},
</if>
<if test="wantShopAreaId != null"> <if test="wantShopAreaId != null">
want_shop_area_id = #{wantShopAreaId,jdbcType=BIGINT}, want_shop_area_id = #{wantShopAreaId,jdbcType=BIGINT},
</if> </if>
@@ -112,6 +122,9 @@
<if test="null != regionId"> <if test="null != regionId">
and t.region_id = #{regionId,jdbcType=BIGINT} and t.region_id = #{regionId,jdbcType=BIGINT}
</if> </if>
<if test="null != regionPath">
and t.region_path = #{regionPath,jdbcType=VARCHAR}
</if>
<if test="null != wantShopAreaId"> <if test="null != wantShopAreaId">
and t.want_shop_area_id = #{wantShopAreaId,jdbcType=BIGINT} and t.want_shop_area_id = #{wantShopAreaId,jdbcType=BIGINT}
</if> </if>
@@ -139,6 +152,14 @@
where region_id = #{regionId} where region_id = #{regionId}
</delete> </delete>
<delete id="deleteByWantShopAreaIds">
delete from xfsg_region_area_config
where want_shop_area_id in
<foreach collection="wantShopAreaIds" item="wantShopAreaId" open="(" separator="," close=")">
#{wantShopAreaId}
</foreach>
</delete>
<insert id="batchInsertOrUpdateRegionAreaConfig"> <insert id="batchInsertOrUpdateRegionAreaConfig">
insert into xfsg_region_area_config insert into xfsg_region_area_config
( (
@@ -176,4 +197,17 @@
from xfsg_region_area_config from xfsg_region_area_config
where want_shop_area_id = #{wantShopAreaId} where want_shop_area_id = #{wantShopAreaId}
</select> </select>
<select id="listAreaByRegionIdList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xfsg_region_area_config
where 1 = 1
<if test="regionIdList != null and regionIdList.size >0 ">
<foreach collection="regionIdList" item="regionId" separator=" or " open="and (" close=" )">
region_path like concat('%/', #{regionId}, '/%')
</foreach>
</if>
</select>
</mapper> </mapper>

View File

@@ -17,7 +17,8 @@
region_type as regionType, region_type as regionType,
region_path as regionPath, region_path as regionPath,
deleted as deleted, deleted as deleted,
third_dept_id as thirdDeptId third_dept_id as thirdDeptId,
third_region_type as thirdRegionType
</sql> </sql>
<select id="getRegionByRegionIdsForMap" resultType="com.cool.store.entity.RegionDO"> <select id="getRegionByRegionIdsForMap" resultType="com.cool.store.entity.RegionDO">
@@ -332,4 +333,17 @@
</select> </select>
<select id="listByThirdRegionType" resultType="com.cool.store.entity.RegionDO">
select <include refid="fields"/>
from region_${enterpriseId}
where deleted = 0
<if test="parentId != null">
and parent_id= #{parentId}
</if>
<if test="thirdRegionType != null and thirdRegionType != ''">
and third_region_type = #{thirdRegionType}
</if>
</select>
</mapper> </mapper>

View File

@@ -51,6 +51,16 @@
<if test="entity.experienceStatus != null">#{entity.experienceStatus},</if> <if test="entity.experienceStatus != null">#{entity.experienceStatus},</if>
<if test="entity.abandonCause != null">#{entity.abandonCause},</if> <if test="entity.abandonCause != null">#{entity.abandonCause},</if>
</trim> </trim>
ON DUPLICATE KEY UPDATE
<trim suffixOverrides=",">
<if test="entity.partnerId != null">partner_id = #{entity.partnerId},</if>
<if test="entity.storeName != null">store_name = #{entity.storeName},</if>
<if test="entity.storeId != null">store_id = #{entity.storeId},</if>
<if test="entity.experienceStartTime != null">experience_start_time = #{entity.experienceStartTime},</if>
<if test="entity.experienceEndTime != null">experience_end_time = #{entity.experienceEndTime},</if>
<if test="entity.experienceStatus != null">experience_status = #{entity.experienceStatus},</if>
<if test="entity.abandonCause != null">abandon_cause = #{entity.abandonCause},</if>
</trim>
</insert> </insert>
<update id="updateStatus"> <update id="updateStatus">
update update

View File

@@ -0,0 +1,187 @@
<?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.cool.store.mapper.UserAuthMappingMapper" >
<resultMap id="baseResult" type="com.cool.store.entity.UserAuthMappingDO">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="mappingId" column="mapping_id"/>
<result property="type" column="type"/>
<result property="source" column="source"/>
<result property="createId" column="create_id"/>
<result property="createTime" column="create_time"/>
<result property="updateId" column="update_id"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="listUserAuthMappingByUserId" resultMap="baseResult">
select * from user_auth_mapping_${enterpriseId}
where user_id=#{userId}
</select>
<select id="listUserAuthMappingByUserIdList" resultMap="baseResult">
select * from user_auth_mapping_${enterpriseId}
<where>
<if test="userList!=null and userList.size>0">
<foreach collection="userList" item="userId" open="user_id in (" separator="," close=")">
#{userId}
</foreach>
</if>
</where>
</select>
<select id="listUserAuthMappingByMappingList" resultMap="baseResult">
select * from user_auth_mapping_${enterpriseId}
<where>
<if test="mappingIdList!=null and mappingIdList.size>0">
<foreach collection="mappingIdList" item="mappingId" open="mapping_id in (" separator="," close=")">
#{mappingId}
</foreach>
</if>
<if test="type!=null and type!=''">
and type =#{type}
</if>
</where>
</select>
<select id="listUserAuthMappingByAuth" resultMap="baseResult">
select a.id,a.user_id,mapping_id,a.type from user_auth_mapping_${enterpriseId} a
join enterprise_user_${enterpriseId} e on a.user_id= e.user_id
JOIN enterprise_user_role_${enterpriseId} ur on e.user_id =ur.user_id
JOIN sys_role_${enterpriseId} b on ur.role_id=b.id
<where>
e.user_status= '1' and e.active= true
<if test="mappingIdList!=null and mappingIdList.size>0">
<foreach collection="mappingIdList" item="mappingId" open="and a.mapping_id in (" separator="," close=")">
#{mappingId}
</foreach>
</if>
<if test="positionType!=null and positionType!=''">
and b.position_type =#{positionType}
</if>
<if test="notRoleAuth!=null and notRoleAuth!=''">
and b.role_auth !=#{notRoleAuth}
</if>
<if test="type!=null and type!=''">
and a.type =#{type}
</if>
</where>
</select>
<select id="listUserAuthMappingByUserList" resultMap="baseResult">
select * from user_auth_mapping_${enterpriseId}
<where>
<if test="userIdList!=null and userIdList.size>0">
<foreach collection="userIdList" item="userId" open="user_id in (" separator="," close=")">
#{userId}
</foreach>
</if>
</where>
</select>
<select id="listUserAuthMappingByUserAndType" resultMap="baseResult">
select * from user_auth_mapping_${enterpriseId}
<where>
<if test="userId!=null and userId !=''">
and user_id=#{userId}
</if>
<if test="type!=null and type!=''">
and type =#{type}
</if>
</where>
</select>
<select id="selectIdsByUserId" resultType="java.lang.Long">
select id from user_auth_mapping_${enterpriseId} where user_id = #{userId}
</select>
<select id="selectIdsByUserIds" resultType="java.lang.Long">
select id from user_auth_mapping_${enterpriseId} where user_id in
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</select>
<select id="listByUserIdAndSource" resultMap="baseResult">
select *
from user_auth_mapping_${enterpriseId}
where user_id = #{userId}
and source = #{source}
</select>
<select id="getUserAuthByUserIdAndMappingId" resultMap="baseResult">
select * from user_auth_mapping_${enterpriseId}
where user_id = #{userId} and mapping_id =#{mappingId} and type =#{type}
</select>
<select id="listStoreAuthByEid" resultMap="baseResult">
select * FROM
user_auth_mapping_${enterpriseId}
WHERE type = 'store'
order by id asc
</select>
<select id="getAllAuthMapping" resultMap="baseResult">
select *
from user_auth_mapping_${enterpriseId}
</select>
<select id="getUserIdsByMappingIds" resultType="string">
select
user_id
from
user_auth_mapping_${enterpriseId}
where
mapping_id in
<foreach collection="mappingIdList" item="mappingId" open="(" separator="," close=")">
#{mappingId}
</foreach>
</select>
<select id="getUserAuthByMappingIds" resultMap="baseResult">
select
user_id,
mapping_id
from
user_auth_mapping_${enterpriseId}
where
mapping_id in
<foreach collection="mappingIdList" item="mappingId" open="(" separator="," close=")">
#{mappingId}
</foreach>
</select>
<select id="getMappingIdsByUserId" resultType="string">
select
mapping_id
from
user_auth_mapping_${enterpriseId}
where
user_id = #{userId}
</select>
<select id="getRegionIdByUserId" resultType="java.lang.String">
select mapping_id
from user_auth_mapping_${enterpriseId}
where user_id = #{userId}
</select>
<select id="listByUserIdListAndSource" resultMap="baseResult">
select *
from user_auth_mapping_${enterpriseId}
where `source` =#{source}
and user_id in
<foreach collection="userIdList" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</select>
<select id="getAllByUserIds" resultMap="baseResult">
select *
from user_auth_mapping_${enterpriseId}
<where>
user_id in
<foreach collection="userIdsByRoleIdList" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</where>
</select>
</mapper>

View File

@@ -24,6 +24,9 @@ public class RegionAreaConfigDO implements Serializable {
@ApiModelProperty("区域ID 战区id") @ApiModelProperty("区域ID 战区id")
private Long regionId; private Long regionId;
@ApiModelProperty("区域路径")
private String regionPath;
@ApiModelProperty("意向开店区域 省市code") @ApiModelProperty("意向开店区域 省市code")
private Long wantShopAreaId; private Long wantShopAreaId;

View File

@@ -150,6 +150,8 @@ public class RegionDO {
*/ */
private Boolean isExternalNode; private Boolean isExternalNode;
private String thirdRegionType;
public RegionDO(Long id, String name, String parentId, String groupId, Long createTime, String createName) { public RegionDO(Long id, String name, String parentId, String groupId, Long createTime, String createName) {
this.id = id; this.id = id;
this.name = name; this.name = name;

View File

@@ -0,0 +1,38 @@
package com.cool.store.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* describe:人员权限映射表
*
* @author zhouyiping
* @date 2020/10/10
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserAuthMappingDO {
private Long id;
private String userId;
private String mappingId;
private String type;
private String source;
private String createId;
private Long createTime;
private String updateId;
private Long updateTime;
public UserAuthMappingDO(String userId, String mappingId, String type, String source, String createId, Long createTime) {
this.userId = userId;
this.mappingId = mappingId;
this.type = type;
this.source = source;
this.createId = createId;
this.createTime = createTime;
}
}

View File

@@ -17,7 +17,7 @@ public class BaseInfoVO {
private Long lineId; private Long lineId;
@ApiModelProperty("partnerId") @ApiModelProperty("partnerId")
private Integer partnerId; private String partnerId;
@ApiModelProperty("线索名称") @ApiModelProperty("线索名称")
private String username; private String username;

View File

@@ -1,7 +1,10 @@
package com.cool.store.service; package com.cool.store.service;
import com.cool.store.entity.RegionDO;
import com.cool.store.vo.RegionPathNameVO; import com.cool.store.vo.RegionPathNameVO;
import java.util.List;
public interface RegionService { public interface RegionService {
RegionPathNameVO getAllRegionName(Long regionId); RegionPathNameVO getAllRegionName(Long regionId);
@@ -13,4 +16,6 @@ public interface RegionService {
*/ */
Long getBigRegionIdByAreaId(Long wantShopAreaId); Long getBigRegionIdByAreaId(Long wantShopAreaId);
List<RegionDO> listByThirdRegionType(Long parentId, String thirdRegionType);
} }

View File

@@ -0,0 +1,8 @@
package com.cool.store.service;
public interface SysRoleService {
Boolean checkIsAdmin(String userId);
}

View File

@@ -0,0 +1,38 @@
package com.cool.store.service;
import com.cool.store.entity.EnterpriseUserDO;
import com.cool.store.entity.UserAuthMappingDO;
import java.util.List;
/**
* describe:
*
* @author wxp
* @date 2020/11/11
*/
public interface UserAuthMappingService {
/**
* 获取用户权限
* @param userId
* @return
*/
List<UserAuthMappingDO> listUserAuthMappingByUserId(String userId);
/**
* 提供 根据职位 意向区域 查 对应人的接口 同时返回人名字
* @param roleId
* @param wantShopAreaId
* @return
*/
EnterpriseUserDO listUserByRoleIdAndAreaId(Long roleId, Long wantShopAreaId);
/**
* 根据 人 查 这个人管辖区域 对应的意向区域省市code 团队线索
* @param userId
* @return
*/
List<Long> listWantShopAreaIdByUserId(String userId);
}

View File

@@ -55,7 +55,7 @@ public class IntentAgreementServiceImpl implements IntentAgreementService {
if (Objects.isNull(lineInfoDO)){ if (Objects.isNull(lineInfoDO)){
throw new ServiceException(ErrorCodeEnum.INTERVIEW_PARTNER_NOT_EXIST); throw new ServiceException(ErrorCodeEnum.INTERVIEW_PARTNER_NOT_EXIST);
} }
lineInfoDO.setWorkflowSubStageStatus(WorkflowSubStageStatusEnum.SIGN_INTENT_AGREEMENT_60.getCode()); lineInfoDO.setWorkflowSubStageStatus(WorkflowSubStageStatusEnum.SIGN_INTENT_AGREEMENT_63.getCode());
lineInfoMapper.updateByPrimaryKeySelective(lineInfoDO); lineInfoMapper.updateByPrimaryKeySelective(lineInfoDO);
return Boolean.TRUE; return Boolean.TRUE;

View File

@@ -2,7 +2,11 @@ package com.cool.store.service.impl;
import com.cool.store.context.LoginUserInfo; import com.cool.store.context.LoginUserInfo;
import com.cool.store.dao.RegionAreaConfigDao; import com.cool.store.dao.RegionAreaConfigDao;
import com.cool.store.dao.RegionDao;
import com.cool.store.entity.RegionAreaConfigDO; import com.cool.store.entity.RegionAreaConfigDO;
import com.cool.store.entity.RegionDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.request.RegionAreaConfigAddRequest; import com.cool.store.request.RegionAreaConfigAddRequest;
import com.cool.store.service.RegionAreaConfigService; import com.cool.store.service.RegionAreaConfigService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -27,17 +31,25 @@ public class RegionAreaConfigServiceImpl implements RegionAreaConfigService {
@Resource @Resource
private RegionAreaConfigDao regionAreaConfigDao; private RegionAreaConfigDao regionAreaConfigDao;
@Resource
private RegionDao regionDao;
@Override @Override
public Boolean saveOrUpdateRegionAreaConfig(RegionAreaConfigAddRequest regionAreaConfigAddRequest, LoginUserInfo user) { public Boolean saveOrUpdateRegionAreaConfig(RegionAreaConfigAddRequest regionAreaConfigAddRequest, LoginUserInfo user) {
RegionDO regionDO = regionDao.getRegionById(regionAreaConfigAddRequest.getRegionId());
if(regionDO == null){
throw new ServiceException(ErrorCodeEnum.REGION_NOT_EXIST);
}
List<Long> areaIdList = regionAreaConfigAddRequest.getAreaIdList(); List<Long> areaIdList = regionAreaConfigAddRequest.getAreaIdList();
if(CollectionUtils.isEmpty(areaIdList)){ if(CollectionUtils.isEmpty(areaIdList)){
return Boolean.TRUE; return Boolean.TRUE;
} }
regionAreaConfigDao.deleteRegionAreaConfigByRegionId(regionAreaConfigAddRequest.getRegionId()); regionAreaConfigDao.deleteByWantShopAreaIds(areaIdList);
List<RegionAreaConfigDO> regionAreaConfigList = new ArrayList<>(); List<RegionAreaConfigDO> regionAreaConfigList = new ArrayList<>();
for (Long areaId: areaIdList) { for (Long areaId: areaIdList) {
RegionAreaConfigDO regionAreaConfigDO = new RegionAreaConfigDO(); RegionAreaConfigDO regionAreaConfigDO = new RegionAreaConfigDO();
regionAreaConfigDO.setRegionId(regionAreaConfigAddRequest.getRegionId()); regionAreaConfigDO.setRegionId(regionAreaConfigAddRequest.getRegionId());
regionAreaConfigDO.setRegionPath(regionDO.getFullRegionPath());
regionAreaConfigDO.setWantShopAreaId(areaId); regionAreaConfigDO.setWantShopAreaId(areaId);
regionAreaConfigDO.setCreateUserId(user.getUserId()); regionAreaConfigDO.setCreateUserId(user.getUserId());
regionAreaConfigDO.setUpdateUserId(user.getUserId()); regionAreaConfigDO.setUpdateUserId(user.getUserId());

View File

@@ -24,6 +24,8 @@ import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.cool.store.enums.ErrorCodeEnum.PARAMS_VALIDATE_ERROR;
/** /**
* @ClassName RegionServiceImpl * @ClassName RegionServiceImpl
* @Description 区域服务 * @Description 区域服务
@@ -114,4 +116,12 @@ public class RegionServiceImpl implements RegionService {
} }
return 0L; return 0L;
} }
@Override
public List<RegionDO> listByThirdRegionType(Long parentId, String thirdRegionType) {
if(Objects.isNull(parentId) && StringUtils.isBlank(thirdRegionType)){
throw new ServiceException(PARAMS_VALIDATE_ERROR);
}
return regionDao.listByThirdRegionType(parentId, thirdRegionType);
}
} }

View File

@@ -0,0 +1,37 @@
package com.cool.store.service.impl;
import com.cool.store.entity.SysRoleDO;
import com.cool.store.enums.Role;
import com.cool.store.mapper.SysRoleMapper;
import com.cool.store.service.SysRoleService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 角色service
* @author wxp
*/
@Slf4j
@Service
public class SysRoleServiceImpl implements SysRoleService {
@Resource
private SysRoleMapper sysRoleMapper;
@Override
public Boolean checkIsAdmin(String userId) {
// 1.取出所有用户角色
// 2.匹配是否有管理员角色
List<SysRoleDO> sysRoleDOList = sysRoleMapper.listRoleByUserId(userId);
return ListUtils.emptyIfNull(sysRoleDOList)
.stream()
.anyMatch(role-> StringUtils.equals(Role.MASTER.getRoleEnum(),role.getRoleEnum()));
}
}

View File

@@ -4,6 +4,7 @@ import com.cool.store.entity.LeaseBaseInfoDO;
import com.cool.store.entity.LineInfoDO; import com.cool.store.entity.LineInfoDO;
import com.cool.store.enums.ErrorCodeEnum; import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.ExperienceStatusEnum; import com.cool.store.enums.ExperienceStatusEnum;
import com.cool.store.enums.WorkflowSubStageEnum;
import com.cool.store.enums.WorkflowSubStageStatusEnum; import com.cool.store.enums.WorkflowSubStageStatusEnum;
import com.cool.store.exception.ServiceException; import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.LineInfoMapper; import com.cool.store.mapper.LineInfoMapper;
@@ -31,6 +32,7 @@ public class TrainingExperienceServiceImpl implements TrainingExperienceService
LineInfoMapper lineInfoMapper; LineInfoMapper lineInfoMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class)
public boolean distribution(TrainingExperienceDistributionRequest request) { public boolean distribution(TrainingExperienceDistributionRequest request) {
if (Objects.isNull(request)) { if (Objects.isNull(request)) {
return Boolean.FALSE; return Boolean.FALSE;
@@ -38,7 +40,12 @@ public class TrainingExperienceServiceImpl implements TrainingExperienceService
if (Objects.isNull(request.getLineId())) { if (Objects.isNull(request.getLineId())) {
throw new ServiceException(INTERVIEW_LINE_ID_IS_NULL); throw new ServiceException(INTERVIEW_LINE_ID_IS_NULL);
} }
trainingExperienceMapper.insert(request.toLeaseBaseInfoDO()); LeaseBaseInfoDO leaseBaseInfoDO = request.toLeaseBaseInfoDO();
trainingExperienceMapper.insert(leaseBaseInfoDO);
LineInfoDO lineInfoDO = new LineInfoDO();
lineInfoDO.setWorkflowSubStage(WorkflowSubStageEnum.SIGN_INTENT_AGREEMENT.getCode());
lineInfoDO.setId(request.getLineId());
lineInfoMapper.updateByPrimaryKey(lineInfoDO);
return true; return true;
} }

View File

@@ -0,0 +1,193 @@
package com.cool.store.service.impl;
import cn.hutool.core.util.StrUtil;
import com.cool.store.dao.EnterpriseUserDAO;
import com.cool.store.dao.RegionAreaConfigDao;
import com.cool.store.entity.EnterpriseUserDO;
import com.cool.store.entity.RegionAreaConfigDO;
import com.cool.store.entity.RegionDO;
import com.cool.store.entity.UserAuthMappingDO;
import com.cool.store.enums.AuthRoleEnum;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.Role;
import com.cool.store.enums.UserAuthMappingTypeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.RegionMapper;
import com.cool.store.mapper.SysRoleMapper;
import com.cool.store.mapper.UserAuthMappingMapper;
import com.cool.store.service.UserAuthMappingService;
import com.cool.store.vo.SysRoleVO;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* describe:
* @author wxp
* @date 2020/11/11
*/
@Service
@Slf4j
public class UserAuthMappingServiceImpl implements UserAuthMappingService {
@Resource
private UserAuthMappingMapper userAuthMappingMapper;
@Resource
private RegionAreaConfigDao regionAreaConfigDao;
@Resource
private SysRoleMapper sysRoleMapper;
@Resource
private RegionMapper regionMapper;
@Resource
private EnterpriseUserDAO enterpriseUserDAO;
@Override
public List<UserAuthMappingDO> listUserAuthMappingByUserId(String userId) {
if(StringUtils.isBlank(userId)){
return Lists.newArrayList();
}
return userAuthMappingMapper.listUserAuthMappingByUserId(userId);
}
/**
* 提供 根据职位 意向区域 查 对应人的接口 同时返回人名字
* @param roleId
* @param wantShopAreaId
* @return
*/
@Override
public EnterpriseUserDO listUserByRoleIdAndAreaId(Long roleId, Long wantShopAreaId) {
if(roleId == null || wantShopAreaId == null){
return null;
}
Long warRegionId = regionAreaConfigDao.getByWantShopAreaId(wantShopAreaId);
// 查找有战区权限的人
List<String> authWarRegionUserIdList = authWarRegionUser(warRegionId);
List<String> userIds = sysRoleMapper.getPositionUserIds(Collections.singletonList(String.valueOf(roleId)));
authWarRegionUserIdList.retainAll(userIds);
List<EnterpriseUserDO> userDOList = enterpriseUserDAO.getUserInfoByUserIds(authWarRegionUserIdList);
// 用redis实现 用户列表轮询返回
return userDOList.get(0);
}
/**
* 根据 人 查 这个人管辖区域 对应的意向区域省市code 团队线索
* @param userId
* @return
*/
@Override
public List<Long> listWantShopAreaIdByUserId(String userId) {
List<UserAuthMappingDO> userAuthList = this.listUserAuthMappingByUserId(userId);
List<String> authRegionIds = ListUtils.emptyIfNull(userAuthList)
.stream().map(UserAuthMappingDO::getMappingId)
.collect(Collectors.toList());
List<Long> authRegionIdList = ListUtils.emptyIfNull(authRegionIds).stream().map(regionId -> Long.valueOf(regionId)).collect(Collectors.toList());
List<RegionAreaConfigDO> regionAreaConfigDOList = regionAreaConfigDao.listAreaByRegionIdList(authRegionIdList);
List<Long> wantShopAreaIdList = ListUtils.emptyIfNull(regionAreaConfigDOList)
.stream().map(RegionAreaConfigDO::getWantShopAreaId)
.collect(Collectors.toList());
return wantShopAreaIdList;
}
// 查找有战区权限的人
public List<String> authWarRegionUser(Long warRegionId) {
List<String> result = new ArrayList<>();
if(Objects.isNull(warRegionId)){
return result;
}
RegionDO regionDO = regionMapper.getByRegionId(warRegionId);
if(regionDO == null){
throw new ServiceException(ErrorCodeEnum.REGION_NOT_EXIST);
}
//将拥有管理员角色、角色属性为全企业数据的人查询出来
List<SysRoleVO> roleUserByRoleId = sysRoleMapper.getRoleUserByRoleEnum(Role.MASTER.getRoleEnum(), null);
List<SysRoleVO> roleUserByRoleAuth = sysRoleMapper.getRoleUserByRoleAuth(AuthRoleEnum.ALL.getCode(), null);
//组合出拥有所有门店信息的人
List<String> allWarRegionUserIdList = getAllWarRegionAuthUserIdList(roleUserByRoleId, roleUserByRoleAuth);
//查询出有门店权限配置的的人员
// 1.将门店区域切分出门店所属于的区域ID
// 2.将配置了区域的人 查询出来
List<String> fullAreaIdList = StrUtil.splitTrim(regionDO.getRegionPath(),"/");
List<String> lastAreaIdList = Collections.singletonList(String.valueOf(regionDO.getId()));
//除不包含子区域的可视化范围的区域配置。
List<UserAuthMappingDO> regionUserAuthMappingList =
userAuthMappingMapper.listUserAuthMappingByAuth(UserAuthMappingTypeEnum.REGION.getCode(), fullAreaIdList, null, AuthRoleEnum.NOT_INCLUDE_SUBORDINATE.getCode());
//不包含子区域的的直属连接门店的区域下的配置(会重复一些选择了上面数据)
List<UserAuthMappingDO> notIncludeRegionUserAuthMappingList =
userAuthMappingMapper.listUserAuthMappingByAuth(UserAuthMappingTypeEnum.REGION.getCode(), lastAreaIdList, null, null);
List<String> authWarRegionUserIdList = mapAuthStoreUserDTO(regionUserAuthMappingList, allWarRegionUserIdList, notIncludeRegionUserAuthMappingList);
return authWarRegionUserIdList;
}
private List<String> getAllWarRegionAuthUserIdList(List<SysRoleVO> roleUserByRoleId, List<SysRoleVO> roleUserByRoleAuth) {
List<String> allUserIdList= new ArrayList<>();
List<String> masterUserList = ListUtils.emptyIfNull(roleUserByRoleId).stream()
.map(SysRoleVO::getEnterpriseDOs)
.flatMap(Collection::stream)
.map(EnterpriseUserDO::getUserId)
.collect(Collectors.toList());
List<String> roleAllUserList = ListUtils.emptyIfNull(roleUserByRoleAuth).stream()
.map(SysRoleVO::getEnterpriseDOs)
.flatMap(Collection::stream)
.map(EnterpriseUserDO::getUserId)
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(masterUserList)) {
allUserIdList.addAll(masterUserList);
}
if (CollectionUtils.isNotEmpty(roleAllUserList)) {
allUserIdList.addAll(roleAllUserList);
}
return ListUtils.emptyIfNull(allUserIdList)
.stream()
.distinct()
.collect(Collectors.toList());
}
private List<String> mapAuthStoreUserDTO(
List<UserAuthMappingDO> regionUserAuthMappingList,
List<String> allWarRegionUserIdList,
List<UserAuthMappingDO> notIncludeRegionUserAuthMappingList) {
//组装全部的人员信息
List<String> authUserIdList = new ArrayList<>();
//组装拥有所有门店信息的人
if (CollectionUtils.isNotEmpty(allWarRegionUserIdList)) {
authUserIdList.addAll(allWarRegionUserIdList);
}
//组装配置了区域权限的人(除了不包含子区域可视化范围)
List<String> regionUserIdList = ListUtils.emptyIfNull(regionUserAuthMappingList).stream()
.map(UserAuthMappingDO::getUserId)
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(regionUserIdList)) {
authUserIdList.addAll(regionUserIdList);
}
//组装配置了区域权限的人(不包含子区域可视化范围)
List<String> notIncludeRegionUserIdList = ListUtils.emptyIfNull(notIncludeRegionUserAuthMappingList).stream()
.map(UserAuthMappingDO::getUserId)
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(notIncludeRegionUserIdList)) {
authUserIdList.addAll(notIncludeRegionUserIdList);
}
//去除重复数据
List<String> distinctUserIdList = ListUtils.emptyIfNull(authUserIdList).stream()
.distinct()
.collect(Collectors.toList());
return distinctUserIdList;
}
}

View File

@@ -23,7 +23,7 @@ public class PCTrainingExperienceController {
@Resource @Resource
TrainingExperienceService trainingExperienceService; TrainingExperienceService trainingExperienceService;
@ApiOperation("实训体验分配") @ApiOperation("实训体验分配或更新")
@PostMapping("/distribution") @PostMapping("/distribution")
public ResponseResult<Boolean> distribution(@RequestBody TrainingExperienceDistributionRequest request) { public ResponseResult<Boolean> distribution(@RequestBody TrainingExperienceDistributionRequest request) {
return ResponseResult.success(trainingExperienceService.distribution(request)); return ResponseResult.success(trainingExperienceService.distribution(request));

View File

@@ -0,0 +1,38 @@
package com.cool.store.controller.webb;
import com.cool.store.entity.RegionDO;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.RegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @ClassName RegionController
* @Description 区域
*/
@RestController
@RequestMapping("/pc/region")
@Api(tags = "区域信息")
@Slf4j
public class RegionController {
@Autowired
private RegionService regionService;
@ApiOperation("根据三方区域类型获取区域列表 0-根 1=大区 2=战区 3=小区(督导区 4=门店")
@GetMapping("/listByThirdRegionType")
public ResponseResult<List<RegionDO>> listByThirdRegionType(@RequestParam(value = "parentId", required = false) Long parentId,
@RequestParam(value = "thirdRegionType", required = false) String thirdRegionType) {
return ResponseResult.success(regionService.listByThirdRegionType(parentId, thirdRegionType));
}
}