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,16 +106,14 @@
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>
@ -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,11 +148,12 @@
</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() { data() {
return { return {
// //
@ -188,26 +183,22 @@
name: null, name: null,
tel: null, tel: null,
email: null, email: null,
createTime: null createTime: null,
}, },
// //
form: {}, form: {},
// //
rules: { rules: {
name: [ name: [
{required: true, message: "学生姓名不能为空}", trigger: "blur"}, { required: true, message: "学生姓名不能为空}", trigger: "blur" },
], ],
tel: [ tel: [
{required: true, message: "电话不能为空}", trigger: "blur"}, { required: true, message: "电话不能为空}", trigger: "blur" },
{pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger: "blur"}, { pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger:"blur"},
], ],
email: [ email: [
{required: true, message: "电子邮件不能为空}", trigger: "blur"}, { required: true, message: "电子邮件不能为空}", trigger: "blur" },
{ { pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/, message: '电子邮件格式有误', trigger:"blur"},
pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
message: '电子邮件格式有误',
trigger: "blur"
},
], ],
} }
}; };
@ -219,7 +210,7 @@
/** 查询学生列表 */ /** 查询学生列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listStu(this.addCreateDateRange(this.queryParams, this.daterangeCreateTime)).then(response => { listStu(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response =>{
this.stuList = response.rows; this.stuList = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
@ -237,7 +228,10 @@
name: null, name: null,
tel: null, tel: null,
email: null, email: null,
createTime: null createTime: null,
createBy: null,
updateTime: null,
updateBy: null
}; };
this.resetForm("form"); this.resetForm("form");
}, },
@ -255,7 +249,7 @@
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.id) this.ids = selection.map(item => item.id)
this.single = selection.length !== 1 this.single = selection.length!==1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
@ -301,7 +295,7 @@
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function () { }).then(function() {
return delStu(ids); return delStu(ids);
}).then(() => { }).then(() => {
this.getList(); this.getList();
@ -315,12 +309,12 @@
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;
@ -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>