feat(): 运营平台添加企业再添加部门和用户角色
parent
18914f5b70
commit
b80d833bea
|
@ -39,6 +39,10 @@ public class Result<T> implements Serializable {
|
|||
|
||||
private T data;
|
||||
|
||||
public static <T> Result<T> buildCode(int code, String msg, T data){
|
||||
return restResult(data, code, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success () {
|
||||
return restResult(null, SUCCESS, null);
|
||||
}
|
||||
|
@ -50,7 +54,6 @@ public class Result<T> implements Serializable {
|
|||
public static <T> Result<T> success (T data, String msg) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error () {
|
||||
return restResult(null, FAIL, null);
|
||||
}
|
||||
|
|
|
@ -111,11 +111,11 @@ public class VehicleController extends BaseController {
|
|||
return toAjax(vehicleService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
// @Autowired
|
||||
// private VehicleMapper vehicleMapper;
|
||||
|
||||
@GetMapping("/list/all")
|
||||
public Result<List<Vehicle>> findAll () {
|
||||
return Result.success(vehicleMapper.selectList(new QueryWrapper<>()));
|
||||
}
|
||||
// @GetMapping("/list/all")
|
||||
// public Result<List<Vehicle>> findAll () {
|
||||
// return Result.success(vehicleMapper.selectList(new QueryWrapper<>()));
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-many-datasource</artifactId>
|
||||
<description>
|
||||
动态多数据源
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
package com.muyu.many.datasource;
|
||||
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* 多数据源启动类 CloudManyDataSourceApplication
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/3 18:51
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication(exclude =
|
||||
{DynamicDataSourceAutoConfiguration.class, DataSourceAutoConfiguration.class}
|
||||
)
|
||||
public class MuYuManyDataSourceApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(MuYuManyDataSourceApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.muyu.many.datasource.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.many.datasource.domain.Vehicle;
|
||||
import com.muyu.many.datasource.mapper.VehicleMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆控制层 VehicleController
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/4 14:08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/vehicle")
|
||||
public class VehicleController {
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@GetMapping("/list/all")
|
||||
public Result<List<Vehicle>> findAll () {
|
||||
return Result.success(vehicleMapper.selectList(new QueryWrapper<>()));
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package com.muyu.many.datasource.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 车辆录入对象 vehicle
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-27
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName(value = "vehicle")
|
||||
public class Vehicle extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 车辆id */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 车辆vin */
|
||||
private String vin;
|
||||
|
||||
/** 品牌 */
|
||||
private String brand;
|
||||
|
||||
/** 型号 */
|
||||
private String model;
|
||||
|
||||
/** 生产日期 */
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date productionDate;
|
||||
|
||||
/** 车身类型 */
|
||||
private String bodyType;
|
||||
|
||||
/** 车身颜色 */
|
||||
private String color;
|
||||
|
||||
/** 发动机排量 */
|
||||
private BigDecimal engineCapacity;
|
||||
|
||||
/** 燃油类型 */
|
||||
private String fuelType;
|
||||
|
||||
/** 变速器类型 */
|
||||
private String transmission;
|
||||
|
||||
/** 驱动方式 */
|
||||
private String driveType;
|
||||
|
||||
/** 行驶里程 */
|
||||
@Excel(name = "行驶里程")
|
||||
@ApiModelProperty(name = "行驶里程", value = "行驶里程")
|
||||
private BigDecimal mileage;
|
||||
|
||||
/** 注册日期 */
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date registrationDate;
|
||||
|
||||
/** 车牌号码 */
|
||||
private String licenseNumber;
|
||||
|
||||
/** 持有者 */
|
||||
private String holder;
|
||||
|
||||
/** 车辆类型 */
|
||||
private String vehicleType;
|
||||
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.muyu.many.datasource.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.many.datasource.domain.Vehicle;
|
||||
|
||||
/**
|
||||
* 车辆mapper VehicleMapper
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/4 14:07
|
||||
*/
|
||||
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -1,30 +0,0 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9206
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-many-datasource
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace: jinmo
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
namespace: jinmo
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.many.datasource.mapper: DEBUG
|
|
@ -1,74 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/muyu-many-datasource"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -1,29 +0,0 @@
|
|||
package com.muyu.net.working.feign;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 用户添加远程调用 UserFeign
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/6 09:06
|
||||
*/
|
||||
@FeignClient("muyu-system/dept")
|
||||
public interface DeptFeign {
|
||||
|
||||
@RequiresPermissions("system:dept:add")
|
||||
@PostMapping
|
||||
public Result add (@Validated @RequestBody SysDept dept);
|
||||
|
||||
@RequiresPermissions("system:dept:list")
|
||||
@GetMapping("/list")
|
||||
public Result list (SysDept dept);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package com.muyu.net.working.feign;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 用户添加远程调用 UserFeign
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/6 09:06
|
||||
*/
|
||||
@FeignClient("muyu-system/user")
|
||||
public interface UserFeign {
|
||||
@RequiresPermissions("system:user:add")
|
||||
@PostMapping("")
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
}
|
|
@ -28,6 +28,11 @@
|
|||
<artifactId>muyu-net-working-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
package com.muyu.net.working.controller;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.net.working.feign.DeptFeign;
|
||||
import com.muyu.net.working.feign.UserFeign;
|
||||
import com.muyu.system.remote.RemoteSysDeptService;
|
||||
import com.muyu.system.remote.RemoteSysUserService;
|
||||
import com.muyu.system.remote.factory.RemoteSysDeptFactory;
|
||||
import io.swagger.annotations.*;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -37,15 +43,17 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
* @date 2024-06-05
|
||||
*/
|
||||
@Api(tags = "车辆运营平台")
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/car")
|
||||
public class EnterpriseController extends BaseController {
|
||||
@Autowired
|
||||
private EnterpriseService enterpriseService;
|
||||
|
||||
@Autowired
|
||||
private UserFeign userFeign;
|
||||
private RemoteSysDeptService remoteSysDeptService;
|
||||
@Autowired
|
||||
private DeptFeign deptFeign;
|
||||
private RemoteSysUserService remoteSysUserService;
|
||||
|
||||
/**
|
||||
* 查询车辆运营平台列表
|
||||
|
@ -91,19 +99,64 @@ public class EnterpriseController extends BaseController {
|
|||
@PostMapping
|
||||
@ApiOperation("新增车辆运营平台")
|
||||
public Result<String> add(@RequestBody EnterpriseSaveReq enterpriseSaveReq) {
|
||||
|
||||
|
||||
SysDept sysDept = new SysDept();
|
||||
sysDept.setDeptName(enterpriseSaveReq.getEbterpriseName());
|
||||
Result list = deptFeign.list(sysDept);
|
||||
if (list!=null){
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser sysUser = loginUser.getSysUser();
|
||||
Result<SysDept> DeptList = remoteSysDeptService.selectDeptByName(enterpriseSaveReq.getEbterpriseName());
|
||||
SysDept sysDept = DeptList.getData();
|
||||
if(sysDept!=null){
|
||||
return Result.error("部门名称重复");
|
||||
}
|
||||
Result add = deptFeign.add(sysDept);
|
||||
addDept(enterpriseSaveReq, sysUser);
|
||||
addUser(enterpriseSaveReq,sysUser);
|
||||
|
||||
return toAjax(enterpriseService.save(Enterprise.saveBuild(enterpriseSaveReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加部门表信息
|
||||
* @param enterpriseSaveReq
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
public void addDept(EnterpriseSaveReq enterpriseSaveReq,SysUser sysUser){
|
||||
|
||||
SysDept DeptBuild = SysDept.builder()
|
||||
.deptName(enterpriseSaveReq.getEbterpriseName())
|
||||
.parentId(100L)
|
||||
.ancestors("0,100")
|
||||
.orderNum(2)
|
||||
.status("0")
|
||||
.createBy(sysUser.getUserName())
|
||||
.createTime(new Date())
|
||||
.leader(sysUser.getNickName())
|
||||
.phone(sysUser.getPhonenumber())
|
||||
.email(sysUser.getEmail())
|
||||
.delFlag("0")
|
||||
.build();
|
||||
remoteSysDeptService.add(DeptBuild);
|
||||
}
|
||||
|
||||
public void addUser(EnterpriseSaveReq enterpriseSaveReq,SysUser sysUser){
|
||||
Result<SysDept> sysDeptResult = remoteSysDeptService.selectDeptByName(enterpriseSaveReq.getEbterpriseName());
|
||||
SysDept sysDept = sysDeptResult.getData();
|
||||
SysUser UserBuild = SysUser.builder()
|
||||
.userName(enterpriseSaveReq.getEbterpriseName())
|
||||
.nickName(enterpriseSaveReq.getEbterpriseName())
|
||||
.password("123456")
|
||||
.deptId(sysDept.getDeptId())
|
||||
.email(enterpriseSaveReq.getEmail())
|
||||
.phonenumber(enterpriseSaveReq.getContactPhone())
|
||||
.status("0")
|
||||
.delFlag("0")
|
||||
.roleId(3L)
|
||||
.roleIds(new Long[]{3L})
|
||||
.createBy(sysUser.getUserName())
|
||||
.createTime(new Date())
|
||||
.remark(enterpriseSaveReq.getRemark())
|
||||
.build();
|
||||
remoteSysUserService.add(UserBuild);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车辆运营平台
|
||||
*/
|
||||
|
@ -124,6 +177,7 @@ public class EnterpriseController extends BaseController {
|
|||
@ApiOperation("删除车辆运营平台")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "String", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<String> ids) {
|
||||
|
||||
return toAjax(enterpriseService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,12 @@ public class SysDeptController extends BaseController {
|
|||
return success(depts);
|
||||
}
|
||||
|
||||
@GetMapping("/selectDeptByName")
|
||||
public Result<SysDept> selectDeptByName (@RequestParam("name") String name) {
|
||||
SysDept sysDept = deptService.selectDeptByName(name);
|
||||
return Result.success(sysDept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门列表(排除节点)
|
||||
*/
|
||||
|
|
|
@ -128,4 +128,6 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById (Long deptId);
|
||||
|
||||
SysDept selectDeptByName(@Param("name") String name);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.system.remote;
|
||||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.system.remote.factory.RemoteSysDeptFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 远程调用部门接口 RemoteSysDeptService
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/7 09:00
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "remoteSysDeptService",
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE,
|
||||
fallbackFactory = RemoteSysDeptFactory.class,
|
||||
path = "/dept"
|
||||
)
|
||||
public interface RemoteSysDeptService {
|
||||
@GetMapping("/selectDeptByName")
|
||||
public Result<SysDept> selectDeptByName (@RequestParam("name") String name);
|
||||
|
||||
@PostMapping
|
||||
public Result add (@Validated @RequestBody SysDept dept);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.system.remote;
|
||||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.remote.factory.RemoteSysUserFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 远程调用用户 RemoteSysUserService
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/7 08:51
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "remoteSysUserService",
|
||||
value = ServiceNameConstants.SYSTEM_SERVICE,
|
||||
fallbackFactory = RemoteSysUserFactory.class,
|
||||
path = "/user"
|
||||
)
|
||||
public interface RemoteSysUserService {
|
||||
/**
|
||||
* 新增用户服务
|
||||
* @param user
|
||||
* @return Result
|
||||
*/
|
||||
@RequiresPermissions("system:user:add")
|
||||
@PostMapping
|
||||
public Result add (@Validated @RequestBody SysUser user);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.muyu.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.system.remote.RemoteSysDeptService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
/**
|
||||
* 远程调用部门熔断器 RemoteSysDeptFactory
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/7 09:00
|
||||
*/
|
||||
@Log4j2
|
||||
public class RemoteSysDeptFactory implements FallbackFactory<RemoteSysDeptService> {
|
||||
@Override
|
||||
public RemoteSysDeptService create(Throwable cause) {
|
||||
|
||||
return new RemoteSysDeptService() {
|
||||
/**
|
||||
* 查找部门列表
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<SysDept> selectDeptByName(String name) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加部门管理
|
||||
* @param dept
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result add(SysDept dept) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.muyu.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.system.remote.RemoteSysUserService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
/**
|
||||
* 远程调用用户熔断器 RemoteSysUserFactory
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* Date 2024/6/7 08:54
|
||||
*/
|
||||
public class RemoteSysUserFactory implements FallbackFactory<RemoteSysUserService> {
|
||||
|
||||
@Override
|
||||
public RemoteSysUserService create(Throwable cause) {
|
||||
return new RemoteSysUserService() {
|
||||
|
||||
/**
|
||||
* 新增用户服务
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result add(SysUser user) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -135,4 +135,6 @@ public interface SysDeptService extends IService<SysDept> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteDeptById (Long deptId);
|
||||
|
||||
SysDept selectDeptByName(String name);
|
||||
}
|
||||
|
|
|
@ -280,6 +280,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|||
return deptMapper.deleteDeptById(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDept selectDeptByName(String name) {
|
||||
return deptMapper.selectDeptByName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
|
|
|
@ -238,11 +238,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
public int insertUser (SysUser user) {
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
|
||||
//赋值userId
|
||||
// user.setUserId((long) rows);
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
return rows;
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
com.muyu.system.remote.factory.RemoteSysUserFactory
|
||||
com.muyu.system.remote.factory.RemoteSysDeptFactory
|
|
@ -108,6 +108,9 @@
|
|||
<include refid="selectDeptVo"/>
|
||||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||
</select>
|
||||
<select id="selectDeptByName" resultType="com.muyu.common.system.domain.SysDept">
|
||||
select * from sys_dept where dept_name=#{name}
|
||||
</select>
|
||||
|
||||
<insert id="insertDept" parameterType="com.muyu.common.system.domain.SysDept">
|
||||
insert into sys_dept(
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
<module>muyu-file</module>
|
||||
<module>muyu-net-working</module>
|
||||
<module>muyu-customer-business</module>
|
||||
<module>muyu-many-datasource</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>muyu-modules</artifactId>
|
||||
|
|
Loading…
Reference in New Issue