This commit is contained in:
20932067@zju.edu.cn 2021-01-22 18:28:46 +08:00
parent 8bdf414948
commit 3b4192b848
5 changed files with 206 additions and 162 deletions

View File

@ -55,7 +55,8 @@
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
@ -66,7 +67,8 @@
: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
@ -77,7 +79,8 @@
: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
@ -87,7 +90,8 @@
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>
@ -106,14 +110,16 @@
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>
@ -152,8 +158,7 @@ import { listStu, getStu, delStu, addStu, updateStu, exportStu } from "@/api/tes
export default { export default {
name: "Stu", name: "Stu",
components: { components: {},
},
data() { data() {
return { return {
// //
@ -189,6 +194,21 @@ export default {
form: {}, form: {},
// //
rules: { rules: {
name: [
{required: true, message: "学生姓名不能为空}", trigger: "blur"},
],
tel: [
{required: true, message: "电话不能为空}", trigger: "blur"},
{pattern: /^1[0-9]{10}$/, message: '电话格式有误', trigger: "blur"},
],
email: [
{required: true, message: "电子邮件不能为空}", trigger: "blur"},
{
pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
message: '电子邮件格式有误',
trigger: "blur"
},
],
} }
}; };
}, },
@ -199,11 +219,6 @@ export default {
/** 查询学生列表 */ /** 查询学生列表 */
getList() { getList() {
this.loading = true; 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 => { 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;

View File

@ -192,9 +192,6 @@ public class GenTableServiceImpl implements IGenTableService {
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory()); List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
for (String template : templates) { for (String template : templates) {
// 渲染模板 // 渲染模板
if (template.equals("")){
}
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8); Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw); tpl.merge(context, sw);

View File

@ -135,6 +135,11 @@ public class ${ClassName}Controller extends HcyBaseController {
return AjaxResult.error("${column.columnComment}不能为空!"); return AjaxResult.error("${column.columnComment}不能为空!");
} }
#end #end
#if($column.isRegular != 1)
if (!Pattern.matches("${column.regular}",${className}.get${AttrName}())){
return AjaxResult.error("${column.columnComment}格式错误!");
}
#end
#end #end
try { try {
ServerResult<Integer> serverResult = ${className}Service.insert${ClassName}(${className}); ServerResult<Integer> serverResult = ${className}Service.insert${ClassName}(${className});
@ -173,6 +178,11 @@ public class ${ClassName}Controller extends HcyBaseController {
return AjaxResult.error("${column.columnComment}不能为空!"); return AjaxResult.error("${column.columnComment}不能为空!");
} }
#end #end
#if($column.isRegular != 1)
if (!Pattern.matches("${column.regular}",${className}.get${AttrName}())){
return AjaxResult.error("${column.columnComment}格式错误!");
}
#end
#end #end
ServerResult<Integer> serverResult = ${className}Service.update${ClassName}(${className}); ServerResult<Integer> serverResult = ${className}Service.update${ClassName}(${className});
if (serverResult.isStart()) { if (serverResult.isStart()) {
@ -194,6 +204,9 @@ public class ${ClassName}Controller extends HcyBaseController {
@DeleteMapping("/{${pkColumn.javaField}s}") @DeleteMapping("/{${pkColumn.javaField}s}")
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
try { try {
if (${pkColumn.javaField}s.length<0){
return AjaxResult.error("id不能为空!");
}
ServerResult<Integer> serverResult = ${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s); ServerResult<Integer> serverResult = ${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s);
if (serverResult.isStart()) { if (serverResult.isStart()) {
return AjaxResult.success(); return AjaxResult.success();

View File

@ -418,7 +418,10 @@ export default {
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
$column.javaField: [ $column.javaField: [
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end } { required: true, message: "${comment}不能为空}", trigger: #if($column.htmlType == "select")"change"#else"blur"#end },
#if($column.isRegular != 1)
{ pattern: /${column.regular}/, message: '${column.columnComment}格式有误', trigger:"blur"},
#end
]#if($velocityCount != $columns.size()),#end ]#if($velocityCount != $columns.size()),#end
#end #end
@ -442,20 +445,21 @@ export default {
this.loading = true; this.loading = true;
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
this.queryParams.params = {};
#break #break
#end #end
#end #end
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($VariableName= "daterange"+$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) { #set($variable = true)
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0]; #break
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
}
#end #end
#end #end
#if($variable)
list${BusinessName}(this.addCreateDateRange(this.queryParams,this.$VariableName)).then(response =>{
#else
list${BusinessName}(this.queryParams).then(response => { list${BusinessName}(this.queryParams).then(response => {
#end
this.${businessName}List = response.rows; this.${businessName}List = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;

View File

@ -115,9 +115,15 @@ public class StuController extends HcyBaseController {
if (stu.getTel() == null || stu.getTel()<0) { if (stu.getTel() == null || stu.getTel()<0) {
return AjaxResult.error("电话不能为空!"); return AjaxResult.error("电话不能为空!");
} }
if (!Pattern.matches("^1[0-9]{10}$",String.valueOf(stu.getTel()))){
return AjaxResult.error("电话格式错误!");
}
if (stu.getEmail() == null || stu.getEmail().equals("")) { if (stu.getEmail() == null || stu.getEmail().equals("")) {
return AjaxResult.error("电子邮件不能为空!"); return AjaxResult.error("电子邮件不能为空!");
} }
if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",stu.getEmail())){
return AjaxResult.error("电子邮件格式错误!");
}
try { try {
ServerResult<Integer> serverResult = stuService.insertStu(stu); ServerResult<Integer> serverResult = stuService.insertStu(stu);
if (serverResult.isStart()) { if (serverResult.isStart()) {
@ -146,9 +152,15 @@ public class StuController extends HcyBaseController {
if (stu.getTel() == null || stu.getTel()<0) { if (stu.getTel() == null || stu.getTel()<0) {
return AjaxResult.error("电话不能为空!"); return AjaxResult.error("电话不能为空!");
} }
if (!Pattern.matches("^1[0-9]{10}$",String.valueOf(stu.getTel()))){
return AjaxResult.error("电话格式错误!");
}
if (stu.getEmail() == null || stu.getEmail().equals("")) { if (stu.getEmail() == null || stu.getEmail().equals("")) {
return AjaxResult.error("电子邮件不能为空!"); return AjaxResult.error("电子邮件不能为空!");
} }
if (!Pattern.matches("^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",stu.getEmail())){
return AjaxResult.error("电子邮件格式错误!");
}
ServerResult<Integer> serverResult = stuService.updateStu(stu); ServerResult<Integer> serverResult = stuService.updateStu(stu);
if (serverResult.isStart()) { if (serverResult.isStart()) {
return AjaxResult.success(); return AjaxResult.success();
@ -169,6 +181,9 @@ public class StuController extends HcyBaseController {
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
try { try {
if (ids.length<0){
return AjaxResult.error("id不能为空!");
}
ServerResult<Integer> serverResult = stuService.deleteStuByIds(ids); ServerResult<Integer> serverResult = stuService.deleteStuByIds(ids);
if (serverResult.isStart()) { if (serverResult.isStart()) {
return AjaxResult.success(); return AjaxResult.success();