From 3e800a08d6bc93e2723bf0e18e5732684bb3b387 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 27 十一月 2024 22:54:13 +0800
Subject: [PATCH] 项目基本信息
---
business/src/main/resources/mapper/ProgressPlanMapper.xml | 6 ---
business/src/main/resources/mapper/ProjectProcessMapper.xml | 3 -
system/src/main/java/com/ycl/system/domain/base/AbsEntity.java | 2
business/src/main/java/com/ycl/domain/entity/File.java | 6 +--
common/src/main/java/com/ycl/common/enums/business/FileTypeEnum.java | 9 +++-
system/src/main/java/com/ycl/system/domain/base/AbsVo.java | 2
business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java | 51 ++++++++++++++++++++++---
common/pom.xml | 6 ++
business/src/main/java/com/ycl/domain/vo/ProjectInfoVO.java | 13 ++++++
start/src/main/resources/application.yml | 2
system/pom.xml | 5 --
business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java | 2
12 files changed, 75 insertions(+), 32 deletions(-)
diff --git a/business/src/main/java/com/ycl/domain/entity/File.java b/business/src/main/java/com/ycl/domain/entity/File.java
index 0602ab1..806883c 100644
--- a/business/src/main/java/com/ycl/domain/entity/File.java
+++ b/business/src/main/java/com/ycl/domain/entity/File.java
@@ -1,9 +1,6 @@
package com.ycl.domain.entity;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
import com.ycl.common.enums.business.FileTypeEnum;
import com.ycl.system.domain.base.AbsEntity;
import lombok.Data;
@@ -34,6 +31,7 @@
/**
* 鏂囦欢鍒嗙被
*/
+ @TableField(value = "type")
private FileTypeEnum type;
/**
* 鏂囦欢鍚�
diff --git a/business/src/main/java/com/ycl/domain/vo/ProjectInfoVO.java b/business/src/main/java/com/ycl/domain/vo/ProjectInfoVO.java
index 2fc8f32..ee49ea6 100644
--- a/business/src/main/java/com/ycl/domain/vo/ProjectInfoVO.java
+++ b/business/src/main/java/com/ycl/domain/vo/ProjectInfoVO.java
@@ -1,5 +1,7 @@
package com.ycl.domain.vo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ycl.domain.entity.File;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.system.domain.base.AbsVo;
import io.swagger.annotations.ApiModel;
@@ -93,14 +95,17 @@
/** 绔嬮」鏃堕棿 */
@ApiModelProperty("绔嬮」鏃堕棿")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createProjectTime;
/** 璁″垝寮�宸ユ椂闂� */
@ApiModelProperty("璁″垝寮�宸ユ椂闂�")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date planStartTime;
/** 璁″垝绔e伐鏃堕棿 */
@ApiModelProperty("璁″垝绔e伐鏃堕棿")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date planCompleteTime;
/** 涓爣鍗曚綅 */
@@ -113,6 +118,7 @@
/** 涓爣鏃堕棿 */
@ApiModelProperty("涓爣鏃堕棿")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date winTime;
/** 璇︾粏鍦板潃 */
@@ -147,6 +153,13 @@
@ApiModelProperty("鍒涘缓浜�")
private Long createBy;
+ /** 鐘舵�佺爜 */
+ @ApiModelProperty("鐘舵�佺爜")
+ private String projectColorCode;
+
+ @ApiModelProperty("鏂囦欢")
+ private List<File> fileList;
+
public static ProjectInfoVO getVoByEntity(@NonNull ProjectInfo entity, ProjectInfoVO vo) {
if(vo == null) {
vo = new ProjectInfoVO();
diff --git a/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java b/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java
index d1a54f3..fa9dd84 100644
--- a/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java
+++ b/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java
@@ -22,7 +22,7 @@
* @param id
* @return
*/
- ProjectInfoVO getById(Integer id);
+ ProjectInfo getById(Integer id);
/**
* 鍒嗛〉
diff --git a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
index 7f650e5..22848db 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -1,15 +1,18 @@
package com.ycl.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.common.base.Result;
import com.ycl.common.enums.business.FileTypeEnum;
+import com.ycl.common.utils.SecurityUtils;
import com.ycl.domain.entity.File;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.domain.form.ProjectInfoForm;
import com.ycl.domain.query.ProjectInfoQuery;
import com.ycl.domain.vo.*;
import com.ycl.framework.utils.PageUtil;
+import com.ycl.mapper.FileMapper;
import com.ycl.mapper.ProjectInfoMapper;
import com.ycl.service.FileService;
import com.ycl.service.ProjectInfoService;
@@ -37,6 +40,7 @@
private final ProjectInfoMapper projectInfoMapper;
private final FileService fileService;
+ private final FileMapper fileMapper;
/**
* 娣诲姞
*
@@ -48,6 +52,9 @@
public Result add(ProjectInfoForm form) {
//娣诲姞鍩烘湰淇℃伅
ProjectInfo entity = ProjectInfoForm.getEntityByForm(form, null);
+ Long userId = SecurityUtils.getUserId();
+ entity.setCreateBy(userId);
+ entity.setUpdateBy(userId);
baseMapper.insert(entity);
//娣诲姞鏂囦欢
List<File> fileList = form.getFileList();
@@ -66,12 +73,28 @@
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public Result update(ProjectInfoForm form) {
ProjectInfo entity = baseMapper.selectById(form.getId());
-
// 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
- BeanUtils.copyProperties(form, entity);
+ ProjectInfoForm.getEntityByForm(form,entity);
+ Long userId = SecurityUtils.getUserId();
+ entity.setUpdateBy(userId);
+
+ List<File> fileList = form.getFileList();
+ fileList.forEach(item->{
+ item.setBusId(entity.getId());
+ item.setType(FileTypeEnum.PROJECT_INFO);
+ });
+ //鍒犻櫎鍘熸湁鏂囦欢
+ QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
+ fileQueryWrapper.eq("type",FileTypeEnum.PROJECT_INFO.getType());
+ fileQueryWrapper.eq("bus_id",entity.getId());
+ fileMapper.delete(fileQueryWrapper);
+ //鏇挎崲鎴愮幇鏈�
+ fileService.saveBatch(fileList);
+ //鏇存柊椤圭洰淇℃伅
baseMapper.updateById(entity);
return Result.ok("淇敼鎴愬姛");
}
@@ -83,6 +106,7 @@
* @return
*/
@Override
+ //TODO:寰呭畬鍠�
public Result remove(List<String> ids) {
baseMapper.deleteBatchIds(ids);
return Result.ok("鍒犻櫎鎴愬姛");
@@ -95,6 +119,7 @@
* @return
*/
@Override
+ //TODO:寰呭畬鍠�
public Result removeById(String id) {
baseMapper.deleteById(id);
return Result.ok("鍒犻櫎鎴愬姛");
@@ -108,9 +133,17 @@
*/
@Override
public Result page(ProjectInfoQuery query) {
- IPage<ProjectInfoVO> page = PageUtil.getPage(query, ProjectInfoVO.class);
+ IPage<ProjectInfo> page = PageUtil.getPage(query, ProjectInfo.class);
baseMapper.getPage(page, query);
- return Result.ok().data(page.getRecords()).total(page.getTotal());
+ List<ProjectInfo> records = page.getRecords();
+ List<ProjectInfoVO> list = records.stream()
+ .map(entity -> {
+ ProjectInfoVO vo = ProjectInfoVO.getVoByEntity(entity, null);
+ vo.setProjectColorCode("green");
+ return vo;
+ })
+ .collect(Collectors.toList());
+ return Result.ok().data(list).total(page.getTotal());
}
/**
@@ -121,8 +154,14 @@
*/
@Override
public Result detail(Integer id) {
- ProjectInfoVO vo = baseMapper.getById(id);
- Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+ ProjectInfo entity = baseMapper.getById(id);
+ Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+ ProjectInfoVO vo = ProjectInfoVO.getVoByEntity(entity, null);
+ QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
+ fileQueryWrapper.eq("type",FileTypeEnum.PROJECT_INFO.getType());
+ fileQueryWrapper.eq("bus_id",vo.getId());
+ List<File> files = fileMapper.selectList(fileQueryWrapper);
+ vo.setFileList(files);
return Result.ok().data(vo);
}
diff --git a/business/src/main/resources/mapper/ProgressPlanMapper.xml b/business/src/main/resources/mapper/ProgressPlanMapper.xml
index 4d1c63d..adf99f4 100644
--- a/business/src/main/resources/mapper/ProgressPlanMapper.xml
+++ b/business/src/main/resources/mapper/ProgressPlanMapper.xml
@@ -13,12 +13,6 @@
<result column="gmt_update_time" property="gmtUpdateTime" />
</resultMap>
-
-
-
-
-
-
<select id="getById" resultMap="BaseResultMap">
SELECT
TPP.project_info_id,
diff --git a/business/src/main/resources/mapper/ProjectProcessMapper.xml b/business/src/main/resources/mapper/ProjectProcessMapper.xml
index 2e19f42..1e3cf70 100644
--- a/business/src/main/resources/mapper/ProjectProcessMapper.xml
+++ b/business/src/main/resources/mapper/ProjectProcessMapper.xml
@@ -45,9 +45,6 @@
-
-
-
<select id="getById" resultMap="BaseResultMap">
SELECT
TPP.project_id,
diff --git a/common/pom.xml b/common/pom.xml
index 2f8038a..99d8e16 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -16,7 +16,11 @@
</description>
<dependencies>
-
+ <!-- MybatisPlus -->
+ <dependency>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-boot-starter</artifactId>
+ </dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
diff --git a/common/src/main/java/com/ycl/common/enums/business/FileTypeEnum.java b/common/src/main/java/com/ycl/common/enums/business/FileTypeEnum.java
index 7b5ef08..f2c0231 100644
--- a/common/src/main/java/com/ycl/common/enums/business/FileTypeEnum.java
+++ b/common/src/main/java/com/ycl/common/enums/business/FileTypeEnum.java
@@ -1,5 +1,6 @@
package com.ycl.common.enums.business;
+import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
@@ -13,12 +14,14 @@
public enum FileTypeEnum {
PROJECT_INFO("project_info", "椤圭洰鍩烘湰淇℃伅");
- private final String code;
+ @EnumValue // 鏍囨槑璇ュ瓧娈靛瓨鍏ユ暟鎹簱
+ private final String type;
+ @JsonValue // 鏍囨槑鍦ㄨ浆JSON鏃朵娇鐢ㄨ瀛楁
private final String desc;
- FileTypeEnum(String code, String desc) {
- this.code = code;
+ FileTypeEnum(String type, String desc) {
+ this.type = type;
this.desc = desc;
}
}
diff --git a/start/src/main/resources/application.yml b/start/src/main/resources/application.yml
index f70d518..59ac04d 100644
--- a/start/src/main/resources/application.yml
+++ b/start/src/main/resources/application.yml
@@ -5,7 +5,7 @@
# 瀹炰綋鎵弿锛屽涓猵ackage鐢ㄩ�楀彿鎴栬�呭垎鍙峰垎闅�
typeAliasesPackage: com.ycl.**.domain
configuration:
- default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler # 閫氱敤鏋氫妇澶勭悊鍣�
+ default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler # 閫氱敤鏋氫妇澶勭悊鍣�
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 鏃ュ織鎵撳嵃
global-config:
db-config:
diff --git a/system/pom.xml b/system/pom.xml
index 439845d..18ddae0 100644
--- a/system/pom.xml
+++ b/system/pom.xml
@@ -28,11 +28,6 @@
<artifactId>easyexcel</artifactId>
</dependency>
- <!-- MybatisPlus -->
- <dependency>
- <groupId>com.baomidou</groupId>
- <artifactId>mybatis-plus-boot-starter</artifactId>
- </dependency>
<!-- 楠岃瘉鐮� -->
<dependency>
diff --git a/system/src/main/java/com/ycl/system/domain/base/AbsEntity.java b/system/src/main/java/com/ycl/system/domain/base/AbsEntity.java
index 3dbfca3..3f3cca0 100644
--- a/system/src/main/java/com/ycl/system/domain/base/AbsEntity.java
+++ b/system/src/main/java/com/ycl/system/domain/base/AbsEntity.java
@@ -17,7 +17,7 @@
private static final long serialVersionUID = 1L;
- @TableId(value = "id", type = IdType.ASSIGN_ID)
+ @TableId(value = "id", type = IdType.AUTO)
private Long id;
/** 鍒涘缓鏃堕棿 */
diff --git a/system/src/main/java/com/ycl/system/domain/base/AbsVo.java b/system/src/main/java/com/ycl/system/domain/base/AbsVo.java
index f1489cf..864fa69 100644
--- a/system/src/main/java/com/ycl/system/domain/base/AbsVo.java
+++ b/system/src/main/java/com/ycl/system/domain/base/AbsVo.java
@@ -13,7 +13,7 @@
public abstract class AbsVo {
@ApiModelProperty("id")
- private Integer id;
+ private Long id;
@ApiModelProperty("鍒涘缓鏃堕棿")
private Date gmtCreate;
--
Gitblit v1.8.0