feat:新增客户管理模块

master
HuangHuiKang 1 week ago
parent 5d0c33d283
commit d09de29de9

@ -15,14 +15,15 @@
<!-- 各种 module 拓展 -->
<module>yudao-module-system</module>
<module>yudao-module-infra</module>
<!-- <module>yudao-module-member</module>-->
<module>yudao-module-customer</module>
<!-- <module>yudao-module-member</module>-->
<!-- <module>yudao-module-bpm</module>-->
<!-- <module>yudao-module-report</module>-->
<!-- <module>yudao-module-mp</module>-->
<!-- <module>yudao-module-pay</module>-->
<!-- <module>yudao-module-mall</module>-->
<!-- <module>yudao-module-crm</module>-->
<!-- <module>yudao-module-erp</module>-->
<module>yudao-module-erp</module>
<!-- <module>yudao-module-iot</module>-->
<!-- AI 大模型的开启,请参考 https://doc.iocoder.cn/ai/build/ 文档,对 JDK 版本要要求! -->
<!-- <module>yudao-module-ai</module>-->

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yudao-module-customer</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
customer 包下,客户管理
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-redis</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,104 @@
package cn.iocoder.yudao.module.cus.controller.admin.management;
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.cus.controller.admin.management.vo.*;
import cn.iocoder.yudao.module.cus.dal.dataobject.management.ManagementDO;
import cn.iocoder.yudao.module.cus.service.management.ManagementService;
@Tag(name = "管理后台 - 客户管理")
@RestController
@RequestMapping("/cus/management")
@Validated
public class ManagementController {
@Resource
private ManagementService managementService;
@PostMapping("/create")
@Operation(summary = "创建客户管理")
@PreAuthorize("@ss.hasPermission('cus:management:create')")
public CommonResult<Long> createManagement(@Valid @RequestBody ManagementSaveReqVO createReqVO) {
return success(managementService.createManagement(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新客户管理")
@PreAuthorize("@ss.hasPermission('cus:management:update')")
public CommonResult<Boolean> updateManagement(@Valid @RequestBody ManagementSaveReqVO updateReqVO) {
managementService.updateManagement(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除客户管理")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('cus:management:delete')")
public CommonResult<Boolean> deleteManagement(@RequestParam("id") Long id) {
managementService.deleteManagement(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除客户管理")
@PreAuthorize("@ss.hasPermission('cus:management:delete')")
public CommonResult<Boolean> deleteManagementList(@RequestParam("ids") List<Long> ids) {
managementService.deleteManagementListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得客户管理")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('cus:management:query')")
public CommonResult<ManagementRespVO> getManagement(@RequestParam("id") Long id) {
ManagementDO management = managementService.getManagement(id);
return success(BeanUtils.toBean(management, ManagementRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得客户管理分页")
@PreAuthorize("@ss.hasPermission('cus:management:query')")
public CommonResult<PageResult<ManagementRespVO>> getManagementPage(@Valid ManagementPageReqVO pageReqVO) {
PageResult<ManagementDO> pageResult = managementService.getManagementPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ManagementRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出客户管理 Excel")
@PreAuthorize("@ss.hasPermission('cus:management:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportManagementExcel(@Valid ManagementPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ManagementDO> list = managementService.getManagementPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "客户管理.xls", "数据", ManagementRespVO.class,
BeanUtils.toBean(list, ManagementRespVO.class));
}
}

@ -0,0 +1,72 @@
package cn.iocoder.yudao.module.cus.controller.admin.management.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
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
public class ManagementPageReqVO extends PageParam {
@Schema(description = "客户编码")
private String customerCode;
@Schema(description = "客户名称", example = "张三")
private String customerName;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "售后负责人")
private String afterSalesManager;
@Schema(description = "国家编码")
private String countryCode;
@Schema(description = "国家名称", example = "王五")
private String countryName;
@Schema(description = "省编码")
private String provinceCode;
@Schema(description = "省名称", example = "王五")
private String provinceName;
@Schema(description = "城市编码")
private String cityCode;
@Schema(description = "城市名称", example = "赵六")
private String cityName;
@Schema(description = "详细地址")
private String address;
@Schema(description = "经度")
private BigDecimal longitude;
@Schema(description = "纬度")
private BigDecimal latitude;
@Schema(description = "数据库IP")
private String dbIp;
@Schema(description = "数据库端口")
private Integer dbPort;
@Schema(description = "数据库账号", example = "赵六")
private String dbUsername;
@Schema(description = "数据库密码")
private String dbPassword;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,92 @@
package cn.iocoder.yudao.module.cus.controller.admin.management.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import cn.idev.excel.annotation.*;
@Schema(description = "管理后台 - 客户管理 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ManagementRespVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14051")
@ExcelProperty("id")
private Long id;
@Schema(description = "客户编码")
@ExcelProperty("客户编码")
private String customerCode;
@Schema(description = "客户名称", example = "张三")
@ExcelProperty("客户名称")
private String customerName;
@Schema(description = "备注", example = "随便")
@ExcelProperty("备注")
private String remark;
@Schema(description = "售后负责人")
@ExcelProperty("售后负责人")
private String afterSalesManager;
@Schema(description = "国家编码")
@ExcelProperty("国家编码")
private String countryCode;
@Schema(description = "国家名称", example = "王五")
@ExcelProperty("国家名称")
private String countryName;
@Schema(description = "省编码")
@ExcelProperty("省编码")
private String provinceCode;
@Schema(description = "省名称", example = "王五")
@ExcelProperty("省名称")
private String provinceName;
@Schema(description = "城市编码")
@ExcelProperty("城市编码")
private String cityCode;
@Schema(description = "城市名称", example = "赵六")
@ExcelProperty("城市名称")
private String cityName;
@Schema(description = "详细地址")
@ExcelProperty("详细地址")
private String address;
@Schema(description = "经度")
@ExcelProperty("经度")
private BigDecimal longitude;
@Schema(description = "纬度")
@ExcelProperty("纬度")
private BigDecimal latitude;
@Schema(description = "数据库IP")
@ExcelProperty("数据库IP")
private String dbIp;
@Schema(description = "数据库端口")
@ExcelProperty("数据库端口")
private Integer dbPort;
@Schema(description = "数据库账号", example = "赵六")
@ExcelProperty("数据库账号")
private String dbUsername;
@Schema(description = "数据库密码")
@ExcelProperty("数据库密码")
private String dbPassword;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,67 @@
package cn.iocoder.yudao.module.cus.controller.admin.management.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 客户管理新增/修改 Request VO")
@Data
public class ManagementSaveReqVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14051")
private Long id;
@Schema(description = "客户编码")
private String customerCode;
@Schema(description = "客户名称", example = "张三")
private String customerName;
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "售后负责人")
private String afterSalesManager;
@Schema(description = "国家编码")
private String countryCode;
@Schema(description = "国家名称", example = "王五")
private String countryName;
@Schema(description = "省编码")
private String provinceCode;
@Schema(description = "省名称", example = "王五")
private String provinceName;
@Schema(description = "城市编码")
private String cityCode;
@Schema(description = "城市名称", example = "赵六")
private String cityName;
@Schema(description = "详细地址")
private String address;
@Schema(description = "经度")
private BigDecimal longitude;
@Schema(description = "纬度")
private BigDecimal latitude;
@Schema(description = "数据库IP")
private String dbIp;
@Schema(description = "数据库端口")
private Integer dbPort;
@Schema(description = "数据库账号", example = "赵六")
private String dbUsername;
@Schema(description = "数据库密码")
private String dbPassword;
}

@ -0,0 +1,106 @@
package cn.iocoder.yudao.module.cus.dal.dataobject.management;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigDecimal;
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("cus_management")
@KeySequence("cus_management_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ManagementDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
*
*/
private String customerCode;
/**
*
*/
private String customerName;
/**
*
*/
private String remark;
/**
*
*/
private String afterSalesManager;
/**
*
*/
private String countryCode;
/**
*
*/
private String countryName;
/**
*
*/
private String provinceCode;
/**
*
*/
private String provinceName;
/**
*
*/
private String cityCode;
/**
*
*/
private String cityName;
/**
*
*/
private String address;
/**
*
*/
private BigDecimal longitude;
/**
*
*/
private BigDecimal latitude;
/**
* IP
*/
private String dbIp;
/**
*
*/
private Integer dbPort;
/**
*
*/
private String dbUsername;
/**
*
*/
private String dbPassword;
/**
*
*/
private Long tenantId;
}

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.cus.dal.mysql.management;
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.cus.dal.dataobject.management.ManagementDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.cus.controller.admin.management.vo.*;
/**
* Mapper
*
* @author
*/
@Mapper
public interface ManagementMapper extends BaseMapperX<ManagementDO> {
default PageResult<ManagementDO> selectPage(ManagementPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ManagementDO>()
.eqIfPresent(ManagementDO::getCustomerCode, reqVO.getCustomerCode())
.likeIfPresent(ManagementDO::getCustomerName, reqVO.getCustomerName())
.eqIfPresent(ManagementDO::getRemark, reqVO.getRemark())
.eqIfPresent(ManagementDO::getAfterSalesManager, reqVO.getAfterSalesManager())
.eqIfPresent(ManagementDO::getCountryCode, reqVO.getCountryCode())
.likeIfPresent(ManagementDO::getCountryName, reqVO.getCountryName())
.eqIfPresent(ManagementDO::getProvinceCode, reqVO.getProvinceCode())
.likeIfPresent(ManagementDO::getProvinceName, reqVO.getProvinceName())
.eqIfPresent(ManagementDO::getCityCode, reqVO.getCityCode())
.likeIfPresent(ManagementDO::getCityName, reqVO.getCityName())
.eqIfPresent(ManagementDO::getAddress, reqVO.getAddress())
.eqIfPresent(ManagementDO::getLongitude, reqVO.getLongitude())
.eqIfPresent(ManagementDO::getLatitude, reqVO.getLatitude())
.eqIfPresent(ManagementDO::getDbIp, reqVO.getDbIp())
.eqIfPresent(ManagementDO::getDbPort, reqVO.getDbPort())
.likeIfPresent(ManagementDO::getDbUsername, reqVO.getDbUsername())
.eqIfPresent(ManagementDO::getDbPassword, reqVO.getDbPassword())
.betweenIfPresent(ManagementDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ManagementDO::getId));
}
}

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.cus.framework.web.config;
import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* cus web Configuration
*
* @author
*/
@Configuration(proxyBeanMethods = false)
public class CusWebConfiguration {
/**
* cus API
*/
@Bean
public GroupedOpenApi cusGroupedOpenApi() {
return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("cus");
}
}

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.cus.service.management;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.cus.controller.admin.management.vo.*;
import cn.iocoder.yudao.module.cus.dal.dataobject.management.ManagementDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* Service
*
* @author
*/
public interface ManagementService {
/**
*
*
* @param createReqVO
* @return
*/
Long createManagement(@Valid ManagementSaveReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updateManagement(@Valid ManagementSaveReqVO updateReqVO);
/**
*
*
* @param id
*/
void deleteManagement(Long id);
/**
*
*
* @param ids
*/
void deleteManagementListByIds(List<Long> ids);
/**
*
*
* @param id
* @return
*/
ManagementDO getManagement(Long id);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<ManagementDO> getManagementPage(ManagementPageReqVO pageReqVO);
}

@ -0,0 +1,81 @@
package cn.iocoder.yudao.module.cus.service.management;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.cus.controller.admin.management.vo.*;
import cn.iocoder.yudao.module.cus.dal.dataobject.management.ManagementDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.cus.dal.mysql.management.ManagementMapper;
import static cn.iocoder.yudao.module.cus.enums.ErrorCodeConstants.MANAGEMENT_NOT_EXISTS;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
/**
* Service
*
* @author
*/
@Service
@Validated
public class ManagementServiceImpl implements ManagementService {
@Resource
private ManagementMapper managementMapper;
@Override
public Long createManagement(ManagementSaveReqVO createReqVO) {
// 插入
ManagementDO management = BeanUtils.toBean(createReqVO, ManagementDO.class);
managementMapper.insert(management);
// 返回
return management.getId();
}
@Override
public void updateManagement(ManagementSaveReqVO updateReqVO) {
// 校验存在
validateManagementExists(updateReqVO.getId());
// 更新
ManagementDO updateObj = BeanUtils.toBean(updateReqVO, ManagementDO.class);
managementMapper.updateById(updateObj);
}
@Override
public void deleteManagement(Long id) {
// 校验存在
validateManagementExists(id);
// 删除
managementMapper.deleteById(id);
}
@Override
public void deleteManagementListByIds(List<Long> ids) {
// 删除
managementMapper.deleteByIds(ids);
}
private void validateManagementExists(Long id) {
if (managementMapper.selectById(id) == null) {
throw exception(MANAGEMENT_NOT_EXISTS);
}
}
@Override
public ManagementDO getManagement(Long id) {
return managementMapper.selectById(id);
}
@Override
public PageResult<ManagementDO> getManagementPage(ManagementPageReqVO pageReqVO) {
return managementMapper.selectPage(pageReqVO);
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.cus.dal.mysql.management.ManagementMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -95,11 +95,11 @@
<!-- </dependency>-->
<!-- ERP 相关模块。默认注释,保证编译速度 -->
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.boot</groupId>-->
<!-- <artifactId>yudao-module-erp</artifactId>-->
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-erp</artifactId>
<version>${revision}</version>
</dependency>
<!-- AI 大模型相关模块。默认注释,保证编译速度 -->
<!-- <dependency>-->
@ -115,6 +115,13 @@
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<!-- 客户管理相关模块。默认注释,保证编译速度 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-customer</artifactId>
<version>${revision}</version>
</dependency>
<!-- spring boot 配置所需依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>

Loading…
Cancel
Save