mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-26 05:48:33 +08:00
1.一些fix,关于封装工具类以及layui模板优化等.<br> 2.优化表备注的获取逻辑.<br> 3.生成时间格式改为yyyy-MM-dd,移除具体的时间,只保留日期
This commit is contained in:
parent
a4f72c80dd
commit
83f15b4034
@ -14,9 +14,9 @@
|
||||
# Advantage
|
||||
- 支持DDL SQL/INSERT SQL/SIMPLE JSON生成模式
|
||||
- 自动记忆最近生成的内容,最多保留9个
|
||||
- 支持特殊字符模板(`#`请用`井`代替;`$`请用`¥`代替)
|
||||
- 提供众多通用模板,易于使用,复制粘贴加简单修改即可完成CRUD操作
|
||||
|
||||
- 支持特殊字符模板(`#`请用`井`代替;`$`请用`¥`代替)
|
||||
- 根据comment=(mysql)或者comment on table(pgsql/oracle)生成类名注释
|
||||
|
||||
# Url
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
|
||||
|更新日期|更新内容|
|
||||
|----|----|
|
||||
|20200525|1.一些fix,关于封装工具类以及layui模板优化等.<br> 2.优化表备注的获取逻辑.<br> 3.生成时间格式改为yyyy-MM-dd,移除具体的时间,只保留日期|
|
||||
|20200522|1.新增insert-sql模式,支持对"insert into table (xxx) values (xxx)"语句进行处理,生成java代码(感谢三叔的建议).|
|
||||
|20200517|1.代码重构!异常处理优化,Freemarker相关工具类优化,简化模板生成部分,通过template.json来配置需要生成的模板,不需要配置java文件.<br> 2.修复包含comment关键字时注释无法识别的问题.(感谢@1nchaos的反馈).<br> 3.赞赏优化,感谢大家的赞赏.<br> 4.新增mapper2(Mybatis-Annotation模板)(感谢@baisi525和@CHKEGit的建议).|
|
||||
|20200503|1.优化对特殊字符的处理,对于包含#和$等特殊字符的,在模板使用井和¥代替便可,escapeString方法会自动处理.<br> 2.优化mybatisplus实体类相关(感谢@chunchengmeigui的反馈).<br> 3.修优化对所有类型的判断(感谢@cnlw的反馈).<br> 4.移除swagger-entity,该功能已经包含在‘swagger-ui’的下拉选项中 <br> 5.升级hutool和lombok版本|
|
||||
|
||||
@ -14,7 +14,7 @@ public class GlobalDefaultExceptionHandler {
|
||||
@ResponseBody
|
||||
public ReturnT defaultExceptionHandler(HttpServletRequest req,Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
|
||||
return ReturnT.ERROR(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -34,10 +34,10 @@ public class IndexController {
|
||||
|
||||
@PostMapping("/genCode")
|
||||
@ResponseBody
|
||||
public ReturnT<Map<String, String>> codeGenerate(@RequestBody ParamInfo paramInfo ) throws Exception {
|
||||
public ReturnT codeGenerate(@RequestBody ParamInfo paramInfo ) throws Exception {
|
||||
|
||||
if (paramInfo.getTableSql().trim().length()<1) {
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE, "表结构信息不可为空");
|
||||
return ReturnT.ERROR("表结构信息不可为空");
|
||||
}
|
||||
|
||||
//1.Parse Table Structure 表结构解析
|
||||
@ -68,7 +68,7 @@ public class IndexController {
|
||||
//3.generate the code by freemarker template and param . Freemarker根据参数和模板生成代码
|
||||
Map<String, String> result = generatorService.getResultByParams(params);
|
||||
|
||||
return new ReturnT<>(result);
|
||||
return ReturnT.SUCCESS(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,29 +5,61 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* common return
|
||||
* @author xuxueli 2015-12-4 16:32:31
|
||||
* common returnT:公共返回封装类
|
||||
* @author zhengkai.blog.csdn.net
|
||||
*/
|
||||
@Data
|
||||
public class ReturnT<T> implements Serializable {
|
||||
public class ReturnT implements Serializable {
|
||||
public static final long serialVersionUID = 42L;
|
||||
|
||||
public static final int SUCCESS_CODE = 200;
|
||||
public static final int FAIL_CODE = 500;
|
||||
public static final ReturnT<String> SUCCESS = new ReturnT<>(null);
|
||||
public static final ReturnT<String> FAIL = new ReturnT<>(FAIL_CODE, null);
|
||||
|
||||
public static final int PAGE_CODE = 0;
|
||||
public static final String OBJECT_NOT_FOUND = "找不到该对象";
|
||||
public static final String OPERATION_SUCCESS = "操作成功";
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
private Object data;
|
||||
private int count;
|
||||
|
||||
public ReturnT(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
public ReturnT(T data) {
|
||||
public ReturnT(int code, String msg,Object data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
public ReturnT(Object data) {
|
||||
this.code = SUCCESS_CODE;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ReturnT( Object data , int count ) {
|
||||
this.code = PAGE_CODE;
|
||||
this.data = data;
|
||||
this.count = count;
|
||||
}
|
||||
public static ReturnT PAGE( Object data , int count){
|
||||
return new ReturnT(data,count);
|
||||
}
|
||||
public static ReturnT PAGE( Object data , long count){
|
||||
return new ReturnT(data,Integer.parseInt(count+""));
|
||||
}
|
||||
public static ReturnT SUCCESS(){
|
||||
return new ReturnT(SUCCESS_CODE,OPERATION_SUCCESS);
|
||||
}
|
||||
public static ReturnT SUCCESS(String msg){
|
||||
return new ReturnT(SUCCESS_CODE,msg);
|
||||
}
|
||||
public static ReturnT SUCCESS(Object data){
|
||||
return new ReturnT(data);
|
||||
}
|
||||
public static ReturnT ERROR(String msg){
|
||||
return new ReturnT(FAIL_CODE,msg);
|
||||
}
|
||||
public static ReturnT ERROR(){
|
||||
return new ReturnT(FAIL_CODE,OBJECT_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,28 +80,17 @@ public class TableParseUtil {
|
||||
// class Comment
|
||||
String classComment = null;
|
||||
//mysql是comment=,pgsql/oracle是comment on table,
|
||||
if (tableSql.contains("comment=")) {
|
||||
String classCommentTmp = tableSql.substring(tableSql.lastIndexOf("comment=")+8).replaceAll("`","").trim();
|
||||
if (classCommentTmp.indexOf(" ")!=classCommentTmp.lastIndexOf(" ")) {
|
||||
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf(" ")+1, classCommentTmp.lastIndexOf(" "));
|
||||
}
|
||||
if (classCommentTmp!=null && classCommentTmp.trim().length()>0) {
|
||||
classComment = classCommentTmp;
|
||||
}else{
|
||||
//修复表备注为空问题
|
||||
classComment = className;
|
||||
}
|
||||
}else if(tableSql.contains("comment on table")) {
|
||||
//COMMENT ON TABLE CT_BAS_FEETYPE IS 'CT_BAS_FEETYPE';
|
||||
String classCommentTmp = tableSql.substring(tableSql.lastIndexOf("comment on table")+17).trim();
|
||||
//证明这是一个常规的COMMENT ON TABLE xxx IS 'xxxx'
|
||||
//2020-05-25 优化表备注的获取逻辑
|
||||
if (tableSql.contains("comment=")||tableSql.contains("comment on table")) {
|
||||
String classCommentTmp = (tableSql.contains("comment="))?
|
||||
tableSql.substring(tableSql.lastIndexOf("comment=")+8).trim():tableSql.substring(tableSql.lastIndexOf("comment on table")+17).trim();
|
||||
if (classCommentTmp.contains("`")) {
|
||||
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf("`")+1);
|
||||
classCommentTmp = classCommentTmp.substring(0,classCommentTmp.indexOf("`"));
|
||||
classComment = classCommentTmp;
|
||||
}else{
|
||||
//非常规的没法分析
|
||||
classComment = tableName;
|
||||
classComment = className;
|
||||
}
|
||||
}else{
|
||||
//修复表备注为空问题
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${classInfo.className?uncap_first}")
|
||||
|
||||
@ -6,7 +6,7 @@ import java.util.List;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Data<#if swagger?exists && swagger==true>
|
||||
@ApiModel("${classInfo.classComment}")</#if>
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.List;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
public interface I${classInfo.className}DAO {
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import java.util.List;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Repository
|
||||
public class ${classInfo.className}DaoImpl implements I${classInfo.className}Dao{
|
||||
|
||||
@ -15,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
|
||||
@ -17,7 +17,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${classInfo.className?uncap_first}")
|
||||
|
||||
@ -16,7 +16,7 @@ import org.springframework.stereotype.Repository;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Repository
|
||||
public interface ${classInfo.className}Repository extends JpaRepository<${classInfo.className},Integer> {
|
||||
|
||||
@ -20,7 +20,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -37,17 +37,17 @@ public class ${classInfo.className}Controller {
|
||||
public Object save(@RequestBody ${classInfo.className} ${classInfo.className?uncap_first}){
|
||||
log.info("${classInfo.className?uncap_first}:"+JSON.toJSONString(${classInfo.className?uncap_first}));
|
||||
${classInfo.className} old${classInfo.className} = ${classInfo.className?uncap_first}Mapper.selectOne(new QueryWrapper<${classInfo.className}>().eq("${classInfo.className?uncap_first}_id",${classInfo.className?uncap_first}.get${classInfo.className}Id()));
|
||||
${classInfo.className?uncap_first}.setModifyDate(new Date());
|
||||
${classInfo.className?uncap_first}.setUpdateTime(new Date());
|
||||
if(old${classInfo.className}!=null){
|
||||
${classInfo.className?uncap_first}Mapper.updateById(${classInfo.className?uncap_first});
|
||||
}else{
|
||||
if(${classInfo.className?uncap_first}Mapper.selectOne(new QueryWrapper<${classInfo.className}>().eq("${classInfo.className?uncap_first}_name",${classInfo.className?uncap_first}.get${classInfo.className}Name()))!=null){
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE,"保存失败,名字重复");
|
||||
return ${returnUtil}.ERROR("保存失败,名字重复");
|
||||
}
|
||||
${classInfo.className?uncap_first}.setCreateDate(new Date());
|
||||
${classInfo.className?uncap_first}.setCreateTime(new Date());
|
||||
${classInfo.className?uncap_first}Mapper.insert(${classInfo.className?uncap_first});
|
||||
}
|
||||
return new ReturnT<>(ReturnT.SUCCESS_CODE,"保存成功");
|
||||
return ${returnUtil}.SUCCESS("保存成功");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,9 +58,9 @@ public class ${classInfo.className}Controller {
|
||||
${classInfo.className} ${classInfo.className?uncap_first} = ${classInfo.className?uncap_first}Mapper.selectOne(new QueryWrapper<${classInfo.className}>().eq("${classInfo.className?uncap_first}_id",id));
|
||||
if(${classInfo.className?uncap_first}!=null){
|
||||
${classInfo.className?uncap_first}Mapper.deleteById(id);
|
||||
return new ReturnT<>(ReturnT.SUCCESS_CODE,"删除成功");
|
||||
return ${returnUtil}.SUCCESS("删除成功");
|
||||
}else{
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE,"没有找到该对象");
|
||||
return ${returnUtil}.ERROR("没有找到该对象");
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,14 +71,14 @@ public class ${classInfo.className}Controller {
|
||||
public Object find(int id){
|
||||
${classInfo.className} ${classInfo.className?uncap_first} = ${classInfo.className?uncap_first}Mapper.selectOne(new QueryWrapper<${classInfo.className}>().eq("${classInfo.className?uncap_first}_id",id));
|
||||
if(${classInfo.className?uncap_first}!=null){
|
||||
return new ReturnT<>(${classInfo.className?uncap_first});
|
||||
return ${returnUtil}.SUCCESS(${classInfo.className?uncap_first});
|
||||
}else{
|
||||
return new ReturnT<>(ReturnT.FAIL_CODE,"没有找到该对象");
|
||||
return ${returnUtil}.ERROR("没有找到该对象");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* 自动分页查询
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Object list(String searchParams,
|
||||
@ -96,12 +96,33 @@ public class ${classInfo.className}Controller {
|
||||
//执行分页
|
||||
IPage<${classInfo.className}> pageList = ${classInfo.className?uncap_first}Mapper.selectPage(buildPage, queryWrapper);
|
||||
//返回结果
|
||||
return new ReturnT<>(pageList.getRecords(),Integer.parseInt(pageList.getTotal()+""));
|
||||
return ${returnUtil}.PAGE(pageList.getRecords(),pageList.getTotal());
|
||||
}
|
||||
/**
|
||||
* 手工分页查询(按需使用)
|
||||
*/
|
||||
@PostMapping("/list2")
|
||||
public ReturnT list2(String searchParams,
|
||||
@RequestParam(required = false, defaultValue = "0") int page,
|
||||
@RequestParam(required = false, defaultValue = "10") int limit) {
|
||||
log.info("searchParams:"+ JSON.toJSONString(searchParams));
|
||||
//通用模式
|
||||
${classInfo.className} queryParamDTO = JSON.parseObject(searchParams, ${classInfo.className}.class);
|
||||
//专用DTO模式
|
||||
//QueryParamDTO queryParamDTO = JSON.parseObject(searchParams, QueryParamDTO.class);
|
||||
//queryParamDTO.setPage((page - 1)* limit);
|
||||
//queryParamDTO.setLimit(limit);
|
||||
//(page - 1) * limit, limit
|
||||
List<${classInfo.className}> itemList = ${classInfo.className?uncap_first}Mapper.pageAll(queryParamDTO,(page - 1)* limit,limit);
|
||||
Integer itemCount = ${classInfo.className?uncap_first}Mapper.countAll(queryParamDTO);
|
||||
//返回结果
|
||||
return ReturnT.PAGE(itemList,itemCount);
|
||||
}
|
||||
@GetMapping("/list")
|
||||
public ModelAndView listPage(){
|
||||
return new ModelAndView("cms/${classInfo.className?uncap_first}-list");
|
||||
}
|
||||
|
||||
@GetMapping("/edit")
|
||||
public ModelAndView editPage(int id){
|
||||
${classInfo.className} ${classInfo.className?uncap_first} = ${classInfo.className?uncap_first}Mapper.selectOne(new QueryWrapper<${classInfo.className}>().eq("${classInfo.className?uncap_first}_id",id));
|
||||
|
||||
@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Data<#if swagger?exists && swagger==true>
|
||||
@ApiModel("${classInfo.classComment}")</#if>
|
||||
|
||||
@ -4,11 +4,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import ${packageName}.entity.${classInfo.className};
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${classInfo.className}Mapper extends BaseMapper<${classInfo.className}> {
|
||||
@ -23,7 +24,7 @@ public interface ${classInfo.className}Mapper extends BaseMapper<${classInfo.cla
|
||||
//add here if need page limit
|
||||
//" limit ¥{page},¥{limit} " +
|
||||
" </script>")
|
||||
List<${classInfo.className}> pageAll(${classInfo.className} queryParamDTO);
|
||||
List<${classInfo.className}> pageAll(${classInfo.className} queryParamDTO,int page,int limit);
|
||||
|
||||
@Select("<script>select count(1) from ${classInfo.tableName} t0 " +
|
||||
//add here if need left join
|
||||
|
||||
@ -11,7 +11,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/${classInfo.className}")
|
||||
|
||||
@ -6,7 +6,7 @@ import java.util.List;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
|
||||
@ -7,7 +7,7 @@ import java.util.List;
|
||||
/**
|
||||
* @description ${classInfo.classComment}Mapper
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
|
||||
@ -5,7 +5,7 @@ import java.util.List;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
public class ${classInfo.className} implements Serializable {
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
public interface ${classInfo.className}Service {
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd HH:mm:ss')}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Service
|
||||
public class ${classInfo.className}ServiceImpl implements ${classInfo.className}Service {
|
||||
@ -23,25 +23,25 @@ public class ${classInfo.className}ServiceImpl implements ${classInfo.className}
|
||||
|
||||
// valid
|
||||
if (${classInfo.className?uncap_first} == null) {
|
||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "必要参数缺失");
|
||||
return ${returnUtil}.ERROR("必要参数缺失");
|
||||
}
|
||||
|
||||
${classInfo.className?uncap_first}Mapper.insert(${classInfo.className?uncap_first});
|
||||
return ReturnT.SUCCESS;
|
||||
return ${returnUtil}.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ReturnT<String> delete(int id) {
|
||||
int ret = ${classInfo.className?uncap_first}Mapper.delete(id);
|
||||
return ret>0?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||
return ret>0?${returnUtil}.SUCCESS():${returnUtil}.ERROR();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ReturnT<String> update(${classInfo.className} ${classInfo.className?uncap_first}) {
|
||||
int ret = ${classInfo.className?uncap_first}Mapper.update(${classInfo.className?uncap_first});
|
||||
return ret>0?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||
return ret>0?${returnUtil}.SUCCESS():${returnUtil}.ERROR();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">${fieldItem.fieldComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="${fieldItem.fieldName}" lay-verify="required" lay-reqtext="${fieldItem.fieldComment}不能为空" placeholder="请输入${fieldItem.fieldComment}" value="" class="layui-input">
|
||||
<input type="text" name="${fieldItem.fieldName}" lay-verify="required" lay-reqtext="${fieldItem.fieldComment}不能为空" placeholder="请输入${fieldItem.fieldComment}" value="¥{(${classInfo.className?uncap_first}.${fieldItem.fieldName})!!}" class="layui-input">
|
||||
<#--<tip>${fieldItem.fieldComment}</tip>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -40,8 +40,8 @@
|
||||
|
||||
<script type="text/html" id="toolbarDemo">
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-sm data-add-btn"> 添加${classInfo.classComment} </button>
|
||||
<#-- <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn"> 删除${classInfo.classComment} </button>-->
|
||||
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> <i class="layui-icon layui-icon-addition"></i>${classInfo.classComment} </button>
|
||||
<#-- <button class="layui-btn layui-btn-normal layui-btn-sm layui-btn-danger data-delete-btn" lay-event="del"> 删除${classInfo.classComment} </button>-->
|
||||
</div>
|
||||
</script>
|
||||
|
||||
@ -52,11 +52,20 @@
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="statusTemplate">
|
||||
{{# if(d.status = 1){ }}
|
||||
启用
|
||||
<script type="text/html" id="typeTemplate">
|
||||
{{# if(d.type == '1'){ }}
|
||||
常规
|
||||
{{# } else if(d.type =='2') { }}
|
||||
专项
|
||||
{{# } else { }}
|
||||
停用
|
||||
其它
|
||||
{{# } }}
|
||||
</script>
|
||||
<script type="text/html" id="statusTemplate">
|
||||
{{# if(d.status == '1' ){ }}
|
||||
<i class="layui-icon layui-icon-ok"></i>已发布
|
||||
{{# } else { }}
|
||||
- 未发布
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
@ -66,8 +75,7 @@
|
||||
layui.use(['form', 'table'], function () {
|
||||
var $ = layui.jquery,
|
||||
form = layui.form,
|
||||
table = layui.table,
|
||||
layuimini = layui.layuimini;
|
||||
table = layui.table;
|
||||
|
||||
table.render({
|
||||
elem: '#currentTableId',
|
||||
@ -83,23 +91,26 @@
|
||||
{type: "checkbox", width: 50, fixed: "left"},
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
{field: '${fieldItem.fieldName}', width: 150, title: '${fieldItem.fieldComment}', sort: true}, <#if fieldItem_has_next> </#if>
|
||||
{field: '${fieldItem.fieldName}', title: '${fieldItem.fieldComment}', sort: true}, <#if fieldItem_has_next> </#if>
|
||||
</#list>
|
||||
</#if>
|
||||
{title: '操作', minWidth: 50, templet: '#currentTableBar', fixed: "right", align: "center"}
|
||||
/* 需要时间请自行解封
|
||||
{title: '创建时间', sort: true,templet: "<div>{{layui.util.toDateString(d.createTime, 'yyyy-MM-dd')}}</div>"},
|
||||
{title: '修改时间', sort: true,templet: "<div>{{layui.util.toDateString(d.updateTime, 'yyyy-MM-dd')}}</div>"},
|
||||
*/
|
||||
{title: '操作', minWidth: 400, templet: '#currentTableBar', fixed: "right", align: "center"}
|
||||
]],
|
||||
limits: [10, 20, 50 , 100],
|
||||
limit: 10,
|
||||
limits: [20 , 50 , 100],
|
||||
limit: 20,
|
||||
page: true
|
||||
});
|
||||
|
||||
var result;
|
||||
// 监听搜索操作
|
||||
/**
|
||||
* submit(data-search-btn):监听搜索操作
|
||||
*/
|
||||
form.on('submit(data-search-btn)', function (data) {
|
||||
result = JSON.stringify(data.field);
|
||||
// layer.alert(result, {
|
||||
// title: '最终的搜索信息'
|
||||
// });
|
||||
|
||||
//执行搜索重载
|
||||
table.reload('currentTableId', {
|
||||
@ -113,51 +124,54 @@
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
var searchBtn = $("#searchBtn");
|
||||
// 监听添加操作
|
||||
$(".data-add-btn").on("click", function () {
|
||||
var index = layer.open({
|
||||
title: '添加${classInfo.classComment}',
|
||||
type: 2,
|
||||
shade: 0.2,
|
||||
maxmin:true,
|
||||
shadeClose: true,
|
||||
area: ['800px', '500px'],
|
||||
content: '¥{request.contextPath}/${classInfo.className?uncap_first}/edit?id=0',
|
||||
});
|
||||
layer.full(index);
|
||||
return false;
|
||||
});
|
||||
|
||||
// 监听删除操作
|
||||
$(".data-delete-btn").on("click", function () {
|
||||
var checkStatus = table.checkStatus('currentTableId')
|
||||
, data = checkStatus.data;
|
||||
layer.alert(JSON.stringify(data));
|
||||
});
|
||||
|
||||
//监听表格复选框选择
|
||||
table.on('checkbox(currentTableFilter)', function (obj) {
|
||||
console.log(obj)
|
||||
});
|
||||
|
||||
//监听表格编辑删除等功能按钮
|
||||
table.on('tool(currentTableFilter)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'edit') {
|
||||
/**
|
||||
* toolbar监听事件:表格添加按钮
|
||||
*/
|
||||
table.on('toolbar(currentTableFilter)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
var index = layer.open({
|
||||
title: '编辑${classInfo.classComment}',
|
||||
title: '添加',
|
||||
type: 2,
|
||||
shade: 0.2,
|
||||
maxmin:true,
|
||||
shadeClose: true,
|
||||
area: ['800px', '500px'],
|
||||
area: ['1000px', '700px'],
|
||||
content: '¥{request.contextPath}/${classInfo.className?uncap_first}/edit?id=0',
|
||||
});
|
||||
return false;
|
||||
}else if(obj.event === 'del') {
|
||||
var checkStatus = table.checkStatus('currentTableId')
|
||||
, data = checkStatus.data;
|
||||
layer.alert(JSON.stringify(data));
|
||||
}
|
||||
});
|
||||
/**
|
||||
* checkbox(currentTableFilter):表格复选框选择
|
||||
*/
|
||||
table.on('checkbox(currentTableFilter)', function (obj) {
|
||||
//console.log(obj)
|
||||
});
|
||||
|
||||
/**
|
||||
* tool监听事件:表格编辑删除等功能按钮
|
||||
*/
|
||||
table.on('tool(currentTableFilter)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'edit') {
|
||||
var index = layer.open({
|
||||
title: '编辑',
|
||||
type: 2,
|
||||
shade: 0.2,
|
||||
maxmin:true,
|
||||
shadeClose: true,
|
||||
area: ['1000px', '700px'],
|
||||
content: '¥{request.contextPath}/${classInfo.className?uncap_first}/edit?id='+obj.data.${classInfo.className?uncap_first}Id,
|
||||
});
|
||||
layer.full(index);
|
||||
return false;
|
||||
} else if (obj.event === 'delete') {
|
||||
layer.confirm('真的删除行么', function (index) {
|
||||
layer.confirm('确认删除该记录吗?', function (index) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "¥{request.contextPath}/${classInfo.className?uncap_first}/delete",
|
||||
|
||||
@ -229,11 +229,11 @@
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">作者名称</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="authorName" name="authorName" value="大狼狗">
|
||||
<input type="text" class="form-control" id="authorName" name="authorName" value="zhengkai.blog.csdn.net">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">返回封装</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="returnUtil" name="returnUtil" value="new ReturnT<>">
|
||||
<input type="text" class="form-control" id="returnUtil" name="returnUtil" value="ReturnT">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">包名路径</span>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user