fix: 客户管理字段权限控制
This commit is contained in:
@@ -14,6 +14,7 @@ import org.agt.framework.common.pojo.PageResult;
|
||||
import org.agt.framework.common.util.object.BeanUtils;
|
||||
import org.agt.framework.excel.core.util.ExcelUtils;
|
||||
import org.agt.framework.ip.core.utils.AreaUtils;
|
||||
import org.agt.framework.security.core.service.SecurityFrameworkService;
|
||||
import org.agt.module.license.controller.admin.customer.vo.CustomerImportRespVO;
|
||||
import org.agt.module.license.controller.admin.customer.vo.CustomerPageReqVO;
|
||||
import org.agt.module.license.controller.admin.customer.vo.CustomerRespVO;
|
||||
@@ -50,6 +51,9 @@ public class CustomerController {
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
|
||||
@Resource
|
||||
private SecurityFrameworkService securityFrameworkService;
|
||||
|
||||
@GetMapping("/dashboard")
|
||||
@Operation(summary = "获得首页数据")
|
||||
public CommonResult<DashboardRespVO> dashboard() {
|
||||
@@ -87,6 +91,13 @@ public class CustomerController {
|
||||
@PreAuthorize("@ss.hasPermission('license:customer:query')")
|
||||
public CommonResult<CustomerRespVO> getCustomer(@RequestParam("id") Long id) {
|
||||
CustomerDO customer = customerService.getCustomer(id);
|
||||
|
||||
if (!securityFrameworkService.hasRole("business")) {
|
||||
customer.setContacts(null);
|
||||
customer.setRole(null);
|
||||
customer.setPhone(null);
|
||||
}
|
||||
|
||||
return success(BeanUtils.toBean(customer, CustomerRespVO.class, customerRespVO -> {
|
||||
if (customerRespVO.getAreaId() != null) {
|
||||
customerRespVO.setAreaIds(AreaUtils.formatToIdList(customerRespVO.getAreaId().intValue()));
|
||||
@@ -119,6 +130,16 @@ public class CustomerController {
|
||||
@PreAuthorize("@ss.hasPermission('license:customer:query')")
|
||||
public CommonResult<PageResult<CustomerRespVO>> getCustomerPage(@Valid CustomerPageReqVO pageReqVO) {
|
||||
PageResult<CustomerDO> pageResult = customerService.getCustomerPage(pageReqVO);
|
||||
|
||||
if (!securityFrameworkService.hasRole("business")) {
|
||||
List<CustomerDO> list = pageResult.getList();
|
||||
list.forEach(customerDO -> {
|
||||
customerDO.setContacts(null);
|
||||
customerDO.setRole(null);
|
||||
customerDO.setPhone(null);
|
||||
});
|
||||
}
|
||||
|
||||
return success(buildCustomerVOList(pageResult));
|
||||
}
|
||||
|
||||
@@ -127,6 +148,15 @@ public class CustomerController {
|
||||
@PreAuthorize("@ss.hasPermission('license:customer:query')")
|
||||
public CommonResult<List<CustomerRespVO>> getCustomerList() {
|
||||
List<CustomerDO> listResult = customerService.getCustomerList();
|
||||
|
||||
if (!securityFrameworkService.hasRole("business")) {
|
||||
listResult.forEach(customerDO -> {
|
||||
customerDO.setContacts(null);
|
||||
customerDO.setRole(null);
|
||||
customerDO.setPhone(null);
|
||||
});
|
||||
}
|
||||
|
||||
return success(BeanUtils.toBean(listResult, CustomerRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.agt.module.license.controller.admin.customer.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 客户新增/修改 Request VO")
|
||||
@Data
|
||||
@@ -29,7 +29,6 @@ public class CustomerSaveReqVO {
|
||||
private Long areaId;
|
||||
|
||||
@Schema(description = "联系人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "联系人不能为空")
|
||||
private String contacts;
|
||||
|
||||
@Schema(description = "角色")
|
||||
|
||||
Reference in New Issue
Block a user