浏览代码

Merge remote-tracking branch 'origin/master'

tags/24080901
liuxinxin 1年前
父节点
当前提交
4d16c33fbd
共有 8 个文件被更改,包括 225 次插入19 次删除
  1. +21
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ReviewTemplateSettingsController.java
  2. +63
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ReviewTemplateSettingsManage.java
  3. +22
    -11
      pmapi/src/main/java/com/ningdatech/pmapi/expert/model/entity/ReviewTemplateSettings.java
  4. +46
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/expert/model/enumeration/ReviewTemplateTypeEnum.java
  5. +32
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/expert/model/req/ReviewTemplateReq.java
  6. +34
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/expert/model/vo/ReviewTemplateVO.java
  7. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Menu.java
  8. +6
    -5
      pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java

+ 21
- 2
pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ReviewTemplateSettingsController.java 查看文件

@@ -1,10 +1,15 @@
package com.ningdatech.pmapi.expert.controller;


import com.ningdatech.pmapi.expert.manage.ReviewTemplateSettingsManage;
import com.ningdatech.pmapi.expert.model.req.ReviewTemplateReq;
import com.ningdatech.pmapi.expert.model.vo.ReviewTemplateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
* <p>
@@ -20,4 +25,18 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api/v1/reviewTemplateSettings")
public class ReviewTemplateSettingsController {

private final ReviewTemplateSettingsManage reviewTemplateSettingsManage;

@GetMapping("/template/{templateType}")
@ApiOperation("根据模版类型获取模版")
public ReviewTemplateVO getReviewTemplateByType(@PathVariable Integer templateType) {
return reviewTemplateSettingsManage.getReviewTemplateSettings(templateType);
}

@PostMapping("/modify")
@ApiOperation("修改或保存模版配置")
public void modifyReviewTemplateSettings(@RequestBody @Valid ReviewTemplateReq req) {
reviewTemplateSettingsManage.saveOrUpdate(req);
}

}

+ 63
- 0
pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ReviewTemplateSettingsManage.java 查看文件

@@ -0,0 +1,63 @@
package com.ningdatech.pmapi.expert.manage;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.expert.model.dto.ReviewTemplateSettingsDTO;
import com.ningdatech.pmapi.expert.model.entity.ReviewTemplateSettings;
import com.ningdatech.pmapi.expert.model.req.ReviewTemplateReq;
import com.ningdatech.pmapi.expert.model.vo.ReviewTemplateVO;
import com.ningdatech.pmapi.expert.service.IReviewTemplateSettingsService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
* <p>
* ReviewTemplateSettingsManage
* </p>
*
* @author WendyYang
* @since 09:41 2023/2/15
*/
@Component
@AllArgsConstructor
public class ReviewTemplateSettingsManage {

private final IReviewTemplateSettingsService reviewTemplateSettingsService;

@Transactional(rollbackFor = Exception.class)
public void saveOrUpdate(ReviewTemplateReq req) {
LambdaUpdateWrapper<ReviewTemplateSettings> update = Wrappers.lambdaUpdate(ReviewTemplateSettings.class)
.eq(ReviewTemplateSettings::getTemplateType, req.getTemplateType())
.eq(ReviewTemplateSettings::getIsLast, Boolean.TRUE)
.set(ReviewTemplateSettings::getIsLast, Boolean.FALSE)
.last(BizConst.LIMIT_1);
reviewTemplateSettingsService.update(update);
ReviewTemplateSettings settings = new ReviewTemplateSettings();
settings.setTemplateType(req.getTemplateType());
settings.setIsLast(Boolean.TRUE);
settings.setContent(JSONUtil.toJsonStr(req.getTemplates()));
reviewTemplateSettingsService.save(settings);
}

public ReviewTemplateVO getReviewTemplateSettings(Integer templateType) {
LambdaQueryWrapper<ReviewTemplateSettings> query = Wrappers.lambdaQuery(ReviewTemplateSettings.class)
.eq(ReviewTemplateSettings::getIsLast, Boolean.TRUE)
.eq(ReviewTemplateSettings::getTemplateType, templateType)
.last(BizConst.LIMIT_1);
ReviewTemplateSettings settings = reviewTemplateSettingsService.getOne(query);
if (settings == null) {
throw BizException.wrap("模版不存在");
}
return ReviewTemplateVO.builder()
.templateId(settings.getId())
.templateType(settings.getTemplateType())
.templates(JSONUtil.toList(settings.getContent(), ReviewTemplateSettingsDTO.class))
.build();
}

}

+ 22
- 11
pmapi/src/main/java/com/ningdatech/pmapi/expert/model/entity/ReviewTemplateSettings.java 查看文件

@@ -1,11 +1,14 @@
package com.ningdatech.pmapi.expert.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
* <p>
* 评审模版配置表
@@ -21,6 +24,7 @@ public class ReviewTemplateSettings implements Serializable {
private static final long serialVersionUID = 1L;

@ApiModelProperty("主键")
@TableId(type = IdType.AUTO)
private Long id;

@ApiModelProperty("模版类型:1 初步方案评审模版、2 建设方案评审模版、3 验收方案评审模版")
@@ -47,6 +51,7 @@ public class ReviewTemplateSettings implements Serializable {
public void setId(Long id) {
this.id = id;
}

public Integer getTemplateType() {
return templateType;
}
@@ -54,6 +59,7 @@ public class ReviewTemplateSettings implements Serializable {
public void setTemplateType(Integer templateType) {
this.templateType = templateType;
}

public String getContent() {
return content;
}
@@ -61,6 +67,7 @@ public class ReviewTemplateSettings implements Serializable {
public void setContent(String content) {
this.content = content;
}

public Long getCreateBy() {
return createBy;
}
@@ -68,6 +75,7 @@ public class ReviewTemplateSettings implements Serializable {
public void setCreateBy(Long createBy) {
this.createBy = createBy;
}

public Long getUpdateBy() {
return updateBy;
}
@@ -75,6 +83,7 @@ public class ReviewTemplateSettings implements Serializable {
public void setUpdateBy(Long updateBy) {
this.updateBy = updateBy;
}

public LocalDateTime getCreateOn() {
return createOn;
}
@@ -82,6 +91,7 @@ public class ReviewTemplateSettings implements Serializable {
public void setCreateOn(LocalDateTime createOn) {
this.createOn = createOn;
}

public LocalDateTime getUpdateOn() {
return updateOn;
}
@@ -89,6 +99,7 @@ public class ReviewTemplateSettings implements Serializable {
public void setUpdateOn(LocalDateTime updateOn) {
this.updateOn = updateOn;
}

public Boolean getIsLast() {
return isLast;
}
@@ -100,14 +111,14 @@ public class ReviewTemplateSettings implements Serializable {
@Override
public String toString() {
return "NdReviewTemplateSettings{" +
"id=" + id +
", templateType=" + templateType +
", content=" + content +
", createBy=" + createBy +
", updateBy=" + updateBy +
", createOn=" + createOn +
", updateOn=" + updateOn +
", isLast=" + isLast +
"}";
"id=" + id +
", templateType=" + templateType +
", content=" + content +
", createBy=" + createBy +
", updateBy=" + updateBy +
", createOn=" + createOn +
", updateOn=" + updateOn +
", isLast=" + isLast +
"}";
}
}

+ 46
- 0
pmapi/src/main/java/com/ningdatech/pmapi/expert/model/enumeration/ReviewTemplateTypeEnum.java 查看文件

@@ -0,0 +1,46 @@
package com.ningdatech.pmapi.expert.model.enumeration;

import lombok.Getter;

import java.util.Arrays;

/**
* <p>
* ReviewTemplateTypeEnum
* </p>
*
* @author WendyYang
* @since 09:48 2023/2/15
*/
@Getter
public enum ReviewTemplateTypeEnum {
/**
* 评审模版类型
*/
PRELIMINARY_SCHEME_REVIEW("初步方案评审", 1),

CONSTRUCTION_SCHEME_REVIEW("建设方案评审", 2),

ACCEPTANCE_SCHEME_REVIEW("验收方案评审", 3);


private final String value;
private final Integer code;

ReviewTemplateTypeEnum(String value, Integer code) {
this.value = value;
this.code = code;
}

public boolean eq(Integer code) {
return this.getCode().equals(code);
}

public static ReviewTemplateTypeEnum getByCode(Integer code) {
return Arrays.stream(values())
.filter(w -> w.getCode().equals(code))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("评审模版类型编码无效"));
}

}

+ 32
- 0
pmapi/src/main/java/com/ningdatech/pmapi/expert/model/req/ReviewTemplateReq.java 查看文件

@@ -0,0 +1,32 @@
package com.ningdatech.pmapi.expert.model.req;

import com.ningdatech.pmapi.expert.model.dto.ReviewTemplateSettingsDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
* <p>
* ReviewTemplateReq
* </p>
*
* @author WendyYang
* @since 10:11 2023/2/15
*/
@Data
public class ReviewTemplateReq {

@ApiModelProperty("模版类型")
@NotNull(message = "模版类型不能为空")
private Integer templateType;

@Valid
@NotEmpty(message = "模版不能为空")
@ApiModelProperty("模版数据")
private List<ReviewTemplateSettingsDTO> templates;

}

+ 34
- 0
pmapi/src/main/java/com/ningdatech/pmapi/expert/model/vo/ReviewTemplateVO.java 查看文件

@@ -0,0 +1,34 @@
package com.ningdatech.pmapi.expert.model.vo;

import com.ningdatech.pmapi.expert.model.dto.ReviewTemplateSettingsDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
* <p>
* ReviewTemplateReq
* </p>
*
* @author WendyYang
* @since 10:11 2023/2/15
*/
@Data
@Builder
public class ReviewTemplateVO {

@ApiModelProperty("模版ID")
private Long templateId;

@ApiModelProperty("模版类型")
private Integer templateType;

@ApiModelProperty("模版数据")
private List<ReviewTemplateSettingsDTO> templates;

}

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/sys/model/entity/Menu.java 查看文件

@@ -46,7 +46,7 @@ public class Menu extends MenuTreeEntity<Menu, Long> {

@ApiModelProperty(value = "是否隐藏")
@TableField(value = "hidden")
private Boolean hidden;
private Integer hidden;

@ApiModelProperty(value = "activeMenu")
@TableField(value = "active_menu")


+ 6
- 5
pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java 查看文件

@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ningdatech.pmapi.AppTests;
@@ -46,11 +45,13 @@ class IMenuServiceTest extends AppTests {

@Test
public void initMenu() {
/*String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8");
menuService.remove(null);
roleMenuService.remove(null);
String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8");
List<JSONObject> obj = JSONUtil.toList(str, JSONObject.class);
save(obj, 0);*/
save(obj, 0);
menuService.list().forEach(w -> {
roleMenuService.save(new RoleMenu(){{
roleMenuService.save(new RoleMenu() {{
setRoleId(1L);
setMenuId(w.getId());
}});
@@ -67,7 +68,7 @@ class IMenuServiceTest extends AppTests {
menu.setName(w.getStr("path").replace("/", ""));
menu.setTopMenu(w.getStr("topMenu"));
menu.setTitle(w.getStr("title"));
menu.setHidden(w.getBool("hidden"));
menu.setHidden(w.getInt("hidden"));
menu.setPid(parentId);
menu.setRedirect(w.getStr("redirect"));
menu.setSort(w.getInt("sort"));


正在加载...
取消
保存