需求功能前后端代码实现
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package com.test.test.controller;
|
||||
|
||||
import com.test.common.annotation.Log;
|
||||
import com.test.common.core.controller.BaseController;
|
||||
import com.test.common.core.domain.AjaxResult;
|
||||
import com.test.common.core.page.TableDataInfo;
|
||||
import com.test.common.enums.BusinessType;
|
||||
import com.test.test.domain.TestProject;
|
||||
import com.test.test.domain.qo.IDQO;
|
||||
import com.test.test.domain.qo.TestProjectListQO;
|
||||
import com.test.test.service.ITestProjectService;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/test/project")
|
||||
public class TestProjectController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private ITestProjectService testProjectService;
|
||||
|
||||
/**
|
||||
* 查询需求列表
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/projectList")
|
||||
public TableDataInfo projectList(@Validated TestProjectListQO qo) {
|
||||
startPage();
|
||||
List<TestProject> list = testProjectService.selectTestProjectList(qo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增需求
|
||||
*/
|
||||
@Log(title = "需求", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addProject")
|
||||
public AjaxResult addProject(@RequestBody TestProject testProject) {
|
||||
return toAjax(testProjectService.insertTestProject(testProject));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除需求
|
||||
*/
|
||||
@Log(title = "需求", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/delProject")
|
||||
public AjaxResult delProject(@RequestBody IDQO qo) {
|
||||
return toAjax(testProjectService.deleteTestProjectById(qo.getId()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.test.test.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.test.common.annotation.Excel;
|
||||
import com.test.common.core.domain.BaseEntity;
|
||||
import java.util.Date;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class TestProject extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = -8420426086386159695L;
|
||||
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 需求编码 */
|
||||
@Excel(name = "需求编码")
|
||||
private String serialNumber;
|
||||
|
||||
/** 需求名称 */
|
||||
@Excel(name = "需求名称")
|
||||
private String name;
|
||||
|
||||
/** 需求概要 */
|
||||
@Excel(name = "需求概要")
|
||||
private String outline;
|
||||
|
||||
/** 需求描述 */
|
||||
@Excel(name = "需求描述")
|
||||
private String detail;
|
||||
|
||||
/** 优先级(p0,p1,p2,p3,p4) */
|
||||
@Excel(name = "优先级(p0,p1,p2,p3,p4)")
|
||||
private String priority;
|
||||
|
||||
/** 预计完成时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "预计完成时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date estimatedTime;
|
||||
|
||||
/** 需求来源(0,产品经理,1,客户) */
|
||||
@Excel(name = "需求来源(0,产品经理,1,客户)")
|
||||
private String source;
|
||||
|
||||
/** 需求类型(0,优化,1,新功能) */
|
||||
@Excel(name = "需求类型(0,优化,1,新功能)")
|
||||
private String type;
|
||||
|
||||
/** 状态(0,未开始,1,进行中,2,已完成,3,已终止) */
|
||||
@Excel(name = "状态(0,未开始,1,进行中,2,已完成,3,已终止)")
|
||||
private String status;
|
||||
|
||||
/** 负责人 */
|
||||
@Excel(name = "负责人")
|
||||
private String manager;
|
||||
|
||||
/** 版本 */
|
||||
@Excel(name = "版本")
|
||||
private String version;
|
||||
|
||||
/** 0,正常,1,删除 */
|
||||
private String delFlag;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.test.test.domain.qo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 查询需求列表请求参数qo
|
||||
*
|
||||
* @author pfl
|
||||
*/
|
||||
@Data
|
||||
public class TestProjectListQO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4632218018365273102L;
|
||||
|
||||
/**
|
||||
* 需求编码
|
||||
*/
|
||||
private String serialNumber;
|
||||
|
||||
/**
|
||||
* 需求概要
|
||||
*/
|
||||
private String outline;
|
||||
|
||||
/**
|
||||
* 开始创建时间
|
||||
*/
|
||||
private Date startCreateTime;
|
||||
|
||||
/**
|
||||
* 结束创建时间
|
||||
*/
|
||||
private Date endCreateTime;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String manager;
|
||||
|
||||
/**
|
||||
* 优先级(p0,p1,p2,p3,p4)
|
||||
*/
|
||||
private String priority;
|
||||
|
||||
/**
|
||||
* 状态(0,未开始,1,进行中,2,已完成,3,已终止)
|
||||
*/
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.test.test.mapper;
|
||||
|
||||
import com.test.test.domain.TestProject;
|
||||
import com.test.test.domain.qo.TestProjectListQO;
|
||||
import java.util.List;
|
||||
|
||||
public interface TestProjectMapper {
|
||||
|
||||
/**
|
||||
* 查询需求列表
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
List<TestProject> selectTestProjectList(TestProjectListQO qo);
|
||||
|
||||
/**
|
||||
* 新增需求
|
||||
* @param testProject
|
||||
* @return
|
||||
*/
|
||||
int insertTestProject(TestProject testProject);
|
||||
|
||||
/**
|
||||
* 删除需求
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int deleteTestProjectById(Long id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.test.test.service;
|
||||
|
||||
import com.test.test.domain.TestProject;
|
||||
import com.test.test.domain.qo.TestProjectListQO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 需求Service接口
|
||||
*
|
||||
* @author pfl
|
||||
*/
|
||||
public interface ITestProjectService {
|
||||
|
||||
/**
|
||||
* 查询需求列表
|
||||
* @param qo
|
||||
* @return
|
||||
*/
|
||||
List<TestProject> selectTestProjectList(TestProjectListQO qo);
|
||||
|
||||
/**
|
||||
* 新增需求
|
||||
* @param testProject
|
||||
* @return
|
||||
*/
|
||||
public int insertTestProject(TestProject testProject);
|
||||
|
||||
/**
|
||||
* 删除需求
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public int deleteTestProjectById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.test.test.service.impl;
|
||||
|
||||
import com.test.common.utils.DateUtils;
|
||||
import com.test.test.domain.TestProject;
|
||||
import com.test.test.domain.qo.TestProjectListQO;
|
||||
import com.test.test.mapper.TestProjectMapper;
|
||||
import com.test.test.service.ITestProjectService;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TestProjectServiceImpl implements ITestProjectService {
|
||||
// 0正常,1删除
|
||||
private static final String DEL_FLAG = "0";
|
||||
|
||||
// 状态: 0未开始,1进行中,2已完成,3已终止
|
||||
private static final String STATUS = "0";
|
||||
|
||||
@Resource
|
||||
private TestProjectMapper testProjectMapper;
|
||||
|
||||
/**
|
||||
* 查询需求列表
|
||||
* @param qo
|
||||
* @return TestProject
|
||||
*/
|
||||
@Override
|
||||
public List<TestProject> selectTestProjectList(TestProjectListQO qo) {
|
||||
return testProjectMapper.selectTestProjectList(qo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增需求
|
||||
* @param testProject
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int insertTestProject(TestProject testProject) {
|
||||
testProject.setStatus(STATUS);
|
||||
testProject.setCreateTime(DateUtils.getNowDate());
|
||||
testProject.setDelFlag(DEL_FLAG);
|
||||
return testProjectMapper.insertTestProject(testProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除需求
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int deleteTestProjectById(Long id) {
|
||||
return testProjectMapper.deleteTestProjectById(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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.test.test.mapper.TestProjectMapper">
|
||||
|
||||
<insert id="insertTestProject" parameterType="testProject" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO test_project (
|
||||
<trim prefix="" suffix="" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">serial_number,</if>
|
||||
<if test="name != null and name != ''">name,</if>
|
||||
<if test="outline != null and outline != ''">outline,</if>
|
||||
<if test="detail != null and detail != ''">detail,</if>
|
||||
<if test="priority != null and priority != ''">priority,</if>
|
||||
<if test="estimatedTime != null">estimated_time,</if>
|
||||
<if test="source != null and source != ''">source,</if>
|
||||
<if test="type != null and type != ''">type,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="manager != null and manager != ''">manager,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="version != null">version,</if>
|
||||
<if test="delFlag != null and delFlag != ''">del_flag,</if>
|
||||
</trim>
|
||||
) VALUES (
|
||||
<trim prefix="" suffix="" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="outline != null and outline != ''">#{outline},</if>
|
||||
<if test="detail != null and detail != ''">#{detail},</if>
|
||||
<if test="priority != null and priority != ''">#{priority},</if>
|
||||
<if test="estimatedTime != null">#{estimatedTime},</if>
|
||||
<if test="source != null and source != ''">#{source},</if>
|
||||
<if test="type != null and type != ''">#{type},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="manager != null and manager != ''">#{manager},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="version != null">#{version},</if>
|
||||
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
|
||||
</trim>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteTestProjectById">
|
||||
DELETE
|
||||
FROM test_project
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="selectTestProjectList" parameterType="TestProjectListQO" resultType="TestProject">
|
||||
SELECT
|
||||
tp.id AS id,
|
||||
tp.serial_number AS serialNumber,
|
||||
tp.name ,
|
||||
tp.outline,
|
||||
tp.detail,
|
||||
tp.priority,
|
||||
tp.estimated_time AS estimatedTime,
|
||||
tp.source,
|
||||
tp.type,
|
||||
tp.status,
|
||||
su.user_name AS manager,
|
||||
tp.create_time AS createTime,
|
||||
tp.version,
|
||||
tp.del_flag
|
||||
FROM test_project tp
|
||||
LEFT JOIN sys_user su ON su.user_id = tp.manager
|
||||
where 1=1
|
||||
<if test="serialNumber != null and serialNumber != ''">
|
||||
AND serial_number LIKE concat('%', #{serialNumber}, '%')
|
||||
</if>
|
||||
<if test="outline != null and outline != ''">
|
||||
AND outline LIKE concat('%', #{outline}, '%')
|
||||
</if>
|
||||
<if test="startCreateTime != null">
|
||||
AND DATE_FORMAT(IFNULL(tp.create_time,''),'%Y%m%d') <![CDATA[ >= ]]> DATE_FORMAT(#{startCreateTime},'%Y%m%d')
|
||||
</if>
|
||||
<if test="endCreateTime != null">
|
||||
AND DATE_FORMAT(IFNULL(tp.create_time,''),'%Y%m%d') <![CDATA[ <= ]]> DATE_FORMAT(#{endCreateTime},'%Y%m%d')
|
||||
</if>
|
||||
<if test="manager != null and manager != ''">
|
||||
AND manager = #{manager}
|
||||
</if>
|
||||
<if test="priority != null and priority != ''">
|
||||
AND priority = #{priority}
|
||||
</if>
|
||||
<if test="status !=null and status != ''">
|
||||
AND tp.status = #{status}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user