@@ -1,10 +1,15 @@ | |||||
package com.ningdatech.pmapi.expert.controller; | 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.Api; | ||||
import io.swagger.annotations.ApiOperation; | |||||
import lombok.AllArgsConstructor; | 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> | * <p> | ||||
@@ -20,4 +25,18 @@ import org.springframework.web.bind.annotation.RestController; | |||||
@RequestMapping("/api/v1/reviewTemplateSettings") | @RequestMapping("/api/v1/reviewTemplateSettings") | ||||
public class ReviewTemplateSettingsController { | 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); | |||||
} | |||||
} | } |
@@ -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(); | |||||
} | |||||
} |
@@ -1,11 +1,14 @@ | |||||
package com.ningdatech.pmapi.expert.model.entity; | 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 com.baomidou.mybatisplus.annotation.TableName; | ||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||
import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
/** | /** | ||||
* <p> | * <p> | ||||
* 评审模版配置表 | * 评审模版配置表 | ||||
@@ -21,6 +24,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
@ApiModelProperty("主键") | @ApiModelProperty("主键") | ||||
@TableId(type = IdType.AUTO) | |||||
private Long id; | private Long id; | ||||
@ApiModelProperty("模版类型:1 初步方案评审模版、2 建设方案评审模版、3 验收方案评审模版") | @ApiModelProperty("模版类型:1 初步方案评审模版、2 建设方案评审模版、3 验收方案评审模版") | ||||
@@ -47,6 +51,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
public void setId(Long id) { | public void setId(Long id) { | ||||
this.id = id; | this.id = id; | ||||
} | } | ||||
public Integer getTemplateType() { | public Integer getTemplateType() { | ||||
return templateType; | return templateType; | ||||
} | } | ||||
@@ -54,6 +59,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
public void setTemplateType(Integer templateType) { | public void setTemplateType(Integer templateType) { | ||||
this.templateType = templateType; | this.templateType = templateType; | ||||
} | } | ||||
public String getContent() { | public String getContent() { | ||||
return content; | return content; | ||||
} | } | ||||
@@ -61,6 +67,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
public void setContent(String content) { | public void setContent(String content) { | ||||
this.content = content; | this.content = content; | ||||
} | } | ||||
public Long getCreateBy() { | public Long getCreateBy() { | ||||
return createBy; | return createBy; | ||||
} | } | ||||
@@ -68,6 +75,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
public void setCreateBy(Long createBy) { | public void setCreateBy(Long createBy) { | ||||
this.createBy = createBy; | this.createBy = createBy; | ||||
} | } | ||||
public Long getUpdateBy() { | public Long getUpdateBy() { | ||||
return updateBy; | return updateBy; | ||||
} | } | ||||
@@ -75,6 +83,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
public void setUpdateBy(Long updateBy) { | public void setUpdateBy(Long updateBy) { | ||||
this.updateBy = updateBy; | this.updateBy = updateBy; | ||||
} | } | ||||
public LocalDateTime getCreateOn() { | public LocalDateTime getCreateOn() { | ||||
return createOn; | return createOn; | ||||
} | } | ||||
@@ -82,6 +91,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
public void setCreateOn(LocalDateTime createOn) { | public void setCreateOn(LocalDateTime createOn) { | ||||
this.createOn = createOn; | this.createOn = createOn; | ||||
} | } | ||||
public LocalDateTime getUpdateOn() { | public LocalDateTime getUpdateOn() { | ||||
return updateOn; | return updateOn; | ||||
} | } | ||||
@@ -89,6 +99,7 @@ public class ReviewTemplateSettings implements Serializable { | |||||
public void setUpdateOn(LocalDateTime updateOn) { | public void setUpdateOn(LocalDateTime updateOn) { | ||||
this.updateOn = updateOn; | this.updateOn = updateOn; | ||||
} | } | ||||
public Boolean getIsLast() { | public Boolean getIsLast() { | ||||
return isLast; | return isLast; | ||||
} | } | ||||
@@ -100,14 +111,14 @@ public class ReviewTemplateSettings implements Serializable { | |||||
@Override | @Override | ||||
public String toString() { | public String toString() { | ||||
return "NdReviewTemplateSettings{" + | 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 + | |||||
"}"; | |||||
} | } | ||||
} | } |
@@ -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("评审模版类型编码无效")); | |||||
} | |||||
} |
@@ -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; | |||||
} |
@@ -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; | |||||
} |
@@ -46,7 +46,7 @@ public class Menu extends MenuTreeEntity<Menu, Long> { | |||||
@ApiModelProperty(value = "是否隐藏") | @ApiModelProperty(value = "是否隐藏") | ||||
@TableField(value = "hidden") | @TableField(value = "hidden") | ||||
private Boolean hidden; | |||||
private Integer hidden; | |||||
@ApiModelProperty(value = "activeMenu") | @ApiModelProperty(value = "activeMenu") | ||||
@TableField(value = "active_menu") | @TableField(value = "active_menu") | ||||
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; | |||||
import cn.hutool.core.io.FileUtil; | import cn.hutool.core.io.FileUtil; | ||||
import cn.hutool.db.Db; | import cn.hutool.db.Db; | ||||
import cn.hutool.db.Entity; | import cn.hutool.db.Entity; | ||||
import cn.hutool.json.JSONArray; | |||||
import cn.hutool.json.JSONObject; | import cn.hutool.json.JSONObject; | ||||
import cn.hutool.json.JSONUtil; | import cn.hutool.json.JSONUtil; | ||||
import com.ningdatech.pmapi.AppTests; | import com.ningdatech.pmapi.AppTests; | ||||
@@ -46,11 +45,13 @@ class IMenuServiceTest extends AppTests { | |||||
@Test | @Test | ||||
public void initMenu() { | 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); | List<JSONObject> obj = JSONUtil.toList(str, JSONObject.class); | ||||
save(obj, 0);*/ | |||||
save(obj, 0); | |||||
menuService.list().forEach(w -> { | menuService.list().forEach(w -> { | ||||
roleMenuService.save(new RoleMenu(){{ | |||||
roleMenuService.save(new RoleMenu() {{ | |||||
setRoleId(1L); | setRoleId(1L); | ||||
setMenuId(w.getId()); | setMenuId(w.getId()); | ||||
}}); | }}); | ||||
@@ -67,7 +68,7 @@ class IMenuServiceTest extends AppTests { | |||||
menu.setName(w.getStr("path").replace("/", "")); | menu.setName(w.getStr("path").replace("/", "")); | ||||
menu.setTopMenu(w.getStr("topMenu")); | menu.setTopMenu(w.getStr("topMenu")); | ||||
menu.setTitle(w.getStr("title")); | menu.setTitle(w.getStr("title")); | ||||
menu.setHidden(w.getBool("hidden")); | |||||
menu.setHidden(w.getInt("hidden")); | |||||
menu.setPid(parentId); | menu.setPid(parentId); | ||||
menu.setRedirect(w.getStr("redirect")); | menu.setRedirect(w.getStr("redirect")); | ||||
menu.setSort(w.getInt("sort")); | menu.setSort(w.getInt("sort")); | ||||