dev.wei
parent
f27b14dc33
commit
3bf6f0d929
|
@ -30,6 +30,10 @@ public class RegisterBody extends LoginBody {
|
|||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phoneNumber;
|
||||
private String phonenumber;
|
||||
/**
|
||||
* 公司注册人名称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
}
|
||||
|
|
|
@ -127,10 +127,18 @@ public class SysLoginService {
|
|||
|
||||
// 注册用户信息
|
||||
SysUser sysUser = new SysUser();
|
||||
//公司账号
|
||||
sysUser.setUserName(registerBody.getUsername());
|
||||
//公司邮箱
|
||||
sysUser.setEmail(registerBody.getEmail());
|
||||
sysUser.setPhonenumber(registerBody.getPhoneNumber());
|
||||
//公司号码
|
||||
sysUser.setPhonenumber(registerBody.getPhonenumber());
|
||||
//密码
|
||||
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
||||
//公司注册人名称
|
||||
sysUser.setNickName(registerBody.getNickName());
|
||||
//企业名称
|
||||
sysUser.setFirmName(registerBody.getFirmName());
|
||||
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||
|
||||
if (Result.FAIL == registerResult.getCode()) {
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -87,7 +87,6 @@ public class SysUser extends BaseEntity {
|
|||
* 企业ID
|
||||
*/
|
||||
private Integer firmId;
|
||||
|
||||
/**
|
||||
* 所属数据库
|
||||
*/
|
||||
|
@ -145,6 +144,12 @@ public class SysUser extends BaseEntity {
|
|||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
* @param userId
|
||||
*/
|
||||
private String firmName;
|
||||
|
||||
public SysUser (Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.muyu.server.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.firmmanage.domain.Firm;
|
||||
import com.muyu.domain.Firm;
|
||||
|
||||
/**
|
||||
* 公司业务层
|
||||
|
|
|
@ -152,4 +152,5 @@ public class CarInformationServiceImpl
|
|||
});
|
||||
return carInformationResps;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.muyu.server.mapper.CarFenceMapper;
|
|||
import com.muyu.server.mapper.CarInformationMapper;
|
||||
import com.muyu.server.mapper.FaultConditionMapper;
|
||||
import com.muyu.server.mapper.FaultRuleMapper;
|
||||
import com.muyu.server.service.CarInformationService;
|
||||
import com.muyu.server.service.FaultRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -29,6 +30,8 @@ import java.util.List;
|
|||
@Service
|
||||
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultRule> implements FaultRuleService {
|
||||
|
||||
@Autowired
|
||||
private CarInformationService carInformationService;
|
||||
@Autowired
|
||||
private CarInformationMapper carInformationMapper;
|
||||
@Autowired
|
||||
|
@ -45,6 +48,7 @@ public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultR
|
|||
//根据车辆VIN判断它属于什么类型的车辆
|
||||
CarInformation carInformation = carInformationMapper.selectById(carFaultRule.getVin());
|
||||
Integer carInformationType = carInformation.getCarInformationType();
|
||||
// carInformationService.selectTypeByVIN(carFaultRule.getVin());
|
||||
//根据车辆类型,查询表获取对应的类型的故障规则
|
||||
|
||||
List<FaultConditionResp> faultConditionResps = faultConditionMapper.selectJoinList(FaultConditionResp.class, new MPJLambdaWrapper<FaultCondition>()
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package com.muyu.server.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.firmmanage.domain.Firm;
|
||||
import com.muyu.firmmanage.domain.SysUser;
|
||||
import com.muyu.firmmanage.domain.req.FirmListReq;
|
||||
import com.muyu.firmmanage.domain.resp.firmlist.FirmListResp;
|
||||
import com.muyu.firmmanage.domain.resp.firmlist.FirmTotalListResp;
|
||||
import com.muyu.firmmanage.mapper.FirmManageMapper;
|
||||
import com.muyu.firmmanage.service.FirmManageService;
|
||||
import com.muyu.firmmanage.service.FirmService;
|
||||
import com.muyu.domain.Firm;
|
||||
import com.muyu.domain.SysUser;
|
||||
import com.muyu.domain.req.FirmListReq;
|
||||
import com.muyu.domain.resp.FirmListResp;
|
||||
import com.muyu.domain.resp.FirmTotalListResp;
|
||||
import com.muyu.server.mapper.FirmManageMapper;
|
||||
import com.muyu.server.service.FirmManageService;
|
||||
import com.muyu.server.service.FirmService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ package com.muyu.server.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.firmmanage.domain.Firm;
|
||||
import com.muyu.firmmanage.mapper.FirmMapper;
|
||||
import com.muyu.firmmanage.service.FirmService;
|
||||
import com.muyu.domain.Firm;
|
||||
import com.muyu.server.mapper.FirmMapper;
|
||||
import com.muyu.server.service.FirmService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -142,4 +142,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
|
||||
List<SysUser> companyList();
|
||||
|
||||
/**
|
||||
* 添加公司名称
|
||||
* @param firmName
|
||||
* @param datbaseName
|
||||
* @return
|
||||
*/
|
||||
Integer insertFirm(@Param("firmName") String firmName, @Param("datbaseName") String datbaseName);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.server.service;
|
||||
package com.muyu.system.service;
|
||||
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.muyu.server.service.impl;
|
||||
package com.muyu.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.server.service.DataBaseCreator;
|
||||
import com.muyu.system.service.DataBaseCreator;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
@ -30,22 +30,20 @@ public class DataBaseCreatorImpl implements DataBaseCreator {
|
|||
try {
|
||||
Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
||||
Statement statement = conn.createStatement();
|
||||
String datbaseName="company"+RandomUtil.randomString(10000);
|
||||
String datbaseName="company"+RandomUtil.randomNumbers(5);
|
||||
//创建数据库
|
||||
String sql="CREATE DATABASE IF NOT EXISTS "+datbaseName;
|
||||
statement.execute(sql);
|
||||
//使用数据库
|
||||
sql="USE "+datbaseName;
|
||||
statement.execute(sql);
|
||||
//创建表
|
||||
sql="CREATE TABLE user ("+
|
||||
String sqlCreateDatabase ="CREATE DATABASE IF NOT EXISTS "+datbaseName;
|
||||
String sqlUseDatabase="USE "+datbaseName;
|
||||
String sqlCreateTable="CREATE TABLE user ("+
|
||||
"user_id INT AUTO_INCREMENT PRIMARY KEY,"+
|
||||
"user_name VARCHAR(50) NOT NULL )";
|
||||
statement.execute(sql);
|
||||
statement.execute(sqlCreateDatabase);
|
||||
statement.execute(sqlUseDatabase);
|
||||
statement.execute(sqlCreateTable);
|
||||
return datbaseName;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("数据库创建失败");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import com.muyu.system.domain.SysPost;
|
|||
import com.muyu.system.domain.SysUserPost;
|
||||
import com.muyu.system.domain.SysUserRole;
|
||||
import com.muyu.system.mapper.*;
|
||||
import com.muyu.system.service.DataBaseCreator;
|
||||
import com.muyu.system.service.SysUserService;
|
||||
import com.muyu.system.service.SysConfigService;
|
||||
import jakarta.validation.Validator;
|
||||
|
@ -50,6 +51,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
private SysUserPostMapper userPostMapper;
|
||||
@Autowired
|
||||
private SysConfigService configService;
|
||||
@Autowired
|
||||
private DataBaseCreator baseCreator;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
|
@ -254,9 +257,24 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
*/
|
||||
@Override
|
||||
public boolean registerUser (SysUser user) {
|
||||
|
||||
|
||||
return userMapper.insertUser(user) > 0;
|
||||
//根据新注册的用户创建对应数据库
|
||||
String datbaseName = baseCreator.createDatbase(user);
|
||||
//添加公司名称
|
||||
userMapper.insertFirm(user.getFirmName(),datbaseName);
|
||||
Integer firmId = user.getFirmId();
|
||||
user.setFirmId(firmId);
|
||||
//添加用户表
|
||||
int i = userMapper.insertUser(user);
|
||||
List<SysUser> userList = userMapper.selectUserList(user);
|
||||
Long userId = userList.get(0).getUserId();
|
||||
ArrayList<SysUserRole> list = new ArrayList<>();
|
||||
//将用户和角色进行关联
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(userId);
|
||||
userRole.setRoleId(2L);
|
||||
list.add(userRole);
|
||||
userRoleMapper.batchUserRole(list);
|
||||
return i > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -222,6 +222,11 @@
|
|||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertFirm" useGeneratedKeys="true" keyProperty="firmId">
|
||||
INSERT INTO `eight`.`firm`
|
||||
(`firm_id`, `firm_name`, `database_name`) VALUES
|
||||
(0, #{firmName}, #{datbaseName});
|
||||
</insert>
|
||||
|
||||
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
||||
update sys_user
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
Loading…
Reference in New Issue