Commit 716b081464dae1ffd507b317326b0fadde64645b
1 parent
8c9873c4
crm:合并最新的数据权限
Showing
8 changed files
with
45 additions
and
28 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java
| ... | ... | @@ -34,6 +34,7 @@ import java.util.stream.Collectors; |
| 34 | 34 | |
| 35 | 35 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 36 | 36 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 37 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 37 | 38 | |
| 38 | 39 | // TODO @zya:crm 所有的类,dou带 Crm 前缀,因为它的名字太通用了,可能和后续的 erp 之类的冲突 |
| 39 | 40 | @Tag(name = "管理后台 - CRM 联系人") |
| ... | ... | @@ -55,7 +56,7 @@ public class ContactController { |
| 55 | 56 | @Operation(summary = "创建联系人") |
| 56 | 57 | @PreAuthorize("@ss.hasPermission('crm:contact:create')") |
| 57 | 58 | public CommonResult<Long> createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { |
| 58 | - return success(contactService.createContact(createReqVO)); | |
| 59 | + return success(contactService.createContact(createReqVO, getLoginUserId())); | |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | @PutMapping("/update") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.controller.admin.customer; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| ... | ... | @@ -33,8 +34,6 @@ import java.util.Map; |
| 33 | 34 | import java.util.Set; |
| 34 | 35 | |
| 35 | 36 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 36 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 37 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; | |
| 38 | 37 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 39 | 38 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 40 | 39 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| ... | ... | @@ -111,16 +110,16 @@ public class CrmCustomerController { |
| 111 | 110 | @Operation(summary = "获得客户分页") |
| 112 | 111 | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| 113 | 112 | public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |
| 114 | - PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO); | |
| 113 | + PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO, getLoginUserId()); | |
| 115 | 114 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 116 | 115 | return success(PageResult.empty(pageResult.getTotal())); |
| 117 | 116 | } |
| 118 | 117 | // 拼接数据 |
| 119 | - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | |
| 120 | - convertSetByFlatMap(pageResult.getList(), user -> Stream.of(NumberUtil.parseLong(user.getCreator()), user.getOwnerUserId()))); | |
| 121 | - Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( | |
| 122 | - convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); | |
| 123 | - return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap)); | |
| 118 | + // TODO 芋艿:需要 review 下; | |
| 119 | +// Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | |
| 120 | +// convertSetByFlatMap(pageResult.getList(), user -> Stream.of(NumberUtil.parseLong(user.getCreator()), user.getOwnerUserId()))); | |
| 121 | +// Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( | |
| 122 | +// convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); | |
| 124 | 123 | return convertPage(customerService.getCustomerPage(pageVO, getLoginUserId())); |
| 125 | 124 | } |
| 126 | 125 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.contact; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | - | |
| 7 | 4 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; |
| 8 | 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; |
| 9 | 6 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 10 | 7 | import org.mapstruct.Mapper; |
| 8 | +import org.mapstruct.Mapping; | |
| 9 | +import org.mapstruct.Mappings; | |
| 11 | 10 | import org.mapstruct.factory.Mappers; |
| 12 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | |
| 13 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * crm联系人 Convert | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java
| ... | ... | @@ -4,13 +4,9 @@ import cn.hutool.core.util.NumberUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 6 | 6 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 7 | -import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | |
| 8 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; |
| 9 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 10 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; |
| 11 | -import cn.iocoder.yudao.module.crm.service.permission.bo.CrmTransferPermissionReqBO; | |
| 12 | -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | |
| 13 | -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 14 | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| 15 | 11 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 16 | 12 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| ... | ... | @@ -24,7 +20,6 @@ import java.util.List; |
| 24 | 20 | import java.util.Map; |
| 25 | 21 | |
| 26 | 22 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| 27 | -import java.util.Map; | |
| 28 | 23 | |
| 29 | 24 | /** |
| 30 | 25 | * 客户 Convert |
| ... | ... | @@ -70,7 +65,7 @@ public interface CrmCustomerConvert { |
| 70 | 65 | MapUtils.findAndThen(userMap, customerRespVO.getOwnerUserId(), ownerUser -> { |
| 71 | 66 | customerRespVO.setOwnerUserName(ownerUser.getNickname()); |
| 72 | 67 | MapUtils.findAndThen(deptMap, ownerUser.getDeptId(), dept -> |
| 73 | - customerRespVO.setOwnerUserDept(dept.getName())); | |
| 68 | + customerRespVO.setOwnerUserDeptName(dept.getName())); | |
| 74 | 69 | }); |
| 75 | 70 | }); |
| 76 | 71 | return result; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.contact; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | -import javax.validation.*; | |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; | |
| 6 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | |
| 7 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; | |
| 9 | + | |
| 10 | +import javax.validation.Valid; | |
| 11 | +import java.util.Collection; | |
| 12 | +import java.util.List; | |
| 8 | 13 | |
| 9 | 14 | /** |
| 10 | 15 | * crm联系人 Service 接口 |
| ... | ... | @@ -17,9 +22,10 @@ public interface ContactService { |
| 17 | 22 | * 创建crm联系人 |
| 18 | 23 | * |
| 19 | 24 | * @param createReqVO 创建信息 |
| 25 | + * @param userId 用户编号 | |
| 20 | 26 | * @return 编号 |
| 21 | 27 | */ |
| 22 | - Long createContact(@Valid ContactCreateReqVO createReqVO); | |
| 28 | + Long createContact(@Valid ContactCreateReqVO createReqVO, Long userId); | |
| 23 | 29 | |
| 24 | 30 | /** |
| 25 | 31 | * 更新crm联系人 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java
| ... | ... | @@ -10,7 +10,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactUpdateReqV |
| 10 | 10 | import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; |
| 11 | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; |
| 12 | 12 | import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; |
| 13 | +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; | |
| 14 | +import cn.iocoder.yudao.module.crm.framework.enums.CrmBizTypeEnum; | |
| 15 | +import cn.iocoder.yudao.module.crm.framework.enums.CrmPermissionLevelEnum; | |
| 16 | +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | |
| 17 | +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | |
| 13 | 18 | import org.springframework.stereotype.Service; |
| 19 | +import org.springframework.transaction.annotation.Transactional; | |
| 14 | 20 | import org.springframework.validation.annotation.Validated; |
| 15 | 21 | |
| 16 | 22 | import javax.annotation.Resource; |
| ... | ... | @@ -32,8 +38,11 @@ public class ContactServiceImpl implements ContactService { |
| 32 | 38 | @Resource |
| 33 | 39 | private ContactMapper contactMapper; |
| 34 | 40 | |
| 41 | + @Resource | |
| 42 | + private CrmPermissionService crmPermissionService; | |
| 43 | + | |
| 35 | 44 | @Override // TODO @zyna:新增和修改时,关联字段要校验,例如说 直属上级,是不是真的存在; |
| 36 | - public Long createContact(ContactCreateReqVO createReqVO) { | |
| 45 | + public Long createContact(ContactCreateReqVO createReqVO, Long userId) { | |
| 37 | 46 | // 插入 |
| 38 | 47 | ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); |
| 39 | 48 | contactMapper.insert(contact); | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.api.dept; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 3 | 4 | import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO; |
| 4 | -import cn.iocoder.yudao.module.system.convert.dept.PostConvert; | |
| 5 | +import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; | |
| 5 | 6 | import cn.iocoder.yudao.module.system.service.dept.PostService; |
| 6 | 7 | import org.springframework.stereotype.Service; |
| 7 | 8 | |
| ... | ... | @@ -27,7 +28,8 @@ public class PostApiImpl implements PostApi { |
| 27 | 28 | |
| 28 | 29 | @Override |
| 29 | 30 | public List<PostRespDTO> getPostList(Collection<Long> ids) { |
| 30 | - return PostConvert.INSTANCE.convert(postService.getPostList(ids)); | |
| 31 | + List<PostDO> list = postService.getPostList(ids); | |
| 32 | + return BeanUtils.toBean(list, PostRespDTO.class); | |
| 31 | 33 | } |
| 32 | 34 | |
| 33 | 35 | } | ... | ... |