提交代码

main
姜玉琦 2024-02-24 14:09:00 +08:00
parent 238fa041ca
commit 04c7450903
8 changed files with 922 additions and 0 deletions

View File

@ -0,0 +1,104 @@
package com.yanzhu.base.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.yanzhu.common.annotation.Log;
import com.yanzhu.common.core.controller.BaseController;
import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.common.enums.BusinessType;
import com.yanzhu.base.domain.BaseAssetsType;
import com.yanzhu.base.service.IBaseAssetsTypeService;
import com.yanzhu.common.utils.poi.ExcelUtil;
import com.yanzhu.common.core.page.TableDataInfo;
/**
* Controller
*
* @author yanZhu
* @date 2024-02-24
*/
@RestController
@RequestMapping("/base/assetsType")
public class BaseAssetsTypeController extends BaseController
{
@Autowired
private IBaseAssetsTypeService baseAssetsTypeService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:assetsType:list')")
@GetMapping("/list")
public TableDataInfo list(BaseAssetsType baseAssetsType)
{
startPage();
List<BaseAssetsType> list = baseAssetsTypeService.selectBaseAssetsTypeList(baseAssetsType);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:assetsType:export')")
@Log(title = "物资类型", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BaseAssetsType baseAssetsType)
{
List<BaseAssetsType> list = baseAssetsTypeService.selectBaseAssetsTypeList(baseAssetsType);
ExcelUtil<BaseAssetsType> util = new ExcelUtil<BaseAssetsType>(BaseAssetsType.class);
util.exportExcel(response, list, "物资类型数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:assetsType:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(baseAssetsTypeService.selectBaseAssetsTypeById(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:assetsType:add')")
@Log(title = "物资类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BaseAssetsType baseAssetsType)
{
return toAjax(baseAssetsTypeService.insertBaseAssetsType(baseAssetsType));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:assetsType:edit')")
@Log(title = "物资类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BaseAssetsType baseAssetsType)
{
return toAjax(baseAssetsTypeService.updateBaseAssetsType(baseAssetsType));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:assetsType:remove')")
@Log(title = "物资类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(baseAssetsTypeService.deleteBaseAssetsTypeByIds(ids));
}
}

View File

@ -0,0 +1,126 @@
package com.yanzhu.base.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.yanzhu.common.annotation.Excel;
import com.yanzhu.common.core.domain.BaseEntity;
/**
* base_assets_type
*
* @author yanZhu
* @date 2024-02-24
*/
public class BaseAssetsType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 父级分类 */
@Excel(name = "父级分类")
private Long parentId;
/** 单位主键 */
@Excel(name = "单位主键")
private Long deptId;
/** 资产类型 */
@Excel(name = "资产类型")
private String type;
/** 资产名称 */
@Excel(name = "资产名称")
private String name;
/** 资产单位 */
@Excel(name = "资产单位")
private String unit;
/** 是否删除 */
@Excel(name = "是否删除")
private String isDel;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public Long getParentId()
{
return parentId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getDeptId()
{
return deptId;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setUnit(String unit)
{
this.unit = unit;
}
public String getUnit()
{
return unit;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("parentId", getParentId())
.append("deptId", getDeptId())
.append("type", getType())
.append("name", getName())
.append("unit", getUnit())
.append("isDel", getIsDel())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.yanzhu.base.mapper;
import java.util.List;
import com.yanzhu.base.domain.BaseAssetsType;
/**
* Mapper
*
* @author yanZhu
* @date 2024-02-24
*/
public interface BaseAssetsTypeMapper
{
/**
*
*
* @param id
* @return
*/
public BaseAssetsType selectBaseAssetsTypeById(Long id);
/**
*
*
* @param baseAssetsType
* @return
*/
public List<BaseAssetsType> selectBaseAssetsTypeList(BaseAssetsType baseAssetsType);
/**
*
*
* @param baseAssetsType
* @return
*/
public int insertBaseAssetsType(BaseAssetsType baseAssetsType);
/**
*
*
* @param baseAssetsType
* @return
*/
public int updateBaseAssetsType(BaseAssetsType baseAssetsType);
/**
*
*
* @param id
* @return
*/
public int deleteBaseAssetsTypeById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteBaseAssetsTypeByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.yanzhu.base.service;
import java.util.List;
import com.yanzhu.base.domain.BaseAssetsType;
/**
* Service
*
* @author yanZhu
* @date 2024-02-24
*/
public interface IBaseAssetsTypeService
{
/**
*
*
* @param id
* @return
*/
public BaseAssetsType selectBaseAssetsTypeById(Long id);
/**
*
*
* @param baseAssetsType
* @return
*/
public List<BaseAssetsType> selectBaseAssetsTypeList(BaseAssetsType baseAssetsType);
/**
*
*
* @param baseAssetsType
* @return
*/
public int insertBaseAssetsType(BaseAssetsType baseAssetsType);
/**
*
*
* @param baseAssetsType
* @return
*/
public int updateBaseAssetsType(BaseAssetsType baseAssetsType);
/**
*
*
* @param ids
* @return
*/
public int deleteBaseAssetsTypeByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteBaseAssetsTypeById(Long id);
}

View File

@ -0,0 +1,96 @@
package com.yanzhu.base.service.impl;
import java.util.List;
import com.yanzhu.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.base.mapper.BaseAssetsTypeMapper;
import com.yanzhu.base.domain.BaseAssetsType;
import com.yanzhu.base.service.IBaseAssetsTypeService;
/**
* Service
*
* @author yanZhu
* @date 2024-02-24
*/
@Service
public class BaseAssetsTypeServiceImpl implements IBaseAssetsTypeService
{
@Autowired
private BaseAssetsTypeMapper baseAssetsTypeMapper;
/**
*
*
* @param id
* @return
*/
@Override
public BaseAssetsType selectBaseAssetsTypeById(Long id)
{
return baseAssetsTypeMapper.selectBaseAssetsTypeById(id);
}
/**
*
*
* @param baseAssetsType
* @return
*/
@Override
public List<BaseAssetsType> selectBaseAssetsTypeList(BaseAssetsType baseAssetsType)
{
return baseAssetsTypeMapper.selectBaseAssetsTypeList(baseAssetsType);
}
/**
*
*
* @param baseAssetsType
* @return
*/
@Override
public int insertBaseAssetsType(BaseAssetsType baseAssetsType)
{
baseAssetsType.setCreateTime(DateUtils.getNowDate());
return baseAssetsTypeMapper.insertBaseAssetsType(baseAssetsType);
}
/**
*
*
* @param baseAssetsType
* @return
*/
@Override
public int updateBaseAssetsType(BaseAssetsType baseAssetsType)
{
baseAssetsType.setUpdateTime(DateUtils.getNowDate());
return baseAssetsTypeMapper.updateBaseAssetsType(baseAssetsType);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteBaseAssetsTypeByIds(Long[] ids)
{
return baseAssetsTypeMapper.deleteBaseAssetsTypeByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteBaseAssetsTypeById(Long id)
{
return baseAssetsTypeMapper.deleteBaseAssetsTypeById(id);
}
}

View File

@ -0,0 +1,103 @@
<?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.yanzhu.base.mapper.BaseAssetsTypeMapper">
<resultMap type="BaseAssetsType" id="BaseAssetsTypeResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="deptId" column="dept_id" />
<result property="type" column="type" />
<result property="name" column="name" />
<result property="unit" column="unit" />
<result property="isDel" column="is_del" />
<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="remark" column="remark" />
</resultMap>
<sql id="selectBaseAssetsTypeVo">
select id, parent_id, dept_id, type, name, unit, is_del, create_by, create_time, update_by, update_time, remark from base_assets_type
</sql>
<select id="selectBaseAssetsTypeList" parameterType="BaseAssetsType" resultMap="BaseAssetsTypeResult">
<include refid="selectBaseAssetsTypeVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
<if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
</where>
</select>
<select id="selectBaseAssetsTypeById" parameterType="Long" resultMap="BaseAssetsTypeResult">
<include refid="selectBaseAssetsTypeVo"/>
where id = #{id}
</select>
<insert id="insertBaseAssetsType" parameterType="BaseAssetsType">
insert into base_assets_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="parentId != null">parent_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="type != null">type,</if>
<if test="name != null">name,</if>
<if test="unit != null">unit,</if>
<if test="isDel != null">is_del,</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>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="parentId != null">#{parentId},</if>
<if test="deptId != null">#{deptId},</if>
<if test="type != null">#{type},</if>
<if test="name != null">#{name},</if>
<if test="unit != null">#{unit},</if>
<if test="isDel != null">#{isDel},</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>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateBaseAssetsType" parameterType="BaseAssetsType">
update base_assets_type
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="type != null">type = #{type},</if>
<if test="name != null">name = #{name},</if>
<if test="unit != null">unit = #{unit},</if>
<if test="isDel != null">is_del = #{isDel},</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>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteBaseAssetsTypeById" parameterType="Long">
delete from base_assets_type where id = #{id}
</delete>
<delete id="deleteBaseAssetsTypeByIds" parameterType="String">
delete from base_assets_type where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询物资类型列表
export function listAssetsType(query) {
return request({
url: '/base/assetsType/list',
method: 'get',
params: query
})
}
// 查询物资类型详细
export function getAssetsType(id) {
return request({
url: '/base/assetsType/' + id,
method: 'get'
})
}
// 新增物资类型
export function addAssetsType(data) {
return request({
url: '/base/assetsType',
method: 'post',
data: data
})
}
// 修改物资类型
export function updateAssetsType(data) {
return request({
url: '/base/assetsType',
method: 'put',
data: data
})
}
// 删除物资类型
export function delAssetsType(id) {
return request({
url: '/base/assetsType/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,327 @@
<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="parentId">
<el-input
v-model="queryParams.parentId"
placeholder="请输入父级分类"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="单位主键" prop="deptId">
<el-input
v-model="queryParams.deptId"
placeholder="请输入单位主键"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="资产名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入资产名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="资产单位" prop="unit">
<el-input
v-model="queryParams.unit"
placeholder="请输入资产单位"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="是否删除" prop="isDel">
<el-select v-model="queryParams.isDel" placeholder="请选择是否删除" clearable>
<el-option
v-for="dict in dict.type.sys_is_del"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</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="['base:assetsType: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="['base:assetsType: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="['base:assetsType: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="['base:assetsType:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="assetsTypeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" />
<el-table-column label="父级分类" align="center" prop="parentId" />
<el-table-column label="单位主键" align="center" prop="deptId" />
<el-table-column label="资产类型" align="center" prop="type" />
<el-table-column label="资产名称" align="center" prop="name" />
<el-table-column label="资产单位" align="center" prop="unit" />
<el-table-column label="是否删除" align="center" prop="isDel">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_is_del" :value="scope.row.isDel"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<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="['base:assetsType:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['base:assetsType: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="parentId">
<el-input v-model="form.parentId" placeholder="请输入父级分类" />
</el-form-item>
<el-form-item label="单位主键" prop="deptId">
<el-input v-model="form.deptId" placeholder="请输入单位主键" />
</el-form-item>
<el-form-item label="资产名称" prop="name">
<el-input v-model="form.name" placeholder="请输入资产名称" />
</el-form-item>
<el-form-item label="资产单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入资产单位" />
</el-form-item>
<el-form-item label="是否删除" prop="isDel">
<el-select v-model="form.isDel" placeholder="请选择是否删除">
<el-option
v-for="dict in dict.type.sys_is_del"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" 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 { listAssetsType, getAssetsType, delAssetsType, addAssetsType, updateAssetsType } from "@/api/base/assetsType";
export default {
name: "AssetsType",
dicts: ['sys_is_del'],
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
assetsTypeList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
parentId: null,
deptId: null,
type: null,
name: null,
unit: null,
isDel: null,
},
//
form: {},
//
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询物资类型列表 */
getList() {
this.loading = true;
listAssetsType(this.queryParams).then(response => {
this.assetsTypeList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
parentId: null,
deptId: null,
type: null,
name: null,
unit: null,
isDel: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: 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
getAssetsType(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) {
updateAssetsType(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addAssetsType(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 delAssetsType(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('base/assetsType/export', {
...this.queryParams
}, `assetsType_${new Date().getTime()}.xlsx`)
}
}
};
</script>