From 0b05d6399b425327c83ea5b8b40b812d28059670 Mon Sep 17 00:00:00 2001 From: PQZ Date: Wed, 7 Aug 2024 12:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iocoder/yudao/common/BaseConstants.java | 10 ++ .../admin/CustomerMainController.java | 6 +- .../module/custom/entity/CustomerMain.java | 4 +- .../custom/service/CustomerMainService.java | 3 +- .../service/impl/CustomerMainServiceImpl.java | 99 ++++++++++++++----- .../mapper/custom/CustomerMainMapper.xml | 1 + .../yudao/module/system/api/dept/DeptApi.java | 9 ++ .../system/api/dict/dto/DictDataRespDTO.java | 2 + .../module/system/api/dept/DeptApiImpl.java | 14 +++ .../system/dal/mysql/dept/DeptMapper.java | 4 + .../system/service/dept/DeptService.java | 9 ++ .../system/service/dept/DeptServiceImpl.java | 13 +++ 12 files changed, 146 insertions(+), 28 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java index 0ec319f4..44f87724 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java @@ -7,10 +7,20 @@ package cn.iocoder.yudao.common; public class BaseConstants { /**政企客户经办人*/ public static final String CUS_TYPE_CORP_ATTN = "04"; + /**政企客户*/ + public static final String CUS_TYPE_CORP = "03"; /**客户标识*/ public static final String CUS_SIGN_CUSTOMER = "customer"; /**车辆标识*/ public static final String CUS_SIGN_CAR = "car"; /**客户信息表名称*/ public static final String TABLE_BASE_CUSTOMER_MAIN = "base_customer_main"; + /**新增标识*/ + public static final String SIGN_CREATE = "create"; + /**编辑标识*/ + public static final String SIGN_UPDATE = "update"; + /**默认密码*/ + public static final String PASSWORD_DEFAULT = "123456"; + /**租户下部门名称*/ + public static final String DEPT_NAME_CORP_NAME = "政企客户"; } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java index 8d2336eb..2a27a9a8 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java @@ -21,7 +21,7 @@ import javax.validation.Valid; import java.util.List; -import static cn.iocoder.yudao.common.BaseConstants.TABLE_BASE_CUSTOMER_MAIN; +import static cn.iocoder.yudao.common.BaseConstants.*; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -72,7 +72,7 @@ public class CustomerMainController { @Operation(summary = "创建客户管理") @PreAuthorize("@ss.hasPermission('base:customer-main:create')") public CommonResult createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) { - customerMainService.saveCustomer(saveReqVO); + customerMainService.saveCustomer(saveReqVO,SIGN_CREATE); return success(true); } @@ -88,7 +88,7 @@ public class CustomerMainController { @Operation(summary = "更新客户管理") @PreAuthorize("@ss.hasPermission('base:customer-main:update')") public CommonResult updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) { - customerMainService.saveCustomer(saveReqVO); + customerMainService.saveCustomer(saveReqVO,SIGN_UPDATE); return success(true); } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerMain.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerMain.java index 836af398..d981777c 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerMain.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CustomerMain.java @@ -33,7 +33,7 @@ public class CustomerMain extends TenantBaseDO { /** * sys_user表id */ - private String userId; + private Long userId; /** * 用户类型 */ @@ -42,7 +42,7 @@ public class CustomerMain extends TenantBaseDO { /** * 所属企业code(部门表code) */ - private String deptCode; + private Long deptCode; /** * 客户名称(政企客户填企业名称) */ diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java index c31bd407..a91faa05 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java @@ -33,11 +33,12 @@ public interface CustomerMainService extends IService { * 保存客户信息 * * @param saveReqVO 保存客户信息扩展实体 + * @param sign 标识(新增客户created/编辑客户update) * @return void * @author PQZ * @date 15:46 2024/8/1 **/ - void saveCustomer(CustomerMainSaveReqVO saveReqVO); + void saveCustomer(CustomerMainSaveReqVO saveReqVO, String sign); /** * 根据客户id查询客户信息 diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java index c1b5d9bd..b33f479a 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java @@ -1,17 +1,16 @@ package cn.iocoder.yudao.module.custom.service.impl; import cn.hutool.json.JSONUtil; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.module.custom.entity.CarMain; import cn.iocoder.yudao.module.custom.entity.CustomerCar; import cn.iocoder.yudao.module.custom.entity.CustomerItem; import cn.iocoder.yudao.module.custom.entity.CustomerMain; -import cn.iocoder.yudao.module.custom.mapper.CarMainMapper; import cn.iocoder.yudao.module.custom.mapper.CustomerCarMapper; import cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper; -import cn.iocoder.yudao.module.custom.service.CarMainService; import cn.iocoder.yudao.module.custom.service.CustomerCarService; import cn.iocoder.yudao.module.custom.service.CustomerItemService; import cn.iocoder.yudao.module.custom.service.CustomerMainService; @@ -21,21 +20,29 @@ import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO; import cn.iocoder.yudao.module.label.entity.BusiLabel; import cn.iocoder.yudao.module.label.service.BusiLabelService; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; +import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.util.*; -import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CUSTOMER; -import static cn.iocoder.yudao.common.BaseConstants.CUS_TYPE_CORP_ATTN; +import static cn.iocoder.yudao.common.BaseConstants.*; +import static cn.iocoder.yudao.common.DictBaseConstants.DICT_CUS_TYPE; /** * 客户管理 Service 实现类 @@ -55,9 +62,16 @@ public class CustomerMainServiceImpl extends ServiceImpl roleCodes = new HashSet<>(); + roleCodes.add(dict.getRemark()); + permissionApi.assignUserRole(userId, roleCodes); } + /*3、保存客户主表信息*/ this.saveOrUpdate(main); - /*2、保存扩展表信息*/ + /*4、保存扩展表信息*/ if (!saveReqVO.getItemList().isEmpty()) { customerItemService.saveCutomItem(main.getId(), saveReqVO.getItemList()); } @@ -156,11 +211,11 @@ public class CustomerMainServiceImpl extends ServiceImpl customerCars = new ArrayList<>(); List carList = saveReqVO.getCarList(); - if (null != carList){ + if (null != carList) { //组装数据 carList.forEach(item -> { CustomerCar customerCar = new CustomerCar(); @@ -170,6 +225,6 @@ public class CustomerMainServiceImpl extends ServiceImpl + diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java index 8a0b8e41..e083d71f 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java @@ -54,6 +54,15 @@ public interface DeptApi { */ DeptRespDTO getDeptByParentIdAndName(Long parentId,String name); + /** + * 查询部门名称是xx的部门 + * @author PQZ + * @date 10:49 2024/8/7 + * @param name 部门名称 + * @return cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO + **/ + DeptRespDTO getDeptByName(String name); + /** * 获得部门信息数组 * diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/dto/DictDataRespDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/dto/DictDataRespDTO.java index fe5ab6a2..9b779226 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/dto/DictDataRespDTO.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/dto/DictDataRespDTO.java @@ -29,5 +29,7 @@ public class DictDataRespDTO { * 枚举 {@link CommonStatusEnum} */ private Integer status; + /**备注*/ + private String remark; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java index 0ccb6774..799c8a51 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java @@ -80,6 +80,20 @@ public class DeptApiImpl implements DeptApi { return BeanUtils.toBean(dept, DeptRespDTO.class); } + /** + * 查询部门名称是xx的部门 + * + * @param name 部门名称 + * @return cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO + * @author PQZ + * @date 10:49 2024/8/7 + **/ + @Override + public DeptRespDTO getDeptByName(String name) { + DeptDO dept = deptService.selectDeptByName(name); + return BeanUtils.toBean(dept, DeptRespDTO.class); + } + @Override public List getDeptList(Collection ids) { List depts = deptService.getDeptList(ids); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java index 51cab2ec..2aa68e32 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java @@ -22,6 +22,10 @@ public interface DeptMapper extends BaseMapperX { return selectOne(DeptDO::getParentId, parentId, DeptDO::getName, name); } + default DeptDO selectByDeptName(String name) { + return selectOne( DeptDO::getName, name); + } + default DeptDO selectByParentId(Long parentId) { return selectOne(DeptDO::getParentId, parentId); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java index 426281b7..ffd396c7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java @@ -70,6 +70,15 @@ public interface DeptService { */ DeptDO getDeptByParentIdAndName(Long parentId,String name); + /** + * 根据部门名称查询部门 + * @author PQZ + * @date 10:51 2024/8/7 + * @param name 部门名称 + * @return cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO + **/ + DeptDO selectDeptByName(String name); + /** * 获得部门信息数组 * diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java index f54868a1..8530f882 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java @@ -193,6 +193,19 @@ public class DeptServiceImpl implements DeptService { return deptMapper.selectByParentIdAndName(parentId, name); } + /** + * 根据部门名称查询部门 + * + * @param name 部门名称 + * @return cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO + * @author PQZ + * @date 10:51 2024/8/7 + **/ + @Override + public DeptDO selectDeptByName(String name) { + return deptMapper.selectByDeptName(name); + } + @Override public List getDeptList(Collection ids) {