This commit is contained in:
20932067@zju.edu.cn 2021-01-22 21:01:14 +08:00
parent 3b4192b848
commit eb5f3e8884
7 changed files with 209 additions and 175 deletions

View File

@ -55,8 +55,7 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['test:stu:add']" v-hasPermi="['test:stu:add']"
>新增 >新增</el-button>
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -67,8 +66,7 @@
:disabled="single" :disabled="single"
@click="handleUpdate" @click="handleUpdate"
v-hasPermi="['test:stu:edit']" v-hasPermi="['test:stu:edit']"
>修改 >修改</el-button>
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -79,8 +77,7 @@
:disabled="multiple" :disabled="multiple"
@click="handleDelete" @click="handleDelete"
v-hasPermi="['test:stu:remove']" v-hasPermi="['test:stu:remove']"
>删除 >删除</el-button>
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -90,18 +87,17 @@
size="mini" size="mini"
@click="handleExport" @click="handleExport"
v-hasPermi="['test:stu:export']" v-hasPermi="['test:stu:export']"
>导出 >导出</el-button>
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="stuList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="stuList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"/> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id"/> <el-table-column label="id" align="center" prop="id" />
<el-table-column label="学生姓名" align="center" prop="name"/> <el-table-column label="学生姓名" align="center" prop="name" />
<el-table-column label="电话" align="center" prop="tel"/> <el-table-column label="电话" align="center" prop="tel" />
<el-table-column label="电子邮件" align="center" prop="email"/> <el-table-column label="电子邮件" align="center" prop="email" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -110,20 +106,18 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['test:stu:edit']" v-hasPermi="['test:stu:edit']"
>修改 >修改</el-button>
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['test:stu:remove']" v-hasPermi="['test:stu:remove']"
>删除 >删除</el-button>
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
@ -136,13 +130,13 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <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 ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="学生姓名" prop="name"> <el-form-item label="学生姓名" prop="name">
<el-input v-model="form.name" placeholder="请输入学生姓名"/> <el-input v-model="form.name" placeholder="请输入学生姓名" />
</el-form-item> </el-form-item>
<el-form-item label="电话" prop="tel"> <el-form-item label="电话" prop="tel">
<el-input v-model="form.tel" placeholder="请输入电话"/> <el-input v-model="form.tel" placeholder="请输入电话" />
</el-form-item> </el-form-item>
<el-form-item label="电子邮件" prop="email"> <el-form-item label="电子邮件" prop="email">
<el-input v-model="form.email" placeholder="请输入电子邮件"/> <el-input v-model="form.email" placeholder="请输入电子邮件" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
@ -154,173 +148,173 @@
</template> </template>
<script> <script>
import {listStu, getStu, delStu, addStu, updateStu, exportStu} from "@/api/test/stu"; import { listStu, getStu, delStu, addStu, updateStu, exportStu } from "@/api/test/stu";
export default { export default {
name: "Stu", name: "Stu",
components: {}, components: {
data() { },
return { data() {
// return {
loading: true, //
// loading: true,
ids: [], //
// ids: [],
single: true, //
// single: true,
multiple: true, //
// multiple: true,
showSearch: true, //
// showSearch: true,
total: 0, //
// total: 0,
stuList: [], //
// stuList: [],
title: "", //
// title: "",
open: false, //
// open: false,
daterangeCreateTime: [], //
// daterangeCreateTime: [],
queryParams: { //
pageNum: 1, queryParams: {
pageSize: 10, pageNum: 1,
name: null, pageSize: 10,
tel: null, name: null,
email: null, tel: null,
createTime: null email: null,
}, createTime: null,
// },
form: {}, //
// form: {},
rules: { //
name: [ rules: {
{required: true, message: "学生姓名不能为空}", trigger: "blur"}, name: [
], { required: true, message: "学生姓名不能为空}", trigger: "blur" },
tel: [ ],
{required: true, message: "电话不能为空}", trigger: "blur"}, tel: [
{pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger: "blur"}, { required: true, message: "电话不能为空}", trigger: "blur" },
], { pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger:"blur"},
email: [ ],
{required: true, message: "电子邮件不能为空}", trigger: "blur"}, email: [
{ { required: true, message: "电子邮件不能为空}", trigger: "blur" },
pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/, { pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/, message: '电子邮件格式有误', trigger:"blur"},
message: '电子邮件格式有误', ],
trigger: "blur" }
}, };
], },
} created() {
}; this.getList();
},
methods: {
/** 查询学生列表 */
getList() {
this.loading = true;
listStu(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response =>{
this.stuList = response.rows;
this.total = response.total;
this.loading = false;
});
}, },
created() { //
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
name: null,
tel: null,
email: null,
createTime: null,
createBy: null,
updateTime: null,
updateBy: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList(); this.getList();
}, },
methods: { /** 重置按钮操作 */
/** 查询学生列表 */ resetQuery() {
getList() { this.daterangeCreateTime = [];
this.loading = true; this.resetForm("queryForm");
listStu(this.addCreateDateRange(this.queryParams, this.daterangeCreateTime)).then(response => { this.handleQuery();
this.stuList = response.rows; },
this.total = response.total; //
this.loading = false; handleSelectionChange(selection) {
}); this.ids = selection.map(item => item.id)
}, this.single = selection.length!==1
// this.multiple = !selection.length
cancel() { },
this.open = false; /** 新增按钮操作 */
this.reset(); handleAdd() {
}, this.reset();
// this.open = true;
reset() { this.title = "添加学生";
this.form = { },
id: null, /** 修改按钮操作 */
name: null, handleUpdate(row) {
tel: null, this.reset();
email: null, const id = row.id || this.ids
createTime: null getStu(id).then(response => {
}; this.form = response.data;
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.open = true;
this.title = "添加学生"; this.title = "修改学生";
}, });
/** 修改按钮操作 */ },
handleUpdate(row) { /** 提交按钮 */
this.reset(); submitForm() {
const id = row.id || this.ids this.$refs["form"].validate(valid => {
getStu(id).then(response => { if (valid) {
this.form = response.data; if (this.form.id != null) {
this.open = true; updateStu(this.form).then(response => {
this.title = "修改学生"; this.msgSuccess("修改成功");
}); this.open = false;
}, this.getList();
/** 提交按钮 */ });
submitForm() { } else {
this.$refs["form"].validate(valid => { addStu(this.form).then(response => {
if (valid) { this.msgSuccess("新增成功");
if (this.form.id != null) { this.open = false;
updateStu(this.form).then(response => { this.getList();
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; handleDelete(row) {
this.$confirm('是否确认删除学生编号为"' + ids + '"的数据项?', "警告", { const ids = row.id || this.ids;
this.$confirm('是否确认删除学生编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function () { }).then(function() {
return delStu(ids); return delStu(ids);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}) })
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有学生数据项?', "警告", { this.$confirm('是否确认导出所有学生数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function () { }).then(function() {
return exportStu(queryParams); return exportStu(queryParams);
}).then(response => { }).then(response => {
this.download(response.msg); this.download(response.msg);
}) })
}
} }
}; }
};
</script> </script>

View File

@ -5,6 +5,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
@ -48,6 +49,11 @@ public class BaseEntity implements Serializable {
*/ */
private String remark; private String remark;
/**
* 参数
*/
private String parameter;
/** /**
* 开始时间 * 开始时间
*/ */
@ -65,6 +71,15 @@ public class BaseEntity implements Serializable {
*/ */
private Map<String, Object> params; private Map<String, Object> params;
public void setParameter(String parameter) {
if (parameter != null || parameter.equals("")) {
this.parameter = parameter;
JSONObject jsonObject = JSONObject.parseObject(parameter);
params = new HashMap<>();
params.put("",jsonObject.get(""));
}
}
public String getSearchValue() { public String getSearchValue() {
return searchValue; return searchValue;
} }

View File

@ -9,6 +9,10 @@ import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.utils.DateUtils; import com.hchyun.common.utils.DateUtils;
#break #break
#end #end
#if($column.javaField == 'updateBy' || $column.javaField == 'createBy')
import com.hchyun.common.utils.SecurityUtils;
#break
#end
#end #end
import com.hchyun.common.utils.ServerResult; import com.hchyun.common.utils.ServerResult;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -97,7 +101,7 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service {
${className}.setCreateTime(DateUtils.getNowDate()); ${className}.setCreateTime(DateUtils.getNowDate());
#end #end
#if($column.javaField == 'createBy') #if($column.javaField == 'createBy')
${className}.setCreateBy(SecurityUtils.getUserId()); ${className}.setCreateBy(SecurityUtils.getUserId());
#end #end
#end #end
#if($table.sub) #if($table.sub)
@ -134,8 +138,8 @@ public class ${ClassName}ServiceImpl implements ${ClassName}Service {
#if($column.javaField == 'updateTime') #if($column.javaField == 'updateTime')
${className}.setUpdateTime(DateUtils.getNowDate()); ${className}.setUpdateTime(DateUtils.getNowDate());
#end #end
#if($column.javaField == 'createBy') #if($column.javaField == 'updateBy')
${className}.setCreateBy(SecurityUtils.getUserId()); ${className}.setUpdateBy(SecurityUtils.getUserId());
#end #end
#end #end
#if($table.sub) #if($table.sub)

View File

@ -399,7 +399,7 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.query) #if($column.query && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
$column.javaField: null#if($velocityCount != $columns.size()),#end $column.javaField: null#if($velocityCount != $columns.size()),#end
#end #end
@ -488,6 +488,7 @@ export default {
reset() { reset() {
this.form = { this.form = {
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType != "datetime" && $column.queryType != "BETWEEN")
#if($column.htmlType == "radio") #if($column.htmlType == "radio")
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end $column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
@ -497,6 +498,7 @@ export default {
#else #else
$column.javaField: null#if($velocityCount != $columns.size()),#end $column.javaField: null#if($velocityCount != $columns.size()),#end
#end
#end #end
#end #end
}; };

View File

@ -75,6 +75,9 @@ public class Stu extends BaseEntity
.append("tel", getTel()) .append("tel", getTel())
.append("email", getEmail()) .append("email", getEmail())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.toString(); .toString();
} }
} }

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.hchyun.common.constant.ReturnConstants; import com.hchyun.common.constant.ReturnConstants;
import com.hchyun.common.utils.DateUtils; import com.hchyun.common.utils.DateUtils;
import com.hchyun.common.utils.SecurityUtils;
import com.hchyun.common.utils.ServerResult; import com.hchyun.common.utils.ServerResult;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -79,6 +80,7 @@ public class StuServiceImpl implements StuService {
public ServerResult<Integer> insertStu(Stu stu) { public ServerResult<Integer> insertStu(Stu stu) {
try { try {
stu.setCreateTime(DateUtils.getNowDate()); stu.setCreateTime(DateUtils.getNowDate());
stu.setCreateBy(SecurityUtils.getUserId());
Integer renewal = stuDao.insertStu(stu); Integer renewal = stuDao.insertStu(stu);
if (renewal >0){ if (renewal >0){
return new ServerResult<Integer>(true,renewal); return new ServerResult<Integer>(true,renewal);
@ -100,6 +102,8 @@ public class StuServiceImpl implements StuService {
@Override @Override
public ServerResult<Integer> updateStu(Stu stu) { public ServerResult<Integer> updateStu(Stu stu) {
try { try {
stu.setUpdateTime(DateUtils.getNowDate());
stu.setUpdateBy(SecurityUtils.getUserId());
Integer renewal = stuDao.updateStu(stu); Integer renewal = stuDao.updateStu(stu);
if (renewal >0){ if (renewal >0){
return new ServerResult<Integer>(true,renewal); return new ServerResult<Integer>(true,renewal);

View File

@ -10,18 +10,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tel" column="tel" /> <result property="tel" column="tel" />
<result property="email" column="email" /> <result property="email" column="email" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap> </resultMap>
<sql id="selectStuVo"> <sql id="selectStuVo">
select id, name, tel, email, create_time from sys_stu select id, name, tel, email, create_time, create_by, update_time, update_by from sys_stu
</sql> </sql>
<select id="selectStuList" parameterType="Stu" resultMap="StuResult"> <select id="selectStuList" parameterType="Stu" resultMap="StuResult">
<include refid="selectStuVo"/> <include refid="selectStuVo"/>
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="tel != null "> and tel = #{tel}</if> <if test="tel != null "> and tel like concat('%', #{tel}, '%')</if>
<if test="email != null and email != ''"> and email = #{email}</if> <if test="email != null and email != ''"> and email like concat('%', #{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> <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> </where>
</select> </select>
@ -38,12 +41,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tel != null">tel,</if> <if test="tel != null">tel,</if>
<if test="email != null and email != ''">email,</if> <if test="email != null and email != ''">email,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if> <if test="name != null and name != ''">#{name},</if>
<if test="tel != null">#{tel},</if> <if test="tel != null">#{tel},</if>
<if test="email != null and email != ''">#{email},</if> <if test="email != null and email != ''">#{email},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim> </trim>
</insert> </insert>
@ -54,6 +63,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tel != null">tel = #{tel},</if> <if test="tel != null">tel = #{tel},</if>
<if test="email != null and email != ''">email = #{email},</if> <if test="email != null and email != ''">email = #{email},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>