Commit d293fdd474fe661f96ed3a1f9768a6f2a412c3d9
1 parent
8920b978
fix: 修复 CRM 的一些 bug
Showing
7 changed files
with
42 additions
and
6 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordRespVO.java
| @@ -44,6 +44,11 @@ public class CrmFollowUpRecordRespVO { | @@ -44,6 +44,11 @@ public class CrmFollowUpRecordRespVO { | ||
| 44 | @Schema(description = "关联的联系人名称数组") | 44 | @Schema(description = "关联的联系人名称数组") |
| 45 | private List<String> contactNames; | 45 | private List<String> contactNames; |
| 46 | 46 | ||
| 47 | + @Schema(description = "图片") | ||
| 48 | + private List<String> picUrls; | ||
| 49 | + @Schema(description = "附件") | ||
| 50 | + private List<String> fileUrls; | ||
| 51 | + | ||
| 47 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 52 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 48 | private LocalDateTime createTime; | 53 | private LocalDateTime createTime; |
| 49 | 54 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/followup/vo/CrmFollowUpRecordSaveReqVO.java
| @@ -37,8 +37,12 @@ public class CrmFollowUpRecordSaveReqVO { | @@ -37,8 +37,12 @@ public class CrmFollowUpRecordSaveReqVO { | ||
| 37 | 37 | ||
| 38 | @Schema(description = "关联的商机编号数组") | 38 | @Schema(description = "关联的商机编号数组") |
| 39 | private List<Long> businessIds; | 39 | private List<Long> businessIds; |
| 40 | - | ||
| 41 | @Schema(description = "关联的联系人编号数组") | 40 | @Schema(description = "关联的联系人编号数组") |
| 42 | private List<Long> contactIds; | 41 | private List<Long> contactIds; |
| 43 | 42 | ||
| 43 | + @Schema(description = "图片") | ||
| 44 | + private List<String> picUrls; | ||
| 45 | + @Schema(description = "附件") | ||
| 46 | + private List<String> fileUrls; | ||
| 47 | + | ||
| 44 | } | 48 | } |
| 45 | \ No newline at end of file | 49 | \ No newline at end of file |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java
| @@ -28,6 +28,7 @@ import org.springframework.validation.annotation.Validated; | @@ -28,6 +28,7 @@ import org.springframework.validation.annotation.Validated; | ||
| 28 | import org.springframework.web.bind.annotation.*; | 28 | import org.springframework.web.bind.annotation.*; |
| 29 | 29 | ||
| 30 | import java.util.*; | 30 | import java.util.*; |
| 31 | +import java.util.stream.Stream; | ||
| 31 | 32 | ||
| 32 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 33 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 33 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 34 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| @@ -103,7 +104,12 @@ public class CrmPermissionController { | @@ -103,7 +104,12 @@ public class CrmPermissionController { | ||
| 103 | // 拼接数据 | 104 | // 拼接数据 |
| 104 | List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId)); | 105 | List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId)); |
| 105 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); | 106 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); |
| 106 | - Set<Long> postIds = CollectionUtils.convertSetByFlatMap(userList, AdminUserRespDTO::getPostIds, Collection::stream); | 107 | + Set<Long> postIds = CollectionUtils.convertSetByFlatMap(userList, AdminUserRespDTO::getPostIds, item -> { |
| 108 | + if (item == null) { | ||
| 109 | + return Stream.empty(); | ||
| 110 | + } | ||
| 111 | + return item.stream(); | ||
| 112 | + }); | ||
| 107 | Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); | 113 | Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); |
| 108 | return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap)); | 114 | return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap)); |
| 109 | } | 115 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java
| 1 | package cn.iocoder.yudao.module.crm.convert.permission; | 1 | package cn.iocoder.yudao.module.crm.convert.permission; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 3 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 4 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO; | 5 | import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO; |
| @@ -49,11 +48,11 @@ public interface CrmPermissionConvert { | @@ -49,11 +48,11 @@ public interface CrmPermissionConvert { | ||
| 49 | findAndThen(userMap, item.getUserId(), user -> { | 48 | findAndThen(userMap, item.getUserId(), user -> { |
| 50 | item.setNickname(user.getNickname()); | 49 | item.setNickname(user.getNickname()); |
| 51 | findAndThen(deptMap, user.getDeptId(), deptRespDTO -> item.setDeptName(deptRespDTO.getName())); | 50 | findAndThen(deptMap, user.getDeptId(), deptRespDTO -> item.setDeptName(deptRespDTO.getName())); |
| 52 | - List<PostRespDTO> postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); | ||
| 53 | - if (CollUtil.isEmpty(postRespList)) { | 51 | + if (user.getPostIds() == null) { |
| 54 | item.setPostNames(Collections.emptySet()); | 52 | item.setPostNames(Collections.emptySet()); |
| 55 | return; | 53 | return; |
| 56 | } | 54 | } |
| 55 | + List<PostRespDTO> postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); | ||
| 57 | item.setPostNames(CollectionUtils.convertSet(postRespList, PostRespDTO::getName)); | 56 | item.setPostNames(CollectionUtils.convertSet(postRespList, PostRespDTO::getName)); |
| 58 | }); | 57 | }); |
| 59 | return item; | 58 | return item; |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/followup/CrmFollowUpRecordDO.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.followup; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.followup; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; | 4 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.type.StringListTypeHandler; | ||
| 5 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 7 | import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; | 8 | import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; |
| @@ -67,6 +68,18 @@ public class CrmFollowUpRecordDO extends BaseDO { | @@ -67,6 +68,18 @@ public class CrmFollowUpRecordDO extends BaseDO { | ||
| 67 | private LocalDateTime nextTime; | 68 | private LocalDateTime nextTime; |
| 68 | 69 | ||
| 69 | /** | 70 | /** |
| 71 | + * 图片 | ||
| 72 | + */ | ||
| 73 | + @TableField(typeHandler = StringListTypeHandler.class) | ||
| 74 | + private List<String> picUrls; | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 附件 | ||
| 78 | + */ | ||
| 79 | + @TableField(typeHandler = StringListTypeHandler.class) | ||
| 80 | + private List<String> fileUrls; | ||
| 81 | + | ||
| 82 | + /** | ||
| 70 | * 关联的商机编号数组 | 83 | * 关联的商机编号数组 |
| 71 | * | 84 | * |
| 72 | * 关联 {@link CrmBusinessDO#getId()} | 85 | * 关联 {@link CrmBusinessDO#getId()} |
| @@ -81,4 +94,5 @@ public class CrmFollowUpRecordDO extends BaseDO { | @@ -81,4 +94,5 @@ public class CrmFollowUpRecordDO extends BaseDO { | ||
| 81 | @TableField(typeHandler = LongListTypeHandler.class) | 94 | @TableField(typeHandler = LongListTypeHandler.class) |
| 82 | private List<Long> contactIds; | 95 | private List<Long> contactIds; |
| 83 | 96 | ||
| 97 | + | ||
| 84 | } | 98 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java
| @@ -53,6 +53,11 @@ public interface CrmPermissionMapper extends BaseMapperX<CrmPermissionDO> { | @@ -53,6 +53,11 @@ public interface CrmPermissionMapper extends BaseMapperX<CrmPermissionDO> { | ||
| 53 | .eq(CrmPermissionDO::getId, id).eq(CrmPermissionDO::getUserId, userId)); | 53 | .eq(CrmPermissionDO::getId, id).eq(CrmPermissionDO::getUserId, userId)); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | + default CrmPermissionDO selectByBizIdAndUserId(Long id, Long userId) { | ||
| 57 | + return selectOne(new LambdaQueryWrapperX<CrmPermissionDO>() | ||
| 58 | + .eq(CrmPermissionDO::getBizId, id).eq(CrmPermissionDO::getUserId, userId)); | ||
| 59 | + } | ||
| 60 | + | ||
| 56 | default int deletePermission(Integer bizType, Long bizId) { | 61 | default int deletePermission(Integer bizType, Long bizId) { |
| 57 | return delete(new LambdaQueryWrapperX<CrmPermissionDO>() | 62 | return delete(new LambdaQueryWrapperX<CrmPermissionDO>() |
| 58 | .eq(CrmPermissionDO::getBizType, bizType) | 63 | .eq(CrmPermissionDO::getBizType, bizType) |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java
| @@ -167,7 +167,10 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { | @@ -167,7 +167,10 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { | ||
| 167 | throw exception(CRM_PERMISSION_DELETE_FAIL); | 167 | throw exception(CRM_PERMISSION_DELETE_FAIL); |
| 168 | } | 168 | } |
| 169 | // 校验操作人是否为负责人 | 169 | // 校验操作人是否为负责人 |
| 170 | - CrmPermissionDO permission = permissionMapper.selectByIdAndUserId(permissions.get(0).getBizId(), userId); | 170 | + CrmPermissionDO permission = permissionMapper.selectByBizIdAndUserId(permissions.getFirst().getBizId(), userId); |
| 171 | + if (permission == null) { | ||
| 172 | + throw exception(CRM_PERMISSION_DELETE_DENIED); | ||
| 173 | + } | ||
| 171 | if (!CrmPermissionLevelEnum.isOwner(permission.getLevel())) { | 174 | if (!CrmPermissionLevelEnum.isOwner(permission.getLevel())) { |
| 172 | throw exception(CRM_PERMISSION_DELETE_DENIED); | 175 | throw exception(CRM_PERMISSION_DELETE_DENIED); |
| 173 | } | 176 | } |