Merge branch 'dev.business' into dev
commit
709878fbab
|
@ -62,6 +62,11 @@
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-saas</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.muyu.auth.form.LoginBody;
|
||||||
import com.muyu.auth.form.RegisterBody;
|
import com.muyu.auth.form.RegisterBody;
|
||||||
import com.muyu.auth.service.SysFirmService;
|
import com.muyu.auth.service.SysFirmService;
|
||||||
import com.muyu.auth.service.SysLoginService;
|
import com.muyu.auth.service.SysLoginService;
|
||||||
|
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.JwtUtils;
|
import com.muyu.common.core.utils.JwtUtils;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
@ -13,6 +14,7 @@ import com.muyu.common.security.auth.AuthUtil;
|
||||||
import com.muyu.common.security.service.TokenService;
|
import com.muyu.common.security.service.TokenService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
@ -21,11 +23,17 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* token 控制
|
* token 控制
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@Log4j2
|
||||||
@RestController
|
@RestController
|
||||||
public class TokenController {
|
public class TokenController {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -81,9 +89,39 @@ public class TokenController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业入入驻
|
||||||
|
* @param settlement
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/enterprise")
|
@PostMapping("/enterprise")
|
||||||
public Result<?> enterprise( @RequestBody EnterpriseSettlement settlement){
|
public Result<?> enterprise( @RequestBody EnterpriseSettlement settlement){
|
||||||
|
|
||||||
|
String createDatabaseUrl="jdbc:mysql://"+ DatasourceContent.IP+":"+DatasourceContent.PORT+"?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
||||||
|
String createDatabaseSql = "CREATE DATABASE IF NOT EXISTS " + settlement.getDatabaseName() + ";";
|
||||||
|
try (Connection adminConn = DriverManager.getConnection(createDatabaseUrl, DatasourceContent.USER_NAME, DatasourceContent.PASSWORD);
|
||||||
|
Statement stmt = adminConn.createStatement()) {
|
||||||
|
|
||||||
|
boolean success = stmt.execute(createDatabaseSql);
|
||||||
|
if (success) {
|
||||||
|
log.info("数据库 {} 创建成功", settlement.getDatabaseName());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.warn("数据库 {} 创建失败", settlement.getDatabaseName());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("连接数据库时发生错误或创建数据库失败", e);
|
||||||
|
}
|
||||||
|
//企业入组
|
||||||
sysLoginService.enterprise(settlement.getDatabaseName(),settlement.getFirmName());
|
sysLoginService.enterprise(settlement.getDatabaseName(),settlement.getFirmName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
|
|
||||||
<artifactId>cloud-common-saas</artifactId>
|
<artifactId>cloud-common-saas</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
cloud-common-saas 模块
|
||||||
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
@ -31,6 +35,11 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.29</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -40,7 +40,7 @@ import java.util.Map;
|
||||||
public class ManyDataSource implements ApplicationRunner{
|
public class ManyDataSource implements ApplicationRunner{
|
||||||
private List<EntInfo> dataSourceInfoList(){
|
private List<EntInfo> dataSourceInfoList(){
|
||||||
RemoteSaaSService remoteSaaSService = SpringUtils.getBean(RemoteSaaSService.class);
|
RemoteSaaSService remoteSaaSService = SpringUtils.getBean(RemoteSaaSService.class);
|
||||||
Result<List<Datasource>> tableDataInfoResult = remoteSaaSService.findDatabaseList();
|
Result<List<Datasource>> tableDataInfoResult = remoteSaaSService.findDatabaseList();
|
||||||
if (tableDataInfoResult==null){
|
if (tableDataInfoResult==null){
|
||||||
throw new SaaSException("saas远调数据源错误");
|
throw new SaaSException("saas远调数据源错误");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,8 @@ public class DatasourceContent {
|
||||||
public final static String IP = "47.101.53.251";
|
public final static String IP = "47.101.53.251";
|
||||||
|
|
||||||
public final static Integer PORT = 3306;
|
public final static Integer PORT = 3306;
|
||||||
|
|
||||||
|
public static String getDatasourceUrl(String databaseName) {
|
||||||
|
return String.format(DATASOURCE_URL,USER_NAME,PASSWORD,IP,PORT, databaseName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,6 @@ public interface RemoteUserService {
|
||||||
* @param source
|
* @param source
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/settlement")
|
@PostMapping("/user/enterprise")
|
||||||
Result<Boolean>settlementEnterpriseInfo(@RequestBody Enterprise enterprise, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
Result<Boolean>settlementEnterpriseInfo(@RequestBody Enterprise enterprise, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,20 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
*/
|
*/
|
||||||
int insertUser(SysUser user);
|
int insertUser(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业入驻
|
||||||
|
* @param enterprise
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int enterprise(Enterprise enterprise);
|
int enterprise(Enterprise enterprise);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业管理添加
|
||||||
|
* @param enterprise
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int enterPriseAdd(Enterprise enterprise);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.muyu.system.domain.SysConfig;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 配置plus业务层
|
||||||
* @author DongZl
|
* @author DongZl
|
||||||
* @description: 配置plus业务层
|
* @description: 配置plus业务层
|
||||||
* @Date 2023-11-13 上午 10:06
|
* @Date 2023-11-13 上午 10:06
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 配置plus业务实现层
|
||||||
* @author DongZl
|
* @author DongZl
|
||||||
* @description: 配置plus业务实现层
|
* @description: 配置plus业务实现层
|
||||||
* @Date 2023-11-13 上午 10:06
|
* @Date 2023-11-13 上午 10:06
|
||||||
|
|
|
@ -258,8 +258,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
return userMapper.insertUser(user) > 0;
|
return userMapper.insertUser(user) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业入驻
|
||||||
|
* @param enterprise
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean enterprise(Enterprise enterprise){
|
public boolean enterprise(Enterprise enterprise){
|
||||||
|
userMapper.enterPriseAdd(enterprise);
|
||||||
return userMapper.enterprise(enterprise) > 0;
|
return userMapper.enterprise(enterprise) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,10 @@
|
||||||
<insert id="enterprise">
|
<insert id="enterprise">
|
||||||
INSERT INTO `datasource`.`datasource` (`id`, `firm_name`, `database_name`) VALUES (NULL, #{firmName}, #{databaseName});
|
INSERT INTO `datasource`.`datasource` (`id`, `firm_name`, `database_name`) VALUES (NULL, #{firmName}, #{databaseName});
|
||||||
</insert>
|
</insert>
|
||||||
|
<insert id="enterPriseAdd">
|
||||||
|
INSERT INTO `saas`.`tb_enterprise` (`enterprise_id`, `enterprise_name`, `enterprise_car_count`, `enterprise_fence_count`, `enterprise_database_name`)
|
||||||
|
VALUES (NULL, #{firmName}, 0, 0, #{databaseName});
|
||||||
|
</insert>
|
||||||
|
|
||||||
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
||||||
update sys_user
|
update sys_user
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.muyu.common.domain;
|
package com.muyu.common.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -20,17 +22,27 @@ public class Enterprise {
|
||||||
/**
|
/**
|
||||||
* 企业编号
|
* 企业编号
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "企业编号")
|
||||||
private Integer enterpriseId;
|
private Integer enterpriseId;
|
||||||
/**
|
/**
|
||||||
* 企业名称
|
* 企业名称
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "企业名称")
|
||||||
private String enterpriseName;
|
private String enterpriseName;
|
||||||
/**
|
/**
|
||||||
* 企业车辆数量
|
* 企业车辆数量
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "企业拥有车辆数据")
|
||||||
private Integer enterpriseCarCount;
|
private Integer enterpriseCarCount;
|
||||||
/**
|
/**
|
||||||
* 企业电子围栏数量
|
* 企业电子围栏数量
|
||||||
*/
|
*/
|
||||||
|
@Excel(name = "企业所属电子围栏")
|
||||||
private Integer enterpriseFenceCount;
|
private Integer enterpriseFenceCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业数据库名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "企业所属数据库")
|
||||||
|
private String enterpriseDatabaseName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ import lombok.experimental.SuperBuilder;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:liuxinyue
|
* 报文模版
|
||||||
|
* @author liuxinyue
|
||||||
* @Package:com.sheep.message.domain
|
* @Package:com.sheep.message.domain
|
||||||
* @Project:cloud-server-c
|
* @Project:cloud-server-c
|
||||||
* @name:MessageTemplateType
|
* @name:MessageTemplateType
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
package com.muyu.common.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业信息 sys_car_enterprise
|
|
||||||
* @author 袁子龙
|
|
||||||
* @package com.muyu.breakdown.domain
|
|
||||||
* @name: SysCarEnterprise
|
|
||||||
* @date: 2024/9/26 19:54
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_car_enterprise")
|
|
||||||
public class SysCarEnterprise extends BaseEntity {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 企业id*/
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 企业名称*/
|
|
||||||
@Excel(name = "企业名称")
|
|
||||||
private String enterpriseName;
|
|
||||||
/** 用户姓名 */
|
|
||||||
@Excel(name = "用户姓名")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Excel(name = "用户职位")
|
|
||||||
private String position;
|
|
||||||
|
|
||||||
@Excel(name = "公司所在省")
|
|
||||||
private String province;
|
|
||||||
|
|
||||||
@Excel(name = "公司所在市")
|
|
||||||
private String city;
|
|
||||||
|
|
||||||
@Excel(name = "公司所在县/区")
|
|
||||||
private String county;
|
|
||||||
|
|
||||||
@Excel(name = "公司详细地址")
|
|
||||||
private String address;
|
|
||||||
|
|
||||||
@Excel(name = "统一社会信用代码")
|
|
||||||
private String creditCode;
|
|
||||||
|
|
||||||
@Excel(name = "营业执照")
|
|
||||||
private String businessLicense;
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,7 +18,8 @@ import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:liuxinyue
|
* 报文模版管理
|
||||||
|
* @author liuxinyue
|
||||||
* @Package:com.template.controller
|
* @Package:com.template.controller
|
||||||
* @Project:cloud-server-c
|
* @Project:cloud-server-c
|
||||||
* @name:TemplateController
|
* @name:TemplateController
|
||||||
|
|
|
@ -22,4 +22,7 @@ public class InsertEnterprise {
|
||||||
|
|
||||||
@NotNull(message = "enterpriseFenceCount企业围栏组不能为空")
|
@NotNull(message = "enterpriseFenceCount企业围栏组不能为空")
|
||||||
private Integer enterpriseFenceCount;
|
private Integer enterpriseFenceCount;
|
||||||
|
|
||||||
|
@NotNull(message = "enterpriseDatabaseName企业数据库名称不能为空")
|
||||||
|
private String enterpriseDatabaseName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,7 @@ public class UpdateEnterprise {
|
||||||
|
|
||||||
@NotNull(message = "enterpriseFenceCount企业围栏组不能为空")
|
@NotNull(message = "enterpriseFenceCount企业围栏组不能为空")
|
||||||
private Integer enterpriseFenceCount;
|
private Integer enterpriseFenceCount;
|
||||||
|
|
||||||
|
@NotNull(message = "enterpriseDatabaseName企业数据库名称不能为空")
|
||||||
|
private String enterpriseDatabaseName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.server.mapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* kafka
|
||||||
* @author liuxinyue
|
* @author liuxinyue
|
||||||
* @Package:com.muyu.server.mapper
|
* @Package:com.muyu.server.mapper
|
||||||
* @name:KafkaMapper
|
* @name:KafkaMapper
|
||||||
|
|
|
@ -31,14 +31,15 @@
|
||||||
insert into tb_enterprise
|
insert into tb_enterprise
|
||||||
set enterprise_name = #{enterpriseName},
|
set enterprise_name = #{enterpriseName},
|
||||||
enterprise_car_count = #{enterpriseCarCount},
|
enterprise_car_count = #{enterpriseCarCount},
|
||||||
enterprise_fence_count = #{enterpriseFenceCount}
|
enterprise_fence_count = #{enterpriseFenceCount},
|
||||||
|
enterprise_database_name=#{enterpriseDatabaseName}
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--根据编号查询企业信息-->
|
<!--根据编号查询企业信息-->
|
||||||
<select id="searchById" resultType="java.util.HashMap">
|
<select id="searchById" resultType="java.util.HashMap">
|
||||||
select enterprise_id,enterprise_name,enterprise_car_count,enterprise_fence_count
|
select enterprise_id,enterprise_name,enterprise_car_count,enterprise_fence_count,enterprise_database_name
|
||||||
from tb_enterprise
|
from tb_enterprise
|
||||||
where enterprise_id = #{enterpriseId}
|
where enterprise_id = #{enterpriseId}
|
||||||
</select>
|
</select>
|
||||||
|
@ -47,7 +48,8 @@
|
||||||
update tb_enterprise
|
update tb_enterprise
|
||||||
set enterprise_name = #{enterpriseName},
|
set enterprise_name = #{enterpriseName},
|
||||||
enterprise_car_count = #{enterpriseCarCount},
|
enterprise_car_count = #{enterpriseCarCount},
|
||||||
enterprise_fence_count = #{enterpriseFenceCount}
|
enterprise_fence_count = #{enterpriseFenceCount},
|
||||||
|
enterprise_database_name=#{enterpriseDatabaseName}
|
||||||
where enterprise_id = #{enterpriseId} and enterprise_id != 0
|
where enterprise_id = #{enterpriseId} and enterprise_id != 0
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue