!11 [功能] 拆分出Vo,QueryBo,AddBo,EditBo等领域对象
* [修改] 错误引入的无用导包删除 * [新增] 增加Vo,QueryBo,AddBo,EditBo等视图,并调整controller,service的调用代码 * [新增] 增加CreateAndUpdateMetaObjectHandler,配合fill注解,实现创建和修改人的自动设置,减少重复代码master
parent
5d1e977442
commit
3d6fbb93f5
@ -0,0 +1,67 @@
|
||||
package com.ruoyi.framework.mybatisplus;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author woo
|
||||
* @date 2021/3/11
|
||||
*/
|
||||
public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
//region 处理创建人信息
|
||||
Object createBy = this.getFieldValByName("createBy", metaObject);
|
||||
Object createTime = this.getFieldValByName("createTime", metaObject);
|
||||
if (createBy == null) {
|
||||
createBy = SecurityUtils.getUsername();
|
||||
this.setFieldValByName("createBy", createBy, metaObject);
|
||||
}
|
||||
if (createTime == null) {
|
||||
createTime = new Date();
|
||||
this.setFieldValByName("createTime", createTime, metaObject);
|
||||
}
|
||||
//endregion
|
||||
//region 处理修改人信息
|
||||
Object updateBy = this.getFieldValByName("updateBy", metaObject);
|
||||
Object updateTime = this.getFieldValByName("updateTime", metaObject);
|
||||
if (updateBy == null) {
|
||||
updateBy = createBy;
|
||||
this.setFieldValByName("updateBy", updateBy, metaObject);
|
||||
}
|
||||
if (updateTime == null) {
|
||||
updateTime = createTime;
|
||||
this.setFieldValByName("updateTime", updateTime, metaObject);
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
//region 处理修改人信息
|
||||
Object updateBy = this.getFieldValByName("updateBy", metaObject);
|
||||
Object updateTime = this.getFieldValByName("updateTime", metaObject);
|
||||
if (updateBy == null) {
|
||||
updateBy = SecurityUtils.getUsername();
|
||||
this.setFieldValByName("updateBy", updateBy, metaObject);
|
||||
}
|
||||
if (updateTime == null) {
|
||||
updateTime = new Date();
|
||||
this.setFieldValByName("updateTime", updateTime, metaObject);
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openInsertFill() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openUpdateFill() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package ${packageName}.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}添加对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("${functionName}添加对象")
|
||||
public class ${ClassName}AddBo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isInsert && $column.isPk!=1)
|
||||
/** $column.columnComment */
|
||||
@ApiModelProperty("$column.columnComment")
|
||||
private $column.javaType $column.javaField;
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
|
||||
/** $table.subTable.functionName信息 */
|
||||
@ApiModelProperty("$table.subTable.functionName")
|
||||
private List<${subClassName}> ${subclassName}List;
|
||||
#end
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package ${packageName}.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}编辑对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("${functionName}编辑对象")
|
||||
public class ${ClassName}EditBo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.isEdit)
|
||||
|
||||
/** $column.columnComment */
|
||||
@ApiModelProperty("$column.columnComment")
|
||||
private $column.javaType $column.javaField;
|
||||
#end
|
||||
#end
|
||||
#if($table.sub)
|
||||
|
||||
/** $table.subTable.functionName信息 */
|
||||
@ApiModelProperty("$table.subTable.functionName")
|
||||
private List<${subClassName}> ${subclassName}List;
|
||||
#end
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package ${packageName}.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}分页查询对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("${functionName}分页查询对象")
|
||||
public class ${ClassName}QueryBo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/** 分页大小 */
|
||||
@ApiModelProperty("分页大小")
|
||||
private Integer pageSize;
|
||||
/** 当前页数 */
|
||||
@ApiModelProperty("当前页数")
|
||||
private Integer pageNum;
|
||||
/** 排序列 */
|
||||
@ApiModelProperty("排序列")
|
||||
private String orderByColumn;
|
||||
/** 排序的方向desc或者asc */
|
||||
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
||||
private String isAsc;
|
||||
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField) && $column.query)
|
||||
/** $column.columnComment */
|
||||
@ApiModelProperty("$column.columnComment")
|
||||
private $column.javaType $column.javaField;
|
||||
#end
|
||||
#end
|
||||
}
|
||||
Loading…
Reference in new issue