# Conflicts:
#	dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerMainService.java
This commit is contained in:
“hhk” 2024-08-02 18:31:45 +08:00
commit 30eafec000
31 changed files with 851 additions and 48 deletions

View File

@ -0,0 +1,10 @@
package cn.iocoder.yudao.common;
/**
* 通用常量类
* @author PQZ
* @date 16:20 2024/8/1
**/
public class BaseConstants {
/**政企客户经办人*/
public static final String CUS_TYPE_CORP_ATTN = "04";
}

View File

@ -1,4 +1,5 @@
package cn.iocoder.yudao.module.company.controller.admin;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@ -28,6 +29,7 @@ import java.util.List;
/**
* 企业信息表每个租户的下属企业信息;(dl_company)表控制层
*
* @author : http://www.chiner.pro
* @date : 2024-7-31
*/
@ -39,24 +41,44 @@ public class CompanyController {
@Autowired
private CompanyService companyService;
@GetMapping("/page")
@Operation(summary = "获得企业信息表(每个租户的下属企业信息)分页")
@PreAuthorize("@ss.hasPermission('base:company:query')")
public CommonResult<IPage<?>> getCompanyPage(CompanyReqVO pageReqVO,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
Page<Company> page = new Page<>(pageNo, pageSize);
return success(companyService.queryListPage(pageReqVO,page));
}
/**
* 分页查询
* @author vinjor-M
* @date 9:52 2024/8/2
* @param pageReqVO 查询条件对象
* @param pageNo 页码
* @param pageSize 条数
**/
@GetMapping("/page")
@Operation(summary = "获得企业信息表(每个租户的下属企业信息)分页")
@PreAuthorize("@ss.hasPermission('base:company:query')")
public CommonResult<IPage<?>> getCompanyPage(CompanyReqVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<Company> page = new Page<>(pageNo, pageSize);
return success(companyService.queryListPage(pageReqVO, page));
}
/**
* 新增企业
* @author vinjor-M
* @date 9:53 2024/8/2
* @param companyRespVO 企业对象
**/
@PostMapping("/create")
@Operation(summary = "创建企业信息表(每个租户的下属企业信息)")
@PreAuthorize("@ss.hasPermission('base:company:create')")
public CommonResult<String> createCompany(@RequestBody Company company) {
companyService.save(company);
public CommonResult<String> createCompany(@RequestBody CompanyRespVO companyRespVO) {
companyService.save(companyRespVO);
return CommonResult.ok();
}
/**
* 更新企业
* @author vinjor-M
* @date 9:53 2024/8/2
* @param company 企业对象
**/
@PutMapping("/update")
@Operation(summary = "更新企业信息表(每个租户的下属企业信息)")
@PreAuthorize("@ss.hasPermission('base:company:update')")
@ -65,6 +87,12 @@ public class CompanyController {
return CommonResult.ok();
}
/**
* 删除企业
* @author vinjor-M
* @date 9:53 2024/8/2
* @param id 企业id
**/
@DeleteMapping("/delete")
@Operation(summary = "删除企业信息表(每个租户的下属企业信息)")
@Parameter(name = "id", description = "编号", required = true)
@ -74,6 +102,12 @@ public class CompanyController {
return success(true);
}
/**
* 查询企业
* @author vinjor-M
* @date 9:53 2024/8/2
* @param id 企业id
**/
@GetMapping("/get")
@Operation(summary = "获得企业信息表(每个租户的下属企业信息)")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@ -83,11 +117,18 @@ public class CompanyController {
return success(BeanUtils.toBean(company, CompanyRespVO.class));
}
/**
* 导出企业
* @author vinjor-M
* @date 9:53 2024/8/2
* @param pageReqVO 查询条件--暂时导出所有
* @param response 返回体
**/
@GetMapping("/export-excel")
@Operation(summary = "导出企业信息表(每个租户的下属企业信息) Excel")
@PreAuthorize("@ss.hasPermission('base:company:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportCompanyExcel( CompanyReqVO pageReqVO,
public void exportCompanyExcel(CompanyReqVO pageReqVO,
HttpServletResponse response) throws IOException {
List<Company> list = companyService.list();
// 导出 Excel

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.company.service;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.vo.CompanyReqVO;
import cn.iocoder.yudao.module.company.vo.CompanyRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
@ -19,4 +20,12 @@ public interface CompanyService extends IService<Company> {
* @return 企业信息表每个租户的下属企业信息分页
*/
IPage<Company> queryListPage(CompanyReqVO pageReqVO, Page<Company> page);
/**
* 新增企业信息
* @author vinjor-M
* @date 9:56 2024/8/2
* @param companyRespVO 企业对象
**/
void saveDataObj(CompanyRespVO companyRespVO);
}

View File

@ -1,14 +1,30 @@
package cn.iocoder.yudao.module.company.service.impl;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.vo.CompanyRespVO;
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.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum;
import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.iocoder.yudao.module.company.vo.CompanyReqVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.iocoder.yudao.module.company.mapper.CompanyMapper;
import cn.iocoder.yudao.module.company.service.CompanyService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import static java.util.Collections.singleton;
/**
* 企业信息表每个租户的下属企业信息;(dl_company)表服务实现类
@ -19,17 +35,73 @@ import cn.iocoder.yudao.module.company.service.CompanyService;
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService {
@Autowired
private CompanyMapper companyMapper;
@Resource
@Lazy // 延迟避免循环依赖报错
private AdminUserApi adminUserApi;
@Resource
private RoleApi roleApi;
@Resource
private PermissionApi permissionApi;
@Resource
private DeptApi deptApi;
/**
* 获得企业信息表每个租户的下属企业信息分页
*
* @param pageReqVO 分页查询
* @param page
* @return 企业信息表每个租户的下属企业信息分页
* @param pageReqVO 分页查询条件
* @param page 分页对象
* @author vinjor-M
*/
@Override
public IPage<Company> queryListPage(CompanyReqVO pageReqVO, Page<Company> page) {
return companyMapper.selectListPage(pageReqVO,page);
}
}
/**
* 新增企业信息
*
* @param companyRespVO 企业对象
* @author vinjor-M
* @date 9:56 2024/8/2
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDataObj(CompanyRespVO companyRespVO) {
/*1.保存企业信息*/
this.save(companyRespVO);
/*2.新增企业管理员角色和用户信息*/
/*3.新增企业部门信息*/
DeptRespDTO deptRespDTO = new DeptRespDTO();
deptRespDTO.setName(companyRespVO.getCorpName());
deptRespDTO.setStatus(CommonStatusEnum.ENABLE.getStatus());
// deptRespDTO.setLeaderUserId(userId);
deptApi.saveDept(deptRespDTO);
/*3.更新企业管理员所属部门信息*/
}
// private Long createUser(Long roleId, CompanyRespVO companyRespVO) {
// // 创建用户
// Long userId = adminUserApi.createUser(TenantConvert.INSTANCE.convert02(createReqVO));
// // 分配角色
// permissionService.assignUserRole(userId, singleton(roleId));
// return userId;
// }
//
// /**
// * 创建企业时自动创建企业管理员角色
// * @author vinjor-M
// * @date 10:22 2024/8/2
// * @param companyRespVO 企业对象
// **/
// private Long createRole(CompanyRespVO companyRespVO) {
// // 创建角色
// RoleReqDTO reqVO = new RoleReqDTO();
// reqVO.setName(RoleCodeEnum.COMPANY_ADMIN.getName()).setCode(RoleCodeEnum.COMPANY_ADMIN.getCode())
// .setSort(0).setRemark("系统自动生成");
// Long roleId = roleApi.createRole(reqVO, RoleTypeEnum.SYSTEM.getType());
// // 分配权限
// permissionApi.assignRoleMenu(roleId, companyRespVO.getMenuIds());
// return roleId;
// }
}

View File

@ -16,5 +16,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
**/
@Data
public class CompanyRespVO extends Company {
/**
* 该企业分配的菜单权限
*/
String menuIds;
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.custom.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
@ -17,6 +18,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
@ -65,6 +68,7 @@ public class CustomerMainController {
@Operation(summary = "创建客户管理")
@PreAuthorize("@ss.hasPermission('base:customer-main:create')")
public CommonResult<Boolean> createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
customerMainService.saveCustomer(saveReqVO);
return success(true);
}
@ -80,6 +84,7 @@ public class CustomerMainController {
@Operation(summary = "更新客户管理")
@PreAuthorize("@ss.hasPermission('base:customer-main:update')")
public CommonResult<Boolean> updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) {
customerMainService.saveCustomer(saveReqVO);
return success(true);
}
@ -111,8 +116,22 @@ public class CustomerMainController {
@Operation(summary = "获得客户管理")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:customer-main:query')")
public CommonResult<Boolean> getCustomerMain(@RequestParam("id") String id) {
return success(true);
public CommonResult<CustomerMainRespVO> getCustomerMain(@RequestParam("id") String id) {
return success(customerMainService.getCustomerById(id));
}
/**
* 根据经办人所属企业查询经办人信息
* @author PQZ
* @date 16:15 2024/8/2
* @param deptCode 经办人所属企业code
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
**/
@GetMapping("/getAttn")
@Operation(summary = "根据deptCode获取经办人信息")
public CommonResult<List<CustomerMain>> getCustomerMainByDeptCode(@RequestParam("deptCode") String deptCode) {
return success(customerMainService.getCustomerByDeptCode(deptCode));
}
}

View File

@ -25,7 +25,7 @@ public class CustomerCar extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.INPUT)
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* 客户信息主表id

View File

@ -25,7 +25,7 @@ public class CustomerItem extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.INPUT)
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* 客户信息主表id

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.custom.service;
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 客户管理 Service 接口
*
@ -10,5 +12,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface CustomerItemService extends IService<CustomerItem> {
/**
* 保存客户扩展信息
*
* @param cusId 客户id
* @param itemList 扩展表集合
* @return void
* @author PQZ
* @date 10:01 2024/8/2
**/
void saveCutomItem(String cusId, List<CustomerItem> itemList);
}

View File

@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 客户管理 Service 接口
*
@ -37,4 +39,22 @@ public interface CustomerMainService extends IService<CustomerMain> {
**/
void saveCustomer(CustomerMainSaveReqVO saveReqVO);
/**
* 根据客户id查询客户信息
* @author PQZ
* @date 15:12 2024/8/2
* @param id 客户id
* @return cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO
**/
CustomerMainRespVO getCustomerById(String id);
/**
* 根据经办人所属企业查询经办人信息
* @author PQZ
* @date 16:15 2024/8/2
* @param deptCode 经办人所属企业code
* @return java.util.List<cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO>
**/
List<CustomerMain> getCustomerByDeptCode(String deptCode);
}

View File

@ -1,12 +1,16 @@
package cn.iocoder.yudao.module.custom.service.impl;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
import cn.iocoder.yudao.module.custom.mapper.CustomerItemMapper;
import cn.iocoder.yudao.module.custom.service.CustomerItemService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
/**
* 客户管理 Service 实现类
*
@ -17,4 +21,27 @@ import org.springframework.validation.annotation.Validated;
public class CustomerItemServiceImpl extends ServiceImpl<CustomerItemMapper, CustomerItem> implements CustomerItemService {
/**
* 保存客户扩展信息
*
* @param cusId 客户id
* @param itemList 扩展表集合
* @return void
* @author PQZ
* @date 10:01 2024/8/2
**/
@Override
public void saveCutomItem(String cusId, List<CustomerItem> itemList) {
/*1、根据客户id删除已有扩展信息*/
LambdaQueryWrapper<CustomerItem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CustomerItem::getCusId, cusId).eq(BaseDO::getDeleted, 0);
this.remove(lambdaQueryWrapper);
/*2、保存扩展信息集合*/
itemList.forEach(item -> {
item.setId(null);
item.setCusId(cusId);
});
this.saveBatch(itemList);
}
}

View File

@ -1,19 +1,30 @@
package cn.iocoder.yudao.module.custom.service.impl;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper;
import cn.iocoder.yudao.module.custom.service.CustomerItemService;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;
import static cn.iocoder.yudao.common.BaseConstants.CUS_TYPE_CORP_ATTN;
/**
* 客户管理 Service 实现类
@ -26,6 +37,8 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
@Resource
private CustomerMainMapper customerMainMapper;
@Resource
private CustomerItemService customerItemService;
/**
* 客户管理分页列表查询
@ -38,7 +51,7 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
**/
@Override
public IPage<CustomerMainRespVO> queryListPage(CustomerMainPageReqVO pageReqVO, Page<CustomerMainRespVO> page) {
return customerMainMapper.selectListPage(pageReqVO,page);
return customerMainMapper.selectListPage(pageReqVO, page);
}
/**
@ -50,8 +63,62 @@ public class CustomerMainServiceImpl extends ServiceImpl<CustomerMainMapper, Cus
* @date 15:46 2024/8/1
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveCustomer(CustomerMainSaveReqVO saveReqVO) {
CustomerMain main = JSONUtil.toBean(JSONUtil.parseObj(saveReqVO).toJSONString(0), CustomerMain.class);
this.saveOrUpdate(main);
try {
/*1、保存主表信息*/
CustomerMain main = JSONUtil.toBean(JSONUtil.parseObj(saveReqVO).toJSONString(0), CustomerMain.class);
//新增情况下非政企客户经办人deptCode设置为id方便分组查询
if (null == main.getId() && !CUS_TYPE_CORP_ATTN.equals(main.getTypeCode())) {
String id = String.valueOf(UUID.randomUUID());
main.setId(id);
main.setDeptCode(id);
}
this.saveOrUpdate(main);
/*2、保存扩展表信息*/
if (!saveReqVO.getItemList().isEmpty()) {
customerItemService.saveCutomItem(main.getId(), saveReqVO.getItemList());
}
} catch (ServiceException e) {
log.error(e.getMessage());
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR);
}
}
/**
* 根据客户id查询客户信息
*
* @param id 客户id
* @return cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO
* @author PQZ
* @date 15:12 2024/8/2
**/
@Override
public CustomerMainRespVO getCustomerById(String id) {
/*1、主表信息*/
CustomerMain main = this.getById(id);
/*2、扩展表信息*/
LambdaQueryWrapper<CustomerItem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BaseDO::getDeleted, 0).eq(CustomerItem::getCusId, id);
List<CustomerItem> itemList = customerItemService.list(lambdaQueryWrapper);
CustomerMainRespVO result = JSONUtil.toBean(JSONUtil.parseObj(main).toJSONString(0), CustomerMainRespVO.class);
result.setItemList(itemList);
return result;
}
/**
* 根据经办人所属企业查询经办人信息
*
* @param deptCode 经办人所属企业code
* @return java.util.List<cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO>
* @author PQZ
* @date 16:15 2024/8/2
**/
@Override
public List<CustomerMain> getCustomerByDeptCode(String deptCode) {
LambdaQueryWrapper<CustomerMain> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BaseDO::getDeleted, 0).eq(CustomerMain::getDeptCode, deptCode).eq(CustomerMain::getTypeCode, CUS_TYPE_CORP_ATTN);
return list(lambdaQueryWrapper);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.custom.vo;
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@ -12,18 +13,12 @@ import com.alibaba.excel.annotation.*;
@Data
@ExcelIgnoreUnannotated
public class CustomerMainRespVO extends CustomerMain {
/**客户管理子表id*/
private String itemId;
/**系统标识*/
private String systemCode;
/**用户等级*/
private String userLevel;
/**服务内容*/
private String serContent;
/**服务开始时间*/
private Date serTimeStart;
/**服务结束时间*/
private Date serTimeEnd;
/**大json*/
private String bigJson;
private String serContents;
/**车辆数量*/
private Integer carCount;
/**扩展信息*/
List<CustomerItem> itemList;
}

View File

@ -1,11 +1,17 @@
package cn.iocoder.yudao.module.custom.vo;
import cn.iocoder.yudao.module.custom.entity.CustomerItem;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - 客户管理新增/修改 Request VO")
@Data
public class CustomerMainSaveReqVO extends CustomerMain {
/**客户扩展信息表内容*/
private List<CustomerItem> itemList;
}

View File

@ -28,16 +28,10 @@
main.inviter AS inviter,
main.inviter_type AS inviterType,
main.status AS status,
item.id AS itemId,
item.system_code AS systemCode,
item.user_level AS userLevel,
item.ser_content AS serContent,
item.ser_time_start AS serTimeStart,
item.ser_time_end AS serTimeEnd,
item.big_json AS bigJson
group_concat(item.ser_content) AS serContents
FROM
base_customer_main main
LEFT JOIN base_customer_item item ON main.id = item.cus_id
LEFT JOIN base_customer_item item ON main.id = item.cus_id AND item.deleted = 0
<where>
main.deleted = 0
<if test="entity.cusName != null and entity.cusName != ''">
@ -50,6 +44,7 @@
AND item.system_code = #{entity.systemCode}
</if>
</where>
GROUP BY main.id
ORDER BY main.create_time DESC
</select>
</mapper>

View File

@ -13,6 +13,13 @@ import java.util.Map;
* @author 芋道源码
*/
public interface DeptApi {
/**
* 创建部门信息
*
* @param deptRespDTO 部门对象
* @return 部门id
*/
Long saveDept(DeptRespDTO deptRespDTO);
/**
* 获得部门信息

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.system.api.permission.dto;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import lombok.Data;
/**
* 角色 Request DTO
*
* @author vinjor-m
*/
@Data
public class RoleReqDTO {
/**
* 角色编号
*/
private Long id;
/**
* 角色名称
*/
private String name;
/**
* 角色编码
*/
private String code;
/**
* 顺序
*/
private Integer sort;
/**
* 备注
*/
private String remark;
}

View File

@ -111,6 +111,11 @@ public interface ErrorCodeConstants {
ErrorCode TENANT_PACKAGE_USED = new ErrorCode(1_002_016_001, "租户正在使用该套餐,请给租户重新设置套餐后再尝试删除");
ErrorCode TENANT_PACKAGE_DISABLE = new ErrorCode(1_002_016_002, "名字为【{}】的租户套餐已被禁用");
// ========== 服务套餐 1-002-017-000 ==========
ErrorCode SERVICE_PACKAGE_NOT_EXISTS = new ErrorCode(1_002_017_000, "服务套餐不存在");
ErrorCode SERVICE_PACKAGE_USED = new ErrorCode(1_002_017_001, "租户正在使用该套餐,请给租户重新设置套餐后再尝试删除");
ErrorCode SERVICE_PACKAGE_DISABLE = new ErrorCode(1_002_017_002, "名字为【{}】的服务套餐已被禁用");
// ========== 社交用户 1-002-018-000 ==========
ErrorCode SOCIAL_USER_AUTH_FAILURE = new ErrorCode(1_002_018_000, "社交授权失败,原因是:{}");
ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1_002_018_001, "社交授权失败,找不到对应的用户");

View File

@ -13,8 +13,9 @@ public enum RoleCodeEnum {
SUPER_ADMIN("super_admin", "超级管理员"),
TENANT_ADMIN("tenant_admin", "租户管理员"),
CRM_ADMIN("crm_admin", "CRM 管理员"); // CRM 系统专用
;
CRM_ADMIN("crm_admin", "CRM 管理员"), // CRM 系统专用
COMPANY_ADMIN("company_admin", "企业管理员");
/**
* 角色编码

View File

@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.system.api.dept;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -22,6 +25,17 @@ public class DeptApiImpl implements DeptApi {
@Resource
private DeptService deptService;
/**
* 创建部门信息
* @param deptRespDTO 部门对象
* @return 部门id
*/
@Override
public Long saveDept(DeptRespDTO deptRespDTO) {
DeptSaveReqVO deptSaveReqVO = BeanUtils.toBean(deptRespDTO,DeptSaveReqVO.class);
return deptService.createDept(deptSaveReqVO);
}
@Override
public DeptRespDTO getDept(Long id) {
DeptDO dept = deptService.getDept(id);

View File

@ -0,0 +1,92 @@
package cn.iocoder.yudao.module.system.controller.admin.service;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageSimpleRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.system.controller.admin.service.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.service.ServicePackageDO;
import cn.iocoder.yudao.module.system.service.service.ServicePackageService;
@Tag(name = "管理后台 - 服务套餐")
@RestController
@RequestMapping("/system/service-package")
@Validated
public class ServicePackageController {
@Resource
private ServicePackageService servicePackageService;
@PostMapping("/create")
@Operation(summary = "创建服务套餐")
@PreAuthorize("@ss.hasPermission('system:service-package:create')")
public CommonResult<String> createServicePackage(@Valid @RequestBody ServicePackageSaveReqVO createReqVO) {
return success(servicePackageService.createServicePackage(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新服务套餐")
@PreAuthorize("@ss.hasPermission('system:service-package:update')")
public CommonResult<Boolean> updateServicePackage(@Valid @RequestBody ServicePackageSaveReqVO updateReqVO) {
servicePackageService.updateServicePackage(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除服务套餐")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:service-package:delete')")
public CommonResult<Boolean> deleteServicePackage(@RequestParam("id") String id) {
servicePackageService.deleteServicePackage(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得服务套餐")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:service-package:query')")
public CommonResult<ServicePackageRespVO> getServicePackage(@RequestParam("id") String id) {
ServicePackageDO servicePackage = servicePackageService.getServicePackage(id);
return success(BeanUtils.toBean(servicePackage, ServicePackageRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得服务套餐分页")
@PreAuthorize("@ss.hasPermission('system:service-package:query')")
public CommonResult<PageResult<ServicePackageRespVO>> getServicePackagePage(@Valid ServicePackagePageReqVO pageReqVO) {
PageResult<ServicePackageDO> pageResult = servicePackageService.getServicePackagePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ServicePackageRespVO.class));
}
@GetMapping({"/get-simple-list", "simple-list"})
@Operation(summary = "获取服务套餐精简信息列表", description = "只包含被开启的服务套餐,主要用于前端的下拉选项")
public CommonResult<List<ServicePackageSimpleRespVO>> getTenantPackageList() {
List<ServicePackageDO> list = servicePackageService.getServicePackageListByStatus(CommonStatusEnum.ENABLE.getStatus());
return success(BeanUtils.toBean(list, ServicePackageSimpleRespVO.class));
}
}

View File

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.system.controller.admin.service.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 服务套餐分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ServicePackagePageReqVO extends PageParam {
@Schema(description = "套餐名", example = "赵六")
private String name;
@Schema(description = "套餐状态0正常 1停用", example = "2")
private Integer status;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.system.controller.admin.service.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 服务套餐 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ServicePackageRespVO {
@Schema(description = "套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1800")
@ExcelProperty("套餐编号")
private String id;
@Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@ExcelProperty("套餐名")
private String name;
@Schema(description = "套餐状态0正常 1停用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("租户状态0正常 1停用")
private Integer status;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "关联的菜单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("关联的菜单编号")
private Set<Long> menuIds;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.system.controller.admin.service.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 服务套餐新增/修改 Request VO")
@Data
public class ServicePackageSaveReqVO {
@Schema(description = "套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1800")
private String id;
@Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotEmpty(message = "套餐名不能为空")
private String name;
@Schema(description = "套餐状态0正常 1停用", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "套餐状态0正常 1停用不能为空")
private Integer status;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "关联的菜单编号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "关联的菜单编号不能为空")
private Set<Long> menuIds;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.system.controller.admin.service.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 -服务套餐精简 Response VO")
@Data
public class ServicePackageSimpleRespVO {
@Schema(description = "套餐编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "套餐编号不能为空")
private String id;
@Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "VIP")
@NotNull(message = "套餐名不能为空")
private String name;
}

View File

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.system.dal.dataobject.service;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 服务套餐 DO
*
* @author 后台管理员
*/
@TableName("system_service_package")
@KeySequence("system_service_package_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ServicePackageDO extends BaseDO {
/**
* 套餐编号
*/
@TableId
private String id;
/**
* 套餐名
*/
private String name;
/**
* 租户状态0正常 1停用
*/
private Integer status;
/**
* 备注
*/
private String remark;
/**
* 关联的菜单编号
*/
private String menuIds;
}

View File

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.system.dal.mysql.service;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.service.ServicePackageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.service.vo.*;
/**
* 服务套餐 Mapper
*
* @author 后台管理员
*/
@Mapper
public interface ServicePackageMapper extends BaseMapperX<ServicePackageDO> {
default PageResult<ServicePackageDO> selectPage(ServicePackagePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ServicePackageDO>()
.likeIfPresent(ServicePackageDO::getName, reqVO.getName())
.eqIfPresent(ServicePackageDO::getStatus, reqVO.getStatus())
.eqIfPresent(ServicePackageDO::getRemark, reqVO.getRemark())
.betweenIfPresent(ServicePackageDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ServicePackageDO::getId));
}
default List<ServicePackageDO> selectListByStatus(Integer status) {
return selectList(ServicePackageDO::getStatus, status);
}
}

View File

@ -59,6 +59,7 @@ public class DeptServiceImpl implements DeptService {
@Override
@CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
allEntries = true) // allEntries 清空所有缓存因为操作一个部门涉及到多个缓存
@TenantIgnore //不自动拼接租户id
public void updateDept(DeptSaveReqVO updateReqVO) {
if (updateReqVO.getParentId() == null) {
updateReqVO.setParentId(DeptDO.PARENT_ID_ROOT);

View File

@ -0,0 +1,71 @@
package cn.iocoder.yudao.module.system.service.service;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.admin.service.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.service.ServicePackageDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
/**
* 服务套餐 Service 接口
*
* @author 后台管理员
*/
public interface ServicePackageService {
/**
* 创建服务套餐
*
* @param createReqVO 创建信息
* @return 编号
*/
String createServicePackage(@Valid ServicePackageSaveReqVO createReqVO);
/**
* 更新服务套餐
*
* @param updateReqVO 更新信息
*/
void updateServicePackage(@Valid ServicePackageSaveReqVO updateReqVO);
/**
* 删除服务套餐
*
* @param id 编号
*/
void deleteServicePackage(String id);
/**
* 获得服务套餐
*
* @param id 编号
* @return 服务套餐
*/
ServicePackageDO getServicePackage(String id);
/**
* 获得服务套餐分页
*
* @param pageReqVO 分页查询
* @return 服务套餐分页
*/
PageResult<ServicePackageDO> getServicePackagePage(ServicePackagePageReqVO pageReqVO);
/**
* 校验服务套餐
*
* @param id 编号
* @return 服务套餐
*/
ServicePackageDO validServicePackage(String id);
/**
* 获得指定状态的服务套餐列表
*
* @param status 状态
* @return 服务套餐
*/
List<ServicePackageDO> getServicePackageListByStatus(Integer status);
}

View File

@ -0,0 +1,100 @@
package cn.iocoder.yudao.module.system.service.service;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.service.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.service.ServicePackageDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.service.ServicePackageMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 服务套餐 Service 实现类
*
* @author 后台管理员
*/
@Service
@Validated
public class ServicePackageServiceImpl implements ServicePackageService {
@Resource
private ServicePackageMapper servicePackageMapper;
@Override
public String createServicePackage(ServicePackageSaveReqVO createReqVO) {
// 插入
ServicePackageDO servicePackage = BeanUtils.toBean(createReqVO, ServicePackageDO.class);
servicePackageMapper.insert(servicePackage);
// 返回
return servicePackage.getId();
}
@Override
public void updateServicePackage(ServicePackageSaveReqVO updateReqVO) {
// 校验存在
if (servicePackageMapper.selectById(updateReqVO.getId()) == null) {
//不存在执行插入
this.createServicePackage(updateReqVO);
}else {
// 更新
ServicePackageDO updateObj = BeanUtils.toBean(updateReqVO, ServicePackageDO.class);
servicePackageMapper.updateById(updateObj);
}
}
@Override
public void deleteServicePackage(String id) {
// 校验存在
validateServicePackageExists(id);
// 校验正在使用--TODO 后续完善
// validateTenantUsed(id);
// 删除
servicePackageMapper.deleteById(id);
}
private void validateServicePackageExists(String id) {
if (servicePackageMapper.selectById(id) == null) {
throw exception(SERVICE_PACKAGE_NOT_EXISTS);
}
}
@Override
public ServicePackageDO getServicePackage(String id) {
return servicePackageMapper.selectById(id);
}
@Override
public PageResult<ServicePackageDO> getServicePackagePage(ServicePackagePageReqVO pageReqVO) {
return servicePackageMapper.selectPage(pageReqVO);
}
@Override
public ServicePackageDO validServicePackage(String id) {
// ServicePackageDO tenantPackage = tenantPackageMapper.selectById(id);
// if (tenantPackage == null) {
// throw exception(TENANT_PACKAGE_NOT_EXISTS);
// }
// if (tenantPackage.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
// throw exception(TENANT_PACKAGE_DISABLE, tenantPackage.getName());
// }
// return tenantPackage;
return null;
}
@Override
public List<ServicePackageDO> getServicePackageListByStatus(Integer status) {
return servicePackageMapper.selectListByStatus(status);
}
}

View File

@ -251,6 +251,7 @@ yudao:
ignore-tables:
- system_tenant
- system_tenant_package
- system_service_package
- system_dict_data
- system_dict_type
- system_error_code