Browse Source

feat: check out new branch commit

Blizzard 1 year ago
parent
commit
b9c05b1bb4

+ 42 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Project.java

@@ -0,0 +1,42 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 15:07
+ * @describe
+ */
+@EqualsAndHashCode(callSuper = true)
+@TableName("blade_project")
+@Data
+public class Project extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	@TableField("project_type")
+	@NotNull(message = "projectType不可为空")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long projectType;
+
+	@TableField("name")
+	private String name;
+
+	@TableField("area_code")
+	@NotNull(message = "areaCode不可为空")
+	private String areaCode;
+
+	@TableField("competent_unit")
+	@NotNull(message = "competentUnit不可为空")
+	@JsonSerialize(using = ToStringSerializer.class)
+	private Long competentUnit;
+
+}

+ 40 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/TypeAndStage.java

@@ -0,0 +1,40 @@
+package com.wtkj.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Jimi Zhang
+ * @create at 2022-12-12 11:36
+ * @describe 项目类型和阶段表
+ */
+@Data
+@TableName("blade_type_and_stage")
+@EqualsAndHashCode(callSuper = true)
+public class TypeAndStage extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	@JsonSerialize(using = ToStringSerializer.class)
+	@TableField("parent_id")
+	@NotNull(message = "parentId不可为空")
+	private Long parentId;
+
+	@TableField("name")
+	@ApiModelProperty("名称")
+	private String name;
+
+	@TableField("sort")
+	@ApiModelProperty("排序")
+	@NotNull(message = "sort不可为空")
+	private Integer sort;
+
+}

+ 47 - 0
blade-service/wt-okr/src/main/java/com/wtkj/config/AsyncConfig.java

@@ -0,0 +1,47 @@
+package com.wtkj.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 15:04
+ * @describe
+ */
+@Configuration
+@EnableAsync
+@Slf4j
+public class AsyncConfig {
+
+	@Bean(name = "asyncPoolTaskExecutor")
+	public ThreadPoolTaskExecutor executor() {
+		ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
+		//核心线程数
+		taskExecutor.setCorePoolSize(10);
+		//线程池维护线程的最大数量,只有在缓冲队列满了之后才会申请超过核心线程数的线程
+		taskExecutor.setMaxPoolSize(100);
+		//缓冲队列
+		taskExecutor.setQueueCapacity(50);
+		//设置线程的空闲时间,当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
+		taskExecutor.setKeepAliveSeconds(200);
+		//异步方法内部线程名称
+		taskExecutor.setThreadNamePrefix("async-");
+		/**
+		 * 当线程池的任务缓存队列已满并且线程池中的线程数目达到maximumPoolSize,如果还有任务到来就会采取任务拒绝策略
+		 * 通常有以下四种策略:
+		 * ThreadPoolExecutor.AbortPolicy:丢弃任务并抛出RejectedExecutionException异常。
+		 * ThreadPoolExecutor.DiscardPolicy:也是丢弃任务,但是不抛出异常。
+		 * ThreadPoolExecutor.DiscardOldestPolicy:丢弃队列最前面的任务,然后重新尝试执行任务(重复此过程)
+		 * ThreadPoolExecutor.CallerRunsPolicy:重试添加当前的任务,自动重复调用 execute() 方法,直到成功
+		 */
+		taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+		taskExecutor.initialize();
+		return taskExecutor;
+	}
+
+}

+ 38 - 0
blade-service/wt-okr/src/main/java/com/wtkj/controller/ProjectController.java

@@ -0,0 +1,38 @@
+package com.wtkj.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.wtkj.entity.Project;
+import com.wtkj.service.IProjectService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 15:50
+ * @describe
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/project")
+@Api(value = "项目模块", tags = "项目模块")
+public class ProjectController {
+
+	private final IProjectService projectService;
+
+	/**
+	 * 创建/修改项目
+	 */
+	@PostMapping("/submit")
+	@ApiOperation(value = "新建或者修改项目", notes = "传入project")
+	@ApiOperationSupport(order = 1)
+	public R<Boolean> create(@RequestBody Project project) {
+		return R.status(projectService.saveOrUpdate(project));
+	}
+
+}

+ 81 - 0
blade-service/wt-okr/src/main/java/com/wtkj/controller/TypeAndStageController.java

@@ -0,0 +1,81 @@
+package com.wtkj.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.wtkj.entity.TypeAndStage;
+import com.wtkj.service.ITypeAndStageService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author Jimi Zhang
+ * @create at 2023-09-13 14:14
+ * @describe
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/typeAndStage")
+@Api(value = "项目类和项目阶段模块", tags = "项目类型和项目阶段")
+public class TypeAndStageController {
+
+	private final ITypeAndStageService typeAndStageService;
+
+	/**
+	 * 分页
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "项目类型分页", notes = " ")
+	public R<IPage<TypeAndStage>> page(Query query) {
+		LambdaQueryWrapper<TypeAndStage> lqw = Wrappers.lambdaQuery();
+		lqw.eq(TypeAndStage::getParentId, 0);
+		lqw.orderByDesc(TypeAndStage::getCreateTime);
+		IPage<TypeAndStage> page = typeAndStageService.page(Condition.getPage(query), lqw);
+		return R.data(page);
+	}
+
+	/**
+	 * 类型下的阶段
+	 */
+	@GetMapping("/v2/stage-list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "阶段列表", notes = "传入parentId")
+	public R<List<TypeAndStage>> list(@RequestParam(value = "parentId") Long parentId) {
+		List<TypeAndStage> list = typeAndStageService.list(new LambdaQueryWrapper<TypeAndStage>().eq(TypeAndStage::getParentId, parentId)
+			.orderByAsc(TypeAndStage::getSort));
+		return R.data(list);
+	}
+
+	/**
+	 * 新增或者修改
+	 */
+	@GetMapping("/submit")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "新增或者修改", notes = "传入typeAndStage")
+	public R submit(@RequestBody TypeAndStage typeAndStage) {
+		return R.status(typeAndStageService.submit(typeAndStage));
+	}
+
+
+	/**
+	 * 详情
+	 */
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "查看类型或阶段详情", notes = "传入id")
+	@GetMapping("/v2/detail")
+	public R detail(Long id) {
+		TypeAndStage detail = typeAndStageService.getById(id);
+		return R.data(detail);
+	}
+
+
+}

+ 12 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectMapper.java

@@ -0,0 +1,12 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.wtkj.entity.Project;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:01
+ * @describe
+ */
+public interface ProjectMapper extends BaseMapper<Project> {
+}

+ 6 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/ProjectMapper.xml

@@ -0,0 +1,6 @@
+<?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="com.wtkj.mapper.ProjectMapper">
+
+
+</mapper>

+ 17 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TypeStageMapper.java

@@ -0,0 +1,17 @@
+package com.wtkj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.wtkj.entity.TypeAndStage;
+
+import java.util.List;
+
+/**
+ * @author Jimi Zhang
+ * @create at 2022-12-12 12:00
+ * @describe
+ */
+public interface TypeStageMapper extends BaseMapper<TypeAndStage> {
+	List<TypeAndStage> getListByParentId(Long parentId);
+
+
+}

+ 12 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TypeStageMapper.xml

@@ -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="com.wtkj.mapper.TypeStageMapper">
+
+    <select id="getListByParentId" resultType="com.wtkj.entity.TypeAndStage">
+        select * from blade_type_stage where is_deleted = 0
+        <if test="param1 != null">
+            and parent_id = #{param1}
+        </if>
+    </select>
+
+</mapper>

+ 12 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/IProjectService.java

@@ -0,0 +1,12 @@
+package com.wtkj.service;
+
+import com.wtkj.entity.Project;
+import org.springblade.core.mp.base.BaseService;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:00
+ * @describe
+ */
+public interface IProjectService extends BaseService<Project> {
+}

+ 16 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/ITypeAndStageService.java

@@ -0,0 +1,16 @@
+package com.wtkj.service;
+
+import com.wtkj.entity.TypeAndStage;
+import org.springblade.core.mp.base.BaseService;
+
+/**
+ * @author Jimi Zhang
+ * @create at 2022-12-12 14:05
+ * @describe
+ */
+public interface ITypeAndStageService extends BaseService<TypeAndStage> {
+
+
+	boolean submit(TypeAndStage typeAndStage);
+
+}

+ 18 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/ProjectServiceImpl.java

@@ -0,0 +1,18 @@
+package com.wtkj.service.impl;
+
+import com.wtkj.entity.Project;
+import com.wtkj.mapper.ProjectMapper;
+import com.wtkj.service.IProjectService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Blizzard
+ * @create at 2023-09-13 16:00
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, Project> implements IProjectService {
+}

+ 39 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TypeAndStageServiceImpl.java

@@ -0,0 +1,39 @@
+package com.wtkj.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.wtkj.entity.TypeAndStage;
+import com.wtkj.mapper.TypeStageMapper;
+import com.wtkj.service.ITypeAndStageService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Jimi Zhang
+ * @create at 2022-12-12 14:06
+ * @describe
+ */
+@Service
+@AllArgsConstructor
+public class TypeAndStageServiceImpl extends BaseServiceImpl<TypeStageMapper, TypeAndStage> implements ITypeAndStageService {
+
+
+	@Override
+	public boolean submit(TypeAndStage typeAndStage) {
+		if (typeAndStage.getId() == null) {
+			LambdaQueryWrapper<TypeAndStage> lqw = Wrappers.lambdaQuery();
+			lqw.eq(TypeAndStage::getName, typeAndStage.getName());
+			Long cnt = baseMapper.selectCount(lqw);
+			if (cnt > 0L) {
+				throw new ServiceException("项目类型或者阶段名称重名,已经存在!");
+			}
+			return save(typeAndStage);
+		} else {
+			return updateById(typeAndStage);
+		}
+	}
+
+
+}