mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-02-01 19:24:57 +08:00
[feat] 新增项目信息管理模块
This commit is contained in:
parent
2632866955
commit
8bfc2a8ef8
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.framework.excel.core.convert;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hhyykk
|
||||
* @description
|
||||
* @date 2024/7/6
|
||||
*/
|
||||
public class ListToStringConvert implements Converter<Object> {
|
||||
@Override
|
||||
public Class<?> supportJavaTypeKey() {
|
||||
return List.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<?> convertToExcelData(Object object, ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) throws Exception {
|
||||
if (object == null) {
|
||||
return new WriteCellData<>("");
|
||||
}
|
||||
String value = String.valueOf(object);
|
||||
// 拼接字符串,逗号隔开
|
||||
// String result = value.replace("[", "").replace("]", "").replace(" ", "");
|
||||
return new WriteCellData<>(value);
|
||||
}
|
||||
}
|
@ -79,6 +79,14 @@ public class CustomerCompanyController {
|
||||
return success(BeanUtils.toBean(pageResult, CustomerCompanyRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得客户公司列表")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:query')")
|
||||
public CommonResult<List<CustomerCompanyRespVO>> getCustomerCompanyList(CustomerCompanyPageReqVO reqVO) {
|
||||
List<CustomerCompanyDO> list = customerCompanyService.getCustomerCompanyList(reqVO);
|
||||
return success(BeanUtils.toBean(list, CustomerCompanyRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出客户公司 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('cms:customer-company:export')")
|
||||
|
@ -27,4 +27,8 @@ public interface CustomerCompanyMapper extends BaseMapperX<CustomerCompanyDO> {
|
||||
.orderByDesc(CustomerCompanyDO::getId));
|
||||
}
|
||||
|
||||
default List<CustomerCompanyDO> selectList(CustomerCompanyPageReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<CustomerCompanyDO>());
|
||||
}
|
||||
|
||||
}
|
@ -52,4 +52,10 @@ public interface CustomerCompanyService {
|
||||
*/
|
||||
PageResult<CustomerCompanyDO> getCustomerCompanyPage(CustomerCompanyPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得客户公司列表
|
||||
* @param reqVO 查询参数
|
||||
* @return 列表信息
|
||||
*/
|
||||
List<CustomerCompanyDO> getCustomerCompanyList(CustomerCompanyPageReqVO reqVO);
|
||||
}
|
@ -71,4 +71,9 @@ public class CustomerCompanyServiceImpl implements CustomerCompanyService {
|
||||
return customerCompanyMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomerCompanyDO> getCustomerCompanyList(CustomerCompanyPageReqVO reqVO) {
|
||||
return customerCompanyMapper.selectList(reqVO);
|
||||
}
|
||||
|
||||
}
|
@ -45,6 +45,14 @@ public class FileController {
|
||||
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
@PostMapping("/uploadEx")
|
||||
@Operation(summary = "上传文件", description = "模式一:后端上传文件")
|
||||
public CommonResult<FileRespVO> uploadFileEx(FileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
return success(fileService.createFileEx(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
@GetMapping("/presigned-url")
|
||||
@Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器")
|
||||
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path) throws Exception {
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||
|
||||
/**
|
||||
@ -63,4 +64,12 @@ public interface FileService {
|
||||
*/
|
||||
FilePresignedUrlRespVO getFilePresignedUrl(String path) throws Exception;
|
||||
|
||||
/**
|
||||
* 创建文件ex
|
||||
* @param name 文件名
|
||||
* @param path 路径
|
||||
* @param content 文件内容
|
||||
* @return 文件对象
|
||||
*/
|
||||
FileRespVO createFileEx(String name, String path, byte[] content);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils;
|
||||
@ -113,4 +114,37 @@ public class FileServiceImpl implements FileService {
|
||||
object -> object.setConfigId(fileClient.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public FileRespVO createFileEx(String name, String path, byte[] content) {
|
||||
// 计算默认的 path 名
|
||||
String type = FileTypeUtils.getMineType(content, name);
|
||||
if (StrUtil.isEmpty(path)) {
|
||||
path = FileUtils.generatePath(content, name);
|
||||
}
|
||||
// 如果 name 为空,则使用 path 填充
|
||||
if (StrUtil.isEmpty(name)) {
|
||||
name = path;
|
||||
}
|
||||
|
||||
// 上传到文件存储器
|
||||
FileClient client = fileConfigService.getMasterFileClient();
|
||||
Assert.notNull(client, "客户端(master) 不能为空");
|
||||
String url = client.upload(content, path, type);
|
||||
|
||||
// 保存到数据库
|
||||
FileDO file = new FileDO();
|
||||
file.setConfigId(client.getId());
|
||||
file.setName(name);
|
||||
file.setPath(path);
|
||||
file.setUrl(url);
|
||||
file.setType(type);
|
||||
file.setSize(content.length);
|
||||
fileMapper.insert(file);
|
||||
FileRespVO vo = new FileRespVO();
|
||||
vo.setName(name);
|
||||
vo.setUrl(url);
|
||||
return vo;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.pms.enums;
|
||||
|
||||
/**
|
||||
* @author hhyykk
|
||||
* @description 字典枚举
|
||||
* @date 2024/7/3
|
||||
*/
|
||||
public interface DictTypeConstants {
|
||||
String PROJECT_TYPE = "project_type"; // 项目类型
|
||||
String ENTRUST_METHOD = "entrust_method"; // 委托方式
|
||||
String INFRA_BOOLEAN_STRING = "infra_boolean_string"; // 布尔
|
||||
String PROCESS_STATUS = "process_status"; // 流程状态
|
||||
String POSSIBILITY_OF_LANDING = "possibility_of_landing"; // 可能性
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.pms.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* @author hhyykk
|
||||
* @description 错误码枚举类 1_021_000_000 段
|
||||
* @date 2024/7/3
|
||||
*/
|
||||
public interface ErrorCodeConstants {
|
||||
ErrorCode PROJECT_NOT_EXISTS = new ErrorCode(1_021_000_000, "项目信息不存在");
|
||||
}
|
@ -30,6 +30,12 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-system-biz</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
@ -52,6 +58,18 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-cms-biz</artifactId>
|
||||
<version>2.1.0-snapshot</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,96 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.project;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.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 jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.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.pms.controller.admin.project.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.module.pms.service.project.ProjectService;
|
||||
|
||||
@Tag(name = "管理后台 - 项目基本信息")
|
||||
@RestController
|
||||
@RequestMapping("/pms/project")
|
||||
@Validated
|
||||
public class ProjectController {
|
||||
|
||||
@Resource
|
||||
private ProjectService projectService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建项目基本信息")
|
||||
@PreAuthorize("@ss.hasPermission('pms:project:create')")
|
||||
public CommonResult<Long> createProject(@Valid @RequestBody ProjectSaveReqVO createReqVO) {
|
||||
return success(projectService.createProject(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新项目基本信息")
|
||||
@PreAuthorize("@ss.hasPermission('pms:project:update')")
|
||||
public CommonResult<Boolean> updateProject(@Valid @RequestBody ProjectSaveReqVO updateReqVO) {
|
||||
projectService.updateProject(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除项目基本信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('pms:project:delete')")
|
||||
public CommonResult<Boolean> deleteProject(@RequestParam("id") Long id) {
|
||||
projectService.deleteProject(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得项目基本信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('pms:project:query')")
|
||||
public CommonResult<ProjectRespDetailVO> getProject(@RequestParam("id") Long id) {
|
||||
ProjectDetailDO project = projectService.getProjectDetail(id);
|
||||
return success(BeanUtils.toBean(project, ProjectRespDetailVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得项目基本信息分页")
|
||||
@PreAuthorize("@ss.hasPermission('pms:project:query')")
|
||||
public CommonResult<PageResult<ProjectRespVO>> getProjectPage(@Valid ProjectPageReqVO pageReqVO) {
|
||||
PageResult<ProjectDetailDO> pageResult = projectService.getProjectDetailPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ProjectRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出项目基本信息 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('pms:project:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportProjectExcel(@Valid ProjectPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ProjectDetailDO> list = projectService.getProjectDetailPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "项目基本信息.xls", "数据", ProjectRespDetailVO.class,
|
||||
BeanUtils.toBean(list, ProjectRespDetailVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.project.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 ProjectPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "跟踪编号")
|
||||
private String trackingCode;
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "项目经理id", example = "1")
|
||||
private Long projectManagerId;
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.project.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.*;
|
||||
import cn.iocoder.yudao.module.pms.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hhyykk
|
||||
* @description
|
||||
* @date 2024/7/4
|
||||
*/
|
||||
@Schema(description = "管理后台 - 项目基本信息 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProjectRespDetailVO {
|
||||
@Schema(description = "id", example = "11213")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@ExcelProperty("项目编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "省份", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京")
|
||||
@ExcelProperty("省份")
|
||||
private String province;
|
||||
|
||||
@Schema(description = "城市", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京")
|
||||
@ExcelProperty("城市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "客户联系人", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("客户联系人")
|
||||
private String customerUser;
|
||||
|
||||
@Schema(description = "出图公司", requiredMode = Schema.RequiredMode.REQUIRED, example = "公司1")
|
||||
@ExcelProperty("出图公司")
|
||||
private String drawingCompany;
|
||||
|
||||
@Schema(description = "追踪部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long trackingDepId;
|
||||
|
||||
@Schema(description = "落地时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-01-01")
|
||||
@ExcelProperty("落地时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "落地可能性", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty("落地可能性")
|
||||
private String possibility;
|
||||
|
||||
@Schema(description = "漏斗预期", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty("漏斗预期")
|
||||
private String funnelExpectation;
|
||||
|
||||
@Schema(description = "委托方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty(value = "委托方式", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.ENTRUST_METHOD)
|
||||
private String entrustMethod;
|
||||
|
||||
@Schema(description = "未落地原因", example = "100")
|
||||
@ExcelProperty("未落地原因")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "审批状态", example = "doing")
|
||||
@DictFormat(DictTypeConstants.PROCESS_STATUS)
|
||||
private String processStatus;
|
||||
|
||||
@Schema(description = "状态", example = "doing")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "跟踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty("跟踪编号")
|
||||
private String trackingCode;
|
||||
|
||||
@Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty(value = "项目类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.PROJECT_TYPE)
|
||||
private String type;
|
||||
|
||||
@Schema(description = "客户公司id", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Long customerCompanyId;
|
||||
|
||||
@Schema(description = "项目经理id", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Long projectManagerId;
|
||||
|
||||
@Schema(description = "开始追踪时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-12-10")
|
||||
@ExcelProperty("开始追踪时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "追踪情况", requiredMode = Schema.RequiredMode.REQUIRED, example = "情况情况")
|
||||
@ExcelProperty("追踪情况")
|
||||
private String situation;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "是否落地", requiredMode = Schema.RequiredMode.REQUIRED, example = "是")
|
||||
@ExcelProperty(value = "是否落地", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.INFRA_BOOLEAN_STRING)
|
||||
private Boolean confirmation;
|
||||
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
// @ExcelProperty(value = "预计合同金额", converter = MoneyConvert.class)
|
||||
private String contractAmount;
|
||||
|
||||
@Schema(description = "客户电话", example = "17656598224")
|
||||
@ExcelProperty("客户电话")
|
||||
private String customerPhone;
|
||||
|
||||
@Schema(description = "省份id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17656598224")
|
||||
private Long provinceId;
|
||||
|
||||
@Schema(description = "城市id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17656598224")
|
||||
private Long cityId;
|
||||
|
||||
@Schema(description = "追踪部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "综合部")
|
||||
@ExcelProperty("追踪部门")
|
||||
private String trackingDepName;
|
||||
|
||||
@Schema(description = "项目经理", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("项目经理")
|
||||
private String projectManagerName;
|
||||
|
||||
@Schema(description = "客户公司", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三公司")
|
||||
@ExcelProperty("客户公司")
|
||||
private String customerCompanyName;
|
||||
|
||||
@Schema(description = "评审附件", example = "http://ryoyi.pro")
|
||||
@ExcelProperty(value = "评审附件", converter = ListToStringConvert.class)
|
||||
private List<String> reviewFileUrl;
|
||||
|
||||
@Schema(description = "中标附件", example = "http://ryoyi.pro")
|
||||
@ExcelProperty(value = "中标附件", converter = ListToStringConvert.class)
|
||||
private List<String> winFileUrl;
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.project.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 项目基本信息 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProjectRespVO {
|
||||
|
||||
@Schema(description = "名称", example = "11213")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "跟踪部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30571")
|
||||
@ExcelProperty("跟踪部门id")
|
||||
private Long trackingDepId;
|
||||
|
||||
@Schema(description = "跟踪部门", example = "30571")
|
||||
@ExcelProperty("跟踪部门")
|
||||
private String trackingDepName;
|
||||
|
||||
@Schema(description = "跟踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30571")
|
||||
@ExcelProperty("跟踪编号")
|
||||
private String trackingCode;
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
@ExcelProperty(value = "类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.PROJECT_TYPE)
|
||||
private String type;
|
||||
|
||||
@Schema(description = "项目经理id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26238")
|
||||
@ExcelProperty("项目经理id")
|
||||
private Long projectManagerId;
|
||||
|
||||
@Schema(description = "项目经理", example = "26238")
|
||||
private String projectManagerName;
|
||||
|
||||
@Schema(description = "预计合同金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1216569")
|
||||
@ExcelProperty("预计合同金额")
|
||||
private String contractAmount;
|
||||
|
||||
@Schema(description = "客户公司", example = "26238")
|
||||
@ExcelProperty("客户公司")
|
||||
private String customerCompanyName;
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package cn.iocoder.yudao.module.pms.controller.admin.project.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 项目基本信息新增/修改 Request VO")
|
||||
@Data
|
||||
public class ProjectSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16059")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@NotEmpty(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "项目编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "客户联系人")
|
||||
private String customerUser;
|
||||
|
||||
@Schema(description = "出图公司", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "出图公司不能为空")
|
||||
private String drawingCompany;
|
||||
|
||||
@Schema(description = "跟踪部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30571")
|
||||
@NotNull(message = "跟踪部门id不能为空")
|
||||
private Long trackingDepId;
|
||||
|
||||
@Schema(description = "落地时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "落地可能性", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "落地可能性不能为空")
|
||||
private String possibility;
|
||||
|
||||
@Schema(description = "漏斗预期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "漏斗预期不能为空")
|
||||
private String funnelExpectation;
|
||||
|
||||
@Schema(description = "委托方式", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "委托方式不能为空")
|
||||
private String entrustMethod;
|
||||
|
||||
@Schema(description = "未落地原因", example = "不喜欢")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "审批状态", example = "2")
|
||||
private String processStatus;
|
||||
|
||||
@Schema(description = "跟踪编号")
|
||||
private String trackingCode;
|
||||
|
||||
@Schema(description = "类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "客户公司id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12216")
|
||||
@NotNull(message = "客户公司id不能为空")
|
||||
private Long customerCompanyId;
|
||||
|
||||
@Schema(description = "项目经理id", example = "26238")
|
||||
private Long projectManagerId;
|
||||
|
||||
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "跟踪情况")
|
||||
private String situation;
|
||||
|
||||
@Schema(description = "评审附件", example = "https://www.iocoder.cn")
|
||||
private List<String> reviewFileUrl;
|
||||
|
||||
@Schema(description = "是否落地")
|
||||
private Boolean confirmation;
|
||||
|
||||
@Schema(description = "中标附件", example = "https://www.iocoder.cn")
|
||||
private List<String> winFileUrl;
|
||||
|
||||
@Schema(description = "预计合同金额")
|
||||
private String contractAmount;
|
||||
|
||||
@Schema(description = "客户电话", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "客户电话不能为空")
|
||||
private String customerPhone;
|
||||
|
||||
@Schema(description = "省份id", example = "25195")
|
||||
private Long provinceId;
|
||||
|
||||
@Schema(description = "城市id", example = "23899")
|
||||
private Long cityId;
|
||||
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package cn.iocoder.yudao.module.pms.dal.dataobject.project;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.enums.DictTypeConstants;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 项目基本信息 DO
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@TableName("pms_project")
|
||||
@KeySequence("pms_project_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProjectDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 流程实体id
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
/**
|
||||
* 客户联系人
|
||||
*/
|
||||
private String customerUser;
|
||||
/**
|
||||
* 出图公司
|
||||
*/
|
||||
private String drawingCompany;
|
||||
/**
|
||||
* 跟踪部门id
|
||||
*/
|
||||
private Long trackingDepId;
|
||||
/**
|
||||
* 落地时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
/**
|
||||
* 落地可能性
|
||||
*
|
||||
* 枚举 {@link DictTypeConstants}
|
||||
*/
|
||||
private String possibility;
|
||||
/**
|
||||
* 漏斗预期
|
||||
*/
|
||||
private String funnelExpectation;
|
||||
/**
|
||||
* 委托方式
|
||||
*
|
||||
* 枚举 {@link DictTypeConstants}
|
||||
*/
|
||||
private String entrustMethod;
|
||||
/**
|
||||
* 是否审批
|
||||
*
|
||||
* 枚举 {@link DictTypeConstants}
|
||||
*/
|
||||
private Boolean approve;
|
||||
/**
|
||||
* 未落地原因
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 审批状态
|
||||
*
|
||||
* 枚举 {@link DictTypeConstants}
|
||||
*/
|
||||
private String processStatus;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 跟踪编号
|
||||
*/
|
||||
private String trackingCode;
|
||||
/**
|
||||
* 类型
|
||||
*
|
||||
* 枚举 {@link DictTypeConstants}
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 客户公司id
|
||||
*/
|
||||
private Long customerCompanyId;
|
||||
/**
|
||||
* 项目经理id
|
||||
*/
|
||||
private Long projectManagerId;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
/**
|
||||
* 跟踪情况
|
||||
*/
|
||||
private String situation;
|
||||
/**
|
||||
* 评审附件
|
||||
*/
|
||||
private String reviewFileUrl;
|
||||
/**
|
||||
* 是否落地
|
||||
*
|
||||
* 枚举 {@link DictTypeConstants}
|
||||
*/
|
||||
private Boolean confirmation;
|
||||
/**
|
||||
* 中标附件
|
||||
*/
|
||||
private String winFileUrl;
|
||||
/**
|
||||
* 预计合同金额
|
||||
*/
|
||||
private String contractAmount;
|
||||
/**
|
||||
* 客户电话
|
||||
*/
|
||||
private String customerPhone;
|
||||
/**
|
||||
* 省份id
|
||||
*/
|
||||
private Long provinceId;
|
||||
/**
|
||||
* 城市id
|
||||
*/
|
||||
private Long cityId;
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.pms.dal.dataobject.project;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author hhyykk
|
||||
* @description
|
||||
* @date 2024/7/4
|
||||
*/
|
||||
@Data
|
||||
public class ProjectDetailDO extends ProjectDO{
|
||||
|
||||
/**
|
||||
* 跟踪部门
|
||||
*/
|
||||
private String trackingDepName;
|
||||
/**
|
||||
* 项目经理
|
||||
*/
|
||||
private String projectManagerName;
|
||||
/**
|
||||
* 客户公司
|
||||
*/
|
||||
private String customerCompanyName;
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.pms.dal.mysql.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.cms.dal.dataobject.customerCompany.CustomerCompanyDO;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.project.vo.ProjectPageReqVO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 项目基本信息 Mapper
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProjectMapper extends BaseMapperX<ProjectDO> {
|
||||
|
||||
default PageResult<ProjectDO> selectPage(ProjectPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ProjectDO>()
|
||||
.likeIfPresent(ProjectDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ProjectDO::getTrackingCode, reqVO.getTrackingCode())
|
||||
.eqIfPresent(ProjectDO::getType, reqVO.getType())
|
||||
.orderByDesc(ProjectDO::getId));
|
||||
}
|
||||
|
||||
default PageResult<ProjectDetailDO> selectDetailPage(ProjectPageReqVO reqVO) {
|
||||
return selectJoinPage(reqVO, ProjectDetailDO.class, new MPJLambdaWrapper<ProjectDO>()
|
||||
.selectAll(ProjectDO.class)
|
||||
.selectAs(DeptDO::getName, ProjectDetailDO::getTrackingDepName) // 映射到ProjectDetailDO的trackingDeptName
|
||||
.selectAs(AdminUserDO::getNickname, ProjectDetailDO::getProjectManagerName) // 映射到ProjectDetailDO的projectManagerName
|
||||
.selectAs(CustomerCompanyDO::getName, ProjectDetailDO::getCustomerCompanyName)
|
||||
.likeIfExists(ProjectDO::getName, reqVO.getName())
|
||||
.eqIfExists(ProjectDO::getTrackingCode, reqVO.getTrackingCode())
|
||||
.eqIfExists(ProjectDO::getType, reqVO.getType())
|
||||
.eqIfExists(ProjectDO::getProjectManagerId, reqVO.getProjectManagerId())
|
||||
.orderByDesc(ProjectDO::getId)
|
||||
.leftJoin(DeptDO.class, DeptDO::getId, ProjectDO::getTrackingDepId)
|
||||
.leftJoin(AdminUserDO.class, AdminUserDO::getId, ProjectDO::getProjectManagerId)
|
||||
.leftJoin(CustomerCompanyDO.class, CustomerCompanyDO::getId, ProjectDO::getCustomerCompanyId)
|
||||
);
|
||||
}
|
||||
|
||||
default ProjectDetailDO getDetailById(Long id) {
|
||||
return selectJoinOne(ProjectDetailDO.class, new MPJLambdaWrapper<ProjectDO>()
|
||||
.selectAll(ProjectDO.class)
|
||||
.selectAs(DeptDO::getName, ProjectDetailDO::getTrackingDepName) // 映射到ProjectDetailDO的trackingDeptName
|
||||
.selectAs(AdminUserDO::getNickname, ProjectDetailDO::getProjectManagerName) // 映射到ProjectDetailDO的projectManagerName
|
||||
.selectAs(CustomerCompanyDO::getName, ProjectDetailDO::getCustomerCompanyName)
|
||||
.eqIfExists(ProjectDO::getId, id)
|
||||
.leftJoin(DeptDO.class, DeptDO::getId, ProjectDO::getTrackingDepId)
|
||||
.leftJoin(AdminUserDO.class, AdminUserDO::getId, ProjectDO::getProjectManagerId)
|
||||
.leftJoin(CustomerCompanyDO.class, CustomerCompanyDO::getId, ProjectDO::getCustomerCompanyId)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.pms.service.project;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.project.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 项目基本信息 Service 接口
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
public interface ProjectService {
|
||||
|
||||
/**
|
||||
* 创建项目基本信息
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createProject(@Valid ProjectSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新项目基本信息
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateProject(@Valid ProjectSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除项目基本信息
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteProject(Long id);
|
||||
|
||||
/**
|
||||
* 获得项目基本信息
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 项目基本信息
|
||||
*/
|
||||
ProjectDO getProject(Long id);
|
||||
|
||||
/**
|
||||
* 获得项目基本信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 项目基本信息分页
|
||||
*/
|
||||
PageResult<ProjectDO> getProjectPage(ProjectPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得项目基本信息分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 项目基本信息分页
|
||||
*/
|
||||
PageResult<ProjectDetailDO> getProjectDetailPage(ProjectPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得项目基本信息
|
||||
* @param id id
|
||||
* @return 基本信息
|
||||
*/
|
||||
ProjectDetailDO getProjectDetail(Long id);
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package cn.iocoder.yudao.module.pms.service.project;
|
||||
|
||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDetailDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.project.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
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.pms.dal.mysql.project.ProjectMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 项目基本信息 Service 实现类
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProjectServiceImpl implements ProjectService {
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Override
|
||||
public Long createProject(ProjectSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ProjectDO project = BeanUtils.toBean(createReqVO, ProjectDO.class);
|
||||
projectMapper.insert(project);
|
||||
// todo 启动流程
|
||||
// 返回
|
||||
return project.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProject(ProjectSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateProjectExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ProjectDO updateObj = BeanUtils.toBean(updateReqVO, ProjectDO.class);
|
||||
projectMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProject(Long id) {
|
||||
// 校验存在
|
||||
validateProjectExists(id);
|
||||
// 删除
|
||||
projectMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateProjectExists(Long id) {
|
||||
if (projectMapper.selectById(id) == null) {
|
||||
throw exception(PROJECT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectDO getProject(Long id) {
|
||||
return projectMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProjectDO> getProjectPage(ProjectPageReqVO pageReqVO) {
|
||||
return projectMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProjectDetailDO> getProjectDetailPage(ProjectPageReqVO pageReqVO) {
|
||||
PageResult<ProjectDetailDO> pageResult = projectMapper.selectDetailPage(pageReqVO);
|
||||
// 处理省市
|
||||
pageResult.getList().forEach(item -> {
|
||||
item.setCity(AreaUtils.format(Math.toIntExact(item.getCityId())));
|
||||
item.setProvince(AreaUtils.format(Math.toIntExact(item.getProvinceId())));
|
||||
});
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectDetailDO getProjectDetail(Long id) {
|
||||
ProjectDetailDO dto = projectMapper.getDetailById(id);
|
||||
String province = AreaUtils.getArea(Math.toIntExact(dto.getProvinceId())).getName();
|
||||
String city = AreaUtils.getArea(Math.toIntExact(dto.getCityId())).getName();
|
||||
dto.setCity(city);
|
||||
dto.setProvince(province);
|
||||
return dto;
|
||||
}
|
||||
|
||||
}
|
@ -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.pms.dal.mysql.project.ProjectMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,138 @@
|
||||
package cn.iocoder.yudao.module.pms.service.project;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.pms.controller.admin.project.vo.*;
|
||||
import cn.iocoder.yudao.module.pms.dal.dataobject.project.ProjectDO;
|
||||
import cn.iocoder.yudao.module.pms.dal.mysql.project.ProjectMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link ProjectServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author hhyykk
|
||||
*/
|
||||
@Import(ProjectServiceImpl.class)
|
||||
public class ProjectServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ProjectServiceImpl projectService;
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateProject_success() {
|
||||
// 准备参数
|
||||
ProjectSaveReqVO createReqVO = randomPojo(ProjectSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long projectId = projectService.createProject(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(projectId);
|
||||
// 校验记录的属性是否正确
|
||||
ProjectDO project = projectMapper.selectById(projectId);
|
||||
assertPojoEquals(createReqVO, project, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateProject_success() {
|
||||
// mock 数据
|
||||
ProjectDO dbProject = randomPojo(ProjectDO.class);
|
||||
projectMapper.insert(dbProject);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ProjectSaveReqVO updateReqVO = randomPojo(ProjectSaveReqVO.class, o -> {
|
||||
o.setId(dbProject.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
projectService.updateProject(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
ProjectDO project = projectMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, project);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateProject_notExists() {
|
||||
// 准备参数
|
||||
ProjectSaveReqVO updateReqVO = randomPojo(ProjectSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> projectService.updateProject(updateReqVO), PROJECT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteProject_success() {
|
||||
// mock 数据
|
||||
ProjectDO dbProject = randomPojo(ProjectDO.class);
|
||||
projectMapper.insert(dbProject);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbProject.getId();
|
||||
|
||||
// 调用
|
||||
projectService.deleteProject(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(projectMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteProject_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> projectService.deleteProject(id), PROJECT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetProjectPage() {
|
||||
// mock 数据
|
||||
ProjectDO dbProject = randomPojo(ProjectDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setTrackingCode(null);
|
||||
o.setType(null);
|
||||
});
|
||||
projectMapper.insert(dbProject);
|
||||
// 测试 name 不匹配
|
||||
projectMapper.insert(cloneIgnoreId(dbProject, o -> o.setName(null)));
|
||||
// 测试 trackingCode 不匹配
|
||||
projectMapper.insert(cloneIgnoreId(dbProject, o -> o.setTrackingCode(null)));
|
||||
// 测试 type 不匹配
|
||||
projectMapper.insert(cloneIgnoreId(dbProject, o -> o.setType(null)));
|
||||
// 准备参数
|
||||
ProjectPageReqVO reqVO = new ProjectPageReqVO();
|
||||
reqVO.setName(null);
|
||||
reqVO.setTrackingCode(null);
|
||||
reqVO.setType(null);
|
||||
|
||||
// 调用
|
||||
PageResult<ProjectDO> pageResult = projectService.getProjectPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbProject, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -40,19 +40,19 @@ spring:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
url: jdbc:mysql://192.168.6.167:3306/hhyykk?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
username: root
|
||||
password: 123456
|
||||
slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
|
||||
lazy: true # 开启懒加载,保证启动速度
|
||||
url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
url: jdbc:mysql://127.0.0.1:3306/hhyykk?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
data:
|
||||
redis:
|
||||
host: 400-infra.server.iocoder.cn # 地址
|
||||
host: 192.168.6.167 # 地址
|
||||
port: 6379 # 端口
|
||||
database: 1 # 数据库索引
|
||||
# password: 123456 # 密码,建议生产环境开启
|
||||
@ -170,7 +170,7 @@ yudao:
|
||||
pay:
|
||||
order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址
|
||||
refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址
|
||||
demo: true # 开启演示模式
|
||||
demo: false # 开启演示模式
|
||||
tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc
|
||||
|
||||
justauth:
|
||||
|
Loading…
Reference in New Issue
Block a user