This commit is contained in:
2025-12-01 22:37:00 +08:00
parent 25ed2391e9
commit 6fe44b3c81
44 changed files with 2934 additions and 339 deletions

View File

@@ -0,0 +1,15 @@
package com.jeesite.modules.biz.dao;
import com.jeesite.common.dao.CrudDao;
import com.jeesite.common.mybatis.annotation.MyBatisDao;
import com.jeesite.modules.biz.entity.BizDbConfig;
/**
* 连接信息DAO接口
* @author gaoxq
* @version 2025-12-01
*/
@MyBatisDao(dataSourceName="work")
public interface BizDbConfigDao extends CrudDao<BizDbConfig> {
}

View File

@@ -0,0 +1,15 @@
package com.jeesite.modules.biz.dao;
import com.jeesite.common.dao.CrudDao;
import com.jeesite.common.mybatis.annotation.MyBatisDao;
import com.jeesite.modules.biz.entity.BizTableInfo;
/**
* 数据信息DAO接口
* @author gaoxq
* @version 2025-12-01
*/
@MyBatisDao(dataSourceName="work")
public interface BizTableInfoDao extends CrudDao<BizTableInfo> {
}

View File

@@ -0,0 +1,110 @@
package com.jeesite.modules.biz.entity;
import java.io.Serializable;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import jakarta.validation.constraints.NotNull;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 连接信息Entity
*
* @author gaoxq
* @version 2025-12-01
*/
@EqualsAndHashCode(callSuper = true)
@Table(name = "biz_db_config", alias = "a", label = "连接信息信息", columns = {
@Column(name = "create_time", attrName = "createTime", label = "创建时间", isUpdate = false, isUpdateForce = true),
@Column(name = "id", attrName = "id", label = "主键ID", isPK = true),
@Column(name = "db_type", attrName = "dbType", label = "数据库类型"),
@Column(name = "db_name", attrName = "dbName", label = "数据库名称", queryType = QueryType.LIKE),
@Column(name = "db_ip", attrName = "dbIp", label = "数据库IP"),
@Column(name = "db_port", attrName = "dbPort", label = "数据库端口", isQuery = false),
@Column(name = "db_username", attrName = "dbUsername", label = "数据库账号", isQuery = false),
@Column(name = "db_password", attrName = "dbPassword", label = "数据库密码", isQuery = false),
@Column(name = "description", attrName = "description", label = "数据库描述", queryType = QueryType.LIKE),
@Column(name = "is_enabled", attrName = "isEnabled", label = "是否启用"),
@Column(name = "db_schema_name", attrName = "dbSchemaName", label = "schema名称", isQuery = false),
@Column(name = "update_time", attrName = "updateTime", label = "更新时间", isQuery = false, isUpdateForce = true),
@Column(name = "f_tenant_id", attrName = "ftenantId", label = "租户id", isUpdate = false, isQuery = false),
@Column(name = "f_flow_id", attrName = "fflowId", label = "流程id", isUpdate = false, isQuery = false),
@Column(name = "f_flow_task_id", attrName = "fflowTaskId", label = "流程任务主键", isUpdate = false, isQuery = false),
@Column(name = "f_flow_state", attrName = "fflowState", label = "流程任务状态", isUpdate = false, isQuery = false, isUpdateForce = true),
}, orderBy = "a.id DESC"
)
@Data
public class BizDbConfig extends DataEntity<BizDbConfig> implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Date createTime; // 创建时间
private String dbType; // 数据库类型
private String dbName; // 数据库名称
private String dbIp; // 数据库IP
private Integer dbPort; // 数据库端口
private String dbUsername; // 数据库账号
private String dbPassword; // 数据库密码
private String description; // 数据库描述
private String isEnabled; // 是否启用
private String dbSchemaName; // schema名称
private Date updateTime; // 更新时间
private String ftenantId; // 租户id
private String fflowId; // 流程id
private String fflowTaskId; // 流程任务主键
private Integer fflowState; // 流程任务状态
@ExcelFields({
@ExcelField(title = "创建时间", attrName = "createTime", align = Align.CENTER, sort = 10, dataFormat = "yyyy-MM-dd hh:mm"),
@ExcelField(title = "主键ID", attrName = "id", align = Align.CENTER, sort = 20),
@ExcelField(title = "数据库类型", attrName = "dbType", align = Align.CENTER, sort = 30),
@ExcelField(title = "数据库名称", attrName = "dbName", align = Align.CENTER, sort = 40),
@ExcelField(title = "数据库IP", attrName = "dbIp", align = Align.CENTER, sort = 50),
@ExcelField(title = "数据库端口", attrName = "dbPort", align = Align.CENTER, sort = 60),
@ExcelField(title = "数据库账号", attrName = "dbUsername", align = Align.CENTER, sort = 70),
@ExcelField(title = "数据库密码", attrName = "dbPassword", align = Align.CENTER, sort = 80),
@ExcelField(title = "数据库描述", attrName = "description", align = Align.CENTER, sort = 90),
@ExcelField(title = "是否启用", attrName = "isEnabled", dictType = "is_active", align = Align.CENTER, sort = 100),
@ExcelField(title = "schema名称", attrName = "dbSchemaName", align = Align.CENTER, sort = 110),
@ExcelField(title = "更新时间", attrName = "updateTime", align = Align.CENTER, sort = 120, dataFormat = "yyyy-MM-dd hh:mm"),
})
public BizDbConfig() {
this(null);
}
public BizDbConfig(String id) {
super(id);
}
public Date getCreateTime_gte() {
return sqlMap.getWhere().getValue("create_time", QueryType.GTE);
}
public void setCreateTime_gte(Date createTime) {
sqlMap.getWhere().and("create_time", QueryType.GTE, createTime);
}
public Date getCreateTime_lte() {
return sqlMap.getWhere().getValue("create_time", QueryType.LTE);
}
public void setCreateTime_lte(Date createTime) {
sqlMap.getWhere().and("create_time", QueryType.LTE, createTime);
}
}

View File

@@ -0,0 +1,119 @@
package com.jeesite.modules.biz.entity;
import java.io.Serializable;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import lombok.Data;
import java.io.Serial;
/**
* 数据信息Entity
*
* @author gaoxq
* @version 2025-12-01
*/
@Table(name = "biz_table_info", alias = "a", label = "数据信息信息", columns = {
@Column(name = "create_time", attrName = "createTime", label = "创建时间", isUpdate = false, isUpdateForce = true),
@Column(name = "table_id", attrName = "tableId", label = "唯一标识", isPK = true),
@Column(name = "data_name", attrName = "dataName", label = "数据表名称", queryType = QueryType.LIKE),
@Column(name = "table_comment", attrName = "tableComment", label = "数据表描述", queryType = QueryType.LIKE),
@Column(name = "table_size", attrName = "tableSize", label = "数据表大小", isQuery = false, isUpdateForce = true),
@Column(name = "data_source", attrName = "dataSource", label = "数据来源"),
@Column(name = "creator", attrName = "creator", label = "创建人员", isQuery = false),
@Column(name = "data_rows", attrName = "dataRows", label = "记录条数", isQuery = false, isUpdateForce = true),
@Column(name = "update_time", attrName = "updateTime", label = "更新时间", isQuery = false, isUpdateForce = true),
@Column(name = "remarks", attrName = "remarks", label = "备注信息", queryType = QueryType.LIKE),
@Column(name = "db_id", attrName = "dbId", label = "数据标识"),
@Column(name = "ds", attrName = "ds", label = "分区日期"),
@Column(name = "f_tenant_id", attrName = "ftenantId", label = "租户id", isUpdate = false, isQuery = false),
@Column(name = "f_flow_id", attrName = "fflowId", label = "流程id", isUpdate = false, isQuery = false),
@Column(name = "f_flow_task_id", attrName = "fflowTaskId", label = "流程任务主键", isUpdate = false, isQuery = false),
@Column(name = "f_flow_state", attrName = "fflowState", label = "流程任务状态", isUpdate = false, isQuery = false, isUpdateForce = true),
}, joinTable = {
@JoinTable(type = Type.LEFT_JOIN, entity = BizDbConfig.class, attrName = "this", alias = "b",
on = "a.db_id = b.id",
columns = {
@Column(name = "db_type", attrName = "dbType", label = "数据库类型"),
@Column(name = "db_name", attrName = "dbName", label = "数据库名称"),
@Column(name = "db_ip", attrName = "dbIp", label = "数据库IP"),
}),
}, orderBy = "a.create_time DESC"
)
@Data
public class BizTableInfo extends DataEntity<BizTableInfo> implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Date createTime; // 创建时间
private String tableId; // 唯一标识
private String dataName; // 数据表名称
private String tableComment; // 数据表描述
private Double tableSize; // 数据表大小
private String dataSource; // 数据来源
private String creator; // 创建人员
private Long dataRows; // 记录条数
private Date updateTime; // 更新时间
private String dbId; // 数据标识
private String ds; // 分区日期
private String ftenantId; // 租户id
private String fflowId; // 流程id
private String fflowTaskId; // 流程任务主键
private Integer fflowState; // 流程任务状态
private String dbType;
private String dbName;
private String dbIp;
@ExcelFields({
@ExcelField(title = "创建时间", attrName = "createTime", align = Align.CENTER, sort = 10, dataFormat = "yyyy-MM-dd hh:mm"),
@ExcelField(title = "唯一标识", attrName = "tableId", align = Align.CENTER, sort = 20),
@ExcelField(title = "数据表名称", attrName = "dataName", align = Align.CENTER, sort = 30),
@ExcelField(title = "数据表描述", attrName = "tableComment", align = Align.CENTER, sort = 40),
@ExcelField(title = "数据表大小", attrName = "tableSize", align = Align.CENTER, sort = 50),
@ExcelField(title = "数据来源", attrName = "dataSource", align = Align.CENTER, sort = 60),
@ExcelField(title = "创建人员", attrName = "creator", align = Align.CENTER, sort = 70),
@ExcelField(title = "记录条数", attrName = "dataRows", align = Align.CENTER, sort = 80),
@ExcelField(title = "更新时间", attrName = "updateTime", align = Align.CENTER, sort = 90, dataFormat = "yyyy-MM-dd hh:mm"),
@ExcelField(title = "备注信息", attrName = "remarks", align = Align.CENTER, sort = 100),
@ExcelField(title = "数据库名称", attrName = "dbName", align = Align.CENTER, sort = 110),
@ExcelField(title = "分区日期", attrName = "ds", align = Align.CENTER, sort = 120),
})
public BizTableInfo() {
this(null);
}
public BizTableInfo(String id) {
super(id);
}
public Date getCreateTime_gte() {
return sqlMap.getWhere().getValue("create_time", QueryType.GTE);
}
public void setCreateTime_gte(Date createTime) {
sqlMap.getWhere().and("create_time", QueryType.GTE, createTime);
}
public Date getCreateTime_lte() {
return sqlMap.getWhere().getValue("create_time", QueryType.LTE);
}
public void setCreateTime_lte(Date createTime) {
sqlMap.getWhere().and("create_time", QueryType.LTE, createTime);
}
}

View File

@@ -0,0 +1,134 @@
package com.jeesite.modules.biz.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.biz.entity.BizDbConfig;
import com.jeesite.modules.biz.dao.BizDbConfigDao;
import com.jeesite.common.service.ServiceException;
import com.jeesite.common.config.Global;
import com.jeesite.common.validator.ValidatorUtils;
import com.jeesite.common.utils.excel.ExcelImport;
import org.springframework.web.multipart.MultipartFile;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
/**
* 连接信息Service
* @author gaoxq
* @version 2025-12-01
*/
@Service
public class BizDbConfigService extends CrudService<BizDbConfigDao, BizDbConfig> {
/**
* 获取单条数据
* @param bizDbConfig 主键
*/
@Override
public BizDbConfig get(BizDbConfig bizDbConfig) {
return super.get(bizDbConfig);
}
/**
* 查询分页数据
* @param bizDbConfig 查询条件
* @param bizDbConfig page 分页对象
*/
@Override
public Page<BizDbConfig> findPage(BizDbConfig bizDbConfig) {
return super.findPage(bizDbConfig);
}
/**
* 查询列表数据
* @param bizDbConfig 查询条件
*/
@Override
public List<BizDbConfig> findList(BizDbConfig bizDbConfig) {
return super.findList(bizDbConfig);
}
/**
* 保存数据(插入或更新)
* @param bizDbConfig 数据对象
*/
@Override
@Transactional
public void save(BizDbConfig bizDbConfig) {
super.save(bizDbConfig);
}
/**
* 导入数据
* @param file 导入的数据文件
*/
@Transactional
public String importData(MultipartFile file) {
if (file == null){
throw new ServiceException(text("请选择导入的数据文件!"));
}
int successNum = 0; int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
List<BizDbConfig> list = ei.getDataList(BizDbConfig.class);
for (BizDbConfig bizDbConfig : list) {
try{
ValidatorUtils.validateWithException(bizDbConfig);
this.save(bizDbConfig);
successNum++;
successMsg.append("<br/>" + successNum + "、编号 " + bizDbConfig.getId() + " 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、编号 " + bizDbConfig.getId() + " 导入失败:";
if (e instanceof ConstraintViolationException){
ConstraintViolationException cve = (ConstraintViolationException)e;
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
}
}else{
msg += e.getMessage();
}
failureMsg.append(msg);
logger.error(msg, e);
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
failureMsg.append(e.getMessage());
return failureMsg.toString();
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
}else{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
* 更新状态
* @param bizDbConfig 数据对象
*/
@Override
@Transactional
public void updateStatus(BizDbConfig bizDbConfig) {
super.updateStatus(bizDbConfig);
}
/**
* 删除数据
* @param bizDbConfig 数据对象
*/
@Override
@Transactional
public void delete(BizDbConfig bizDbConfig) {
super.delete(bizDbConfig);
}
}

View File

@@ -0,0 +1,134 @@
package com.jeesite.modules.biz.service;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.biz.entity.BizTableInfo;
import com.jeesite.modules.biz.dao.BizTableInfoDao;
import com.jeesite.common.service.ServiceException;
import com.jeesite.common.config.Global;
import com.jeesite.common.validator.ValidatorUtils;
import com.jeesite.common.utils.excel.ExcelImport;
import org.springframework.web.multipart.MultipartFile;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ConstraintViolationException;
/**
* 数据信息Service
* @author gaoxq
* @version 2025-12-01
*/
@Service
public class BizTableInfoService extends CrudService<BizTableInfoDao, BizTableInfo> {
/**
* 获取单条数据
* @param bizTableInfo 主键
*/
@Override
public BizTableInfo get(BizTableInfo bizTableInfo) {
return super.get(bizTableInfo);
}
/**
* 查询分页数据
* @param bizTableInfo 查询条件
* @param bizTableInfo page 分页对象
*/
@Override
public Page<BizTableInfo> findPage(BizTableInfo bizTableInfo) {
return super.findPage(bizTableInfo);
}
/**
* 查询列表数据
* @param bizTableInfo 查询条件
*/
@Override
public List<BizTableInfo> findList(BizTableInfo bizTableInfo) {
return super.findList(bizTableInfo);
}
/**
* 保存数据(插入或更新)
* @param bizTableInfo 数据对象
*/
@Override
@Transactional
public void save(BizTableInfo bizTableInfo) {
super.save(bizTableInfo);
}
/**
* 导入数据
* @param file 导入的数据文件
*/
@Transactional
public String importData(MultipartFile file) {
if (file == null){
throw new ServiceException(text("请选择导入的数据文件!"));
}
int successNum = 0; int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
List<BizTableInfo> list = ei.getDataList(BizTableInfo.class);
for (BizTableInfo bizTableInfo : list) {
try{
ValidatorUtils.validateWithException(bizTableInfo);
this.save(bizTableInfo);
successNum++;
successMsg.append("<br/>" + successNum + "、编号 " + bizTableInfo.getId() + " 导入成功");
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、编号 " + bizTableInfo.getId() + " 导入失败:";
if (e instanceof ConstraintViolationException){
ConstraintViolationException cve = (ConstraintViolationException)e;
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
}
}else{
msg += e.getMessage();
}
failureMsg.append(msg);
logger.error(msg, e);
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
failureMsg.append(e.getMessage());
return failureMsg.toString();
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
}else{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
* 更新状态
* @param bizTableInfo 数据对象
*/
@Override
@Transactional
public void updateStatus(BizTableInfo bizTableInfo) {
super.updateStatus(bizTableInfo);
}
/**
* 删除数据
* @param bizTableInfo 数据对象
*/
@Override
@Transactional
public void delete(BizTableInfo bizTableInfo) {
super.delete(bizTableInfo);
}
}

View File

@@ -0,0 +1,149 @@
package com.jeesite.modules.biz.web;
import java.util.List;
import com.jeesite.modules.app.utils.vDate;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.DateUtils;
import com.jeesite.common.utils.excel.ExcelExport;
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
import org.springframework.web.multipart.MultipartFile;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.biz.entity.BizDbConfig;
import com.jeesite.modules.biz.service.BizDbConfigService;
/**
* 连接信息Controller
* @author gaoxq
* @version 2025-12-01
*/
@Controller
@RequestMapping(value = "${adminPath}/biz/dbConfig")
public class BizDbConfigController extends BaseController {
private final BizDbConfigService bizDbConfigService;
public BizDbConfigController(BizDbConfigService bizDbConfigService) {
this.bizDbConfigService = bizDbConfigService;
}
/**
* 获取数据
*/
@ModelAttribute
public BizDbConfig get(String id, boolean isNewRecord) {
return bizDbConfigService.get(id, isNewRecord);
}
/**
* 查询列表
*/
@RequiresPermissions("biz:dbConfig:view")
@RequestMapping(value = {"list", ""})
public String list(BizDbConfig bizDbConfig, Model model) {
model.addAttribute("bizDbConfig", bizDbConfig);
return "modules/biz/bizDbConfigList";
}
/**
* 查询列表数据
*/
@RequiresPermissions("biz:dbConfig:view")
@RequestMapping(value = "listData")
@ResponseBody
public Page<BizDbConfig> listData(BizDbConfig bizDbConfig, HttpServletRequest request, HttpServletResponse response) {
bizDbConfig.setPage(new Page<>(request, response));
Page<BizDbConfig> page = bizDbConfigService.findPage(bizDbConfig);
return page;
}
/**
* 查看编辑表单
*/
@RequiresPermissions("biz:dbConfig:view")
@RequestMapping(value = "form")
public String form(BizDbConfig bizDbConfig, Model model) {
model.addAttribute("bizDbConfig", bizDbConfig);
return "modules/biz/bizDbConfigForm";
}
/**
* 保存数据
*/
@RequiresPermissions("biz:dbConfig:edit")
@PostMapping(value = "save")
@ResponseBody
public String save(@Validated BizDbConfig bizDbConfig) {
bizDbConfig.setUpdateTime(vDate.getUpdateTime(bizDbConfig.getIsNewRecord()));
bizDbConfigService.save(bizDbConfig);
return renderResult(Global.TRUE, text("保存连接信息成功!"));
}
/**
* 导出数据
*/
@RequiresPermissions("biz:dbConfig:view")
@RequestMapping(value = "exportData")
public void exportData(BizDbConfig bizDbConfig, HttpServletResponse response) {
List<BizDbConfig> list = bizDbConfigService.findList(bizDbConfig);
String fileName = "连接信息" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
try(ExcelExport ee = new ExcelExport("连接信息", BizDbConfig.class)){
ee.setDataList(list).write(response, fileName);
}
}
/**
* 下载模板
*/
@RequiresPermissions("biz:dbConfig:view")
@RequestMapping(value = "importTemplate")
public void importTemplate(HttpServletResponse response) {
BizDbConfig bizDbConfig = new BizDbConfig();
List<BizDbConfig> list = ListUtils.newArrayList(bizDbConfig);
String fileName = "连接信息模板.xlsx";
try(ExcelExport ee = new ExcelExport("连接信息", BizDbConfig.class, Type.IMPORT)){
ee.setDataList(list).write(response, fileName);
}
}
/**
* 导入数据
*/
@ResponseBody
@RequiresPermissions("biz:dbConfig:edit")
@PostMapping(value = "importData")
public String importData(MultipartFile file) {
try {
String message = bizDbConfigService.importData(file);
return renderResult(Global.TRUE, "posfull:"+message);
} catch (Exception ex) {
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
}
}
/**
* 删除数据
*/
@RequiresPermissions("biz:dbConfig:edit")
@RequestMapping(value = "delete")
@ResponseBody
public String delete(BizDbConfig bizDbConfig) {
bizDbConfigService.delete(bizDbConfig);
return renderResult(Global.TRUE, text("删除连接信息成功!"));
}
}

View File

@@ -2,7 +2,7 @@ package com.jeesite.modules.biz.web;
import java.util.List;
import com.jeesite.modules.app.utils.vo;
import com.jeesite.modules.app.utils.vDate;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -89,7 +89,7 @@ public class BizMonitorHostController extends BaseController {
@PostMapping(value = "save")
@ResponseBody
public String save(@Validated BizMonitorHost bizMonitorHost) {
bizMonitorHost.setUpdateTime(vo.getUpdateTime(bizMonitorHost.getIsNewRecord()));
bizMonitorHost.setUpdateTime(vDate.getUpdateTime(bizMonitorHost.getIsNewRecord()));
bizMonitorHostService.save(bizMonitorHost);
return renderResult(Global.TRUE, text("保存主机信息成功!"));
}

View File

@@ -0,0 +1,150 @@
package com.jeesite.modules.biz.web;
import java.util.List;
import com.jeesite.modules.app.utils.vDate;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.DateUtils;
import com.jeesite.common.utils.excel.ExcelExport;
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
import org.springframework.web.multipart.MultipartFile;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.biz.entity.BizTableInfo;
import com.jeesite.modules.biz.service.BizTableInfoService;
/**
* 数据信息Controller
*
* @author gaoxq
* @version 2025-12-01
*/
@Controller
@RequestMapping(value = "${adminPath}/biz/tableInfo")
public class BizTableInfoController extends BaseController {
private final BizTableInfoService bizTableInfoService;
public BizTableInfoController(BizTableInfoService bizTableInfoService) {
this.bizTableInfoService = bizTableInfoService;
}
/**
* 获取数据
*/
@ModelAttribute
public BizTableInfo get(String tableId, boolean isNewRecord) {
return bizTableInfoService.get(tableId, isNewRecord);
}
/**
* 查询列表
*/
@RequiresPermissions("biz:tableInfo:view")
@RequestMapping(value = {"list", ""})
public String list(BizTableInfo bizTableInfo, Model model) {
model.addAttribute("bizTableInfo", bizTableInfo);
return "modules/biz/bizTableInfoList";
}
/**
* 查询列表数据
*/
@RequiresPermissions("biz:tableInfo:view")
@RequestMapping(value = "listData")
@ResponseBody
public Page<BizTableInfo> listData(BizTableInfo bizTableInfo, HttpServletRequest request, HttpServletResponse response) {
bizTableInfo.setDs(vDate.dsValue());
bizTableInfo.setPage(new Page<>(request, response));
Page<BizTableInfo> page = bizTableInfoService.findPage(bizTableInfo);
return page;
}
/**
* 查看编辑表单
*/
@RequiresPermissions("biz:tableInfo:view")
@RequestMapping(value = "form")
public String form(BizTableInfo bizTableInfo, Model model) {
model.addAttribute("bizTableInfo", bizTableInfo);
return "modules/biz/bizTableInfoForm";
}
/**
* 保存数据
*/
@RequiresPermissions("biz:tableInfo:edit")
@PostMapping(value = "save")
@ResponseBody
public String save(@Validated BizTableInfo bizTableInfo) {
bizTableInfoService.save(bizTableInfo);
return renderResult(Global.TRUE, text("保存数据信息成功!"));
}
/**
* 导出数据
*/
@RequiresPermissions("biz:tableInfo:view")
@RequestMapping(value = "exportData")
public void exportData(BizTableInfo bizTableInfo, HttpServletResponse response) {
List<BizTableInfo> list = bizTableInfoService.findList(bizTableInfo);
String fileName = "数据信息" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
try (ExcelExport ee = new ExcelExport("数据信息", BizTableInfo.class)) {
ee.setDataList(list).write(response, fileName);
}
}
/**
* 下载模板
*/
@RequiresPermissions("biz:tableInfo:view")
@RequestMapping(value = "importTemplate")
public void importTemplate(HttpServletResponse response) {
BizTableInfo bizTableInfo = new BizTableInfo();
List<BizTableInfo> list = ListUtils.newArrayList(bizTableInfo);
String fileName = "数据信息模板.xlsx";
try (ExcelExport ee = new ExcelExport("数据信息", BizTableInfo.class, Type.IMPORT)) {
ee.setDataList(list).write(response, fileName);
}
}
/**
* 导入数据
*/
@ResponseBody
@RequiresPermissions("biz:tableInfo:edit")
@PostMapping(value = "importData")
public String importData(MultipartFile file) {
try {
String message = bizTableInfoService.importData(file);
return renderResult(Global.TRUE, "posfull:" + message);
} catch (Exception ex) {
return renderResult(Global.FALSE, "posfull:" + ex.getMessage());
}
}
/**
* 删除数据
*/
@RequiresPermissions("biz:tableInfo:edit")
@RequestMapping(value = "delete")
@ResponseBody
public String delete(BizTableInfo bizTableInfo) {
bizTableInfoService.delete(bizTableInfo);
return renderResult(Global.TRUE, text("删除数据信息成功!"));
}
}