Merge remote-tracking branch 'origin/dev.entOperation' into dev

# Conflicts:
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/pom.xml
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/CarMessageController.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/FaultRuleController.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/FaultRuleService.java
#	cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/FaultRuleServiceImpl.java
#	cloud-modules/cloud-modules-vehicle-gateway/src/main/resources/banner.txt
dev.entOperation
crj 2024-10-07 20:09:21 +08:00
commit 6e0ed3b883
18 changed files with 269 additions and 62 deletions

View File

@ -76,19 +76,18 @@ public class SysLoginService {
if (Result.FAIL == userResult.getCode()) { if (Result.FAIL == userResult.getCode()) {
throw new ServiceException(userResult.getMsg()); throw new ServiceException(userResult.getMsg());
} }
LoginUser userInfo = userResult.getData(); LoginUser userInfo = userResult.getData();
SysUser user = userResult.getData().getSysUser(); SysUser user = userResult.getData().getSysUser();
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { if(UserStatus.DELETED.getCode().equals(user.getDelFlag())){
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); recordLogService.recordLogininfor(username,Constants.LOGIN_FAIL,"对不起,您的账号已被删除");
throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); throw new ServiceException("对不起,您的账号:" + username + " 已被删除 ");
} }
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { if(UserStatus.DISABLE.getCode().equals(user.getStatus())){
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); recordLogService.recordLogininfor(username,Constants.LOGIN_FAIL,"用户已停用,请联系管理官");
throw new ServiceException("对不起,您的账号" + username + " 已停用"); throw new ServiceException("对不起,您的账号:" + username + " 已停用");
} }
passwordService.validate(user, password); passwordService.validate(user,password);
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); recordLogService.recordLogininfor(username,Constants.LOGIN_SUCCESS,"登录成功");
return userInfo; return userInfo;
} }
@ -128,16 +127,16 @@ public class SysLoginService {
throw new ServiceException("密码长度必须在5到20个字符之间"); throw new ServiceException("密码长度必须在5到20个字符之间");
} }
// 注册用户信息 //注册用户信息
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUserName(username); sysUser.setUserName(username);
sysUser.setNickName(username); sysUser.setNickName(username);
sysUser.setPassword(SecurityUtils.encryptPassword(password)); sysUser.setPassword(SecurityUtils.encryptPassword(password));
Result<?> registerResult = remoteUserService.registerUserInfo(registerBody, SecurityConstants.INNER); Result<Boolean> registerResult = remoteUserService.registerUserInfo(registerBody, SecurityConstants.INNER);
if (Result.FAIL == registerResult.getCode()) { if (Result.FAIL == registerResult.getCode()) {
throw new ServiceException(registerResult.getMsg()); throw new ServiceException(registerResult.getMsg());
} }
recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功");
recordLogService.recordLogininfor(username,Constants.REGISTER,"注册成功");
} }
} }

View File

@ -91,21 +91,19 @@ public class ManyDataSource implements ApplicationRunner {
@Bean @Bean
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) { public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
List<EntInfo> entInfoList = dataSourceInfoList(); List<EntInfo> entInfoList = dataSourceInfoList();
if(StringUtils.isEmpty(entInfoList)){ if (StringUtils.isNotEmpty(entInfoList)) {
throw new SaaSException("数据信息列表为空或为null"); throw new SaaSException("数据信息列表为空或为null");
} }
Map<Object, Object> dataSourceMap = dataSourceInfoList().stream() Map<Object,Object> dataSourceMap = dataSourceInfoList().stream()
.map(entInfo -> DataSourceInfo.hostAndPortBuild( .map(entInfo -> DataSourceInfo.hostAndPortBuild(
entInfo.getEntCode(), entInfo.getEntCode(),
entInfo.getIp(), entInfo.getIp(),
entInfo.getPort() entInfo.getPort()
)
) )
.collect(Collectors.toMap( ).collect(Collectors.toMap(
dataSourceInfo -> dataSourceInfo.getKey(), dataSourceInfo -> dataSourceInfo.getKey(),
dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo) dataSourceInfo -> druidDataSourceFactory.create(dataSourceInfo)
)); ));
//设置动态数据源 //设置动态数据源
DynamicDataSource dynamicDataSource = new DynamicDataSource(); DynamicDataSource dynamicDataSource = new DynamicDataSource();
dynamicDataSource.setTargetDataSources(dataSourceMap); dynamicDataSource.setTargetDataSources(dataSourceMap);

View File

@ -1,8 +1,9 @@
package com.muyu.cloud.common.many.datasource.constents; package com.muyu.cloud.common.many.datasource.constents;
/** /**
* @Author: zi run *
* @Date 2024/9/20 14:52 * @Author chenruijia
* @Date 2024/9/29 17:52
* @Description * @Description
*/ */
public class DatasourceContent { public class DatasourceContent {

View File

@ -8,6 +8,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
*
* @Author: zi run * @Author: zi run
* @Date 2024/9/20 14:52 * @Date 2024/9/20 14:52
* @Description * @Description

View File

@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
import java.sql.SQLException; import java.sql.SQLException;
/** /**
* Druid
* @Author: zi run * @Author: zi run
* @Date 2024/9/20 14:52 * @Date 2024/9/20 14:52
* @Description Druid * @Description Druid

View File

@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
*
* @Author: zi run * @Author: zi run
* @Date 2024/9/20 14:52 * @Date 2024/9/20 14:52
* @Description * @Description

View File

@ -29,18 +29,40 @@ public class FaultRule extends BaseEntity {
@Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID") @Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID")
private Long faultRuleId; private Long faultRuleId;
/** /**
* * ID
*/ */
@Schema(defaultValue = "故障规则名称",type = "String",description = "故障规则名称") @Schema(defaultValue = "车辆类型ID",type = "Integer",description = "车辆类型ID")
private String faultRuleName; private Integer carTypeId;
/**
* ID
*/
@Schema(defaultValue = "故障名称ID",type = "Integer",description = "故障名称ID")
private Integer faultId;
/**
*
*/
@Schema(defaultValue = "故障条件",type = "String",description = "故障条件")
private String faultConditions;
/** /**
* *
*/ */
@Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数") @Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数")
private String faultRuleParameter; private String ruleParameters;
/** /**
* *
*/ */
@Schema(defaultValue = "故障规则描述",type = "String",description = "故障规则描述") @Schema(defaultValue = "车辆类型名称",type = "String",description = "车辆类型名称")
private String faultRuleDescription; private String carTypeName;
/**
*
*/
@Schema(defaultValue = "故障名称",type = "String",description = "故障名称")
private String faultName;
/**
* VIN
*/
@Schema(defaultValue = "车辆VIN",type = "String",description = "车辆VIN")
private String carVin;
} }

View File

@ -3,6 +3,7 @@ package com.muyu.enterprise.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@ -42,6 +43,11 @@ public class SysCarFault extends BaseEntity {
*/ */
@Schema(defaultValue = "车辆故障类型ID",type = "Integer",description = "车辆故障类型ID") @Schema(defaultValue = "车辆故障类型ID",type = "Integer",description = "车辆故障类型ID")
private Integer faultTypeId; private Integer faultTypeId;
/**
* ID
*/
@Schema(defaultValue = "车辆故障规则ID",type = "Integer",description = "车辆故障规则ID")
public Integer faultRuleId;
/** /**
* VIN * VIN
*/ */

View File

@ -0,0 +1,96 @@
package com.muyu.enterprise.domain.resp;
import com.muyu.common.core.annotation.Excel;
import com.muyu.enterprise.domain.SysCarFault;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.function.Supplier;
/**
*
* @author chenruijia
* @Date 2024/9/28 21:11
* @Description FaultResp:
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Tag(name = "故障返回")
public class FaultResp {
/**
*
*/
@Schema(defaultValue = "车辆故障码",type = "String",description = "车辆故障码")
private String faultCode;
/**
* ID
*/
@Schema(defaultValue = "车辆故障那类型ID",type = "Integer",description = "车辆故障类型ID")
private Integer faultTypeId;
/**
* ID
*/
@Schema(defaultValue = "车辆故障规则ID",type = "Integer",description = "车辆故障规则ID")
public Integer faultRuleId;
/**
* VIN
*/
@Schema(defaultValue = "故障VIN编码",type = "String",description = "故障VIN编码")
public String carVin;
/**
*
*/
@Schema(defaultValue = "车辆故障标签",type = "String",description = "车辆故障标签")
public String faultLabel;
/**
*
*/
@Schema(defaultValue = "车辆故障位",type = "String",description = "车辆故障位")
public String faultBit;
/**
*
*/
@Schema(defaultValue = "车辆故障值",type = "String",description = "车辆故障值")
public String faultValue;
/**
* v
*/
@Schema(defaultValue = "故障级别",type = "String",description = "故障级别")
public String faultWarn;
/**
*
*/
@Schema(defaultValue = "报警状态",type = "String",description = "报警状态")
public String warnStatus;
/**
*
*/
@Schema(defaultValue = "故障描述信息",type = "String",description = "故障描述信息")
public String faultDesc;
/**
*
*/
@Schema(defaultValue = "启用状态",type = "Integer",description = "启用状态")
public Integer state;
/**
*
*/
@Schema(defaultValue = "故障规则名称",type = "String",description = "故障规则名称")
public String faultRuleName;
/**
*
*/
@Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数")
public String faultRuleParameter;
/**
*
*/
@Schema(defaultValue = "故障规则描述",type = "String",description = "故障规则描述")
public String faultRuleDescription;
}

View File

@ -9,6 +9,7 @@ import com.muyu.enterprise.domain.CarMessage;
import com.muyu.enterprise.service.CarMessageService; import com.muyu.enterprise.service.CarMessageService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -29,6 +30,8 @@ public class CarMessageController extends BaseController {
private final CarMessageCacheService carMessageCacheService; private final CarMessageCacheService carMessageCacheService;
private final CarMessageService sysCarMessageService; private final CarMessageService sysCarMessageService;
@Autowired
private CarMessageService carMessageService;
/** /**
* *

View File

@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
* @Description SysCarFaultMapper: * @Description SysCarFaultMapper:
*/ */
@Mapper @Mapper
public interface SysCarFaultMapper extends BaseMapper<SysCarFault>{ public interface SysCarFaultMapper extends BaseMapper<SysCarFault> {
} }

View File

@ -7,14 +7,13 @@ import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description FaultLogService: * @Description FaultLogService:
*/ */
public interface FaultLogService extends IService<FaultLog> { public interface FaultLogService extends IService<FaultLog> {
List<FaultLog> faultLogList(FaultLog faultLog); List<FaultLog> faultLogList(FaultLog faultLog);
FaultLog byidId(Long faultLogId); FaultLog byidId(Long faultLogId);
} }

View File

@ -6,7 +6,7 @@ import com.muyu.enterprise.domain.FaultMessage;
import java.util.List; import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description FaultMessageService: * @Description FaultMessageService:
*/ */

View File

@ -6,7 +6,7 @@ import com.muyu.enterprise.domain.FaultType;
import java.util.List; import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description FaultTypeService: * @Description FaultTypeService:
*/ */

View File

@ -6,7 +6,7 @@ import com.muyu.enterprise.domain.SysCarFault;
import java.util.List; import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/28 12.19 * @Date 2024/9/28 12.19
* @Description SysCarFaultService: * @Description SysCarFaultService:
*/ */

View File

@ -21,14 +21,14 @@ import java.util.List;
/** /**
* *
* @Author: chenruijia * @author chenruijia
* @Date 2024/9/26 0:21 * @Date 2024/9/26 0:21
* @Description * @Description
*/ */
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping(value = "/ent") @RequestMapping(value = "/ent")
@Tag(name = "SysEntController",description = "企业管理") @Tag(name = "企业信息",description = "企业管理")
public class SysEntController extends BaseController { public class SysEntController extends BaseController {
/** /**
@ -40,7 +40,7 @@ public class SysEntController extends BaseController {
* *
* @return * @return
*/ */
@GetMapping(value = "/getInfo") @RequestMapping(value = "/selectList",method = RequestMethod.GET)
@Operation(summary = "获取企业信息", description = "现有的基础企业信息") @Operation(summary = "获取企业信息", description = "现有的基础企业信息")
public Result<List<EntResp>> getInfo() { public Result<List<EntResp>> getInfo() {
return Result.success( return Result.success(
@ -48,25 +48,25 @@ public class SysEntController extends BaseController {
); );
} }
/** // /**
* // * 查询企业信息列表
* @param entListReq // * @param entListReq 企业列表请求对象
* @return // * @return 响应结果
*/ // */
@PostMapping(value = "/selectList") // @PostMapping(value = "/selectList")
@Operation(summary = "查询企业信息列表", description = "分页展示企业信息") // @Operation(summary = "查询企业信息列表", description = "分页展示企业信息")
public Result<TableDataInfo<EntResp>> selectList(@RequestBody EntListReq entListReq) { // public Result<TableDataInfo<EntResp>> selectList(@RequestBody EntListReq entListReq) {
startPage(); // startPage();
List<EntResp> entRespList = sysEntService.selectList(entListReq); // List<EntResp> entRespList = sysEntService.selectList(entListReq);
return getDataTable(entRespList); // return getDataTable(entRespList);
} // }
/** /**
* ID * ID
* @param entId ID * @param entId ID
* @return * @return
*/ */
@GetMapping(value = "/{entId}") @GetMapping(value = "/getById/{entId}")
@Operation(summary = "根据ID获取企业信息", description = "根据企业唯一标识获取单体企业信息") @Operation(summary = "根据ID获取企业信息", description = "根据企业唯一标识获取单体企业信息")
public Result<EntResp> getById( public Result<EntResp> getById(
@Schema(title = "企业ID", type = "Long", defaultValue = "1", description = "企业唯一标识") @Schema(title = "企业ID", type = "Long", defaultValue = "1", description = "企业唯一标识")
@ -79,7 +79,7 @@ public class SysEntController extends BaseController {
* @param entAddReq * @param entAddReq
* @return * @return
*/ */
@PostMapping @PostMapping(value = "/save")
@Operation(summary = "添加企业信息", description = "将企业信息添加到系统中") @Operation(summary = "添加企业信息", description = "将企业信息添加到系统中")
public Result<String> save(@Validated @RequestBody EntAddReq entAddReq) { public Result<String> save(@Validated @RequestBody EntAddReq entAddReq) {
sysEntService.save(EntAddReq.addBuild(entAddReq)); sysEntService.save(EntAddReq.addBuild(entAddReq));
@ -92,7 +92,7 @@ public class SysEntController extends BaseController {
* @param entUpdateReq * @param entUpdateReq
* @return * @return
*/ */
@PutMapping(value = "/{entId}") @PutMapping(value = "/update/{entId}")
@Operation(summary = "修改企业信息",description = "根据企业唯一标识修改企业信息") @Operation(summary = "修改企业信息",description = "根据企业唯一标识修改企业信息")
public Result<String> update(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识") public Result<String> update(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId") Long entId, @NotNull(message = "企业ID不能为空") @PathVariable(value = "entId") Long entId,
@ -106,7 +106,7 @@ public class SysEntController extends BaseController {
* @param entId ID * @param entId ID
* @return * @return
*/ */
@RequestMapping(value = "/entId",method = RequestMethod.DELETE) @RequestMapping(value = "/remove/{entId}",method = RequestMethod.DELETE)
@Operation(summary = "删除企业信息",description = "根据企业唯一标识删除企业记录") @Operation(summary = "删除企业信息",description = "根据企业唯一标识删除企业记录")
public Result<String> remove(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识") public Result<String> remove(@Schema(title = "企业ID",type = "Long",defaultValue = "1",description = "企业唯一标识")
@NotNull(message = "企业ID不能为空") @PathVariable(value = "entId")Long entId){ @NotNull(message = "企业ID不能为空") @PathVariable(value = "entId")Long entId){

View File

@ -16,6 +16,7 @@ import com.muyu.system.domain.resp.AuthRoleResp;
import com.muyu.system.domain.resp.UserDetailInfoResp; import com.muyu.system.domain.resp.UserDetailInfoResp;
import com.muyu.system.domain.resp.UserInfoResp; import com.muyu.system.domain.resp.UserInfoResp;
import com.muyu.system.service.*; import com.muyu.system.service.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -23,6 +24,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.sql.*;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -32,6 +35,7 @@ import java.util.stream.Collectors;
* *
* @author muyu * @author muyu
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/user") @RequestMapping("/user")
public class SysUserController extends BaseController { public class SysUserController extends BaseController {
@ -120,20 +124,24 @@ public class SysUserController extends BaseController {
@PostMapping("/register") @PostMapping("/register")
public Result<Boolean> register (@RequestBody RegisterBody registerBody) { public Result<Boolean> register (@RequestBody RegisterBody registerBody) {
String username = registerBody.getUsername(); String username = registerBody.getUsername();
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) { SysUser sysUser = new SysUser();
return Result.error("当前系统没有开启注册功能!"); sysUser.setUserName(username);
} if (!userService.checkUserNameUnique(sysUser)) {
SysUser sysUser = SysUser.builder().userName(username).build(); return Result.error("保存用户'" + username + "'失败,注册账号已存在");
}
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser")))) {
return Result.error("当前系统没有开启注册功能!");
}
if (!userService.checkUserNameUnique(sysUser)) { if (!userService.checkUserNameUnique(sysUser)) {
return Result.error("保存用户'" + username + "'失败,注册账号已存在"); return Result.error("保存用户'" + username + "'失败,注册账号已存在");
} }
//添加企业 //添加企业
SysEnt sysEnt = SysEnt.builder() SysEnt sysEnt = SysEnt.builder()
.name(registerBody.getEntName()) .name(registerBody.getEntName())
.leader(registerBody.getLeader()) .leader(registerBody.getLeader())
.phone(registerBody.getPhone()) .phone(registerBody.getPhone())
.email(registerBody.getEmail()) .email(registerBody.getEmail())
.entCode(registerBody.getUsername())
.build(); .build();
entService.save(sysEnt); entService.save(sysEnt);
@ -151,7 +159,79 @@ public class SysUserController extends BaseController {
sysUser.setDeptId(sysDept.getDeptId()); sysUser.setDeptId(sysDept.getDeptId());
sysUser.setNickName(registerBody.getUsername()); sysUser.setNickName(registerBody.getUsername());
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword())); sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
sysUser.setNickName("注册");
boolean b = userService.registerUser(sysUser);
if (b == true) {
//数据库驱动
String mysqlDriver = "com.mysql.jdbc.Driver";
//数据库地址
String url = "jdbc:mysql://106.15.136.7:3306/";
//数据库用户名
String name = "root";
//数据库密码
String password = "Six@211206";
Collection collection = null;
Collection stmt = null;
//创建数据库SQL
try {
Class.forName(mysqlDriver);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
String databaseSQL = "create database "+username ;
//添加企业信息
String tableSQL = "create table sys_ent (id int auto_increment primary key comment '主键id'," +
"name varchar(16) comment '企业名称'," +
"leader varchar(16) comment '负责人'," +
"phone varchar(11) comment '联系电话'," +
"email varchar(32) comment '邮箱'," +
"ent_code varchar(64) comment '企业编码'," +
"ent_status varchar(64) comment '企业状态'," +
"create_by varchar(32) comment '创建人'," +
"update_by varchar(32) comment '创建时间'," +
"create_time datetime comment '修改人'," +
"update_time datetime comment '修改时间'," +
"remark varchar(32) comment '备注')";
//连接数据库
try {
Connection connection = DriverManager.getConnection(url, name, password);
//用于执行编译sql语句的对象
Statement connStatement = connection.createStatement();
if (connection != null) {
//执行建库语句
connStatement.executeUpdate(databaseSQL);
log.info("创建数据库成功");
//连接新建数据库
Connection connection1 = DriverManager.getConnection(url + username, name, password);
if (connection1 != null) {
log.info("连接数据库成功"+username);
Statement statement = connection1.createStatement();
//执行建表语句
statement.executeUpdate(tableSQL);
log.info("创建表成功");
String insertSQL="INSERT INTO sys_ent (name, leader, phone, email, ent_code, ent_status, create_by, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
try(PreparedStatement preparedStatement = connection1.prepareStatement(insertSQL)) {
//设置插入的值
preparedStatement.setString(1,registerBody.getEntName());
preparedStatement.setString(2,registerBody.getLeader());
preparedStatement.setString(3,registerBody.getPhone());
preparedStatement.setString(4,registerBody.getEmail());
preparedStatement.setString(5,username);
preparedStatement.setInt(6,0);
preparedStatement.setString(7, sysUser.getCreateBy());
preparedStatement.setTimestamp(8, new Timestamp(System.currentTimeMillis())); // 当前时间
preparedStatement.executeUpdate();
log.info("插入企业信息成功");
}
return Result.success();
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return Result.success(userService.registerUser(sysUser)); return Result.success(userService.registerUser(sysUser));
} }