fix(sysProject) add

approve-sys
bob 2 years ago
parent 75818fc75e
commit 7b04efc107

@ -0,0 +1,100 @@
package com.ruoyi.web.controller.system;
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 com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysProject;
import com.ruoyi.system.service.ISysProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Controller
*
* @author ruoyi
* @date 2022-12-30
*/
@RestController
@RequestMapping("/system/project")
public class SysProjectController extends BaseController
{
@Autowired
private ISysProjectService sysProjectService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:project:list')")
@GetMapping("/list")
public TableDataInfo list(SysProject sysProject)
{
startPage();
List<SysProject> list = sysProjectService.selectSysProjectList(sysProject);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:project:export')")
@Log(title = "项目", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(SysProject sysProject)
{
List<SysProject> list = sysProjectService.selectSysProjectList(sysProject);
ExcelUtil<SysProject> util = new ExcelUtil<SysProject>(SysProject.class);
return util.exportExcel(list, "project");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:project:query')")
@GetMapping(value = "/{projectId}")
public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
{
return AjaxResult.success(sysProjectService.selectSysProjectById(projectId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:project:add')")
@Log(title = "项目", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysProject sysProject)
{
sysProject.setUpdateBy(SecurityUtils.getUsername());
return toAjax(sysProjectService.insertSysProject(sysProject));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:project:edit')")
@Log(title = "项目", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysProject sysProject)
{
sysProject.setUpdateBy(SecurityUtils.getUsername());
return toAjax(sysProjectService.updateSysProject(sysProject));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:project:remove')")
@Log(title = "项目", businessType = BusinessType.DELETE)
@DeleteMapping("/{projectIds}")
public AjaxResult remove(@PathVariable Long[] projectIds)
{
return toAjax(sysProjectService.deleteSysProjectByIds(projectIds));
}
}

@ -559,7 +559,7 @@ export default {
#if($table.sub)
this.form.${subclassName}List = this.${subclassName}List;
#end
if (this.form.${pkColumn.javaField} != null) {
if (this.form.${pkColumn.javaField} != undefined) {
update${BusinessName}(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;

@ -0,0 +1,114 @@
package com.ruoyi.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* sys_project
*
* @author ruoyi
* @date 2022-12-30
*/
public class SysProject extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 项目id */
private Long projectId;
/** 项目名称 */
@Excel(name = "项目名称")
private String name;
/** 项目介绍 */
@Excel(name = "项目介绍")
private String introduction;
/** 项目开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "项目开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date startDate;
/** 项目结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "项目结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date endDate;
/** 删除标志0代表存在 2代表删除 */
private Long delFlag;
public void setProjectId(Long projectId)
{
this.projectId = projectId;
}
public Long getProjectId()
{
return projectId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setIntroduction(String introduction)
{
this.introduction = introduction;
}
public String getIntroduction()
{
return introduction;
}
public void setStartDate(Date startDate)
{
this.startDate = startDate;
}
public Date getStartDate()
{
return startDate;
}
public void setEndDate(Date endDate)
{
this.endDate = endDate;
}
public Date getEndDate()
{
return endDate;
}
public void setDelFlag(Long delFlag)
{
this.delFlag = delFlag;
}
public Long getDelFlag()
{
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("projectId", getProjectId())
.append("name", getName())
.append("introduction", getIntroduction())
.append("startDate", getStartDate())
.append("endDate", getEndDate())
.append("delFlag", getDelFlag())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.toString();
}
}

@ -0,0 +1,62 @@
package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.SysProject;
import java.util.List;
/**
* Mapper
*
* @author ruoyi
* @date 2022-12-30
*/
public interface SysProjectMapper
{
/**
*
*
* @param projectId ID
* @return
*/
public SysProject selectSysProjectById(Long projectId);
/**
*
*
* @param sysProject
* @return
*/
public List<SysProject> selectSysProjectList(SysProject sysProject);
/**
*
*
* @param sysProject
* @return
*/
public int insertSysProject(SysProject sysProject);
/**
*
*
* @param sysProject
* @return
*/
public int updateSysProject(SysProject sysProject);
/**
*
*
* @param projectId ID
* @return
*/
public int deleteSysProjectById(Long projectId);
/**
*
*
* @param projectIds ID
* @return
*/
public int deleteSysProjectByIds(Long[] projectIds);
}

@ -0,0 +1,62 @@
package com.ruoyi.system.service;
import com.ruoyi.system.domain.SysProject;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2022-12-30
*/
public interface ISysProjectService
{
/**
*
*
* @param projectId ID
* @return
*/
public SysProject selectSysProjectById(Long projectId);
/**
*
*
* @param sysProject
* @return
*/
public List<SysProject> selectSysProjectList(SysProject sysProject);
/**
*
*
* @param sysProject
* @return
*/
public int insertSysProject(SysProject sysProject);
/**
*
*
* @param sysProject
* @return
*/
public int updateSysProject(SysProject sysProject);
/**
*
*
* @param projectIds ID
* @return
*/
public int deleteSysProjectByIds(Long[] projectIds);
/**
*
*
* @param projectId ID
* @return
*/
public int deleteSysProjectById(Long projectId);
}

@ -0,0 +1,97 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysProject;
import com.ruoyi.system.mapper.SysProjectMapper;
import com.ruoyi.system.service.ISysProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author ruoyi
* @date 2022-12-30
*/
@Service
public class SysProjectServiceImpl implements ISysProjectService
{
@Autowired
private SysProjectMapper sysProjectMapper;
/**
*
*
* @param projectId ID
* @return
*/
@Override
public SysProject selectSysProjectById(Long projectId)
{
return sysProjectMapper.selectSysProjectById(projectId);
}
/**
*
*
* @param sysProject
* @return
*/
@Override
public List<SysProject> selectSysProjectList(SysProject sysProject)
{
return sysProjectMapper.selectSysProjectList(sysProject);
}
/**
*
*
* @param sysProject
* @return
*/
@Override
public int insertSysProject(SysProject sysProject)
{
sysProject.setCreateTime(DateUtils.getNowDate());
return sysProjectMapper.insertSysProject(sysProject);
}
/**
*
*
* @param sysProject
* @return
*/
@Override
public int updateSysProject(SysProject sysProject)
{
sysProject.setUpdateTime(DateUtils.getNowDate());
return sysProjectMapper.updateSysProject(sysProject);
}
/**
*
*
* @param projectIds ID
* @return
*/
@Override
public int deleteSysProjectByIds(Long[] projectIds)
{
return sysProjectMapper.deleteSysProjectByIds(projectIds);
}
/**
*
*
* @param projectId ID
* @return
*/
@Override
public int deleteSysProjectById(Long projectId)
{
return sysProjectMapper.deleteSysProjectById(projectId);
}
}

@ -0,0 +1,87 @@
<?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.system.mapper.SysProjectMapper">
<resultMap type="SysProject" id="SysProjectResult">
<result property="projectId" column="project_id" />
<result property="name" column="name" />
<result property="introduction" column="introduction" />
<result property="startDate" column="start_date" />
<result property="endDate" column="end_date" />
<result property="delFlag" column="del_flag" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectSysProjectVo">
select project_id, name, introduction, start_date, end_date, del_flag, create_time, update_time, update_by from sys_project
</sql>
<select id="selectSysProjectList" parameterType="SysProject" resultMap="SysProjectResult">
<include refid="selectSysProjectVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if>
<if test="startDate != null "> and start_date = #{startDate}</if>
<if test="endDate != null "> and end_date = #{endDate}</if>
</where>
</select>
<select id="selectSysProjectById" parameterType="Long" resultMap="SysProjectResult">
<include refid="selectSysProjectVo"/>
where project_id = #{projectId}
</select>
<insert id="insertSysProject" parameterType="SysProject" useGeneratedKeys="true" keyProperty="projectId">
insert into sys_project
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="introduction != null">introduction,</if>
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="introduction != null">#{introduction},</if>
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateSysProject" parameterType="SysProject">
update sys_project
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="introduction != null">introduction = #{introduction},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where project_id = #{projectId}
</update>
<delete id="deleteSysProjectById" parameterType="Long">
delete from sys_project where project_id = #{projectId}
</delete>
<delete id="deleteSysProjectByIds" parameterType="String">
delete from sys_project where project_id in
<foreach item="projectId" collection="array" open="(" separator="," close=")">
#{projectId}
</foreach>
</delete>
</mapper>

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询项目列表
export function listProject(query) {
return request({
url: '/system/project/list',
method: 'get',
params: query
})
}
// 查询项目详细
export function getProject(projectId) {
return request({
url: '/system/project/' + projectId,
method: 'get'
})
}
// 新增项目
export function addProject(data) {
return request({
url: '/system/project',
method: 'post',
data: data
})
}
// 修改项目
export function updateProject(data) {
return request({
url: '/system/project',
method: 'put',
data: data
})
}
// 删除项目
export function delProject(projectId) {
return request({
url: '/system/project/' + projectId,
method: 'delete'
})
}
// 导出项目
export function exportProject(query) {
return request({
url: '/system/project/export',
method: 'get',
params: query
})
}

@ -0,0 +1,333 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="项目名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入项目名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="项目开始时间" prop="startDate">
<el-date-picker clearable size="small"
v-model="queryParams.startDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择项目开始时间">
</el-date-picker>
</el-form-item>
<el-form-item label="项目结束时间" prop="endDate">
<el-date-picker clearable size="small"
v-model="queryParams.endDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择项目结束时间">
</el-date-picker>
</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">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:project:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:project:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:project:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:project:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="项目id" align="center" prop="projectId" />
<el-table-column label="项目名称" align="center" prop="name" />
<el-table-column label="项目介绍" align="center" prop="introduction" />
<el-table-column label="项目开始时间" align="center" prop="startDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="项目结束时间" align="center" prop="endDate" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:project:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:project:remove']"
>删除</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="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="项目名称" prop="name">
<el-input v-model="form.name" placeholder="请输入项目名称" />
</el-form-item>
<el-form-item label="项目介绍" prop="introduction">
<el-input v-model="form.introduction" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="项目开始时间" prop="startDate">
<el-date-picker clearable size="small"
v-model="form.startDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择项目开始时间">
</el-date-picker>
</el-form-item>
<el-form-item label="项目结束时间" prop="endDate">
<el-date-picker clearable size="small"
v-model="form.endDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择项目结束时间">
</el-date-picker>
</el-form-item>
<el-form-item label="删除标志" prop="delFlag">
<el-input v-model="form.delFlag" placeholder="请输入删除标志" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProject, getProject, delProject, addProject, updateProject, exportProject } from "@/api/system/project";
export default {
name: "Project",
components: {
},
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
projectList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
introduction: null,
startDate: null,
endDate: null,
},
//
form: {},
//
rules: {
name: [
{ required: true, message: "项目名称不能为空", trigger: "blur" }
],
startDate: [
{ required: true, message: "项目开始时间不能为空", trigger: "blur" }
],
delFlag: [
{ required: true, message: "删除标志不能为空", trigger: "blur" }
],
updateTime: [
{ required: true, message: "更新时间不能为空", trigger: "blur" }
],
updateBy: [
{ required: true, message: "更新人不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询项目列表 */
getList() {
this.loading = true;
listProject(this.queryParams).then(response => {
this.projectList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
projectId: null,
name: null,
introduction: null,
startDate: null,
endDate: null,
delFlag: null,
createTime: null,
updateTime: null,
updateBy: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.projectId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加项目";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const projectId = row.projectId || this.ids
getProject(projectId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改项目";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.projectId != undefined) {
updateProject(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addProject(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const projectIds = row.projectId || this.ids;
this.$confirm('是否确认删除项目编号为"' + projectIds + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delProject(projectIds);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有项目数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return exportProject(queryParams);
}).then(response => {
this.download(response.msg);
})
}
}
};
</script>
Loading…
Cancel
Save