Merge remote-tracking branch 'origin/dev.saas'
commit
7e3ae3b7b6
|
@ -16,6 +16,7 @@ public class LoginBody {
|
|||
*/
|
||||
private String password;
|
||||
|
||||
|
||||
public String getUsername () {
|
||||
return username;
|
||||
}
|
||||
|
|
|
@ -25,4 +25,9 @@ public class ServiceNameConstants {
|
|||
* 智能车联服务
|
||||
*/
|
||||
public static final String SMART_SERVICE = "cloud-smart-car";
|
||||
|
||||
|
||||
public static final String SAAS_SERVICE = "cloud-saas";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,34 +1,28 @@
|
|||
package com.muyu.cloud.common.many.datasource;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
||||
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
||||
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
|
||||
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
|
||||
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
|
||||
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
||||
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
||||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.system.domain.SysFirmUser;
|
||||
import com.muyu.common.system.domain.Datasource;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.RemoteSaaSService;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -42,20 +36,18 @@ import java.util.Map;
|
|||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
@AutoConfiguration(before = MybatisPlusAutoConfiguration.class)
|
||||
@AutoConfiguration(before = {MybatisPlusAutoConfiguration.class, MybatisAutoConfiguration.class})
|
||||
public class ManyDataSource implements ApplicationRunner{
|
||||
|
||||
|
||||
private List<EntInfo> dataSourceInfoList(){
|
||||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||
Result<List<SysUser>> tableDataInfoResult = remoteUserService.companyList();
|
||||
RemoteSaaSService remoteSaaSService = SpringUtils.getBean(RemoteSaaSService.class);
|
||||
Result<List<Datasource>> tableDataInfoResult = remoteSaaSService.findDatabaseList();
|
||||
if (tableDataInfoResult==null){
|
||||
throw new SaaSException("saas远调数据源错误");
|
||||
}
|
||||
List<SysUser> data = tableDataInfoResult.getData();
|
||||
List<Datasource> data = tableDataInfoResult.getData();
|
||||
if (tableDataInfoResult.getCode() ==Result.SUCCESS && data !=null){
|
||||
List<EntInfo> list = new ArrayList<>();
|
||||
for (SysUser row : data) {
|
||||
for (Datasource row : data) {
|
||||
list.add(
|
||||
EntInfo.builder()
|
||||
.entCode(row.getDatabaseName())
|
||||
|
@ -114,5 +106,4 @@ public class ManyDataSource implements ApplicationRunner{
|
|||
log.info("存储数据连接池为:key:{}",dataSourceInfo.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
package com.muyu.cloud.car.domain;
|
||||
package com.muyu.cloud.common.saas.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author WangXin
|
||||
* @Data 2024/9/19
|
||||
* @Description
|
||||
* @Version 1.0.0
|
||||
*/
|
||||
@TableName("user")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class User {
|
||||
@TableName(value = "datasource", autoResultMap = true)
|
||||
public class Datasource {
|
||||
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
public String firmName;
|
||||
|
||||
public String databaseName;
|
||||
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer userId;
|
||||
|
||||
private String userName;
|
||||
}
|
|
@ -25,5 +25,8 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "datasource", autoResultMap = true)
|
||||
public class Datasource {
|
||||
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
public String firmName;
|
||||
|
||||
public String databaseName;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.muyu.common.system.remote;
|
||||
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.Datasource;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.factory.RemoteSaaSFallbackFactory;
|
||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@FeignClient(contextId = "SaasService", value = ServiceNameConstants.SAAS_SERVICE, fallbackFactory = RemoteSaaSFallbackFactory.class)
|
||||
public interface RemoteSaaSService {
|
||||
|
||||
@GetMapping("/saas/findDatabaseList")
|
||||
public Result<List<Datasource>> findDatabaseList();
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.common.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.Datasource;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.RemoteSaaSService;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务降级处理
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Component
|
||||
public class RemoteSaaSFallbackFactory implements FallbackFactory<RemoteSaaSService> {
|
||||
|
||||
@Override
|
||||
public RemoteSaaSService create(Throwable cause) {
|
||||
return new RemoteSaaSService() {
|
||||
@Override
|
||||
public Result<List<Datasource>> findDatabaseList() {
|
||||
return Result.error("查询数据库失败:" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
|
||||
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
|
||||
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
|
||||
com.muyu.common.system.remote.factory.RemoteSaaSFallbackFactory
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package com.muyu.cloud.car;
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@EnableCustomConfig
|
||||
//@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication(
|
||||
exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DruidDataSourceAutoConfigure.class,
|
||||
DynamicDataSourceAutoConfiguration.class
|
||||
}
|
||||
)
|
||||
public class CarApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CarApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.muyu.cloud.car.controller;
|
||||
|
||||
import com.muyu.cloud.car.domain.User;
|
||||
import com.muyu.cloud.car.service.CarService;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author WangXin
|
||||
* @Data 2024/9/19
|
||||
* @Description 车控制层
|
||||
* @Version 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test")
|
||||
public class CarController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private CarService carService;
|
||||
|
||||
@GetMapping("/sel")
|
||||
public List<User> sel() {
|
||||
return carService.list();
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package com.muyu.cloud.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.cloud.car.domain.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author WangXin
|
||||
* @Data 2024/9/19
|
||||
* @Description
|
||||
* @Version 1.0.0
|
||||
*/
|
||||
public interface CarMapper extends BaseMapper<User> {
|
||||
|
||||
List<User> selectMyList();
|
||||
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.muyu.cloud.car.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.cloud.car.domain.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author WangXin
|
||||
* @Data 2024/9/19
|
||||
* @Description
|
||||
* @Version 1.0.0
|
||||
*/
|
||||
public interface CarService extends IService<User> {
|
||||
|
||||
List<User> selectList();
|
||||
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.muyu.cloud.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cloud.car.domain.User;
|
||||
import com.muyu.cloud.car.mapper.CarMapper;
|
||||
import com.muyu.cloud.car.service.CarService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author WangXin
|
||||
* @Data 2024/9/19
|
||||
* @Description
|
||||
* @Version 1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class CarServiceImpl extends ServiceImpl<CarMapper, User> implements CarService {
|
||||
|
||||
@Resource
|
||||
private CarMapper carMapper;
|
||||
|
||||
@Override
|
||||
public List<User> selectList() {
|
||||
return carMapper.selectMyList();
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 49701
|
||||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 47.101.53.251:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: four
|
||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||
# Spring
|
||||
spring:
|
||||
amqp:
|
||||
deserialization:
|
||||
trust:
|
||||
all: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: cloud-saas
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: ${nacos.addr}
|
||||
# nacos用户名
|
||||
username: ${nacos.user-name}
|
||||
# nacos密码
|
||||
password: ${nacos.password}
|
||||
# 命名空间
|
||||
namespace: ${nacos.namespace}
|
||||
config:
|
||||
# 服务注册地址
|
||||
server-addr: ${nacos.addr}
|
||||
# nacos用户名
|
||||
username: ${nacos.user-name}
|
||||
# nacos密码
|
||||
password: ${nacos.password}
|
||||
# 命名空间
|
||||
namespace: ${nacos.namespace}
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
# 系统共享配置
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# 系统环境Config共享配置
|
||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.muyu.cloud.mapper: DEBUG
|
|
@ -80,11 +80,11 @@
|
|||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-rabbit</artifactId>
|
||||
<artifactId>cloud-common-saas</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -104,6 +104,4 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package com.muyu;
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DruidDataSourceAutoConfigure.class,
|
||||
DynamicDataSourceAutoConfiguration.class
|
||||
})
|
||||
@EnableFeignClients
|
||||
@MapperScan(value = "com.muyu.mapper")
|
||||
public class CarSystemApplication {
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-saas</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.muyu.fence;
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* @Author YuPing
|
||||
|
@ -10,7 +13,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
* @Version 1.0
|
||||
* @Data 2024-09-18 11:27:38
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DruidDataSourceAutoConfigure.class,
|
||||
DynamicDataSourceAutoConfiguration.class
|
||||
})
|
||||
@EnableMyFeignClients
|
||||
public class FenceApplication {
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.muyu.system.domain.resp.DeptTreeResp;
|
|||
import com.muyu.system.service.SysDeptService;
|
||||
import com.muyu.system.service.SysRoleService;
|
||||
import com.muyu.system.service.SysUserService;
|
||||
import jakarta.websocket.server.PathParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -194,7 +195,7 @@ public class SysRoleController extends BaseController {
|
|||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public Result selectAuthUserAll (Long roleId, Long[] userIds) {
|
||||
public Result selectAuthUserAll (@RequestParam("roleId") Long roleId,@RequestParam("userIds") Long[] userIds) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
|
|
@ -282,7 +282,7 @@ public class SysUserController extends BaseController {
|
|||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authRole")
|
||||
public Result insertAuthRole (Long userId, Long[] roleIds) {
|
||||
public Result insertAuthRole (@RequestParam("userId") Long userId,@RequestParam("roleIds") Long[] roleIds) {
|
||||
userService.checkUserDataScope(userId);
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return success();
|
||||
|
|
|
@ -86,6 +86,10 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu;
|
||||
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
<?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"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>cloud-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-car</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>cloud-saas</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-saas
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-saas</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
@ -77,6 +80,9 @@
|
|||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.saas;
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableMyFeignClients
|
||||
@MapperScan(value = "com.muyu.saas.mapper")
|
||||
public class SaasApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SaasApplication.class,args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.muyu.saas.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.saas.domain.Datasource;
|
||||
import com.muyu.saas.service.SaasService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("saas")
|
||||
public class SaaSController {
|
||||
|
||||
@Autowired
|
||||
private SaasService saasService;
|
||||
|
||||
/**
|
||||
* 数据源查询
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("findDatabaseList")
|
||||
public Result<List<Datasource>> findDatabaseList(){
|
||||
List<Datasource> list=saasService.list();
|
||||
return Result.success(list);
|
||||
};
|
||||
|
||||
/**
|
||||
* 数据源添加
|
||||
* @param datasource
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("addDatasource")
|
||||
public Result addDatasource(@RequestBody Datasource datasource){
|
||||
saasService.save(datasource);
|
||||
return Result.success("添加成功");
|
||||
};
|
||||
|
||||
|
||||
@PostMapping("updDatasource")
|
||||
public Result updDatasource(@RequestBody Datasource datasource){
|
||||
saasService.updateById(datasource);
|
||||
return Result.success("修改成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除成功
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("delDatasource/{id}")
|
||||
public Result delDatasource(@PathVariable("id") Integer id){
|
||||
saasService.removeById(id);
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.saas.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "datasource", autoResultMap = true)
|
||||
public class Datasource {
|
||||
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
public String firmName;
|
||||
|
||||
public String databaseName;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.saas.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.saas.domain.Datasource;
|
||||
|
||||
public interface SaaSMapper extends BaseMapper<Datasource> {
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.muyu.saas.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.saas.domain.Datasource;
|
||||
|
||||
public interface SaasService extends IService<Datasource> {
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.saas.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.saas.domain.Datasource;
|
||||
import com.muyu.saas.mapper.SaaSMapper;
|
||||
import com.muyu.saas.service.SaasService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SaasServiceImpl extends ServiceImpl<SaaSMapper,Datasource> implements SaasService {
|
||||
|
||||
@Autowired
|
||||
private SaaSMapper saaSMapper;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-car"/>
|
||||
<property name="log.path" value="logs/cloud-saas"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-car"/>
|
||||
<property name="log.path" value="logs/cloud-saas"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-car"/>
|
||||
<property name="log.path" value="logs/cloud-saas"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
|
@ -2,9 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.cloud.car.mapper.CarMapper">
|
||||
<mapper namespace="com.muyu.saas.mapper.SaaSMapper">
|
||||
|
||||
|
||||
<select id="selectMyList" resultType="com.muyu.cloud.car.domain.User">
|
||||
select * from user
|
||||
</select>
|
||||
</mapper>
|
|
@ -15,11 +15,10 @@
|
|||
<module>cloud-modules-file</module>
|
||||
<module>cloud-modules-template</module>
|
||||
<module>cloud-modules-fence</module>
|
||||
<module>cloud-modules-car</module>
|
||||
<module>cloud-modules-wechat</module>
|
||||
<module>cloud-modules-breakdown</module>
|
||||
<module>cloud-car</module>
|
||||
<module>cloud-modules-warn</module>
|
||||
<module>cloud-saas</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-modules</artifactId>
|
||||
|
|
Loading…
Reference in New Issue