This commit is contained in:
parent
b6fee1744e
commit
b10200e2af
|
|
@ -1,15 +1,6 @@
|
|||
## 开发
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone https://gitee.com/y_project/RuoYi-Vue
|
||||
|
||||
# 进入项目目录
|
||||
cd ruoyi-ui
|
||||
|
||||
# 安装依赖
|
||||
npm install
|
||||
|
||||
# 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
|
||||
npm install --registry=https://registry.npm.taobao.org
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询学生列表
|
||||
export function listStu(query) {
|
||||
return request({
|
||||
url: '/test/stu/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询学生详细
|
||||
export function getStu(id) {
|
||||
return request({
|
||||
url: '/test/stu/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增学生
|
||||
export function addStu(data) {
|
||||
return request({
|
||||
url: '/test/stu',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改学生
|
||||
export function updateStu(data) {
|
||||
return request({
|
||||
url: '/test/stu',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除学生
|
||||
export function delStu(id) {
|
||||
return request({
|
||||
url: '/test/stu/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出学生
|
||||
export function exportStu(query) {
|
||||
return request({
|
||||
url: '/test/stu/export',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ import './assets/icons' // icon
|
|||
import './permission' // permission control
|
||||
import { getDicts } from "@/api/system/dict/data";
|
||||
import { getConfigKey } from "@/api/system/config";
|
||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/hcy";
|
||||
import { parseTime, resetForm, addDateRange, addCreateDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/hcy";
|
||||
import Pagination from "@/components/Pagination";
|
||||
//自定义表格工具扩展
|
||||
import RightToolbar from "@/components/RightToolbar"
|
||||
|
|
@ -30,6 +30,7 @@ Vue.prototype.parseTime = parseTime
|
|||
Vue.prototype.resetForm = resetForm
|
||||
Vue.prototype.addDateRange = addDateRange
|
||||
Vue.prototype.selectDictLabel = selectDictLabel
|
||||
Vue.prototype.addCreateDateRange = addCreateDateRange
|
||||
Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
|
|
|
|||
|
|
@ -64,6 +64,19 @@ export function addDateRange(params, dateRange) {
|
|||
}
|
||||
return search;
|
||||
}
|
||||
// 添加搜索创建时间日期范围
|
||||
export function addCreateDateRange(params, dateRange) {
|
||||
var search = params;
|
||||
search.parameter= {
|
||||
beginCreateTime : "",
|
||||
endCreateTime : "",
|
||||
};
|
||||
if (null != dateRange && '' != dateRange) {
|
||||
search.parameter.beginCreateTime = dateRange[0];
|
||||
search.parameter.endCreateTime = dateRange[1];
|
||||
}
|
||||
return search;
|
||||
}
|
||||
|
||||
// 回显数据字典
|
||||
export function selectDictLabel(datas, value) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,311 @@
|
|||
<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="tel">
|
||||
<el-input
|
||||
v-model="queryParams.tel"
|
||||
placeholder="请输入电话"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="电子邮件" prop="email">
|
||||
<el-input
|
||||
v-model="queryParams.email"
|
||||
placeholder="请输入电子邮件"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间">
|
||||
<el-date-picker
|
||||
v-model="daterangeCreateTime"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-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="['test:stu: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="['test:stu: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="['test:stu: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="['test:stu:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="stuList" @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="name" />
|
||||
<el-table-column label="电话" align="center" prop="tel" />
|
||||
<el-table-column label="电子邮件" align="center" prop="email" />
|
||||
<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="['test:stu:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['test:stu: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="tel">
|
||||
<el-input v-model="form.tel" placeholder="请输入电话" />
|
||||
</el-form-item>
|
||||
<el-form-item label="电子邮件" prop="email">
|
||||
<el-input v-model="form.email" 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 { listStu, getStu, delStu, addStu, updateStu, exportStu } from "@/api/test/stu";
|
||||
|
||||
export default {
|
||||
name: "Stu",
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 学生表格数据
|
||||
stuList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 创建时间时间范围
|
||||
daterangeCreateTime: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null,
|
||||
tel: null,
|
||||
email: null,
|
||||
createTime: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询学生列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
// this.queryParams.params = {};
|
||||
// if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
||||
// this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
|
||||
// this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
|
||||
// }
|
||||
listStu(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response => {
|
||||
this.stuList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
name: null,
|
||||
tel: null,
|
||||
email: null,
|
||||
createTime: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.daterangeCreateTime = [];
|
||||
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
|
||||
getStu(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) {
|
||||
updateStu(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addStu(this.form).then(response => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$confirm('是否确认删除学生编号为"' + ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return delStu(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
})
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm('是否确认导出所有学生数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return exportStu(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -134,7 +134,7 @@ public class RegularController extends HcyBaseController {
|
|||
}
|
||||
ServerResult<Integer> serverResult = regularService.insertRegular(regular);
|
||||
if (serverResult.isStart()) {
|
||||
return toAjax(serverResult.getData());
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ public class RegularController extends HcyBaseController {
|
|||
}
|
||||
ServerResult<Integer> serverResult = regularService.updateRegular(regular);
|
||||
if (serverResult.isStart()) {
|
||||
return toAjax(serverResult.getData());
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ public class RegularController extends HcyBaseController {
|
|||
}
|
||||
ServerResult<Integer> serverResult = regularService.deleteRegularByIds(ids);
|
||||
if (serverResult.isStart()) {
|
||||
return toAjax(serverResult.getData());
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,4 +14,8 @@ public class ReturnConstants {
|
|||
* 数据库异常
|
||||
*/
|
||||
public static final String DB_EX = "数据库异常!";
|
||||
/**
|
||||
* 操作失败
|
||||
*/
|
||||
public static final String SYS_FAILL = "数据库异常!";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,16 +65,16 @@ public class HcyBaseController {
|
|||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows)
|
||||
{
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||
}
|
||||
// /**
|
||||
// * 响应返回结果
|
||||
// *
|
||||
// * @param rows 影响行数
|
||||
// * @return 操作结果
|
||||
// */
|
||||
// protected AjaxResult toAjax(int rows)
|
||||
// {
|
||||
// return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 页面跳转
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ public class ServerResult<T> {
|
|||
this.start = start;
|
||||
this.msg = msg;
|
||||
}
|
||||
public ServerResult(boolean start){
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -307,9 +307,10 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||
for (String tableName : tableNames) {
|
||||
zip = generatorCode(tableName, zip);
|
||||
if (zip==null){
|
||||
return null;
|
||||
}
|
||||
generatorCode(tableName, zip);
|
||||
// if (zip==null){
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
IOUtils.closeQuietly(zip);
|
||||
return outputStream.toByteArray();
|
||||
|
|
|
|||
|
|
@ -184,11 +184,11 @@ public class VelocityUtils
|
|||
}
|
||||
else if (template.contains("dao.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/dao/{}dao.java", javaPath, className);
|
||||
fileName = StringUtils.format("{}/dao/{}Dao.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("service.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
|
||||
fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className);
|
||||
}
|
||||
else if (template.contains("serviceImpl.java.vm"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ gen:
|
|||
# 作者
|
||||
author: hchyun
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: com.hchyun.system
|
||||
packageName: com.hchyun.test
|
||||
# 自动去除表前缀,默认是false
|
||||
autoRemovePre: false
|
||||
autoRemovePre: true
|
||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||
tablePrefix: sys_
|
||||
|
|
@ -1,6 +1,15 @@
|
|||
package ${packageName}.controller;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.core.controller.HcyBaseController;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
|
@ -12,8 +21,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.hchyun.common.annotation.Log;
|
||||
import com.hchyun.common.core.controller.BaseController;
|
||||
import com.hchyun.common.core.domain.AjaxResult;
|
||||
import com.hchyun.common.core.entity.AjaxResult;
|
||||
import com.hchyun.common.enums.BusinessType;
|
||||
import ${packageName}.entity.${ClassName};
|
||||
import ${packageName}.service.${ClassName}Service;
|
||||
|
|
@ -31,8 +39,9 @@ import com.hchyun.common.core.page.TableDataInfo;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${moduleName}/${businessName}")
|
||||
public class ${ClassName}Controller extends BaseController
|
||||
{
|
||||
public class ${ClassName}Controller extends HcyBaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(${ClassName}Controller.class);
|
||||
|
||||
@Autowired
|
||||
private ${ClassName}Service ${className}Service;
|
||||
|
||||
|
|
@ -42,11 +51,19 @@ public class ${ClassName}Controller extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud || $table.sub)
|
||||
public TableDataInfo list(${ClassName} ${className})
|
||||
{
|
||||
public Serializable list(${ClassName} ${className}) {
|
||||
try {
|
||||
startPage();
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
return getDataTable(list);
|
||||
ServerResult<List<${ClassName}>> serverResult = ${className}Service.select${ClassName}List(${className});
|
||||
if (serverResult.isStart()) {
|
||||
return getDataTable(serverResult.getData());
|
||||
} else {
|
||||
return AjaxResult.info(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
#elseif($table.tree)
|
||||
public AjaxResult list(${ClassName} ${className})
|
||||
|
|
@ -62,11 +79,19 @@ public class ${ClassName}Controller extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(${ClassName} ${className})
|
||||
{
|
||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||
public AjaxResult export(${ClassName} ${className}) {
|
||||
try {
|
||||
ServerResult<List<${ClassName}>> serverResult = ${className}Service.select${ClassName}List(${className});
|
||||
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
|
||||
return util.exportExcel(list, "${businessName}");
|
||||
if (serverResult.isStart()) {
|
||||
return util.exportExcel(serverResult.getData(), "${businessName}");
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,9 +99,18 @@ public class ${ClassName}Controller extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
|
||||
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
try {
|
||||
ServerResult<Stu> serverResult = ${className}Service.select${ClassName}ById(${pkColumn.javaField});
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success(serverResult.getData());
|
||||
} else {
|
||||
return AjaxResult.info(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -85,9 +119,18 @@ public class ${ClassName}Controller extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
||||
{
|
||||
return toAjax(${className}Service.insert${ClassName}(${className}));
|
||||
public AjaxResult add(@RequestBody ${ClassName} ${className}) {
|
||||
try {
|
||||
ServerResult<Integer> serverResult = ${className}Service.insert${ClassName}(${className});
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -96,9 +139,18 @@ public class ${ClassName}Controller extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
||||
{
|
||||
return toAjax(${className}Service.update${ClassName}(${className}));
|
||||
public AjaxResult edit(@RequestBody ${ClassName} ${className}) {
|
||||
try {
|
||||
ServerResult<Integer> serverResult = ${className}Service.update${ClassName}(${className});
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -107,8 +159,17 @@ public class ${ClassName}Controller extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||
{
|
||||
return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
|
||||
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
||||
try {
|
||||
ServerResult<Integer> serverResult = ${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public interface ${ClassName}Dao
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
|
|
@ -28,7 +28,7 @@ public interface ${ClassName}Dao
|
|||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
|
|
@ -36,7 +36,7 @@ public interface ${ClassName}Dao
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
int insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
|
|
@ -44,7 +44,7 @@ public interface ${ClassName}Dao
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
int update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
|
|
@ -52,7 +52,7 @@ public interface ${ClassName}Dao
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
|
|
@ -69,7 +69,7 @@ public interface ${ClassName}Dao
|
|||
* @param customerIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 批量新增${subTable.functionName}
|
||||
|
|
@ -77,7 +77,7 @@ public interface ${ClassName}Dao
|
|||
* @param ${subclassName}List ${subTable.functionName}列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||
int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -86,6 +86,6 @@ public interface ${ClassName}Dao
|
|||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
#end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@ package ${packageName}.entity;
|
|||
import ${import};
|
||||
#end
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
#if($table.crud || $table.sub)
|
||||
#set($Entity="BaseEntity")
|
||||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
import com.hchyun.common.core.entity.${Entity};
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
#if($table.crud || $table.sub)
|
||||
#elseif($table.tree)
|
||||
#end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package ${packageName}.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import ${packageName}.entity.${ClassName};
|
||||
|
||||
/**
|
||||
|
|
@ -17,7 +19,7 @@ public interface ${ClassName}Service
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return ${functionName}
|
||||
*/
|
||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
ServerResult<${ClassName}> select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
|
|
@ -25,7 +27,7 @@ public interface ${ClassName}Service
|
|||
* @param ${className} ${functionName}
|
||||
* @return ${functionName}集合
|
||||
*/
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||
ServerResult<List<${ClassName}>> select${ClassName}List(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
|
|
@ -33,7 +35,7 @@ public interface ${ClassName}Service
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int insert${ClassName}(${ClassName} ${className});
|
||||
ServerResult<Integer> insert${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
|
|
@ -41,7 +43,7 @@ public interface ${ClassName}Service
|
|||
* @param ${className} ${functionName}
|
||||
* @return 结果
|
||||
*/
|
||||
public int update${ClassName}(${ClassName} ${className});
|
||||
ServerResult<Integer> update${ClassName}(${ClassName} ${className});
|
||||
|
||||
/**
|
||||
* 批量删除${functionName}
|
||||
|
|
@ -49,7 +51,7 @@ public interface ${ClassName}Service
|
|||
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
ServerResult<Integer> delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||
|
||||
/**
|
||||
* 删除${functionName}信息
|
||||
|
|
@ -57,5 +59,5 @@ public interface ${ClassName}Service
|
|||
* @param ${pkColumn.javaField} ${functionName}ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
ServerResult<Integer> delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
package ${packageName}.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
||||
import com.hchyun.common.utils.DateUtils;
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
#if($table.sub)
|
||||
|
|
@ -17,7 +23,7 @@ import ${packageName}.entity.${subClassName};
|
|||
#end
|
||||
import ${packageName}.dao.${ClassName}Dao;
|
||||
import ${packageName}.entity.${ClassName};
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
import ${packageName}.service.${ClassName}Service;
|
||||
|
||||
/**
|
||||
* ${functionName}Service业务层处理
|
||||
|
|
@ -26,8 +32,9 @@ import ${packageName}.service.I${ClassName}Service;
|
|||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
||||
{
|
||||
public class ${ClassName}ServiceImpl implements ${ClassName}Service {
|
||||
private Logger logger = LoggerFactory.getLogger(${ClassName}ServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private ${ClassName}Dao ${className}Dao;
|
||||
|
||||
|
|
@ -38,9 +45,18 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
|||
* @return ${functionName}
|
||||
*/
|
||||
@Override
|
||||
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
return ${className}Dao.select${ClassName}ById(${pkColumn.javaField});
|
||||
public ServerResult<${ClassName}> select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
try {
|
||||
${ClassName} ${className} = ${className}Dao.select${ClassName}ById(${pkColumn.javaField});
|
||||
if (stu != null){
|
||||
return new ServerResult<${ClassName}>(true,${className});
|
||||
}else {
|
||||
return new ServerResult<${ClassName}>(false, ReturnConstants.RESULT_EMPTY);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<${ClassName}>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,9 +66,18 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
|||
* @return ${functionName}
|
||||
*/
|
||||
@Override
|
||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
|
||||
{
|
||||
return ${className}Dao.select${ClassName}List(${className});
|
||||
public ServerResult<List<${ClassName}>> select${ClassName}List(${ClassName} ${className}) {
|
||||
try {
|
||||
List<${ClassName}> ${className}List = ${className}Dao.select${ClassName}List(${className});
|
||||
if (${className}List.size()>0){
|
||||
return new ServerResult<List<${ClassName}>>(true,${className}List);
|
||||
}else {
|
||||
return new ServerResult<List<${ClassName}>>(false,ReturnConstants.RESULT_EMPTY);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<List<${ClassName}>>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,20 +90,32 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
|||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int insert${ClassName}(${ClassName} ${className})
|
||||
{
|
||||
public ServerResult<Integer> insert${ClassName}(${ClassName} ${className}) {
|
||||
try {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'createTime')
|
||||
${className}.setCreateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#if($column.javaField == 'createBy')
|
||||
${className}.setCreateBy(SecurityUtils.getUserId());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
int rows = ${className}Dao.insert${ClassName}(${className});
|
||||
insert${subClassName}(${className});
|
||||
return rows;
|
||||
#else
|
||||
return ${className}Dao.insert${ClassName}(${className});
|
||||
Integer renewal = ${className}Dao.insert${ClassName}(${className});
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
#end
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -91,18 +128,30 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
|||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int update${ClassName}(${ClassName} ${className})
|
||||
{
|
||||
public ServerResult<Integer> update${ClassName}(${ClassName} ${className}) {
|
||||
try {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField == 'updateTime')
|
||||
${className}.setUpdateTime(DateUtils.getNowDate());
|
||||
#end
|
||||
#if($column.javaField == 'createBy')
|
||||
${className}.setCreateBy(SecurityUtils.getUserId());
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
${className}Dao.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||
insert${subClassName}(${className});
|
||||
#end
|
||||
return ${className}Dao.update${ClassName}(${className});
|
||||
Integer renewal = ${className}Dao.update${ClassName}(${className});
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -115,12 +164,21 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
|||
@Transactional
|
||||
#end
|
||||
@Override
|
||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||
{
|
||||
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
||||
try {
|
||||
#if($table.sub)
|
||||
${className}Dao.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||
#end
|
||||
return ${className}Dao.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
||||
Integer renewal = ${className}Dao.delete${ClassName}ByIds(${pkColumn.javaField}s);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -130,12 +188,21 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField})
|
||||
{
|
||||
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
try {
|
||||
#if($table.sub)
|
||||
${className}Dao.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||
#end
|
||||
return ${className}Dao.delete${ClassName}ById(${pkColumn.javaField});
|
||||
Integer renewal = ${className}Dao.delete${ClassName}ById(${pkColumn.javaField});
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
#if($table.sub)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,35 @@
|
|||
-- 菜单 SQL
|
||||
|
||||
delete from sys_menu where perms= '${permissionPrefix}:list';
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', ${createBy}, sysdate(), 0, null, '${functionName}菜单');
|
||||
|
||||
-- 按钮父菜单ID
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
delete from sys_menu where perms= '${permissionPrefix}:query';
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', ${createBy}, sysdate(), 0, null, '');
|
||||
|
||||
delete from sys_menu where perms = '${permissionPrefix}:add';
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', ${createBy}, sysdate(), 0, null, '');
|
||||
|
||||
delete from sys_menu where perms = '${permissionPrefix}:edit';
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', ${createBy}, sysdate(), 0, null, '');
|
||||
|
||||
delete from sys_menu where perms = '${permissionPrefix}:remove';
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', ${createBy}, sysdate(), 0, null, '');
|
||||
|
||||
delete from sys_menu where perms = '${permissionPrefix}:export';
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', ${createBy}, sysdate(), 0, null, '');
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${packageName}.dao.${ClassName}Mapper">
|
||||
<mapper namespace="${packageName}.dao.${ClassName}Dao">
|
||||
|
||||
<resultMap type="${ClassName}" id="${ClassName}Result">
|
||||
#foreach ($column in $columns)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,162 @@
|
|||
package com.hchyun.test.controller;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.core.controller.HcyBaseController;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.hchyun.common.annotation.Log;
|
||||
import com.hchyun.common.core.entity.AjaxResult;
|
||||
import com.hchyun.common.enums.BusinessType;
|
||||
import com.hchyun.test.entity.Stu;
|
||||
import com.hchyun.test.service.StuService;
|
||||
import com.hchyun.common.utils.poi.ExcelUtil;
|
||||
|
||||
/**
|
||||
* 学生Controller
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test/stu")
|
||||
public class StuController extends HcyBaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(StuController.class);
|
||||
|
||||
@Autowired
|
||||
private StuService stuService;
|
||||
|
||||
/**
|
||||
* 查询学生列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('test:stu:list')")
|
||||
@GetMapping("/list")
|
||||
public Serializable list(Stu stu) {
|
||||
try {
|
||||
startPage();
|
||||
ServerResult<List<Stu>> serverResult = stuService.selectStuList(stu);
|
||||
if (serverResult.isStart()) {
|
||||
return getDataTable(serverResult.getData());
|
||||
} else {
|
||||
return AjaxResult.info(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出学生列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('test:stu:export')")
|
||||
@Log(title = "学生", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(Stu stu) {
|
||||
try {
|
||||
ServerResult<List<Stu>> serverResult = stuService.selectStuList(stu);
|
||||
ExcelUtil<Stu> util = new ExcelUtil<Stu>(Stu. class);
|
||||
if (serverResult.isStart()) {
|
||||
return util.exportExcel(serverResult.getData(), "stu");
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学生详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('test:stu:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
try {
|
||||
ServerResult<Stu> serverResult = stuService.selectStuById(id);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success(serverResult.getData());
|
||||
} else {
|
||||
return AjaxResult.info(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增学生
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('test:stu:add')")
|
||||
@Log(title = "学生", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Stu stu) {
|
||||
try {
|
||||
ServerResult<Integer> serverResult = stuService.insertStu(stu);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改学生
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('test:stu:edit')")
|
||||
@Log(title = "学生", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Stu stu) {
|
||||
try {
|
||||
ServerResult<Integer> serverResult = stuService.updateStu(stu);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学生
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('test:stu:remove')")
|
||||
@Log(title = "学生", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
try {
|
||||
ServerResult<Integer> serverResult = stuService.deleteStuByIds(ids);
|
||||
if (serverResult.isStart()) {
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.hchyun.test.dao;
|
||||
|
||||
import java.util.List;
|
||||
import com.hchyun.test.entity.Stu;
|
||||
|
||||
/**
|
||||
* 学生Mapper接口
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
*/
|
||||
public interface StuDao
|
||||
{
|
||||
/**
|
||||
* 查询学生
|
||||
*
|
||||
* @param id 学生ID
|
||||
* @return 学生
|
||||
*/
|
||||
Stu selectStuById(Long id);
|
||||
|
||||
/**
|
||||
* 查询学生列表
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 学生集合
|
||||
*/
|
||||
List<Stu> selectStuList(Stu stu);
|
||||
|
||||
/**
|
||||
* 新增学生
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 结果
|
||||
*/
|
||||
int insertStu(Stu stu);
|
||||
|
||||
/**
|
||||
* 修改学生
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 结果
|
||||
*/
|
||||
int updateStu(Stu stu);
|
||||
|
||||
/**
|
||||
* 删除学生
|
||||
*
|
||||
* @param id 学生ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteStuById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除学生
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteStuByIds(Long[] ids);
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package com.hchyun.test.entity;
|
||||
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
import com.hchyun.common.core.entity.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 学生对象 sys_stu
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
*/
|
||||
public class Stu extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
private Long id;
|
||||
|
||||
/** 学生姓名 */
|
||||
@Excel(name = "学生姓名")
|
||||
private String name;
|
||||
|
||||
/** 电话 */
|
||||
@Excel(name = "电话")
|
||||
private Long tel;
|
||||
|
||||
/** 电子邮件 */
|
||||
@Excel(name = "电子邮件")
|
||||
private String email;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setTel(Long tel)
|
||||
{
|
||||
this.tel = tel;
|
||||
}
|
||||
|
||||
public Long getTel()
|
||||
{
|
||||
return tel;
|
||||
}
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("tel", getTel())
|
||||
.append("email", getEmail())
|
||||
.append("createTime", getCreateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.hchyun.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.test.entity.Stu;
|
||||
|
||||
/**
|
||||
* 学生Service接口
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
*/
|
||||
public interface StuService
|
||||
{
|
||||
/**
|
||||
* 查询学生
|
||||
*
|
||||
* @param id 学生ID
|
||||
* @return 学生
|
||||
*/
|
||||
ServerResult<Stu> selectStuById(Long id);
|
||||
|
||||
/**
|
||||
* 查询学生列表
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 学生集合
|
||||
*/
|
||||
ServerResult<List<Stu>> selectStuList(Stu stu);
|
||||
|
||||
/**
|
||||
* 新增学生
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 结果
|
||||
*/
|
||||
ServerResult<Integer> insertStu(Stu stu);
|
||||
|
||||
/**
|
||||
* 修改学生
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 结果
|
||||
*/
|
||||
ServerResult<Integer> updateStu(Stu stu);
|
||||
|
||||
/**
|
||||
* 批量删除学生
|
||||
*
|
||||
* @param ids 需要删除的学生ID
|
||||
* @return 结果
|
||||
*/
|
||||
ServerResult<Integer> deleteStuByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除学生信息
|
||||
*
|
||||
* @param id 学生ID
|
||||
* @return 结果
|
||||
*/
|
||||
ServerResult<Integer> deleteStuById(Long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
package com.hchyun.test.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.utils.DateUtils;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.hchyun.test.dao.StuDao;
|
||||
import com.hchyun.test.entity.Stu;
|
||||
import com.hchyun.test.service.StuService;
|
||||
|
||||
/**
|
||||
* 学生Service业务层处理
|
||||
*
|
||||
* @author hchyun
|
||||
* @date 2021-01-22
|
||||
*/
|
||||
@Service
|
||||
public class StuServiceImpl implements StuService {
|
||||
private Logger logger = LoggerFactory.getLogger(StuServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private StuDao stuDao;
|
||||
|
||||
/**
|
||||
* 查询学生
|
||||
*
|
||||
* @param id 学生ID
|
||||
* @return 学生
|
||||
*/
|
||||
@Override
|
||||
public ServerResult<Stu> selectStuById(Long id) {
|
||||
try {
|
||||
Stu stu = stuDao.selectStuById(id);
|
||||
if (stu != null){
|
||||
return new ServerResult<Stu>(true,stu);
|
||||
}else {
|
||||
return new ServerResult<Stu>(false, ReturnConstants.RESULT_EMPTY);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Stu>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询学生列表
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 学生
|
||||
*/
|
||||
@Override
|
||||
public ServerResult<List<Stu>> selectStuList(Stu stu) {
|
||||
try {
|
||||
List<Stu> stuList = stuDao.selectStuList(stu);
|
||||
if (stuList.size()>0){
|
||||
return new ServerResult<List<Stu>>(true,stuList);
|
||||
}else {
|
||||
return new ServerResult<List<Stu>>(false,ReturnConstants.RESULT_EMPTY);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<List<Stu>>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增学生
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public ServerResult<Integer> insertStu(Stu stu) {
|
||||
try {
|
||||
stu.setCreateTime(DateUtils.getNowDate());
|
||||
Integer renewal = stuDao.insertStu(stu);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改学生
|
||||
*
|
||||
* @param stu 学生
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public ServerResult<Integer> updateStu(Stu stu) {
|
||||
try {
|
||||
Integer renewal = stuDao.updateStu(stu);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除学生
|
||||
*
|
||||
* @param ids 需要删除的学生ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public ServerResult<Integer> deleteStuByIds(Long[] ids) {
|
||||
try {
|
||||
Integer renewal = stuDao.deleteStuByIds(ids);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学生信息
|
||||
*
|
||||
* @param id 学生ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public ServerResult<Integer> deleteStuById(Long id) {
|
||||
try {
|
||||
Integer renewal = stuDao.deleteStuById(id);
|
||||
if (renewal >0){
|
||||
return new ServerResult<Integer>(true,renewal);
|
||||
}else {
|
||||
return new ServerResult<Integer>(false,ReturnConstants.SYS_FAILL);
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return new ServerResult<Integer>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<?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.hchyun.test.dao.StuDao">
|
||||
|
||||
<resultMap type="Stu" id="StuResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="tel" column="tel" />
|
||||
<result property="email" column="email" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectStuVo">
|
||||
select id, name, tel, email, create_time from sys_stu
|
||||
</sql>
|
||||
|
||||
<select id="selectStuList" parameterType="Stu" resultMap="StuResult">
|
||||
<include refid="selectStuVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="tel != null "> and tel = #{tel}</if>
|
||||
<if test="email != null and email != ''"> and email = #{email}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectStuById" parameterType="Long" resultMap="StuResult">
|
||||
<include refid="selectStuVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertStu" parameterType="Stu" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into sys_stu
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">name,</if>
|
||||
<if test="tel != null">tel,</if>
|
||||
<if test="email != null">email,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="tel != null">#{tel},</if>
|
||||
<if test="email != null">#{email},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateStu" parameterType="Stu">
|
||||
update sys_stu
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="tel != null">tel = #{tel},</if>
|
||||
<if test="email != null">email = #{email},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteStuById" parameterType="Long">
|
||||
delete from sys_stu where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteStuByIds" parameterType="String">
|
||||
delete from sys_stu where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue