Browse Source

[fix]工程管理

修改客户信息分页查询后端接口:去掉之前没用的筛选只有业务员才能查看数据的过滤条件。新增根据当前登陆人查找对应的角色Id得到所有的不重复roleKeys然后关联客户信息的creatBy字段实现添加人及上级可查看添加人的数据
新增角色过滤数据后端方法
客户基本信息实体类和数据库表新增createBy字段,新增角色集合allowedCreators字段和其对应的get、set方法
修改客户基本信息Mapper.xml层的所有方法加上createBy字段;修改分页查询方法:加上对allowedCreators里面数据的遍历
dev
liuxiaoxu 4 weeks ago
parent
commit
d5bd2c9090
  1. 24
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java
  2. 13
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomer.java
  3. 6
      ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java
  4. 23
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java
  5. 16
      ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml

24
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerController.java

@ -44,6 +44,7 @@ import javax.servlet.http.HttpSession;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 客户基本信息Controller * 客户基本信息Controller
@ -104,15 +105,26 @@ public class SysCustomerController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(SysCustomerVo sysCustomerVo) public TableDataInfo list(SysCustomerVo sysCustomerVo)
{ {
SysUser curUser = ShiroUtils.getSysUser();
Long userId = curUser.getUserId(); Long userId = ShiroUtils.getUserId();
Set<String> roleKeys = roleService.selectRoleKeys(userId); List<SysUserRole> sysUserRoles = userService.selectUserRoleByUserId(userId);
// 业务员角色只能看到自己创建的数据 //得到所有的不重复roleKeys
if (roleKeys.contains("ywyRole")) { Set<String> roleKeys = sysUserRoles.stream()
sysCustomerVo.setApplyUser(curUser.getLoginName()); .map(SysUserRole::getRoleId)
.map(roleService::selectRoleById)
.map(SysRole::getRoleKey)
.collect(Collectors.toSet());
Set<String> allowedCreators = sysCustomerService.getAllowedCreators(roleKeys);
// 设置可查看的创建者
if (!allowedCreators.isEmpty()) {
sysCustomerVo.setAllowedCreators(new ArrayList<>(allowedCreators));
} }
startPage(); startPage();
List<SysCustomerVo> list = sysCustomerService.selectSysCustomerList(sysCustomerVo); List<SysCustomerVo> list = sysCustomerService.selectSysCustomerList(sysCustomerVo);
return getDataTable(list); return getDataTable(list);
} }

13
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysCustomer.java

@ -293,6 +293,9 @@ public class SysCustomer extends BaseEntity
private String customerId; private String customerId;
/** 角色权限*/
private List<String> allowedCreators;
public String getCustomerSign() { public String getCustomerSign() {
return customerSign; return customerSign;
} }
@ -778,6 +781,14 @@ public class SysCustomer extends BaseEntity
this.customerId = customerId; this.customerId = customerId;
} }
public List<String> getAllowedCreators() {
return allowedCreators;
}
public void setAllowedCreators(List<String> allowedCreators) {
this.allowedCreators = allowedCreators;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -828,6 +839,8 @@ public class SysCustomer extends BaseEntity
.append("customerName",getCustomerName()) .append("customerName",getCustomerName())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("cancelRemark",getCancelRemark()) .append("cancelRemark",getCancelRemark())
.append("allowedCreators",getAllowedCreators())
.toString(); .toString();
} }
} }

6
ruoyi-admin/src/main/java/com/ruoyi/system/service/ISysCustomerService.java

@ -9,6 +9,7 @@ import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 客户基本信息Service接口 * 客户基本信息Service接口
@ -126,4 +127,9 @@ public interface ISysCustomerService
* 根据客户名称查询客户信息 * 根据客户名称查询客户信息
* */ * */
SysCustomer selectSysCustomerByEnterpriseName(String enterpriseName); SysCustomer selectSysCustomerByEnterpriseName(String enterpriseName);
/**
* 角色过滤数据
* */
Set<String> getAllowedCreators(Set<String> roleKeys);
} }

23
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysCustomerServiceImpl.java

@ -182,6 +182,29 @@ public class SysCustomerServiceImpl implements ISysCustomerService
return sysCustomerMapper.selectSysCustomerByEnterpriseName(enterpriseName); return sysCustomerMapper.selectSysCustomerByEnterpriseName(enterpriseName);
} }
/**
* 角色过滤数据
* */
@Override
public Set<String> getAllowedCreators(Set<String> roleKeys) {
Set<String> allowedCreators = new HashSet<>();
if (roleKeys.contains("ywyRole")) {
allowedCreators.add(ShiroUtils.getLoginName()); // 只能看到自己的数据
}
if (roleKeys.contains("ywzgRole")) {
allowedCreators.add("sales_m2");
allowedCreators.add("sales_01");
}
if (roleKeys.contains("ywjlRole")) {
allowedCreators.add("sales_m2");
allowedCreators.add("sales_01");
allowedCreators.add("sales_m1");
}
return allowedCreators;
}
/** /**
* 新增客户基本信息 * 新增客户基本信息
* *

16
ruoyi-admin/src/main/resources/mapper/system/SysCustomerMapper.xml

@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="auditStatus" column="audit_status" /> <result property="auditStatus" column="audit_status" />
<result property="useStatus" column="use_status" /> <result property="useStatus" column="use_status" />
<result property="customerRemarks" column="customer_remarks" /> <result property="customerRemarks" column="customer_remarks" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="customerSign" column="customer_sign" /> <result property="customerSign" column="customer_sign" />
<result property="instanceId" column="instance_id" /> <result property="instanceId" column="instance_id" />
@ -64,7 +65,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="rmbFlag" column="rmb_flag" /> <result property="rmbFlag" column="rmb_flag" />
<result property="usdFlag" column="usd_flag" /> <result property="usdFlag" column="usd_flag" />
<result property="cancelRemark" column="cancel_remark" /> <result property="cancelRemark" column="cancel_remark" />
</resultMap> </resultMap>
<sql id="selectSysCustomerVo"> <sql id="selectSysCustomerVo">
select id,enterprise_code,enterprise_name,english_name,customer_abbreviation ,customer_purser , select id,enterprise_code,enterprise_name,english_name,customer_abbreviation ,customer_purser ,
@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
customer_contact_id,customer_contact,customer_office,contact_number,customer_email,customer_fax, customer_contact_id,customer_contact,customer_office,contact_number,customer_email,customer_fax,
delivery_address_id,delivery_customer_person,delivery_customer_phone, delivery_address_id,delivery_customer_person,delivery_customer_phone,
delivery_address,delivery_customer_postal,delivery_customer_fax,business_members, delivery_address,delivery_customer_postal,delivery_customer_fax,business_members,
identifying_people,first_add_time,update_info_time, create_time ,audit_status,use_status,update_by, update_time,rmb_flag,usd_flag, cancel_remark, identifying_people,first_add_time,update_info_time, create_time ,audit_status,use_status,update_by, create_by,update_time,rmb_flag,usd_flag, cancel_remark,
apply_user,apply_time , instance_id , instance_type from sys_customer apply_user,apply_time , instance_id , instance_type from sys_customer
</sql> </sql>
@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
customer_contact_id,customer_contact,customer_office,contact_number,customer_email,customer_fax, customer_contact_id,customer_contact,customer_office,contact_number,customer_email,customer_fax,
delivery_address_id,delivery_customer_person,delivery_customer_phone, delivery_address_id,delivery_customer_person,delivery_customer_phone,
delivery_address,delivery_customer_postal,delivery_customer_fax,business_members,rmb_flag,usd_flag, delivery_address,delivery_customer_postal,delivery_customer_fax,business_members,rmb_flag,usd_flag,
identifying_people,first_add_time,update_info_time,audit_status,use_status, create_time,update_time from identifying_people,first_add_time,update_info_time,audit_status,use_status, create_by,create_time,update_time from
sys_customer sys_customer
<where> <where>
and audit_status = '1' and use_status = '1' and audit_status = '1' and use_status = '1'
@ -102,7 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
s.customs_code,s.customer_contact_id,s.customer_contact,s.customer_office,s.contact_number,s.customer_email, s.customs_code,s.customer_contact_id,s.customer_contact,s.customer_office,s.contact_number,s.customer_email,
s.customer_fax,s.delivery_address_id,s.delivery_customer_person,s.delivery_customer_phone,s.delivery_address, s.customer_fax,s.delivery_address_id,s.delivery_customer_person,s.delivery_customer_phone,s.delivery_address,
s.delivery_customer_postal,s.delivery_customer_fax,s.business_members,s.identifying_people,s.first_add_time, s.delivery_customer_postal,s.delivery_customer_fax,s.business_members,s.identifying_people,s.first_add_time,
s.update_info_time,s.audit_status,s.use_status,s.update_by,s.instance_id, s.instance_type,p.dict_value as instance_type_name, s.update_info_time,s.audit_status,s.use_status,s.update_by, s.create_by,s.instance_id, s.instance_type,p.dict_value as instance_type_name,
s.submit_instance_id, s.cancel_instance_id, s.restore_instance_id, s.apply_title, s.apply_user, s.apply_time ,s.create_time,s.update_time ,s.rmb_flag,s.usd_flag s.submit_instance_id, s.cancel_instance_id, s.restore_instance_id, s.apply_title, s.apply_user, s.apply_time ,s.create_time,s.update_time ,s.rmb_flag,s.usd_flag
from sys_customer as s from sys_customer as s
left join( left join(
@ -122,6 +122,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deliveryAddress != null and deliveryAddress != ''"> and s.delivery_address like concat('%', #{deliveryAddress}, '%')</if> <if test="deliveryAddress != null and deliveryAddress != ''"> and s.delivery_address like concat('%', #{deliveryAddress}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and s.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if> <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and s.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
<if test="customerSign != null and customerSign != ''"> and s.customer_sign = #{customerSign}</if> <if test="customerSign != null and customerSign != ''"> and s.customer_sign = #{customerSign}</if>
<!-- 添加权限控制逻辑 -->
<if test="allowedCreators != null and !allowedCreators.isEmpty()">
and s.create_by in (<foreach item="item" index="index" collection="allowedCreators" open="" close="" separator=",">
#{item}
</foreach>)
</if>
</where> </where>
order by s.audit_status asc, s.create_time desc order by s.audit_status asc, s.create_time desc
</select> </select>
@ -225,6 +231,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="usdFlag != null">usd_flag,</if> <if test="usdFlag != null">usd_flag,</if>
<if test="cancelRemark != null">cancel_remark,</if> <if test="cancelRemark != null">cancel_remark,</if>
<if test="customerSign != null">customer_sign,</if> <if test="customerSign != null">customer_sign,</if>
<if test="createBy != null">create_by,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="enterpriseCode!=null and enterpriseCode != ''">#{enterpriseCode},</if> <if test="enterpriseCode!=null and enterpriseCode != ''">#{enterpriseCode},</if>
@ -281,6 +288,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="usdFlag != null"> #{usdFlag}, </if> <if test="usdFlag != null"> #{usdFlag}, </if>
<if test="cancelRemark != null">#{cancelRemark},</if> <if test="cancelRemark != null">#{cancelRemark},</if>
<if test="customerSign != null">#{customerSign},</if> <if test="customerSign != null">#{customerSign},</if>
<if test="createBy != null">#{createBy},</if>
</trim> </trim>
</insert> </insert>

Loading…
Cancel
Save