mybatis-plus代码生成器
This commit is contained in:
parent
2dbfbeb725
commit
1d52e4da84
@ -17,13 +17,16 @@ package com.aircraft.base;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.Timestamp;
|
||||
@ -57,6 +60,15 @@ public class BaseEntity implements Serializable {
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Timestamp updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记,1:已删除,0:正常
|
||||
*/
|
||||
@JsonIgnore
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
@TableLogic
|
||||
@TableField(value = "del_flag", fill = FieldFill.INSERT)
|
||||
private Integer delFlag;
|
||||
|
||||
/* 分组校验 */
|
||||
public @interface Create {}
|
||||
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.aircraft.base;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* 通用字段, is_del 根据需求自行添加
|
||||
* @author Zheng Jie
|
||||
* @date 2019年10月24日20:46:32
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SysBaseEntity implements Serializable {
|
||||
|
||||
@CreatedBy
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建人", hidden = true)
|
||||
private String createBy;
|
||||
|
||||
@LastModifiedBy
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@ApiModelProperty(value = "更新人", hidden = true)
|
||||
private String updateBy;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Timestamp createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Timestamp updateTime;
|
||||
|
||||
|
||||
/* 分组校验 */
|
||||
public @interface Create {}
|
||||
|
||||
/* 分组校验 */
|
||||
public @interface Update {}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBuilder builder = new ToStringBuilder(this);
|
||||
Field[] fields = this.getClass().getDeclaredFields();
|
||||
try {
|
||||
for (Field f : fields) {
|
||||
f.setAccessible(true);
|
||||
builder.append(f.getName(), f.get(this)).append("\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
builder.append("toString builder encounter an error");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@ -16,6 +16,7 @@
|
||||
package com.aircraft.config.mybatis;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.aircraft.utils.enums.DelFlagStatus;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.aircraft.utils.SecurityUtils;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
@ -40,6 +41,8 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
try {username = SecurityUtils.getCurrentUsername();}catch (Exception ignored){}
|
||||
this.strictInsertFill(metaObject, "createBy", String.class, username);
|
||||
this.strictInsertFill(metaObject, "updateBy", String.class, username);
|
||||
// 插入时候,默认赋值为【正常】
|
||||
this.strictInsertFill(metaObject, "delFlag", String.class, DelFlagStatus.NORMAL.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.aircraft.utils.enums;
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public enum DelFlagStatus {
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL("0"),
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
DELETED("1");
|
||||
|
||||
private final String value;
|
||||
|
||||
DelFlagStatus(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package com.aircraft.generate;
|
||||
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mysql代码生成器
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public class MysqlGenerator extends SuperGenerator {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* MySQL generator
|
||||
* </p>
|
||||
*/
|
||||
public void generator(String tableName) {
|
||||
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = getAutoGenerator(tableName);
|
||||
mpg.execute();
|
||||
if (tableName == null) {
|
||||
System.err.println(" Generator Success !");
|
||||
} else {
|
||||
System.err.println(" TableName【 " + tableName + " 】" + "Generator Success !");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MysqlGenerator mysqlGenerator = new MysqlGenerator();
|
||||
// Arrays.asList("user","role","user_role").stream().forEach(table -> {
|
||||
Arrays.asList("ttt").stream().forEach(table -> {
|
||||
mysqlGenerator.generator(table);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,231 @@
|
||||
package com.aircraft.generate;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableFill;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代码生成器父类
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public class SuperGenerator {
|
||||
|
||||
/**
|
||||
* 获取TemplateConfig
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected TemplateConfig getTemplateConfig() {
|
||||
return new TemplateConfig().setXml(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取InjectionConfig
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected InjectionConfig getInjectionConfig() {
|
||||
return new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
this.setMap(map);
|
||||
}
|
||||
}.setFileOutConfigList(Collections.<FileOutConfig>singletonList(new FileOutConfig(
|
||||
"/templates/mapper.xml.vm") {
|
||||
// 自定义输出文件目录
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return getResourcePath() + "/mapper/" + tableInfo.getEntityName() + "Mapper.xml";
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取PackageConfig
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected PackageConfig getPackageConfig() {
|
||||
return new PackageConfig()
|
||||
.setParent("com.aircraft.modules.system")
|
||||
.setController("controller")
|
||||
.setEntity("domain")
|
||||
.setMapper("mapper")
|
||||
.setService("service")
|
||||
.setServiceImpl("service.impl");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取StrategyConfig
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
protected StrategyConfig getStrategyConfig(String tableName) {
|
||||
return new StrategyConfig()
|
||||
.setCapitalMode(false)// 全局大写命名
|
||||
// .setTablePrefix("sys_")// 去除前缀
|
||||
.setNaming(NamingStrategy.underline_to_camel)// 表名生成策略
|
||||
//.setInclude(new String[] { "user" }) // 需要生成的表
|
||||
//自定义实体父类
|
||||
.setSuperEntityClass("com.aircraft.base.BaseEntity")
|
||||
// 自定义实体,公共字段
|
||||
.setSuperEntityColumns("create_by")
|
||||
.setSuperEntityColumns("create_time")
|
||||
.setSuperEntityColumns("update_by")
|
||||
.setSuperEntityColumns("update_time")
|
||||
.setSuperEntityColumns("del_flag")
|
||||
|
||||
// 自定义 mapper 父类
|
||||
.setSuperMapperClass("com.baomidou.mybatisplus.core.mapper.BaseMapper")
|
||||
// 自定义 service 实现类父类
|
||||
.setSuperServiceImplClass("com.baomidou.mybatisplus.extension.service.impl.ServiceImpl")
|
||||
// 自定义 service 接口父类
|
||||
.setSuperServiceClass("com.baomidou.mybatisplus.extension.service.IService")
|
||||
// 【实体】是否生成字段常量(默认 false)
|
||||
// .setEntityColumnConstant(true)
|
||||
// 【实体】是否为构建者模型(默认 false)
|
||||
.setEntityBuilderModel(false)
|
||||
// 【实体】是否为lombok模型(默认 false)<a href="https://projectlombok.org/">document</a>
|
||||
.setEntityLombokModel(true)
|
||||
// Boolean类型字段是否移除is前缀处理
|
||||
.setEntityBooleanColumnRemoveIsPrefix(true)
|
||||
.setRestControllerStyle(false)
|
||||
.setRestControllerStyle(true)
|
||||
.setInclude(tableName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取DataSourceConfig
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected DataSourceConfig getDataSourceConfig() {
|
||||
return new DataSourceConfig()
|
||||
.setDbType(DbType.MYSQL)// 数据库类型
|
||||
.setTypeConvert(new MySqlTypeConvert() {
|
||||
@Override
|
||||
public IColumnType processTypeConvert(GlobalConfig globalConfig, String fieldType) {
|
||||
if (fieldType.toLowerCase().equals("bit")) {
|
||||
return DbColumnType.BOOLEAN;
|
||||
}
|
||||
if (fieldType.toLowerCase().equals("tinyint")) {
|
||||
return DbColumnType.BOOLEAN;
|
||||
}
|
||||
if (fieldType.toLowerCase().equals("date")) {
|
||||
return DbColumnType.LOCAL_DATE;
|
||||
}
|
||||
if (fieldType.toLowerCase().equals("time")) {
|
||||
return DbColumnType.LOCAL_TIME;
|
||||
}
|
||||
if (fieldType.toLowerCase().equals("datetime")) {
|
||||
return DbColumnType.DATE;
|
||||
}
|
||||
return super.processTypeConvert(globalConfig, fieldType);
|
||||
}
|
||||
})
|
||||
.setDriverName("com.mysql.cj.jdbc.Driver")
|
||||
.setUsername("root")
|
||||
.setPassword("scutensave")
|
||||
.setUrl("jdbc:mysql://8.138.171.103:3306/aircraft-mp?useUnicode=true&characterEncoding=utf8&autoReconnect=true&serverTimezone=GMT%2B8&useSSL=false");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取GlobalConfig
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected GlobalConfig getGlobalConfig() {
|
||||
return new GlobalConfig()
|
||||
.setOutputDir(getJavaPath())//输出目录
|
||||
.setFileOverride(false)// 是否覆盖文件
|
||||
.setActiveRecord(false)// 开启 activeRecord 模式
|
||||
.setEnableCache(false)// XML 二级缓存
|
||||
.setBaseResultMap(false)// XML ResultMap
|
||||
.setBaseColumnList(false)// XML columList
|
||||
.setKotlin(false) //是否生成 kotlin 代码
|
||||
.setOpen(false)
|
||||
.setAuthor("cli") //作者
|
||||
//自定义文件命名,注意 %s 会自动填充表实体属性!
|
||||
.setEntityName("%s")
|
||||
.setMapperName("%sMapper")
|
||||
.setXmlName("%sMapper")
|
||||
.setServiceName("%sService")
|
||||
.setServiceImplName("%sServiceImpl")
|
||||
.setControllerName("%sController");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取根目录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getRootPath() {
|
||||
String file = Objects.requireNonNull(SuperGenerator.class.getClassLoader().getResource("")).getFile();
|
||||
return new File(file).getParentFile().getParent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JAVA目录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getJavaPath() {
|
||||
String javaPath = getRootPath() + "/src/main/java";
|
||||
System.err.println(" Generator Java Path:【 " + javaPath + " 】");
|
||||
return javaPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Resource目录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getResourcePath() {
|
||||
String resourcePath = getRootPath() + "/src/main/resources";
|
||||
System.err.println(" Generator Resource Path:【 " + resourcePath + " 】");
|
||||
return resourcePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取AutoGenerator
|
||||
*
|
||||
* @param tableName
|
||||
* @return
|
||||
*/
|
||||
protected AutoGenerator getAutoGenerator(String tableName) {
|
||||
return new AutoGenerator()
|
||||
// 全局配置
|
||||
.setGlobalConfig(getGlobalConfig())
|
||||
// 数据源配置
|
||||
.setDataSource(getDataSourceConfig())
|
||||
// 策略配置
|
||||
.setStrategy(getStrategyConfig(tableName))
|
||||
// 包配置
|
||||
.setPackageInfo(getPackageConfig())
|
||||
// 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
|
||||
.setCfg(getInjectionConfig())
|
||||
.setTemplate(getTemplateConfig());
|
||||
}
|
||||
|
||||
}
|
||||
@ -23,7 +23,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ import java.io.Serializable;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("mnt_app")
|
||||
public class App extends BaseEntity implements Serializable {
|
||||
public class App extends SysBaseEntity implements Serializable {
|
||||
|
||||
|
||||
@TableId(value = "app_id", type = IdType.AUTO)
|
||||
|
||||
@ -23,7 +23,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -34,7 +34,7 @@ import java.io.Serializable;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("mnt_database")
|
||||
public class Database extends BaseEntity implements Serializable {
|
||||
public class Database extends SysBaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "db_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
|
||||
@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
@ -39,7 +39,7 @@ import java.util.stream.Collectors;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("mnt_deploy")
|
||||
public class Deploy extends BaseEntity implements Serializable {
|
||||
public class Deploy extends SysBaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "deploy_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
|
||||
@ -23,7 +23,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
@ -35,7 +35,7 @@ import java.util.Objects;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("mnt_server")
|
||||
public class Server extends BaseEntity implements Serializable {
|
||||
public class Server extends SysBaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "server_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
|
||||
@ -102,7 +102,7 @@ public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements AppSe
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<Long> ids) {
|
||||
// 删除应用
|
||||
removeBatchByIds(ids);
|
||||
removeByIds(ids);
|
||||
// 删除部署
|
||||
Set<Long> deployIds = deployMapper.getIdByAppIds(ids);
|
||||
if(CollUtil.isNotEmpty(deployIds)){
|
||||
|
||||
@ -74,7 +74,7 @@ public class DatabaseServiceImpl extends ServiceImpl<DatabaseMapper, Database> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<String> ids) {
|
||||
removeBatchByIds(ids);
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -65,7 +65,7 @@ public class DeployHistoryServiceImpl extends ServiceImpl<DeployHistoryMapper, D
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<String> ids) {
|
||||
removeBatchByIds(ids);
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -103,7 +103,7 @@ public class DeployServiceImpl extends ServiceImpl<DeployMapper, Deploy> impleme
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<Long> ids) {
|
||||
removeBatchByIds(ids);
|
||||
removeByIds(ids);
|
||||
// 删除关联
|
||||
deployServerMapper.deleteByDeployIds(ids);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class ServerServiceImpl extends ServiceImpl<ServerMapper, Server> impleme
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<Long> ids) {
|
||||
removeBatchByIds(ids);
|
||||
removeByIds(ids);
|
||||
// 删除与之关联的服务
|
||||
deployServerMapper.deleteByServerIds(ids);
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
@ -34,7 +34,7 @@ import java.io.Serializable;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_quartz_job")
|
||||
public class QuartzJob extends BaseEntity implements Serializable {
|
||||
public class QuartzJob extends SysBaseEntity implements Serializable {
|
||||
|
||||
public static final String JOB_KEY = "JOB_KEY";
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
@ -38,7 +38,7 @@ import java.util.Set;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_dept")
|
||||
public class Dept extends BaseEntity implements Serializable {
|
||||
public class Dept extends SysBaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@TableId(value="dept_id", type = IdType.AUTO)
|
||||
|
||||
@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
@ -33,7 +33,7 @@ import java.io.Serializable;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_dict")
|
||||
public class Dict extends BaseEntity implements Serializable {
|
||||
public class Dict extends SysBaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
|
||||
@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -33,7 +33,7 @@ import java.io.Serializable;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_dict_detail")
|
||||
public class DictDetail extends BaseEntity implements Serializable {
|
||||
public class DictDetail extends SysBaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
|
||||
@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
@ -34,7 +34,7 @@ import java.util.Objects;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_job")
|
||||
public class Job extends BaseEntity implements Serializable {
|
||||
public class Job extends SysBaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@TableId(value="job_id", type = IdType.AUTO)
|
||||
|
||||
@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@ -38,7 +38,7 @@ import java.util.Set;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_menu")
|
||||
public class Menu extends BaseEntity implements Serializable {
|
||||
public class Menu extends SysBaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = {Update.class})
|
||||
@TableId(value="menu_id", type = IdType.AUTO)
|
||||
|
||||
@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import com.aircraft.utils.enums.DataScopeEnum;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
@ -38,7 +38,7 @@ import java.util.Set;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_role")
|
||||
public class Role extends BaseEntity implements Serializable {
|
||||
public class Role extends SysBaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = {Update.class})
|
||||
@TableId(value="role_id", type = IdType.AUTO)
|
||||
|
||||
@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
@ -38,7 +38,7 @@ import java.util.Set;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("sys_user")
|
||||
public class User extends BaseEntity implements Serializable {
|
||||
public class User extends SysBaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = Update.class)
|
||||
@TableId(value="user_id", type = IdType.AUTO)
|
||||
|
||||
@ -93,7 +93,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobSe
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<Long> ids) {
|
||||
removeBatchByIds(ids);
|
||||
removeByIds(ids);
|
||||
// 删除缓存
|
||||
ids.forEach(this::delCaches);
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
// 更新相关缓存
|
||||
delCaches(id, null);
|
||||
}
|
||||
removeBatchByIds(ids);
|
||||
removeByIds(ids);
|
||||
// 删除角色部门关联数据、角色菜单关联数据
|
||||
roleDeptMapper.deleteByRoleIds(ids);
|
||||
roleMenuMapper.deleteByRoleIds(ids);
|
||||
|
||||
@ -17,6 +17,14 @@ mybatis-plus:
|
||||
cache-enabled: false
|
||||
# 设置本地缓存作用域
|
||||
local-cache-scope: SESSION
|
||||
global-config:
|
||||
db-config:
|
||||
# 全局逻辑删除的字段名
|
||||
logic-delete-field: delFlag
|
||||
# 逻辑已删除值(默认为 1)
|
||||
logic-delete-value: 1
|
||||
# 逻辑未删除值(默认为 0)
|
||||
logic-not-delete-value: 0
|
||||
|
||||
spring:
|
||||
freemarker:
|
||||
|
||||
@ -22,7 +22,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ import java.io.Serializable;
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@TableName("tool_local_storage")
|
||||
public class LocalStorage extends BaseEntity implements Serializable {
|
||||
public class LocalStorage extends SysBaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "storage_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
|
||||
@ -25,7 +25,7 @@ import java.io.Serializable;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import com.aircraft.base.SysBaseEntity;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
@ -35,7 +35,7 @@ import com.aircraft.base.BaseEntity;
|
||||
@Data
|
||||
@TableName("tool_s3_storage")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class S3Storage extends BaseEntity implements Serializable {
|
||||
public class S3Storage extends SysBaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "storage_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键")
|
||||
|
||||
13
pom.xml
13
pom.xml
@ -96,9 +96,18 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--spring boot 集成redis所需common-pool2-->
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
|
||||
<dependency>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user