requirement表的实现
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
package com.ruoyi.oa.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.core.validate.QueryGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.oa.domain.vo.OaRequirementsVo;
|
||||
import com.ruoyi.oa.domain.bo.OaRequirementsBo;
|
||||
import com.ruoyi.oa.service.IOaRequirementsService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* OA 需求
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/oa/requirements")
|
||||
public class OaRequirementsController extends BaseController {
|
||||
|
||||
private final IOaRequirementsService iOaRequirementsService;
|
||||
|
||||
/**
|
||||
* 查询OA 需求列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<OaRequirementsVo> list(OaRequirementsBo bo, PageQuery pageQuery) {
|
||||
return iOaRequirementsService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出OA 需求列表
|
||||
*/
|
||||
@Log(title = "OA 需求", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(OaRequirementsBo bo, HttpServletResponse response) {
|
||||
List<OaRequirementsVo> list = iOaRequirementsService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "OA 需求", OaRequirementsVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取OA 需求详细信息
|
||||
*
|
||||
* @param requirementId 主键
|
||||
*/
|
||||
@GetMapping("/{requirementId}")
|
||||
public R<OaRequirementsVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long requirementId) {
|
||||
return R.ok(iOaRequirementsService.queryById(requirementId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增OA 需求
|
||||
*/
|
||||
@Log(title = "OA 需求", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody OaRequirementsBo bo) {
|
||||
return toAjax(iOaRequirementsService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改OA 需求
|
||||
*/
|
||||
@Log(title = "OA 需求", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OaRequirementsBo bo) {
|
||||
return toAjax(iOaRequirementsService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除OA 需求
|
||||
*
|
||||
* @param requirementIds 主键串
|
||||
*/
|
||||
@Log(title = "OA 需求", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{requirementIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] requirementIds) {
|
||||
return toAjax(iOaRequirementsService.deleteWithValidByIds(Arrays.asList(requirementIds), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.ruoyi.oa.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* OA 需求对象 oa_requirements
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("oa_requirements")
|
||||
public class OaRequirements extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "requirement_id")
|
||||
private Long requirementId;
|
||||
/**
|
||||
* 需求标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 需求方用户 ID
|
||||
*/
|
||||
private Long requesterId;
|
||||
/**
|
||||
* 负责人用户 ID
|
||||
*/
|
||||
private Long ownerId;
|
||||
/**
|
||||
* 挂接项目 ID,可选
|
||||
*/
|
||||
private Long projectId;
|
||||
/**
|
||||
* 需求描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 截止日期(最终时间)
|
||||
*/
|
||||
private Date deadline;
|
||||
/**
|
||||
* 状态:0=未完成,1=已完成
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 附件(路径或 URL),多附件逗号分隔
|
||||
*/
|
||||
private String accessory;
|
||||
/**
|
||||
* 删除标志:0=正常,1=已删除
|
||||
*/
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.ruoyi.oa.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* OA 需求业务对象 oa_requirements
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OaRequirementsBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long requirementId;
|
||||
|
||||
/**
|
||||
* 需求标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 需求方用户 ID
|
||||
*/
|
||||
private Long requesterId;
|
||||
|
||||
/**
|
||||
* 负责人用户 ID
|
||||
*/
|
||||
private Long ownerId;
|
||||
|
||||
/**
|
||||
* 挂接项目 ID,可选
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 需求描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 截止日期(最终时间)
|
||||
*/
|
||||
private Date deadline;
|
||||
|
||||
/**
|
||||
* 状态:0=未完成,1=已完成
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 附件(路径或 URL),多附件逗号分隔
|
||||
*/
|
||||
private String accessory;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.ruoyi.oa.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* OA 需求视图对象 oa_requirements
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class OaRequirementsVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ExcelProperty(value = "主键")
|
||||
private Long requirementId;
|
||||
|
||||
/**
|
||||
* 需求标题
|
||||
*/
|
||||
@ExcelProperty(value = "需求标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 需求方用户 ID
|
||||
*/
|
||||
@ExcelProperty(value = "需求方用户 ID")
|
||||
private Long requesterId;
|
||||
|
||||
/**
|
||||
* 负责人用户 ID
|
||||
*/
|
||||
@ExcelProperty(value = "负责人用户 ID")
|
||||
private Long ownerId;
|
||||
|
||||
/**
|
||||
* 挂接项目 ID,可选
|
||||
*/
|
||||
@ExcelProperty(value = "挂接项目 ID,可选")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 需求描述
|
||||
*/
|
||||
@ExcelProperty(value = "需求描述")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 截止日期(最终时间)
|
||||
*/
|
||||
@ExcelProperty(value = "截止日期", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "最=终时间")
|
||||
private Date deadline;
|
||||
|
||||
/**
|
||||
* 状态:0=未完成,1=已完成
|
||||
*/
|
||||
@ExcelProperty(value = "状态:0=未完成,1=已完成")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 附件(路径或 URL),多附件逗号分隔
|
||||
*/
|
||||
@ExcelProperty(value = "附件", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "路=径或,U=RL")
|
||||
private String accessory;
|
||||
private String requesterNickName;
|
||||
private String ownerNickName;
|
||||
private String projectName;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi.oa.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.oa.domain.OaRequirements;
|
||||
import com.ruoyi.oa.domain.vo.OaRequirementsVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* OA 需求Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface OaRequirementsMapper extends BaseMapperPlus<OaRequirementsMapper, OaRequirements, OaRequirementsVo> {
|
||||
Page<OaRequirementsVo> selectVoListPage(Page<?> page, @Param("ew") Object lqw);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.oa.service;
|
||||
|
||||
import com.ruoyi.oa.domain.OaRequirements;
|
||||
import com.ruoyi.oa.domain.vo.OaRequirementsVo;
|
||||
import com.ruoyi.oa.domain.bo.OaRequirementsBo;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* OA 需求Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
public interface IOaRequirementsService {
|
||||
|
||||
/**
|
||||
* 查询OA 需求
|
||||
*/
|
||||
OaRequirementsVo queryById(Long requirementId);
|
||||
|
||||
/**
|
||||
* 查询OA 需求列表
|
||||
*/
|
||||
TableDataInfo<OaRequirementsVo> queryPageList(OaRequirementsBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询OA 需求列表
|
||||
*/
|
||||
List<OaRequirementsVo> queryList(OaRequirementsBo bo);
|
||||
|
||||
/**
|
||||
* 新增OA 需求
|
||||
*/
|
||||
Boolean insertByBo(OaRequirementsBo bo);
|
||||
|
||||
/**
|
||||
* 修改OA 需求
|
||||
*/
|
||||
Boolean updateByBo(OaRequirementsBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除OA 需求信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.ruoyi.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.oa.domain.bo.OaRequirementsBo;
|
||||
import com.ruoyi.oa.domain.vo.OaRequirementsVo;
|
||||
import com.ruoyi.oa.domain.OaRequirements;
|
||||
import com.ruoyi.oa.mapper.OaRequirementsMapper;
|
||||
import com.ruoyi.oa.service.IOaRequirementsService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* OA 需求Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class OaRequirementsServiceImpl implements IOaRequirementsService {
|
||||
|
||||
private final OaRequirementsMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询OA 需求
|
||||
*/
|
||||
@Override
|
||||
public OaRequirementsVo queryById(Long requirementId){
|
||||
return baseMapper.selectVoById(requirementId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询OA 需求列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<OaRequirementsVo> queryPageList(OaRequirementsBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<OaRequirements> lqw = buildQueryWrapper(bo);
|
||||
Page<OaRequirementsVo> result = baseMapper.selectVoListPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询OA 需求列表
|
||||
*/
|
||||
@Override
|
||||
public List<OaRequirementsVo> queryList(OaRequirementsBo bo) {
|
||||
LambdaQueryWrapper<OaRequirements> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<OaRequirements> buildQueryWrapper(OaRequirementsBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<OaRequirements> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTitle()), OaRequirements::getTitle, bo.getTitle());
|
||||
lqw.eq(bo.getRequesterId() != null, OaRequirements::getRequesterId, bo.getRequesterId());
|
||||
lqw.eq(bo.getOwnerId() != null, OaRequirements::getOwnerId, bo.getOwnerId());
|
||||
lqw.eq(bo.getProjectId() != null, OaRequirements::getProjectId, bo.getProjectId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getDescription()), OaRequirements::getDescription, bo.getDescription());
|
||||
lqw.eq(bo.getDeadline() != null, OaRequirements::getDeadline, bo.getDeadline());
|
||||
lqw.eq(bo.getStatus() != null, OaRequirements::getStatus, bo.getStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAccessory()), OaRequirements::getAccessory, bo.getAccessory());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增OA 需求
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(OaRequirementsBo bo) {
|
||||
OaRequirements add = BeanUtil.toBean(bo, OaRequirements.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setRequirementId(add.getRequirementId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改OA 需求
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(OaRequirementsBo bo) {
|
||||
OaRequirements update = BeanUtil.toBean(bo, OaRequirements.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(OaRequirements entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除OA 需求
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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.ruoyi.oa.mapper.OaRequirementsMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.oa.domain.OaRequirements" id="OaRequirementsResult">
|
||||
<result property="requirementId" column="requirement_id"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="requesterId" column="requester_id"/>
|
||||
<result property="ownerId" column="owner_id"/>
|
||||
<result property="projectId" column="project_id"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="deadline" column="deadline"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="accessory" column="accessory"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
|
||||
</resultMap>
|
||||
<select id="selectVoListPage" resultType="com.ruoyi.oa.domain.vo.OaRequirementsVo">
|
||||
SELECT
|
||||
r.*,
|
||||
u1.nick_name AS requester_nick_name,
|
||||
u2.nick_name AS owner_nick_name,
|
||||
p.project_name
|
||||
FROM oa_requirements r
|
||||
LEFT JOIN sys_user u1 ON r.requester_id = u1.user_id
|
||||
LEFT JOIN sys_user u2 ON r.owner_id = u2.user_id
|
||||
LEFT JOIN sys_oa_project p ON r.project_id = p.project_id
|
||||
<where>
|
||||
<if test="ew != null and ew.sqlSegment != null">
|
||||
${ew.sqlSegment}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user