销售权限控制修改
This commit is contained in:
+3
@@ -57,6 +57,9 @@ public class BmsCustomer extends BaseEntity
|
||||
@Excel(name = "业务员姓名")
|
||||
private String salesUser;
|
||||
|
||||
/** 业务员昵称(join sys_user.nick_name,sales_user_id 存工号=sys_user.user_name) */
|
||||
private String salesUserNickName;
|
||||
|
||||
/** 资金额度(元) */
|
||||
@Excel(name = "资金额度", readConverterExp = "元=")
|
||||
private BigDecimal ed;
|
||||
|
||||
+2
-1
@@ -65,7 +65,8 @@ public class BmsCustomerServiceImpl implements IBmsCustomerService
|
||||
* @return 客户主
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "su", deptField = "dept_id", userAlias = "c", userField = "sales_user_id")
|
||||
// sales_user_id 存的是员工工号(=sys_user.user_name),仅本人/本部门均通过 sys_user 别名 su 关联匹配
|
||||
@DataScope(deptAlias = "su", deptField = "dept_id", userAlias = "su", userField = "user_id")
|
||||
public List<BmsCustomer> selectBmsCustomerList(BmsCustomer bmsCustomer)
|
||||
{
|
||||
return bmsCustomerMapper.selectBmsCustomerList(bmsCustomer);
|
||||
|
||||
@@ -156,7 +156,8 @@ public class OrgSyncService
|
||||
r.setRoleName(truncate(name, 30));
|
||||
r.setRoleKey("ORA_" + rid);
|
||||
r.setRoleSort(sort++);
|
||||
r.setDataScope("1");
|
||||
// 销售类角色默认数据范围:销售经理=本部门数据(3);销售员=仅本人数据(5);其余角色=全部数据(1)
|
||||
r.setDataScope(defaultDataScope(rid));
|
||||
r.setMenuCheckStrictly(true);
|
||||
r.setDeptCheckStrictly(true);
|
||||
r.setStatus("0");
|
||||
@@ -169,6 +170,23 @@ public class OrgSyncService
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步角色的默认数据范围(RuoYi:1全部 2自定义 3本部门 4本部门及以下 5仅本人)。
|
||||
* 6040 销售经理=本部门,6041 销售员=仅本人;其他角色默认全部(可在角色管理中调整)。
|
||||
*/
|
||||
private static String defaultDataScope(Long oracleRoleId)
|
||||
{
|
||||
if (Long.valueOf(6040L).equals(oracleRoleId))
|
||||
{
|
||||
return "3";
|
||||
}
|
||||
if (Long.valueOf(6041L).equals(oracleRoleId))
|
||||
{
|
||||
return "5";
|
||||
}
|
||||
return "1";
|
||||
}
|
||||
|
||||
private List<SysUser> buildUsers(List<Map<String, Object>> rows, Map<String, Long> deptIdByCode)
|
||||
{
|
||||
List<SysUser> list = new ArrayList<>();
|
||||
|
||||
@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="isEnable" column="is_enable" />
|
||||
<result property="salesUserId" column="sales_user_id" />
|
||||
<result property="salesUser" column="sales_user" />
|
||||
<result property="salesUserNickName" column="sales_user_nick_name" />
|
||||
<result property="ed" column="ed" />
|
||||
<result property="zq" column="zq" />
|
||||
<result property="settlementUserId" column="settlement_user_id" />
|
||||
@@ -52,11 +53,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where ca.customer_id = c.customer_id and ca.del_flag = '0') as credit_ed,
|
||||
|
||||
c.product_codes, c.remark,
|
||||
c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag
|
||||
c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag,
|
||||
su.nick_name as sales_user_nick_name
|
||||
from ctr_customer c
|
||||
<!-- 数据权限:销售(仅本人 c.sales_user_id)/销售经理(本部门 su.dept_id);
|
||||
历史迁移数据 sales_user_id 为非数字工号,+0 后不匹配任何 sys_user,仅管理员可见 -->
|
||||
left join sys_user su on su.user_id = c.sales_user_id + 0
|
||||
<!-- 老系统同步数据 sales_user_id 存员工工号(=sys_user.user_name);
|
||||
BMS 手工新建数据可能存数字 user_id,两种都要能关联上。
|
||||
'WS0052'+0 在 MySQL 中结果为 0,不会误关联到任何用户 -->
|
||||
left join sys_user su
|
||||
on su.del_flag = '0'
|
||||
and (su.user_name = c.sales_user_id or su.user_id = c.sales_user_id + 0)
|
||||
</sql>
|
||||
|
||||
<select id="selectBmsCustomerList" parameterType="BmsCustomer" resultMap="BmsCustomerResult">
|
||||
@@ -93,7 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="throwRatio != null "> and c.throw_ratio = #{throwRatio}</if>
|
||||
<if test="creditEd != null "> and c.credit_ed = #{creditEd}</if>
|
||||
<if test="productCodes != null and productCodes != ''"> and c.product_codes = #{productCodes}</if>
|
||||
<!-- 数据权限过滤(@DataScope 生成:仅本人= c.sales_user_id=当前用户;本部门= su.dept_id=当前用户部门) -->
|
||||
<!-- 数据权限过滤(@DataScope 生成:仅本人= su.user_id=当前用户;本部门= su.dept_id=当前用户部门) -->
|
||||
${params.dataScope}
|
||||
</where>
|
||||
order by c.customer_id desc
|
||||
|
||||
@@ -67,6 +67,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="nickName != null and nickName != ''">
|
||||
AND u.nick_name like concat('%', #{nickName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND u.status = #{status}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user