档案行政分类模块添加

master
hansha 2 years ago
parent 33cf9765c1
commit 09b613755b

@ -0,0 +1,104 @@
package com.da.dangan.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.da.common.annotation.Log;
import com.da.common.core.controller.BaseController;
import com.da.common.core.domain.AjaxResult;
import com.da.common.enums.BusinessType;
import com.da.dangan.domain.AreaSort;
import com.da.dangan.service.IAreaSortService;
import com.da.common.utils.poi.ExcelUtil;
import com.da.common.core.page.TableDataInfo;
/**
* Controller
*
* @author hs
* @date 2024-05-11
*/
@RestController
@RequestMapping("/dangan/areaSort")
public class AreaSortController extends BaseController
{
@Autowired
private IAreaSortService areaSortService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:areaSort:list')")
@GetMapping("/list")
public TableDataInfo list(AreaSort areaSort)
{
startPage();
List<AreaSort> list = areaSortService.selectAreaSortList(areaSort);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:areaSort:export')")
@Log(title = "档案行政分类", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AreaSort areaSort)
{
List<AreaSort> list = areaSortService.selectAreaSortList(areaSort);
ExcelUtil<AreaSort> util = new ExcelUtil<AreaSort>(AreaSort.class);
util.exportExcel(response, list, "档案行政分类数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:areaSort:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(areaSortService.selectAreaSortById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:areaSort:add')")
@Log(title = "档案行政分类", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AreaSort areaSort)
{
return toAjax(areaSortService.insertAreaSort(areaSort));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:areaSort:edit')")
@Log(title = "档案行政分类", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AreaSort areaSort)
{
return toAjax(areaSortService.updateAreaSort(areaSort));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('dangan:areaSort:remove')")
@Log(title = "档案行政分类", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(areaSortService.deleteAreaSortByIds(ids));
}
}

@ -0,0 +1,83 @@
package com.da.dangan.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.da.common.annotation.Excel;
import com.da.common.core.domain.BaseEntity;
/**
* area_sort
*
* @author hs
* @date 2024-05-11
*/
public class AreaSort extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 目录名称 */
@Excel(name = "目录名称")
private String muName;
/** 区域分类(字典) */
@Excel(name = "区域分类(字典)")
private String areaType;
/** 父区域ID */
@Excel(name = "父区域ID")
private Long pid;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setMuName(String muName)
{
this.muName = muName;
}
public String getMuName()
{
return muName;
}
public void setAreaType(String areaType)
{
this.areaType = areaType;
}
public String getAreaType()
{
return areaType;
}
public void setPid(Long pid)
{
this.pid = pid;
}
public Long getPid()
{
return pid;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("muName", getMuName())
.append("areaType", getAreaType())
.append("pid", getPid())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -0,0 +1,62 @@
package com.da.dangan.mapper;
import com.da.dangan.domain.AreaSort;
import java.util.List;
/**
* Mapper
*
* @author hs
* @date 2024-05-11
*/
public interface AreaSortMapper
{
/**
*
*
* @param id
* @return
*/
public AreaSort selectAreaSortById(Long id);
/**
*
*
* @param areaSort
* @return
*/
public List<AreaSort> selectAreaSortList(AreaSort areaSort);
/**
*
*
* @param areaSort
* @return
*/
public int insertAreaSort(AreaSort areaSort);
/**
*
*
* @param areaSort
* @return
*/
public int updateAreaSort(AreaSort areaSort);
/**
*
*
* @param id
* @return
*/
public int deleteAreaSortById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteAreaSortByIds(Long[] ids);
}

@ -0,0 +1,62 @@
package com.da.dangan.service;
import com.da.dangan.domain.AreaSort;
import java.util.List;
/**
* Service
*
* @author hs
* @date 2024-05-11
*/
public interface IAreaSortService
{
/**
*
*
* @param id
* @return
*/
public AreaSort selectAreaSortById(Long id);
/**
*
*
* @param areaSort
* @return
*/
public List<AreaSort> selectAreaSortList(AreaSort areaSort);
/**
*
*
* @param areaSort
* @return
*/
public int insertAreaSort(AreaSort areaSort);
/**
*
*
* @param areaSort
* @return
*/
public int updateAreaSort(AreaSort areaSort);
/**
*
*
* @param ids
* @return
*/
public int deleteAreaSortByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteAreaSortById(Long id);
}

@ -0,0 +1,97 @@
package com.da.dangan.service.impl;
import com.da.common.utils.DateUtils;
import com.da.dangan.domain.AreaSort;
import com.da.dangan.mapper.AreaSortMapper;
import com.da.dangan.service.IAreaSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Service
*
* @author hs
* @date 2024-05-11
*/
@Service
public class AreaSortServiceImpl implements IAreaSortService
{
@Autowired
private AreaSortMapper areaSortMapper;
/**
*
*
* @param id
* @return
*/
@Override
public AreaSort selectAreaSortById(Long id)
{
return areaSortMapper.selectAreaSortById(id);
}
/**
*
*
* @param areaSort
* @return
*/
@Override
public List<AreaSort> selectAreaSortList(AreaSort areaSort)
{
return areaSortMapper.selectAreaSortList(areaSort);
}
/**
*
*
* @param areaSort
* @return
*/
@Override
public int insertAreaSort(AreaSort areaSort)
{
areaSort.setCreateTime(DateUtils.getNowDate());
return areaSortMapper.insertAreaSort(areaSort);
}
/**
*
*
* @param areaSort
* @return
*/
@Override
public int updateAreaSort(AreaSort areaSort)
{
areaSort.setUpdateTime(DateUtils.getNowDate());
return areaSortMapper.updateAreaSort(areaSort);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteAreaSortByIds(Long[] ids)
{
return areaSortMapper.deleteAreaSortByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteAreaSortById(Long id)
{
return areaSortMapper.deleteAreaSortById(id);
}
}

@ -0,0 +1,82 @@
<?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.da.dangan.mapper.AreaSortMapper">
<resultMap type="AreaSort" id="AreaSortResult">
<result property="id" column="id" />
<result property="muName" column="mu_name" />
<result property="areaType" column="area_type" />
<result property="pid" column="pid" />
<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="selectAreaSortVo">
select id, mu_name, area_type, pid, create_by, create_time, update_by, update_time from area_sort
</sql>
<select id="selectAreaSortList" parameterType="AreaSort" resultMap="AreaSortResult">
<include refid="selectAreaSortVo"/>
<where>
<if test="muName != null and muName != ''"> and mu_name like concat('%', #{muName}, '%')</if>
<if test="areaType != null and areaType != ''"> and area_type = #{areaType}</if>
<if test="pid != null "> and pid = #{pid}</if>
</where>
</select>
<select id="selectAreaSortById" parameterType="Long" resultMap="AreaSortResult">
<include refid="selectAreaSortVo"/>
where id = #{id}
</select>
<insert id="insertAreaSort" parameterType="AreaSort" useGeneratedKeys="true" keyProperty="id">
insert into area_sort
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="muName != null and muName != ''">mu_name,</if>
<if test="areaType != null and areaType != ''">area_type,</if>
<if test="pid != null">pid,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="muName != null and muName != ''">#{muName},</if>
<if test="areaType != null and areaType != ''">#{areaType},</if>
<if test="pid != null">#{pid},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateAreaSort" parameterType="AreaSort">
update area_sort
<trim prefix="SET" suffixOverrides=",">
<if test="muName != null and muName != ''">mu_name = #{muName},</if>
<if test="areaType != null and areaType != ''">area_type = #{areaType},</if>
<if test="pid != null">pid = #{pid},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAreaSortById" parameterType="Long">
delete from area_sort where id = #{id}
</delete>
<delete id="deleteAreaSortByIds" parameterType="String">
delete from area_sort where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询档案行政分类列表
export function listAreaSort(query) {
return request({
url: '/dangan/areaSort/list',
method: 'get',
params: query
})
}
// 查询档案行政分类详细
export function getAreaSort(id) {
return request({
url: '/dangan/areaSort/' + id,
method: 'get'
})
}
// 新增档案行政分类
export function addAreaSort(data) {
return request({
url: '/dangan/areaSort',
method: 'post',
data: data
})
}
// 修改档案行政分类
export function updateAreaSort(data) {
return request({
url: '/dangan/areaSort',
method: 'put',
data: data
})
}
// 删除档案行政分类
export function delAreaSort(id) {
return request({
url: '/dangan/areaSort/' + id,
method: 'delete'
})
}

@ -0,0 +1,275 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="目录名称" prop="muName">
<el-input
v-model="queryParams.muName"
placeholder="请输入目录名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="父区域ID" prop="pid">
<el-input
v-model="queryParams.pid"
placeholder="请输入父区域ID"
clearable
@keyup.enter.native="handleQuery"
/>
</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="['dangan:areaSort: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="['dangan:areaSort: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="['dangan:areaSort: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="['dangan:areaSort:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="areaSortList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" />
<el-table-column label="目录名称" align="center" prop="muName" />
<el-table-column label="区域分类(字典)" align="center" prop="areaType" />
<el-table-column label="父区域ID" align="center" prop="pid" />
<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="['dangan:areaSort:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['dangan:areaSort: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="muName">
<el-input v-model="form.muName" placeholder="请输入目录名称" />
</el-form-item>
<el-form-item label="父区域ID" prop="pid">
<el-input v-model="form.pid" placeholder="请输入父区域ID" />
</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 { listAreaSort, getAreaSort, delAreaSort, addAreaSort, updateAreaSort } from "@/api/dangan/areaSort";
export default {
name: "AreaSort",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
areaSortList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
muName: null,
areaType: null,
pid: null,
},
//
form: {},
//
rules: {
muName: [
{ required: true, message: "目录名称不能为空", trigger: "blur" }
],
areaType: [
{ required: true, message: "区域分类(字典)不能为空", trigger: "change" }
],
pid: [
{ required: true, message: "父区域ID不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询档案行政分类列表 */
getList() {
this.loading = true;
listAreaSort(this.queryParams).then(response => {
this.areaSortList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
muName: null,
areaType: null,
pid: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: 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.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加档案行政分类";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getAreaSort(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改档案行政分类";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateAreaSort(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addAreaSort(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除档案行政分类编号为"' + ids + '"的数据项?').then(function() {
return delAreaSort(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('dangan/areaSort/export', {
...this.queryParams
}, `areaSort_${new Date().getTime()}.xlsx`)
}
}
};
</script>
Loading…
Cancel
Save