Add custom request management
This commit is contained in:
@@ -0,0 +1,83 @@
|
|||||||
|
package com.ruoyi.web.controller.app;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.app.domain.AppCustomRequest;
|
||||||
|
import com.ruoyi.app.service.IAppCustomRequestService;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目定制需求Controller。
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/app/customRequest")
|
||||||
|
public class AppCustomRequestController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IAppCustomRequestService customRequestService;
|
||||||
|
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@Log(title = "项目定制需求", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult submit(@RequestBody AppCustomRequest request)
|
||||||
|
{
|
||||||
|
return success(customRequestService.submitCustomRequest(request, getUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@GetMapping("/my")
|
||||||
|
public TableDataInfo myList()
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
return getDataTable(customRequestService.selectMyCustomRequestList(getUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@GetMapping("/my/{id}")
|
||||||
|
public AjaxResult myDetail(@PathVariable Long id)
|
||||||
|
{
|
||||||
|
AppCustomRequest request = customRequestService.selectAppCustomRequestById(id);
|
||||||
|
if (request == null || !getUserId().equals(request.getUserId()))
|
||||||
|
{
|
||||||
|
return error("定制需求不存在");
|
||||||
|
}
|
||||||
|
return success(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('app:customRequest:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(AppCustomRequest request)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<AppCustomRequest> list = customRequestService.selectAppCustomRequestList(request);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('app:customRequest:query')")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public AjaxResult detail(@PathVariable Long id)
|
||||||
|
{
|
||||||
|
return success(customRequestService.selectAppCustomRequestById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('app:customRequest:edit')")
|
||||||
|
@Log(title = "项目定制需求", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/status")
|
||||||
|
public AjaxResult updateStatus(@RequestBody AppCustomRequest request)
|
||||||
|
{
|
||||||
|
request.setUpdateBy(getUsername());
|
||||||
|
return toAjax(customRequestService.updateCustomRequestStatus(request));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.ruoyi.app.domain;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目定制需求对象 app_custom_request。
|
||||||
|
*/
|
||||||
|
public class AppCustomRequest extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String requestNo;
|
||||||
|
private Long userId;
|
||||||
|
private String projectName;
|
||||||
|
private String requirementContent;
|
||||||
|
private Long techStackId;
|
||||||
|
/** 保存提交时的技术栈名称,避免后台改名影响历史需求。 */
|
||||||
|
private String techStackName;
|
||||||
|
/** 0待审核 1审核中 2已接单 3开发中 4已完成 5审核未通过 */
|
||||||
|
private Integer status;
|
||||||
|
private String progressNote;
|
||||||
|
private Integer pointAmount;
|
||||||
|
/** 0已扣除 1已退回 */
|
||||||
|
private Integer pointStatus;
|
||||||
|
private String rejectReason;
|
||||||
|
|
||||||
|
/** 仅用于后台列表展示与查询。 */
|
||||||
|
private String userName;
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
public Long getId() { return id; }
|
||||||
|
public void setId(Long id) { this.id = id; }
|
||||||
|
public String getRequestNo() { return requestNo; }
|
||||||
|
public void setRequestNo(String requestNo) { this.requestNo = requestNo; }
|
||||||
|
public Long getUserId() { return userId; }
|
||||||
|
public void setUserId(Long userId) { this.userId = userId; }
|
||||||
|
public String getProjectName() { return projectName; }
|
||||||
|
public void setProjectName(String projectName) { this.projectName = projectName; }
|
||||||
|
public String getRequirementContent() { return requirementContent; }
|
||||||
|
public void setRequirementContent(String requirementContent) { this.requirementContent = requirementContent; }
|
||||||
|
public Long getTechStackId() { return techStackId; }
|
||||||
|
public void setTechStackId(Long techStackId) { this.techStackId = techStackId; }
|
||||||
|
public String getTechStackName() { return techStackName; }
|
||||||
|
public void setTechStackName(String techStackName) { this.techStackName = techStackName; }
|
||||||
|
public Integer getStatus() { return status; }
|
||||||
|
public void setStatus(Integer status) { this.status = status; }
|
||||||
|
public String getProgressNote() { return progressNote; }
|
||||||
|
public void setProgressNote(String progressNote) { this.progressNote = progressNote; }
|
||||||
|
public Integer getPointAmount() { return pointAmount; }
|
||||||
|
public void setPointAmount(Integer pointAmount) { this.pointAmount = pointAmount; }
|
||||||
|
public Integer getPointStatus() { return pointStatus; }
|
||||||
|
public void setPointStatus(Integer pointStatus) { this.pointStatus = pointStatus; }
|
||||||
|
public String getRejectReason() { return rejectReason; }
|
||||||
|
public void setRejectReason(String rejectReason) { this.rejectReason = rejectReason; }
|
||||||
|
public String getUserName() { return userName; }
|
||||||
|
public void setUserName(String userName) { this.userName = userName; }
|
||||||
|
public String getNickName() { return nickName; }
|
||||||
|
public void setNickName(String nickName) { this.nickName = nickName; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.ruoyi.app.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.app.domain.AppCustomRequest;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目定制需求Mapper接口。
|
||||||
|
*/
|
||||||
|
public interface AppCustomRequestMapper
|
||||||
|
{
|
||||||
|
AppCustomRequest selectAppCustomRequestById(Long id);
|
||||||
|
|
||||||
|
AppCustomRequest selectAppCustomRequestByIdForUpdate(Long id);
|
||||||
|
|
||||||
|
List<AppCustomRequest> selectAppCustomRequestList(AppCustomRequest request);
|
||||||
|
|
||||||
|
List<AppCustomRequest> selectMyCustomRequestList(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
int insertAppCustomRequest(AppCustomRequest request);
|
||||||
|
|
||||||
|
int updateAppCustomRequest(AppCustomRequest request);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.ruoyi.app.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.app.domain.AppCustomRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目定制需求Service接口。
|
||||||
|
*/
|
||||||
|
public interface IAppCustomRequestService
|
||||||
|
{
|
||||||
|
AppCustomRequest selectAppCustomRequestById(Long id);
|
||||||
|
|
||||||
|
List<AppCustomRequest> selectAppCustomRequestList(AppCustomRequest request);
|
||||||
|
|
||||||
|
List<AppCustomRequest> selectMyCustomRequestList(Long userId);
|
||||||
|
|
||||||
|
AppCustomRequest submitCustomRequest(AppCustomRequest request, Long userId);
|
||||||
|
|
||||||
|
int updateCustomRequestStatus(AppCustomRequest request);
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package com.ruoyi.app.service.impl;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.app.domain.AppCustomRequest;
|
||||||
|
import com.ruoyi.app.domain.AppIntegralRecord;
|
||||||
|
import com.ruoyi.app.domain.AppTechStack;
|
||||||
|
import com.ruoyi.app.mapper.AppCustomRequestMapper;
|
||||||
|
import com.ruoyi.app.mapper.AppIntegralRecordMapper;
|
||||||
|
import com.ruoyi.app.mapper.AppTechStackMapper;
|
||||||
|
import com.ruoyi.app.service.IAppCustomRequestService;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目定制需求Service业务层处理。
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AppCustomRequestServiceImpl implements IAppCustomRequestService
|
||||||
|
{
|
||||||
|
private static final int SUBMIT_POINTS = 99;
|
||||||
|
private static final int STATUS_REJECTED = 5;
|
||||||
|
private static final int POINT_DEDUCTED = 0;
|
||||||
|
private static final int POINT_REFUNDED = 1;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppCustomRequestMapper customRequestMapper;
|
||||||
|
@Autowired
|
||||||
|
private AppIntegralRecordMapper integralRecordMapper;
|
||||||
|
@Autowired
|
||||||
|
private AppTechStackMapper techStackMapper;
|
||||||
|
@Autowired
|
||||||
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AppCustomRequest selectAppCustomRequestById(Long id)
|
||||||
|
{
|
||||||
|
return customRequestMapper.selectAppCustomRequestById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AppCustomRequest> selectAppCustomRequestList(AppCustomRequest request)
|
||||||
|
{
|
||||||
|
return customRequestMapper.selectAppCustomRequestList(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AppCustomRequest> selectMyCustomRequestList(Long userId)
|
||||||
|
{
|
||||||
|
return customRequestMapper.selectMyCustomRequestList(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public AppCustomRequest submitCustomRequest(AppCustomRequest request, Long userId)
|
||||||
|
{
|
||||||
|
String projectName = StringUtils.trim(request.getProjectName());
|
||||||
|
String requirementContent = StringUtils.trim(request.getRequirementContent());
|
||||||
|
if (StringUtils.isEmpty(projectName) || projectName.length() < 2 || projectName.length() > 30)
|
||||||
|
{
|
||||||
|
throw new ServiceException("项目名称需填写2至30个字");
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(requirementContent) || requirementContent.length() < 20 || requirementContent.length() > 500)
|
||||||
|
{
|
||||||
|
throw new ServiceException("项目需求需填写20至500个字");
|
||||||
|
}
|
||||||
|
if (request.getTechStackId() == null)
|
||||||
|
{
|
||||||
|
throw new ServiceException("请选择技术栈");
|
||||||
|
}
|
||||||
|
AppTechStack techStack = techStackMapper.selectAppTechStackById(request.getTechStackId());
|
||||||
|
if (techStack == null || !"0".equals(techStack.getStatus()))
|
||||||
|
{
|
||||||
|
throw new ServiceException("所选技术栈已停用,请重新选择");
|
||||||
|
}
|
||||||
|
if (sysUserMapper.delIntegralByUserId(SUBMIT_POINTS, userId) != 1)
|
||||||
|
{
|
||||||
|
throw new ServiceException("积分不足,提交需求需要99积分");
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = DateUtils.getNowDate();
|
||||||
|
request.setRequestNo("DZ" + DateUtils.dateTimeNow() + IdUtils.fastSimpleUUID().substring(0, 6).toUpperCase());
|
||||||
|
request.setUserId(userId);
|
||||||
|
request.setProjectName(projectName);
|
||||||
|
request.setRequirementContent(requirementContent);
|
||||||
|
request.setTechStackName(techStack.getName());
|
||||||
|
request.setStatus(0);
|
||||||
|
request.setProgressNote("需求已提交,等待平台审核");
|
||||||
|
request.setPointAmount(SUBMIT_POINTS);
|
||||||
|
request.setPointStatus(POINT_DEDUCTED);
|
||||||
|
request.setRejectReason(null);
|
||||||
|
request.setCreateBy(String.valueOf(userId));
|
||||||
|
request.setCreateTime(now);
|
||||||
|
request.setUpdateBy(String.valueOf(userId));
|
||||||
|
request.setUpdateTime(now);
|
||||||
|
if (customRequestMapper.insertAppCustomRequest(request) != 1)
|
||||||
|
{
|
||||||
|
throw new ServiceException("需求提交失败,请重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
insertIntegralRecord(request, 1L, "定制需求提交");
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int updateCustomRequestStatus(AppCustomRequest update)
|
||||||
|
{
|
||||||
|
if (update.getId() == null || update.getStatus() == null || update.getStatus() < 0 || update.getStatus() > 5)
|
||||||
|
{
|
||||||
|
throw new ServiceException("需求状态不正确");
|
||||||
|
}
|
||||||
|
|
||||||
|
AppCustomRequest current = customRequestMapper.selectAppCustomRequestByIdForUpdate(update.getId());
|
||||||
|
if (current == null)
|
||||||
|
{
|
||||||
|
throw new ServiceException("定制需求不存在");
|
||||||
|
}
|
||||||
|
if (POINT_REFUNDED == current.getPointStatus() && update.getStatus() != STATUS_REJECTED)
|
||||||
|
{
|
||||||
|
throw new ServiceException("该需求已退回积分,不能恢复为其他状态");
|
||||||
|
}
|
||||||
|
if (update.getStatus() == STATUS_REJECTED && StringUtils.isEmpty(StringUtils.trim(update.getRejectReason())))
|
||||||
|
{
|
||||||
|
throw new ServiceException("审核不通过时必须填写原因");
|
||||||
|
}
|
||||||
|
|
||||||
|
current.setStatus(update.getStatus());
|
||||||
|
current.setProgressNote(StringUtils.trim(update.getProgressNote()));
|
||||||
|
current.setUpdateBy(update.getUpdateBy());
|
||||||
|
current.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
if (update.getStatus() == STATUS_REJECTED)
|
||||||
|
{
|
||||||
|
current.setRejectReason(StringUtils.trim(update.getRejectReason()));
|
||||||
|
if (POINT_DEDUCTED == current.getPointStatus())
|
||||||
|
{
|
||||||
|
if (sysUserMapper.addIntegralByUserId(current.getPointAmount(), current.getUserId()) != 1)
|
||||||
|
{
|
||||||
|
throw new ServiceException("积分退回失败,请重试");
|
||||||
|
}
|
||||||
|
insertIntegralRecord(current, 0L, "定制需求退回");
|
||||||
|
current.setPointStatus(POINT_REFUNDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current.setRejectReason("");
|
||||||
|
}
|
||||||
|
return customRequestMapper.updateAppCustomRequest(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertIntegralRecord(AppCustomRequest request, Long isAdd, String source)
|
||||||
|
{
|
||||||
|
AppIntegralRecord record = new AppIntegralRecord();
|
||||||
|
record.setSource(source);
|
||||||
|
record.setIsAdd(isAdd);
|
||||||
|
record.setIntegralNumber(request.getPointAmount().longValue());
|
||||||
|
record.setUserId(request.getUserId());
|
||||||
|
record.setIntegralTime(new Date());
|
||||||
|
if (integralRecordMapper.insertAppIntegralRecord(record) != 1)
|
||||||
|
{
|
||||||
|
throw new ServiceException("积分流水记录失败,请重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?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.app.mapper.AppCustomRequestMapper">
|
||||||
|
|
||||||
|
<resultMap type="AppCustomRequest" id="AppCustomRequestResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="requestNo" column="request_no" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="projectName" column="project_name" />
|
||||||
|
<result property="requirementContent" column="requirement_content" />
|
||||||
|
<result property="techStackId" column="tech_stack_id" />
|
||||||
|
<result property="techStackName" column="tech_stack_name" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="progressNote" column="progress_note" />
|
||||||
|
<result property="pointAmount" column="point_amount" />
|
||||||
|
<result property="pointStatus" column="point_status" />
|
||||||
|
<result property="rejectReason" column="reject_reason" />
|
||||||
|
<result property="userName" column="user_name" />
|
||||||
|
<result property="nickName" column="nick_name" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectAppCustomRequestVo">
|
||||||
|
select r.id, r.request_no, r.user_id, r.project_name, r.requirement_content,
|
||||||
|
r.tech_stack_id, r.tech_stack_name,
|
||||||
|
r.status, r.progress_note, r.point_amount, r.point_status, r.reject_reason,
|
||||||
|
r.create_by, r.create_time, r.update_by, r.update_time,
|
||||||
|
u.user_name, u.nick_name
|
||||||
|
from app_custom_request r
|
||||||
|
left join sys_user u on u.user_id = r.user_id
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectAppCustomRequestById" parameterType="Long" resultMap="AppCustomRequestResult">
|
||||||
|
<include refid="selectAppCustomRequestVo" />
|
||||||
|
where r.id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAppCustomRequestByIdForUpdate" parameterType="Long" resultMap="AppCustomRequestResult">
|
||||||
|
select id, request_no, user_id, project_name, requirement_content,
|
||||||
|
tech_stack_id, tech_stack_name, status,
|
||||||
|
progress_note, point_amount, point_status, reject_reason,
|
||||||
|
create_by, create_time, update_by, update_time
|
||||||
|
from app_custom_request
|
||||||
|
where id = #{id}
|
||||||
|
for update
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectAppCustomRequestList" parameterType="AppCustomRequest" resultMap="AppCustomRequestResult">
|
||||||
|
<include refid="selectAppCustomRequestVo" />
|
||||||
|
<where>
|
||||||
|
<if test="requestNo != null and requestNo != ''">and r.request_no like concat('%', #{requestNo}, '%')</if>
|
||||||
|
<if test="projectName != null and projectName != ''">and r.project_name like concat('%', #{projectName}, '%')</if>
|
||||||
|
<if test="techStackName != null and techStackName != ''">and r.tech_stack_name like concat('%', #{techStackName}, '%')</if>
|
||||||
|
<if test="status != null">and r.status = #{status}</if>
|
||||||
|
<if test="pointStatus != null">and r.point_status = #{pointStatus}</if>
|
||||||
|
<if test="userId != null">and r.user_id = #{userId}</if>
|
||||||
|
<if test="userName != null and userName != ''">
|
||||||
|
and (u.user_name like concat('%', #{userName}, '%') or u.nick_name like concat('%', #{userName}, '%'))
|
||||||
|
</if>
|
||||||
|
<if test="params.beginTime != null and params.beginTime != ''">
|
||||||
|
and date_format(r.create_time, '%Y%m%d') >= date_format(#{params.beginTime}, '%Y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="params.endTime != null and params.endTime != ''">
|
||||||
|
and date_format(r.create_time, '%Y%m%d') <= date_format(#{params.endTime}, '%Y%m%d')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by r.update_time desc, r.id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectMyCustomRequestList" resultMap="AppCustomRequestResult">
|
||||||
|
<include refid="selectAppCustomRequestVo" />
|
||||||
|
where r.user_id = #{userId}
|
||||||
|
order by r.update_time desc, r.id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertAppCustomRequest" parameterType="AppCustomRequest" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into app_custom_request
|
||||||
|
(request_no, user_id, project_name, requirement_content, tech_stack_id, tech_stack_name, status, progress_note,
|
||||||
|
point_amount, point_status, reject_reason, create_by, create_time, update_by, update_time)
|
||||||
|
values
|
||||||
|
(#{requestNo}, #{userId}, #{projectName}, #{requirementContent}, #{techStackId}, #{techStackName}, #{status}, #{progressNote},
|
||||||
|
#{pointAmount}, #{pointStatus}, #{rejectReason}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateAppCustomRequest" parameterType="AppCustomRequest">
|
||||||
|
update app_custom_request
|
||||||
|
<set>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="progressNote != null">progress_note = #{progressNote},</if>
|
||||||
|
<if test="pointStatus != null">point_status = #{pointStatus},</if>
|
||||||
|
<if test="rejectReason != null">reject_reason = #{rejectReason},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
update_time = #{updateTime}
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
||||||
24
ruoyi-ui/src/api/app/customRequest.js
Normal file
24
ruoyi-ui/src/api/app/customRequest.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function listCustomRequest(query) {
|
||||||
|
return request({
|
||||||
|
url: '/app/customRequest/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCustomRequest(id) {
|
||||||
|
return request({
|
||||||
|
url: '/app/customRequest/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateCustomRequestStatus(data) {
|
||||||
|
return request({
|
||||||
|
url: '/app/customRequest/status',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
262
ruoyi-ui/src/views/app/customRequest/index.vue
Normal file
262
ruoyi-ui/src/views/app/customRequest/index.vue
Normal file
@@ -0,0 +1,262 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="82px">
|
||||||
|
<el-form-item label="需求单号" prop="requestNo">
|
||||||
|
<el-input v-model="queryParams.requestNo" placeholder="请输入需求单号" clearable @keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="项目名称" prop="projectName">
|
||||||
|
<el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable @keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="技术栈" prop="techStackName">
|
||||||
|
<el-input v-model="queryParams.techStackName" placeholder="请输入技术栈" clearable @keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户" prop="userName">
|
||||||
|
<el-input v-model="queryParams.userName" placeholder="账号或昵称" clearable @keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="需求状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="全部状态" clearable>
|
||||||
|
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="积分状态" prop="pointStatus">
|
||||||
|
<el-select v-model="queryParams.pointStatus" placeholder="全部状态" clearable>
|
||||||
|
<el-option label="已扣除" :value="0" />
|
||||||
|
<el-option label="已退回" :value="1" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="提交时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="dateRange"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="requestList">
|
||||||
|
<el-table-column label="需求单号" prop="requestNo" min-width="205" show-overflow-tooltip />
|
||||||
|
<el-table-column label="用户" min-width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div>{{ scope.row.nickName || scope.row.userName || '-' }}</div>
|
||||||
|
<div class="secondary-text">{{ scope.row.userName || '-' }} / ID: {{ scope.row.userId }}</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="项目名称" prop="projectName" min-width="180" show-overflow-tooltip />
|
||||||
|
<el-table-column label="技术栈" prop="techStackName" min-width="185" show-overflow-tooltip>
|
||||||
|
<template slot-scope="scope">{{ scope.row.techStackName || '-' }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="项目需求" prop="requirementContent" min-width="250" show-overflow-tooltip />
|
||||||
|
<el-table-column label="状态" align="center" width="120">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag :type="statusType(scope.row.status)" size="small">{{ statusLabel(scope.row.status) }}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="积分" align="center" width="105">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span :class="scope.row.pointStatus === 1 ? 'point-refunded' : ''">
|
||||||
|
{{ scope.row.pointAmount }} / {{ scope.row.pointStatus === 1 ? '已退' : '已扣' }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前进度" prop="progressNote" min-width="210" show-overflow-tooltip />
|
||||||
|
<el-table-column label="更新时间" prop="updateTime" width="165" />
|
||||||
|
<el-table-column label="操作" align="center" width="145" fixed="right">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button v-hasPermi="['app:customRequest:query']" type="text" icon="el-icon-view" size="mini" @click="handleView(scope.row)">详情</el-button>
|
||||||
|
<el-button v-if="scope.row.status !== 5" v-hasPermi="['app:customRequest:edit']" type="text" icon="el-icon-edit" size="mini" @click="handleUpdate(scope.row)">更新</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total > 0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<el-dialog title="定制需求详情" :visible.sync="detailOpen" width="760px" append-to-body>
|
||||||
|
<el-descriptions v-if="detail.id" :column="2" border>
|
||||||
|
<el-descriptions-item label="需求单号" :span="2">{{ detail.requestNo }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="用户昵称">{{ detail.nickName || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="用户账号">{{ detail.userName || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="项目名称" :span="2">{{ detail.projectName }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="技术栈" :span="2">{{ detail.techStackName || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="项目需求" :span="2">
|
||||||
|
<div class="requirement-detail">{{ detail.requirementContent }}</div>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="当前状态">
|
||||||
|
<el-tag :type="statusType(detail.status)" size="small">{{ statusLabel(detail.status) }}</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="积分状态">{{ detail.pointAmount }}积分 / {{ detail.pointStatus === 1 ? '已退回' : '已扣除' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="当前进度" :span="2">{{ detail.progressNote || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item v-if="detail.rejectReason" label="未通过原因" :span="2">{{ detail.rejectReason }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="提交时间">{{ detail.createTime || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="更新时间">{{ detail.updateTime || '-' }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<div slot="footer" class="dialog-footer"><el-button @click="detailOpen = false">关闭</el-button></div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<el-dialog title="更新需求状态" :visible.sync="updateOpen" width="560px" append-to-body>
|
||||||
|
<el-form ref="updateForm" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-form-item label="项目名称"><span>{{ form.projectName }}</span></el-form-item>
|
||||||
|
<el-form-item label="技术栈"><span>{{ form.techStackName || '-' }}</span></el-form-item>
|
||||||
|
<el-form-item label="新状态" prop="status">
|
||||||
|
<el-select v-model="form.status" placeholder="请选择状态" style="width: 100%" @change="handleStatusChange">
|
||||||
|
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" :disabled="form.pointStatus === 1 && item.value !== 5" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.status !== 5" label="进度说明" prop="progressNote">
|
||||||
|
<el-input v-model="form.progressNote" type="textarea" :rows="4" maxlength="300" show-word-limit placeholder="这段内容会展示给用户" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item v-if="form.status === 5" label="未通过原因" prop="rejectReason">
|
||||||
|
<el-input v-model="form.rejectReason" type="textarea" :rows="3" maxlength="300" show-word-limit placeholder="必填,保存后自动退回99积分" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-alert v-if="form.status === 5 && form.pointStatus === 0" title="保存后将自动退回99积分,此操作不能撤销。" type="warning" :closable="false" show-icon />
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="updateOpen = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="submitting" @click="submitUpdate">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getCustomRequest, listCustomRequest, updateCustomRequestStatus } from '@/api/app/customRequest'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'CustomRequest',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
submitting: false,
|
||||||
|
showSearch: true,
|
||||||
|
total: 0,
|
||||||
|
requestList: [],
|
||||||
|
dateRange: [],
|
||||||
|
detailOpen: false,
|
||||||
|
updateOpen: false,
|
||||||
|
detail: {},
|
||||||
|
form: {},
|
||||||
|
statusOptions: [
|
||||||
|
{ value: 0, label: '待审核' },
|
||||||
|
{ value: 1, label: '审核中' },
|
||||||
|
{ value: 2, label: '已接单' },
|
||||||
|
{ value: 3, label: '开发中' },
|
||||||
|
{ value: 4, label: '已完成' },
|
||||||
|
{ value: 5, label: '审核未通过' }
|
||||||
|
],
|
||||||
|
statusProgressDefaults: {
|
||||||
|
0: '需求已提交,等待平台审核',
|
||||||
|
1: '平台正在审核您的项目需求',
|
||||||
|
2: '项目需求已通过审核,平台已接单',
|
||||||
|
3: '项目正在开发中,请耐心等待',
|
||||||
|
4: '项目已开发完成,请联系南音查看演示成果',
|
||||||
|
5: '需求审核未通过,99积分已退回'
|
||||||
|
},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
requestNo: undefined,
|
||||||
|
projectName: undefined,
|
||||||
|
techStackName: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
status: undefined,
|
||||||
|
pointStatus: undefined
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||||
|
progressNote: [{ required: true, message: '请填写进度说明', trigger: 'blur' }],
|
||||||
|
rejectReason: [{ required: true, message: '请填写审核未通过原因', trigger: 'blur' }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() { this.getList() },
|
||||||
|
methods: {
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
listCustomRequest(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||||
|
this.requestList = response.rows || []
|
||||||
|
this.total = response.total || 0
|
||||||
|
}).finally(() => { this.loading = false })
|
||||||
|
},
|
||||||
|
handleQuery() { this.queryParams.pageNum = 1; this.getList() },
|
||||||
|
resetQuery() { this.dateRange = []; this.resetForm('queryForm'); this.handleQuery() },
|
||||||
|
handleView(row) {
|
||||||
|
getCustomRequest(row.id).then(response => { this.detail = response.data; this.detailOpen = true })
|
||||||
|
},
|
||||||
|
handleUpdate(row) {
|
||||||
|
getCustomRequest(row.id).then(response => {
|
||||||
|
const data = response.data
|
||||||
|
this.form = {
|
||||||
|
id: data.id,
|
||||||
|
projectName: data.projectName,
|
||||||
|
techStackName: data.techStackName,
|
||||||
|
status: data.status,
|
||||||
|
pointStatus: data.pointStatus,
|
||||||
|
progressNote: data.progressNote || '',
|
||||||
|
rejectReason: data.rejectReason || ''
|
||||||
|
}
|
||||||
|
this.updateOpen = true
|
||||||
|
this.$nextTick(() => { if (this.$refs.updateForm) this.$refs.updateForm.clearValidate() })
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleStatusChange(status) {
|
||||||
|
this.form.progressNote = this.statusProgressDefaults[status] || ''
|
||||||
|
if (status !== 5) this.form.rejectReason = ''
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.updateForm) this.$refs.updateForm.clearValidate(['progressNote', 'rejectReason'])
|
||||||
|
})
|
||||||
|
},
|
||||||
|
submitUpdate() {
|
||||||
|
this.$refs.updateForm.validate(valid => {
|
||||||
|
if (!valid) return
|
||||||
|
const doUpdate = () => {
|
||||||
|
this.submitting = true
|
||||||
|
const updateData = Object.assign({}, this.form, {
|
||||||
|
progressNote: String(this.form.progressNote || '').trim(),
|
||||||
|
rejectReason: this.form.status === 5 ? String(this.form.rejectReason || '').trim() : ''
|
||||||
|
})
|
||||||
|
updateCustomRequestStatus(updateData).then(() => {
|
||||||
|
this.$modal.msgSuccess(this.form.status === 5 && this.form.pointStatus === 0 ? '已拒绝并退回99积分' : '状态更新成功')
|
||||||
|
this.updateOpen = false
|
||||||
|
this.getList()
|
||||||
|
}).finally(() => { this.submitting = false })
|
||||||
|
}
|
||||||
|
if (this.form.status === 5 && this.form.pointStatus === 0) {
|
||||||
|
this.$modal.confirm('确认审核不通过并退回99积分吗?退款后不能恢复为其他状态。').then(doUpdate).catch(() => {})
|
||||||
|
} else {
|
||||||
|
doUpdate()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
statusLabel(status) {
|
||||||
|
const item = this.statusOptions.find(option => option.value === status)
|
||||||
|
return item ? item.label : '未知状态'
|
||||||
|
},
|
||||||
|
statusType(status) {
|
||||||
|
return { 0: 'info', 1: 'warning', 2: 'success', 3: 'primary', 4: 'success', 5: 'danger' }[status] || 'info'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.secondary-text { margin-top: 2px; color: #909399; font-size: 12px; }
|
||||||
|
.point-refunded { color: #2b9660; }
|
||||||
|
.requirement-detail { white-space: pre-wrap; line-height: 1.7; }
|
||||||
|
</style>
|
||||||
175
sql/custom_request.sql
Normal file
175
sql/custom_request.sql
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
-- 项目定制需求(99积分提交,审核不通过自动退回)
|
||||||
|
-- 可重复执行菜单部分;建表仅在表不存在时执行。
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `app_tech_stack` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`name` varchar(50) NOT NULL COMMENT '技术栈名称',
|
||||||
|
`sort` int NOT NULL DEFAULT 0 COMMENT '显示排序',
|
||||||
|
`status` char(1) NOT NULL DEFAULT '0' COMMENT '0启用 1停用',
|
||||||
|
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||||
|
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_app_tech_stack_name` (`name`),
|
||||||
|
KEY `idx_app_tech_stack_status_sort` (`status`, `sort`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目定制技术栈表';
|
||||||
|
|
||||||
|
INSERT INTO `app_tech_stack` (`name`, `sort`, `status`, `remark`, `create_by`, `create_time`)
|
||||||
|
SELECT 'UniApp + Spring Boot', 1, '0', '适合跨端小程序项目', 'admin', NOW()
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `app_tech_stack` WHERE `name` = 'UniApp + Spring Boot');
|
||||||
|
|
||||||
|
INSERT INTO `app_tech_stack` (`name`, `sort`, `status`, `remark`, `create_by`, `create_time`)
|
||||||
|
SELECT 'Vue + Spring Boot', 2, '0', '适合管理系统和Web项目', 'admin', NOW()
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `app_tech_stack` WHERE `name` = 'Vue + Spring Boot');
|
||||||
|
|
||||||
|
INSERT INTO `app_tech_stack` (`name`, `sort`, `status`, `remark`, `create_by`, `create_time`)
|
||||||
|
SELECT '微信小程序原生 + Spring Boot', 3, '0', '适合微信原生小程序项目', 'admin', NOW()
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `app_tech_stack` WHERE `name` = '微信小程序原生 + Spring Boot');
|
||||||
|
|
||||||
|
INSERT INTO `app_tech_stack` (`name`, `sort`, `status`, `remark`, `create_by`, `create_time`)
|
||||||
|
SELECT '其他(请在需求中说明)', 99, '0', '未确定或需要其他技术栈', 'admin', NOW()
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM `app_tech_stack` WHERE `name` = '其他(请在需求中说明)');
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `app_custom_request` (
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`request_no` varchar(32) NOT NULL COMMENT '需求单号',
|
||||||
|
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||||||
|
`project_name` varchar(30) NOT NULL COMMENT '项目名称',
|
||||||
|
`requirement_content` varchar(500) NOT NULL COMMENT '项目需求',
|
||||||
|
`tech_stack_id` bigint DEFAULT NULL COMMENT '技术栈ID',
|
||||||
|
`tech_stack_name` varchar(50) DEFAULT NULL COMMENT '提交时技术栈名称',
|
||||||
|
`status` tinyint NOT NULL DEFAULT 0 COMMENT '0待审核 1审核中 2已接单 3开发中 4已完成 5审核未通过',
|
||||||
|
`progress_note` varchar(300) DEFAULT NULL COMMENT '当前进度说明',
|
||||||
|
`point_amount` int NOT NULL DEFAULT 99 COMMENT '提交扣除积分',
|
||||||
|
`point_status` tinyint NOT NULL DEFAULT 0 COMMENT '0已扣除 1已退回',
|
||||||
|
`reject_reason` varchar(300) DEFAULT NULL COMMENT '审核未通过原因',
|
||||||
|
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||||
|
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(64) DEFAULT '' COMMENT '更新者',
|
||||||
|
`update_time` datetime NOT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_custom_request_no` (`request_no`),
|
||||||
|
KEY `idx_custom_request_user_time` (`user_id`, `update_time`),
|
||||||
|
KEY `idx_custom_request_status_time` (`status`, `update_time`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='项目定制需求表';
|
||||||
|
|
||||||
|
-- 兼容已经创建过 app_custom_request 的数据库。
|
||||||
|
SET @tech_stack_id_exists := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'app_custom_request' AND COLUMN_NAME = 'tech_stack_id'
|
||||||
|
);
|
||||||
|
SET @tech_stack_id_sql := IF(
|
||||||
|
@tech_stack_id_exists = 0,
|
||||||
|
'ALTER TABLE `app_custom_request` ADD COLUMN `tech_stack_id` bigint DEFAULT NULL COMMENT ''技术栈ID'' AFTER `requirement_content`',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE tech_stack_id_stmt FROM @tech_stack_id_sql;
|
||||||
|
EXECUTE tech_stack_id_stmt;
|
||||||
|
DEALLOCATE PREPARE tech_stack_id_stmt;
|
||||||
|
|
||||||
|
SET @tech_stack_name_exists := (
|
||||||
|
SELECT COUNT(*) FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'app_custom_request' AND COLUMN_NAME = 'tech_stack_name'
|
||||||
|
);
|
||||||
|
SET @tech_stack_name_sql := IF(
|
||||||
|
@tech_stack_name_exists = 0,
|
||||||
|
'ALTER TABLE `app_custom_request` ADD COLUMN `tech_stack_name` varchar(50) DEFAULT NULL COMMENT ''提交时技术栈名称'' AFTER `tech_stack_id`',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE tech_stack_name_stmt FROM @tech_stack_name_sql;
|
||||||
|
EXECUTE tech_stack_name_stmt;
|
||||||
|
DEALLOCATE PREPARE tech_stack_name_stmt;
|
||||||
|
|
||||||
|
SET @custom_request_parent_id := COALESCE(
|
||||||
|
(SELECT parent_id FROM sys_menu WHERE perms = 'app:resource:list' LIMIT 1),
|
||||||
|
(SELECT parent_id FROM sys_menu WHERE perms = 'app:article:list' LIMIT 1),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
SET @custom_request_order_num := COALESCE(
|
||||||
|
(SELECT MAX(order_num) + 1 FROM sys_menu WHERE parent_id = @custom_request_parent_id),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT
|
||||||
|
'项目定制', @custom_request_parent_id, @custom_request_order_num,
|
||||||
|
'customRequest', 'app/customRequest/index', '', 1, 0,
|
||||||
|
'C', '0', '0', 'app:customRequest:list', 'form', 'admin', NOW(), '', NULL,
|
||||||
|
'项目定制需求管理'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:customRequest:list');
|
||||||
|
|
||||||
|
SET @custom_request_menu_id := (
|
||||||
|
SELECT menu_id FROM sys_menu WHERE perms = 'app:customRequest:list' LIMIT 1
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT '定制需求查询', @custom_request_menu_id, 1, '', '', '', 1, 0,
|
||||||
|
'F', '0', '0', 'app:customRequest:query', '#', 'admin', NOW(), '', NULL, ''
|
||||||
|
WHERE @custom_request_menu_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:customRequest:query');
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT '定制状态修改', @custom_request_menu_id, 2, '', '', '', 1, 0,
|
||||||
|
'F', '0', '0', 'app:customRequest:edit', '#', 'admin', NOW(), '', NULL, ''
|
||||||
|
WHERE @custom_request_menu_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:customRequest:edit');
|
||||||
|
|
||||||
|
SET @tech_stack_order_num := COALESCE(
|
||||||
|
(SELECT MAX(order_num) + 1 FROM sys_menu WHERE parent_id = @custom_request_parent_id),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT
|
||||||
|
'技术栈管理', @custom_request_parent_id, @tech_stack_order_num,
|
||||||
|
'techStack', 'app/techStack/index', '', 1, 0,
|
||||||
|
'C', '0', '0', 'app:techStack:list', 'tree-table', 'admin', NOW(), '', NULL,
|
||||||
|
'项目定制技术栈管理'
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:techStack:list');
|
||||||
|
|
||||||
|
SET @tech_stack_menu_id := (
|
||||||
|
SELECT menu_id FROM sys_menu WHERE perms = 'app:techStack:list' LIMIT 1
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT '技术栈查询', @tech_stack_menu_id, 1, '', '', '', 1, 0,
|
||||||
|
'F', '0', '0', 'app:techStack:query', '#', 'admin', NOW(), '', NULL, ''
|
||||||
|
WHERE @tech_stack_menu_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:techStack:query');
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT '技术栈新增', @tech_stack_menu_id, 2, '', '', '', 1, 0,
|
||||||
|
'F', '0', '0', 'app:techStack:add', '#', 'admin', NOW(), '', NULL, ''
|
||||||
|
WHERE @tech_stack_menu_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:techStack:add');
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT '技术栈修改', @tech_stack_menu_id, 3, '', '', '', 1, 0,
|
||||||
|
'F', '0', '0', 'app:techStack:edit', '#', 'admin', NOW(), '', NULL, ''
|
||||||
|
WHERE @tech_stack_menu_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:techStack:edit');
|
||||||
|
|
||||||
|
INSERT INTO sys_menu
|
||||||
|
(menu_name, parent_id, order_num, path, component, query, is_frame, is_cache,
|
||||||
|
menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
|
SELECT '技术栈删除', @tech_stack_menu_id, 4, '', '', '', 1, 0,
|
||||||
|
'F', '0', '0', 'app:techStack:remove', '#', 'admin', NOW(), '', NULL, ''
|
||||||
|
WHERE @tech_stack_menu_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'app:techStack:remove');
|
||||||
Reference in New Issue
Block a user