增加了application和module的增删改查方法。
This commit is contained in:
parent
6c3a2a45b3
commit
4f2048abb6
@ -68,6 +68,7 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
@ -93,7 +94,6 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package io.gisbi;
|
package io.gisbi;
|
||||||
|
|
||||||
import io.gisbi.listener.EhCacheStartListener;
|
import io.gisbi.listener.EhCacheStartListener;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
|
import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration;
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
package io.gisbi.application.baseinfo.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.gisbi.application.baseinfo.domain.Application;
|
||||||
|
import io.gisbi.application.baseinfo.service.IApplicationService;
|
||||||
|
import io.gisbi.config.ResponseResult;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用系统 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-24
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/application")
|
||||||
|
public class ApplicationController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IApplicationService applicationService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询应用列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/page")
|
||||||
|
public ResponseResult page(@RequestParam(defaultValue = "1") Integer current,
|
||||||
|
@RequestParam(defaultValue = "10") Integer size) {
|
||||||
|
Page<Application> page = new Page<>(current, size);
|
||||||
|
LambdaQueryWrapper<Application> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
// 根据创建时间倒序
|
||||||
|
wrapper.orderByDesc(Application::getCode);
|
||||||
|
return ResponseResult.successData(applicationService.page(page, wrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增应用
|
||||||
|
*/
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseResult save(@RequestBody Application application) {
|
||||||
|
return ResponseResult.successData(applicationService.save(application));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改应用
|
||||||
|
*/
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ResponseResult update(@RequestBody Application application) {
|
||||||
|
return ResponseResult.successData(applicationService.updateById(application));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除应用
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResponseResult remove(@PathVariable String id) {
|
||||||
|
return ResponseResult.successData(applicationService.removeById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取应用详情
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ResponseResult getById(@PathVariable String id) {
|
||||||
|
return ResponseResult.successData(applicationService.getById(id));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package io.gisbi.application.baseinfo.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用系统
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-24
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("app_application")
|
||||||
|
public class Application implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用类型 01-数据展示分析
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用编号 自动生成:000001
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用简称
|
||||||
|
*/
|
||||||
|
private String simplename;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建日期
|
||||||
|
*/
|
||||||
|
private Long createdate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用图片 base64存储
|
||||||
|
*/
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用配置 JSON格式存储其他配置相关信息
|
||||||
|
*/
|
||||||
|
private String appconfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库配置 JSON格式存储数据库信息配置(数据库用于存储此应用系统的所有配置数据)
|
||||||
|
*/
|
||||||
|
private String dbconfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户单位 使用这个应用系统的组织单位
|
||||||
|
*/
|
||||||
|
private String organization;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 01-初始创建 02-正常运行 09-已停用
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最近修改者
|
||||||
|
*/
|
||||||
|
private String lastmodifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最近修改日期
|
||||||
|
*/
|
||||||
|
private LocalDateTime lastmodifydate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备用1
|
||||||
|
*/
|
||||||
|
private String custom1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备用2
|
||||||
|
*/
|
||||||
|
private String custom2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备用3
|
||||||
|
*/
|
||||||
|
private String custom3;
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package io.gisbi.application.baseinfo.mapper;
|
||||||
|
|
||||||
|
import io.gisbi.application.baseinfo.domain.Application;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用系统 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-24
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ApplicationMapper extends BaseMapper<Application> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="io.gisbi.application.baseinfo.mapper.ApplicationMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,16 @@
|
|||||||
|
package io.gisbi.application.baseinfo.service;
|
||||||
|
|
||||||
|
import io.gisbi.application.baseinfo.domain.Application;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用系统 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-24
|
||||||
|
*/
|
||||||
|
public interface IApplicationService extends IService<Application> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package io.gisbi.application.baseinfo.service.impl;
|
||||||
|
|
||||||
|
import io.gisbi.application.baseinfo.domain.Application;
|
||||||
|
import io.gisbi.application.baseinfo.mapper.ApplicationMapper;
|
||||||
|
import io.gisbi.application.baseinfo.service.IApplicationService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用系统 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-24
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Application> implements IApplicationService {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package io.gisbi.application.module.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.gisbi.application.module.domain.Module;
|
||||||
|
import io.gisbi.application.module.service.IModuleService;
|
||||||
|
import io.gisbi.config.ResponseResult;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用_系统模块 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-25
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/application/module")
|
||||||
|
public class ModuleController {
|
||||||
|
|
||||||
|
// 添加Service注入
|
||||||
|
@Resource
|
||||||
|
private IModuleService moduleService;
|
||||||
|
|
||||||
|
// 分页查询模块列表
|
||||||
|
@GetMapping("/list")
|
||||||
|
public ResponseResult page(@RequestParam String appId) {
|
||||||
|
LambdaQueryWrapper<Module> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.orderByDesc(Module::getPid,Module::getSort); // 按编码倒序排列
|
||||||
|
return ResponseResult.successData(moduleService.list(wrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增模块
|
||||||
|
@PostMapping("/save")
|
||||||
|
public ResponseResult save(@RequestBody Module module) {
|
||||||
|
return ResponseResult.successData(moduleService.save(module));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改模块
|
||||||
|
@PostMapping("/update")
|
||||||
|
public ResponseResult update(@RequestBody Module module) {
|
||||||
|
return ResponseResult.successData(moduleService.updateById(module));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除模块
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResponseResult remove(@PathVariable String id) {
|
||||||
|
return ResponseResult.successData(moduleService.removeById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取模块详情
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ResponseResult getById(@PathVariable String id) {
|
||||||
|
return ResponseResult.successData(moduleService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增:根据pid判断是否有子节点
|
||||||
|
@GetMapping("/checkHasChildren")
|
||||||
|
public boolean checkHasChildren(@RequestParam String appId,@RequestParam String pid) {
|
||||||
|
boolean hasChildren = moduleService.existsChildrenByPid(appId,pid);
|
||||||
|
return hasChildren;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,158 @@
|
|||||||
|
package io.gisbi.application.module.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用_系统模块
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-25
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("app_module")
|
||||||
|
public class Module implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用ID 关联应用系统
|
||||||
|
*/
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父级ID 父级模块
|
||||||
|
*/
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 层级
|
||||||
|
*/
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点类型 01-目录 02-模块
|
||||||
|
*/
|
||||||
|
private String nodeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型 01-数据大屏 02-数据看板 03-弹窗页面 04-填报页面 06-移动端界面 09-自定义页面
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 样式数据
|
||||||
|
*/
|
||||||
|
private String canvasStyleData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件数据
|
||||||
|
*/
|
||||||
|
private String componentData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 0-未发布 1-已发布
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否单独打开水印 0-关闭 1-开启
|
||||||
|
*/
|
||||||
|
private Integer selfWatermarkStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序 目录内的排序号
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据来源
|
||||||
|
*/
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标志
|
||||||
|
*/
|
||||||
|
private Byte deleteFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime deleteTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除人
|
||||||
|
*/
|
||||||
|
private String deleteBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可视化资源版本
|
||||||
|
*/
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容标识
|
||||||
|
*/
|
||||||
|
private String contentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容检查标识
|
||||||
|
*/
|
||||||
|
private String checkVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备用1
|
||||||
|
*/
|
||||||
|
private String custom1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备用2
|
||||||
|
*/
|
||||||
|
private String custom2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备用3
|
||||||
|
*/
|
||||||
|
private String custom3;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package io.gisbi.application.module.mapper;
|
||||||
|
|
||||||
|
import io.gisbi.application.module.domain.Module;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用_系统模块 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-25
|
||||||
|
*/
|
||||||
|
public interface ModuleMapper extends BaseMapper<Module> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="io.gisbi.application.module.mapper.ModuleMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,23 @@
|
|||||||
|
package io.gisbi.application.module.service;
|
||||||
|
|
||||||
|
import io.gisbi.application.module.domain.Module;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用_系统模块 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-25
|
||||||
|
*/
|
||||||
|
public interface IModuleService extends IService<Module> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否存在子节点
|
||||||
|
* @param pid 父ID
|
||||||
|
* @return 存在返回true
|
||||||
|
*/
|
||||||
|
boolean existsChildrenByPid(String appId,String pid);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package io.gisbi.application.module.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import io.gisbi.application.module.domain.Module;
|
||||||
|
import io.gisbi.application.module.mapper.ModuleMapper;
|
||||||
|
import io.gisbi.application.module.service.IModuleService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 应用_系统模块 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhengsl
|
||||||
|
* @since 2025-03-25
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ModuleServiceImpl extends ServiceImpl<ModuleMapper, Module> implements IModuleService {
|
||||||
|
|
||||||
|
// 新增existsChildrenByPid实现
|
||||||
|
@Override
|
||||||
|
public boolean existsChildrenByPid(String appId,String pid) {
|
||||||
|
return this.count(new LambdaQueryWrapper<Module>()
|
||||||
|
.eq(Module::getAppId, appId).eq(Module::getPid, pid)) > 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
package io.gisbi.commons.utils;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.*;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.builder.GeneratorBuilder;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||||
|
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
// 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
|
||||||
|
public class CodeGenerator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义模板,模板引擎是 freemarker
|
||||||
|
*/
|
||||||
|
private static final String ENTITY_TEMPLATE_PATH = "/templates/entity.java.ftl";
|
||||||
|
private static final String XML_TEMPLATE_PATH = "/templates/mapper.xml.ftl";
|
||||||
|
private static final String MAPPER_TEMPLATE_PATH = "/templates/mapper.java.ftl";
|
||||||
|
private static final String CONTROLLER_TEMPLATE_PATH = "/templates/controller.java.ftl";
|
||||||
|
private static final String SERVICE_IMPL_TEMPLATE_PATH = "/templates/serviceImpl.java.ftl";
|
||||||
|
private static final String SERVICE_TEMPLATE_PATH = "/templates/service.java.ftl";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 读取控制台内容
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public static String scanner(String tip) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
StringBuilder help = new StringBuilder();
|
||||||
|
help.append("请输入" + tip + ":");
|
||||||
|
System.out.println(help.toString());
|
||||||
|
if (scanner.hasNext()) {
|
||||||
|
String ipt = scanner.next();
|
||||||
|
if (StringUtils.isNotBlank(ipt)) {
|
||||||
|
return ipt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new MybatisPlusException("请输入正确的" + tip + "!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 获取项目路径
|
||||||
|
String projectPath = System.getProperty("user.dir");
|
||||||
|
|
||||||
|
// 数据源配置
|
||||||
|
DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder(
|
||||||
|
"jdbc:mysql://121.37.111.42:3306/dataease?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true",
|
||||||
|
"root",
|
||||||
|
"mysql_F8ysiK@2024")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
AutoGenerator mpg = new AutoGenerator(dataSourceConfig);
|
||||||
|
// 全局配置
|
||||||
|
GlobalConfig globalConfig = new GlobalConfig.Builder()
|
||||||
|
.outputDir(projectPath + "/core/core-backend/src/main/java") // 修正路径
|
||||||
|
.author("zhengsl")
|
||||||
|
.disableOpenDir()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
mpg.global(globalConfig);
|
||||||
|
|
||||||
|
// 包配置
|
||||||
|
String moduleName = scanner("模块名称");
|
||||||
|
PackageConfig packageConfig = GeneratorBuilder.packageConfigBuilder()
|
||||||
|
.parent("io.gisbi.application") // 修正包名
|
||||||
|
.moduleName(moduleName)
|
||||||
|
.entity("domain")
|
||||||
|
.build();
|
||||||
|
mpg.packageInfo(packageConfig);
|
||||||
|
|
||||||
|
// 配置模板
|
||||||
|
TemplateConfig templateConfig = GeneratorBuilder.templateConfigBuilder()
|
||||||
|
.entity(ENTITY_TEMPLATE_PATH) // 使用定义的常量
|
||||||
|
.service(SERVICE_TEMPLATE_PATH)
|
||||||
|
.serviceImpl(SERVICE_IMPL_TEMPLATE_PATH)
|
||||||
|
.controller(CONTROLLER_TEMPLATE_PATH)
|
||||||
|
.mapper(MAPPER_TEMPLATE_PATH)
|
||||||
|
.xml(XML_TEMPLATE_PATH)
|
||||||
|
.build();
|
||||||
|
mpg.template(templateConfig);
|
||||||
|
|
||||||
|
// 策略配置
|
||||||
|
StrategyConfig strategyConfig = GeneratorBuilder.strategyConfigBuilder()
|
||||||
|
.addInclude(scanner("表名,多个英文逗号分割").split(","))
|
||||||
|
.addTablePrefix("app_")
|
||||||
|
.entityBuilder()
|
||||||
|
.enableLombok()
|
||||||
|
.naming(NamingStrategy.underline_to_camel)
|
||||||
|
.columnNaming(NamingStrategy.underline_to_camel)
|
||||||
|
.controllerBuilder()
|
||||||
|
.enableRestStyle()
|
||||||
|
.enableHyphenStyle()
|
||||||
|
.build();
|
||||||
|
mpg.strategy(strategyConfig);
|
||||||
|
// 执行代码生成
|
||||||
|
mpg.execute();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package io.gisbi.config;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class ResponseResult extends HashMap<String, Object> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ResponseResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static ResponseResult error() {
|
||||||
|
return error("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseResult success() {
|
||||||
|
return success("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseResult error(String msg) {
|
||||||
|
ResponseResult json = new ResponseResult();
|
||||||
|
json.put((String)"code", "1");//错误
|
||||||
|
json.put((String)"msg", msg);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseResult message(String code, String msg) {
|
||||||
|
ResponseResult json = new ResponseResult();
|
||||||
|
json.put((String)"code", code);
|
||||||
|
json.put((String)"msg", msg);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseResult success(String msg) {
|
||||||
|
ResponseResult json = new ResponseResult();
|
||||||
|
json.put((String)"code", "0");//正常
|
||||||
|
json.put((String)"msg", msg);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseResult successData(Object obj) {
|
||||||
|
ResponseResult json = new ResponseResult();
|
||||||
|
json.put((String)"code", "0");//正常
|
||||||
|
json.put((String)"msg", "操作成功");
|
||||||
|
json.put("data", obj);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ResponseResult put(String key, Object value) {
|
||||||
|
super.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +1,20 @@
|
|||||||
package io.gisbi.license.server;
|
package io.gisbi.license.server;
|
||||||
|
|
||||||
import io.gisbi.api.license.LicenseApi;
|
|
||||||
import io.gisbi.api.license.bo.F2CLicResult;
|
|
||||||
import io.gisbi.api.license.dto.LicenseRequest;
|
import io.gisbi.api.license.dto.LicenseRequest;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/license")
|
@RequestMapping("/license")
|
||||||
public class LicenseServer implements LicenseApi {
|
public class LicenseServer {
|
||||||
|
|
||||||
@Override
|
public Object validate(LicenseRequest request) {
|
||||||
public F2CLicResult validate(LicenseRequest request) {
|
// F2CLicResult result = new F2CLicResult();
|
||||||
F2CLicResult result = new F2CLicResult();
|
return null;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String version() {
|
public String version() {
|
||||||
return "1.0.0";
|
return "1.0.0";
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ spring:
|
|||||||
messages:
|
messages:
|
||||||
basename: i18n/lic,i18n/core,i18n/permissions,i18n/xpack,i18n/sync
|
basename: i18n/lic,i18n/core,i18n/permissions,i18n/xpack,i18n/sync
|
||||||
flyway:
|
flyway:
|
||||||
enabled: true
|
enabled: false
|
||||||
table: de_standalone_version
|
table: de_standalone_version
|
||||||
validate-on-migrate: false
|
validate-on-migrate: false
|
||||||
locations: classpath:db/migration
|
locations: classpath:db/migration
|
||||||
|
@ -1,57 +1,24 @@
|
|||||||
package io.gisbi.api.license.bo;
|
package io.gisbi.api.license.bo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class F2CLicResult implements Serializable {
|
public class F2CLicResult implements Serializable {
|
||||||
private String message;
|
private String message;
|
||||||
private F2CLicense license;
|
private F2CLicense license;
|
||||||
private static final long serialVersionUID = -2285934203104231711L;
|
private static final long serialVersionUID = -2285934203104231711L;
|
||||||
private Status status;
|
private Status status;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setLicense(F2CLicense var1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public F2CLicResult expired() {
|
public F2CLicResult expired() {
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status getStatus() {
|
|
||||||
return this.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(Status var1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static F2CLicResult invalid(String var0) {
|
public static F2CLicResult invalid(String var0) {
|
||||||
F2CLicResult a = new F2CLicResult();
|
F2CLicResult a = new F2CLicResult();
|
||||||
return a;
|
return a;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public F2CLicense getLicense() {
|
|
||||||
return this.license;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return this.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public F2CLicResult() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String var1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum Status {
|
|
||||||
no_record,
|
|
||||||
expired,
|
|
||||||
invalid,
|
|
||||||
valid;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
// Status.java
|
||||||
|
package io.gisbi.api.license.bo;
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
no_record,
|
||||||
|
expired,
|
||||||
|
invalid,
|
||||||
|
valid;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user