初始化提交
This commit is contained in:
85
sysadmin/organization/pom.xml
Normal file
85
sysadmin/organization/pom.xml
Normal file
@ -0,0 +1,85 @@
|
||||
<?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>
|
||||
|
||||
<artifactId>organization</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<!-- <packaging>jar</packaging>-->
|
||||
|
||||
<name>organization</name>
|
||||
<description>Demo Organization project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>sysadmin</artifactId>
|
||||
<groupId>business.chaoran</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alicp.jetcache</groupId>
|
||||
<artifactId>jetcache-starter-redis</artifactId>
|
||||
<version>2.5.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-gateway-core</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- tomcat容易部署运行依赖-->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<!-- war包打包依赖-->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.1.4.RELEASE</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>build-info</goal>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>organization</finalName>
|
||||
</build>
|
||||
</project>
|
||||
@ -0,0 +1,27 @@
|
||||
package com.springboot.cloud.sysadmin.organization;
|
||||
|
||||
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
|
||||
import com.alicp.jetcache.anno.config.EnableMethodCache;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration;
|
||||
|
||||
@SpringBootApplication(exclude = GatewayClassPathWarningAutoConfiguration.class)
|
||||
@EnableDiscoveryClient
|
||||
@EnableCircuitBreaker
|
||||
@EnableMethodCache(basePackages = "com.springboot.cloud")
|
||||
@EnableCreateCacheAnnotation
|
||||
public class OrganizationApplication extends SpringBootServletInitializer {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OrganizationApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||||
return builder.sources(OrganizationApplication.class);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.springboot.cloud.sysadmin.organization.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.core.TopicExchange;
|
||||
import org.springframework.amqp.support.converter.ContentTypeDelegatingMessageConverter;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 消息设置
|
||||
* 监听 company_application_popedom表的操作
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class BusConfig {
|
||||
|
||||
public static final String QUEUE_NAME = "event-organization";
|
||||
public static final String EXCHANGE_NAME = "spring-boot-exchange";
|
||||
public static final String ROUTING_KEY = "organization-popedom";
|
||||
|
||||
/**
|
||||
* 设置消息队列
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
Queue queue() {
|
||||
log.info("queue name:{}", QUEUE_NAME);
|
||||
return new Queue(QUEUE_NAME, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置主题交换机
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
TopicExchange exchange() {
|
||||
log.info("exchange:{}", EXCHANGE_NAME);
|
||||
return new TopicExchange(EXCHANGE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定队列到主题交换机,并设置关联键
|
||||
*
|
||||
* @param queue
|
||||
* @param exchange
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
Binding binding(Queue queue, TopicExchange exchange) {
|
||||
log.info("binding {} to {} with {}", queue, exchange, ROUTING_KEY);
|
||||
return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置消息体用jackson序列化
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MessageConverter messageConverter() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
return new ContentTypeDelegatingMessageConverter(new Jackson2JsonMessageConverter(objectMapper));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.springboot.cloud.sysadmin.organization.config;
|
||||
|
||||
import com.springboot.cloud.common.web.handler.PoMetaObjectHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MyMetaObjectHandler extends PoMetaObjectHandler {
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.springboot.cloud.sysadmin.organization.config;
|
||||
|
||||
import com.springboot.cloud.common.web.redis.RedisConfig;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class MyRedisConfig extends RedisConfig {
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.springboot.cloud.sysadmin.organization.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
|
||||
@EnableTransactionManagement
|
||||
@Configuration
|
||||
public class MybatisConfig {
|
||||
/**
|
||||
* 初使化Mybatis审计字段自动赋值的interceptor
|
||||
*/
|
||||
@Bean
|
||||
public ISqlInjector sqlInjector() {
|
||||
return new LogicSqlInjector();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.springboot.cloud.sysadmin.organization.config;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-24 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.Query;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Set;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class NacosRegisterConfig implements ApplicationRunner {
|
||||
|
||||
@Autowired(required = false)
|
||||
private NacosAutoServiceRegistration registration;
|
||||
|
||||
private Integer port;
|
||||
|
||||
public NacosRegisterConfig() {
|
||||
try {
|
||||
this.port = Integer.parseInt(getTomcatPort());
|
||||
} catch (Exception e) {
|
||||
log.error("获取tomcat端口出错了,原因:{}", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
if (registration != null && port != null) {
|
||||
registration.setPort(port);
|
||||
registration.start();
|
||||
}
|
||||
}
|
||||
|
||||
//获取tomcat端口
|
||||
private String getTomcatPort() throws Exception {
|
||||
MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
|
||||
Set<ObjectName> objectNames = beanServer.queryNames(new ObjectName("*:type=Connector,*"), Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));
|
||||
String port = objectNames.iterator().next().getKeyProperty("port");
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.springboot.cloud.sysadmin.organization.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.springboot.cloud.sysadmin.organization"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("系统管理API")
|
||||
.description("系统管理,组织人员管理、角色权限管理、岗位管理")
|
||||
.termsOfServiceUrl("https://github.com/zhoutaoo/SpringCloud")
|
||||
.version("2.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.springboot.cloud.sysadmin.organization.config;
|
||||
|
||||
import com.springboot.cloud.common.web.interceptor.UserInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebServerMvcConfigurerAdapter implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public HandlerInterceptor userInterceptor() {
|
||||
return new UserInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(userInterceptor());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.GatewayRoute;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface GatewayRouteMapper extends BaseMapper<GatewayRoute> {
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationGrade;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ApplicationGradeMapper extends BaseMapper<ApplicationGrade>{
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationGradePopedom;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ApplicationGradePopedomMapper extends BaseMapper<ApplicationGradePopedom> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.Application;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ApplicationMapper extends BaseMapper<Application> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ApplicationPopedomMapper extends BaseMapper<ApplicationPopedom> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationLicense;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface CompanyApplicationLicenseMapper extends BaseMapper<CompanyApplicationLicense> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationPopedom;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface CompanyApplicationPopedomMapper extends BaseMapper<CompanyApplicationPopedom> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.Company;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface CompanyMapper extends BaseMapper<Company> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface CompanyRoleMapper extends BaseMapper<CompanyRole> {
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRolePopedom;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface CompanyRolePopedomMapper extends BaseMapper<CompanyRolePopedom> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRoleUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface CompanyRoleUserMapper extends BaseMapper<CompanyRoleUser> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.dao.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface CompanyUserMapper extends BaseMapper<CompanyUser> {
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.springboot.cloud.common.web.entity.po.BasePo;
|
||||
import lombok.*;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("gateway_route")
|
||||
public class GatewayRoute extends BasePo {
|
||||
private String uri;
|
||||
private String routeId;
|
||||
private String predicates;
|
||||
private String filters;
|
||||
private String description;
|
||||
private Integer orders = 0;
|
||||
private String status = "Y";
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("user")
|
||||
public class User {
|
||||
@TableId
|
||||
private String id;
|
||||
private String name;
|
||||
private Date registryTime;
|
||||
private String identity;
|
||||
private String nickName;
|
||||
private String photo;
|
||||
private String lastModifier;
|
||||
private Date lastModifyTime;
|
||||
private String state;
|
||||
private String mobile;
|
||||
private String email;
|
||||
private String introduce;
|
||||
private String avatar;
|
||||
private String signature;
|
||||
private String password;
|
||||
private String username;
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@TableName("application")
|
||||
public class Application {
|
||||
@TableId
|
||||
private String code;
|
||||
private String name;
|
||||
private Integer type;
|
||||
private String description;
|
||||
private Date deployedTime;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("application_grade")
|
||||
public class ApplicationGrade {
|
||||
private String applicationCode;
|
||||
private Integer grade;
|
||||
private String mame;
|
||||
private String description;
|
||||
private boolean isFree;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("application_grade_popedom")
|
||||
public class ApplicationGradePopedom {
|
||||
private String applicationCode;
|
||||
private Integer grade;
|
||||
private Integer popedomId;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@TableName("application_popedom")
|
||||
@NoArgsConstructor
|
||||
public class ApplicationPopedom {
|
||||
private String applicationCode;
|
||||
private String id;
|
||||
private String name;
|
||||
private String parentId;
|
||||
private String url;
|
||||
private String icon;
|
||||
private String isMenu;
|
||||
private String description;
|
||||
private String path;
|
||||
private String redirect;
|
||||
private String component;
|
||||
private String title;
|
||||
private boolean alwaysShow;
|
||||
private boolean hidden;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("company")
|
||||
public class Company {
|
||||
@TableId
|
||||
private String id;
|
||||
private String name;
|
||||
private String registerId;
|
||||
private String ownerId;
|
||||
private Date registerTime;
|
||||
private String businessLicense;
|
||||
private String address;
|
||||
private String description;
|
||||
private String photo;
|
||||
private String lastModifier;
|
||||
private Date lastModifyTime;
|
||||
private String province;
|
||||
private String city;
|
||||
private String county;
|
||||
private String street;
|
||||
private Double longitude;
|
||||
private double latitude;
|
||||
private Double state;
|
||||
private String grade;
|
||||
private String contacter;
|
||||
private String mobile;
|
||||
private String tel;
|
||||
private String email;
|
||||
private String weixin;
|
||||
private boolean isFranchiser;
|
||||
private boolean isIsv;
|
||||
private String serviceTime;
|
||||
private String hotlinePhone;
|
||||
private String logo;
|
||||
private String logW;
|
||||
private String icpNo;
|
||||
private String shortName;
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("company_application_license")
|
||||
public class CompanyApplicationLicense {
|
||||
private String companyId;
|
||||
private String franchiserId;
|
||||
private String applicationCode;
|
||||
private String grade;
|
||||
private Date expireDate;
|
||||
private boolean isForever;
|
||||
private String state;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("company_application_popedom")
|
||||
public class CompanyApplicationPopedom {
|
||||
private String companyId;
|
||||
private String applicationCode;
|
||||
private String popedomId;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("company_role")
|
||||
public class CompanyRole {
|
||||
private String companyId;
|
||||
private String id;
|
||||
private String name;
|
||||
private String remark;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("company_role_popedom")
|
||||
public class CompanyRolePopedom {
|
||||
private String companyId;
|
||||
private String roleId;
|
||||
private String applicationCode;
|
||||
private String popedomId;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@TableName("company_role_user")
|
||||
public class CompanyRoleUser {
|
||||
private String companyId;
|
||||
private String roleId;
|
||||
private String userId;
|
||||
private boolean isDefault;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.po.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@TableName("company_user")
|
||||
@NoArgsConstructor
|
||||
public class CompanyUser {
|
||||
private String companyId;
|
||||
private String userId;
|
||||
private String organizationId;
|
||||
private String empNo;
|
||||
private String position;
|
||||
private Integer isDefault;
|
||||
private Integer state;
|
||||
private String mobile;
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.vo;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2021-01-05 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
public class Menu {
|
||||
|
||||
@JsonIgnore
|
||||
private String parentId;
|
||||
|
||||
@JsonIgnore
|
||||
private String id;
|
||||
|
||||
private String redirect;
|
||||
private String path;
|
||||
private String component;
|
||||
private List<Menu> children;
|
||||
private String name;
|
||||
private boolean hidden;
|
||||
private boolean alwaysShow;
|
||||
private Meta meta;
|
||||
|
||||
public Menu(String path, String redirect, boolean hidden) {
|
||||
this.path = path;
|
||||
this.redirect = redirect.equals("") ? null : redirect;
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public Menu(ApplicationPopedom applicationPopedom) {
|
||||
this.meta = new Meta();
|
||||
this.meta.title = applicationPopedom.getTitle();
|
||||
this.meta.icon = applicationPopedom.getIcon();
|
||||
String s = Optional.ofNullable(applicationPopedom.getRedirect()).orElseGet(String::new);
|
||||
this.redirect = s.equals("") ? null : s;
|
||||
this.path = applicationPopedom.getPath();
|
||||
this.component = applicationPopedom.getComponent();
|
||||
this.name = applicationPopedom.getName();
|
||||
this.hidden = applicationPopedom.isHidden();
|
||||
this.alwaysShow = applicationPopedom.isAlwaysShow();
|
||||
this.id = applicationPopedom.getId();
|
||||
this.parentId = applicationPopedom.getParentId();
|
||||
this.children = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
class Meta {
|
||||
private String icon;
|
||||
private String title;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.springboot.cloud.sysadmin.organization.entity.vo;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2021-01-04 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class Popedom extends ApplicationPopedom {
|
||||
private String companyId;
|
||||
|
||||
public Popedom(ApplicationPopedom applicationPopedom, String companyId) {
|
||||
this.companyId = companyId;
|
||||
BeanUtils.copyProperties(applicationPopedom, this);
|
||||
}
|
||||
|
||||
public Popedom(ApplicationPopedom applicationPopedom) {
|
||||
BeanUtils.copyProperties(applicationPopedom, this);
|
||||
}
|
||||
|
||||
public Popedom(String companyId){
|
||||
this.companyId=companyId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Popedom)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
Popedom popedom = (Popedom) o;
|
||||
return Objects.equals(companyId, popedom.companyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), companyId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.springboot.cloud.sysadmin.organization.events;
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.config.BusConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class EventSender {
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private MessageConverter messageConverter;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
rabbitTemplate.setMessageConverter(messageConverter);
|
||||
}
|
||||
|
||||
public void send(String routingKey, Object object) {
|
||||
log.info("routingKey:{}=>message:{}", routingKey, object);
|
||||
rabbitTemplate.convertAndSend(BusConfig.EXCHANGE_NAME, routingKey, object);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.springboot.cloud.sysadmin.organization.exception;
|
||||
|
||||
import com.springboot.cloud.common.core.entity.vo.Result;
|
||||
import com.springboot.cloud.common.web.exception.DefaultGlobalExceptionHandlerAdvice;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandlerAdvice extends DefaultGlobalExceptionHandlerAdvice {
|
||||
|
||||
@ExceptionHandler(value = {UserNotFoundException.class})
|
||||
public Result userNotFound(UserNotFoundException ex) {
|
||||
log.error(ex.getMessage());
|
||||
return Result.fail(ex.getErrorType());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.springboot.cloud.sysadmin.organization.exception;
|
||||
|
||||
import com.springboot.cloud.common.core.exception.ErrorType;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum OrganizationErrorType implements ErrorType {
|
||||
|
||||
USER_NOT_FOUND("030100", "用户未找到!"),
|
||||
ROLE_NOT_FOUND("030200", "角色未找到!");
|
||||
|
||||
/**
|
||||
* 错误类型码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 错误类型描述信息
|
||||
*/
|
||||
private String mesg;
|
||||
|
||||
OrganizationErrorType(String code, String mesg) {
|
||||
this.code = code;
|
||||
this.mesg = mesg;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.springboot.cloud.sysadmin.organization.exception;
|
||||
|
||||
import com.springboot.cloud.common.core.exception.BaseException;
|
||||
|
||||
public class RoleNotFoundException extends BaseException {
|
||||
public RoleNotFoundException() {
|
||||
super(OrganizationErrorType.ROLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
public RoleNotFoundException(String message) {
|
||||
super(OrganizationErrorType.ROLE_NOT_FOUND, message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.springboot.cloud.sysadmin.organization.exception;
|
||||
|
||||
import com.springboot.cloud.common.core.exception.BaseException;
|
||||
|
||||
public class UserNotFoundException extends BaseException {
|
||||
public UserNotFoundException() {
|
||||
super(OrganizationErrorType.USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
public UserNotFoundException(String message) {
|
||||
super(OrganizationErrorType.USER_NOT_FOUND, message);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.springboot.cloud.sysadmin.organization.rest;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.springboot.cloud.common.core.entity.vo.Result;
|
||||
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
|
||||
import com.springboot.cloud.sysadmin.organization.service.ApplicationService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.CompanyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/company")
|
||||
@Slf4j
|
||||
public class CompanyController {
|
||||
|
||||
@Autowired
|
||||
CompanyService companyService;
|
||||
|
||||
@Autowired
|
||||
ApplicationService applicationService;
|
||||
|
||||
@GetMapping("/getPopedom")
|
||||
public Result getCompanyRoleUserPopedom(@RequestParam("companyId") String companyId, @RequestParam("username") String username) {
|
||||
Optional.ofNullable(companyId).orElseThrow(UserNotFoundException::new);
|
||||
Optional.ofNullable(username).orElseThrow(UserNotFoundException::new);
|
||||
return Result.success(companyService.getCompanyUserPopedom(companyId, username));
|
||||
}
|
||||
|
||||
@GetMapping("/getCompanyAllPopedom")
|
||||
public Result getCompanyAllPopedom(@RequestParam("companyId") String companyId) {
|
||||
Optional.ofNullable(companyId).orElseThrow(UserNotFoundException::new);
|
||||
return Result.success(companyService.getCompanyAllPopedom(companyId));
|
||||
}
|
||||
|
||||
@RequestMapping("/license")
|
||||
public Result license(@RequestParam("companyId") String companyId, @RequestParam("applicationCode") String applicationCode) {
|
||||
Optional.ofNullable(companyId).orElseThrow(UserNotFoundException::new);
|
||||
Optional.ofNullable(applicationCode).orElseThrow(UserNotFoundException::new);
|
||||
return Result.success(applicationService.license(companyId, applicationCode));
|
||||
}
|
||||
|
||||
@GetMapping("/getAllPopedom")
|
||||
public Result getAllPopedom() {
|
||||
return Result.success(companyService.getAllPopedom());
|
||||
}
|
||||
|
||||
@GetMapping("/getUserAllCompany")
|
||||
public Result getUserAllCompany(@RequestParam("userId") String userId){
|
||||
Optional.ofNullable(userId).orElseThrow(UserNotFoundException::new);
|
||||
return Result.success(companyService.getUserAllCompany(userId));
|
||||
}
|
||||
|
||||
|
||||
// @GetMapping("/getPopedom")
|
||||
// public Result getCompanyRoleUserPopedom() {
|
||||
// return Result.success(companyService.getCompanyUserPopedom(UserContextHolder.getInstance().getCurrentCompany(), UserContextHolder.getInstance().getUsername()));
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/getCompanyAllPopedom")
|
||||
// public Result getCompanyAllPopedom() {
|
||||
// return Result.success(companyService.getCompanyAllPopedom(UserContextHolder.getInstance().getCurrentCompany()));
|
||||
// }
|
||||
//
|
||||
// @RequestMapping("/license")
|
||||
// public Result license(@RequestParam("applicationCode") String applicationCode) {
|
||||
// return Result.success(applicationService.license(UserContextHolder.getInstance().getCurrentCompany(), applicationCode));
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/getAllPopedom")
|
||||
// public Result getAllPopedom() {
|
||||
// return Result.success(companyService.getAllPopedom());
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/getUserAllCompany")
|
||||
// public Result getUserAllCompany(@RequestParam("userId") String userId) {
|
||||
// Optional.ofNullable(userId).orElseThrow(UserNotFoundException::new);
|
||||
// return Result.success(companyService.getUserAllCompany(userId));
|
||||
// }
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.springboot.cloud.sysadmin.organization.rest;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2021-01-04 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.springboot.cloud.common.core.entity.vo.Result;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/hr")
|
||||
@Slf4j
|
||||
public class HrDemo {
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result list(){
|
||||
return Result.success("list访问成功!");
|
||||
}
|
||||
|
||||
@GetMapping("/delete")
|
||||
public Result delete(){
|
||||
return Result.success("delete访问成功!");
|
||||
}
|
||||
|
||||
@GetMapping("/update")
|
||||
public Result update(){
|
||||
return Result.success("update访问成功!");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.springboot.cloud.sysadmin.organization.rest;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2021-01-05 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
import com.springboot.cloud.common.core.entity.vo.Result;
|
||||
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
|
||||
import com.springboot.cloud.sysadmin.organization.service.MenuService;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/menu")
|
||||
public class MenuController {
|
||||
|
||||
@Autowired
|
||||
MenuService menuService;
|
||||
|
||||
@GetMapping("/index")
|
||||
public Result index(@RequestParam("companyId")String companyId){
|
||||
Optional.ofNullable(companyId).orElseThrow(UserNotFoundException::new);
|
||||
return Result.success(menuService.index(companyId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.springboot.cloud.sysadmin.organization.rest;
|
||||
|
||||
import com.springboot.cloud.common.core.entity.vo.Result;
|
||||
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
|
||||
import com.springboot.cloud.sysadmin.organization.service.CompanyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
@Slf4j
|
||||
public class RoleController {
|
||||
|
||||
@Autowired
|
||||
CompanyService companyService;
|
||||
|
||||
@GetMapping("/getRoleUser")
|
||||
public Result getUserByUsername(@RequestParam("userId")String userId){
|
||||
Optional.ofNullable(userId).orElseThrow(UserNotFoundException::new);
|
||||
return Result.success(companyService.getCompanyRoleUser(userId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.springboot.cloud.sysadmin.organization.rest;
|
||||
|
||||
import com.springboot.cloud.common.core.entity.vo.Result;
|
||||
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
|
||||
import com.springboot.cloud.sysadmin.organization.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@Slf4j
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@GetMapping("/getUserByUsernameOrMobile")
|
||||
public Result getUserByUsername(@RequestParam("payload")String payload){
|
||||
Optional.ofNullable(payload).orElseThrow(UserNotFoundException::new);
|
||||
return Result.success(userService.getUserByUsernameOrMobile(payload));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-31 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationLicense;
|
||||
|
||||
public interface ApplicationService {
|
||||
|
||||
/**
|
||||
* 取得公司应用许可信息
|
||||
* @param companyId 公司编号
|
||||
* @param applicationCode 应用编码
|
||||
* @return
|
||||
*/
|
||||
public CompanyApplicationLicense license(String companyId,String applicationCode);
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRolePopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRoleUser;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyUser;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.vo.Popedom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CompanyService {
|
||||
/**
|
||||
* 得到用户所有的角色
|
||||
* @param companyId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyRoleUser> getCompanyRoleUser(String companyId, String userId);
|
||||
|
||||
/**
|
||||
* 得到用户所有的角色
|
||||
*/
|
||||
public List<CompanyRoleUser> getCompanyRoleUser(String userId);
|
||||
|
||||
/**
|
||||
* 得到角色资源
|
||||
* @param companyId
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId, String roleId);
|
||||
|
||||
/**
|
||||
* 得到角色资源
|
||||
* @param companyId
|
||||
* @param roleIds
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId,List<String> roleIds);
|
||||
|
||||
|
||||
/**
|
||||
* 得到用户资源
|
||||
* @return
|
||||
*/
|
||||
public List<ApplicationPopedom> getCompanyUserPopedom(String companyId,String userId);
|
||||
|
||||
/**
|
||||
* 得到公司所有资源
|
||||
* @param companyId
|
||||
* @return
|
||||
*/
|
||||
public List<ApplicationPopedom> getCompanyAllPopedom(String companyId);
|
||||
|
||||
/**
|
||||
* 得到所有公司资源
|
||||
*/
|
||||
public List<Popedom> getAllPopedom();
|
||||
|
||||
/**
|
||||
* 得到用户对应的所有公司
|
||||
*/
|
||||
public List<CompanyUser> getUserAllCompany(String userId);
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service;
|
||||
|
||||
public interface GatewayService {
|
||||
|
||||
/**
|
||||
* 重新加载网关路由配置到redis
|
||||
*
|
||||
* @return 成功返回true
|
||||
*/
|
||||
void overload();
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2021-01-05 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.vo.Menu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MenuService {
|
||||
|
||||
/**
|
||||
* 公司编号得到菜单信息
|
||||
* @param companyId 公司编号
|
||||
* @return
|
||||
*/
|
||||
public List<Menu> index(String companyId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service;
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.User;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
/**
|
||||
* 账户或者手机号获取用户信息
|
||||
* @param payload
|
||||
* @return
|
||||
*/
|
||||
public User getUserByUsernameOrMobile(String payload);
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.application;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ApplicationPopedomService {
|
||||
|
||||
/**
|
||||
* 根据资源编号获取资源信息
|
||||
* @param ids 资源编号
|
||||
* @return
|
||||
*/
|
||||
public List<ApplicationPopedom> getApplicationPopedom(List<String> ids);
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.application.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.application.ApplicationPopedomMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.service.application.ApplicationPopedomService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ApplicationPopedomServiceImpl extends ServiceImpl<ApplicationPopedomMapper, ApplicationPopedom> implements ApplicationPopedomService {
|
||||
|
||||
@Override
|
||||
public List<ApplicationPopedom> getApplicationPopedom(List<String> ids) {
|
||||
QueryWrapper<ApplicationPopedom> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.in("id",ids);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationLicense;
|
||||
|
||||
public interface CompanyApplicationLicenseService {
|
||||
|
||||
/**
|
||||
* 查询公司应用许可
|
||||
* @param companyId 公司编号
|
||||
* @param applicationCode 应用代码
|
||||
* @return
|
||||
*/
|
||||
public CompanyApplicationLicense license(String companyId,String applicationCode);
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationPopedom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CompanyApplicationPopedomService {
|
||||
|
||||
/**
|
||||
* 得到公司所有应用资源
|
||||
* @param companyId 公司编号
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyApplicationPopedom> getApplicationPopedom(String companyId);
|
||||
|
||||
/**
|
||||
* 得到所有公司资源
|
||||
*/
|
||||
public List<CompanyApplicationPopedom> getApplicationPopedom();
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRolePopedom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CompanyRolePopedomService {
|
||||
/**
|
||||
* 得到公司角色资源
|
||||
* @param companyId 公司编号
|
||||
* @param roleId 角色编号
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId, String roleId);
|
||||
|
||||
|
||||
/**
|
||||
* 得到公司角色资源
|
||||
* @param companyId 公司编号
|
||||
* @param roleIds 角色编号集合
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId,List<String> roleIds);
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRoleUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CompanyRoleUserService {
|
||||
|
||||
/**
|
||||
* 根据公司编号和用户编号得到角色信息
|
||||
* @param companyId 公司编号
|
||||
* @param userId 用户账号
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyRoleUser> getRoleByCompanyIdAndUserId(String companyId, String userId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CompanyUserService {
|
||||
|
||||
/**
|
||||
* 根据公司编号和用户编号取得用户信息
|
||||
*
|
||||
* @param companyId 公司编号
|
||||
* @param userId 用户编号
|
||||
* @return
|
||||
*/
|
||||
public CompanyUser getUserByCompanyIdAndUserId(String companyId, String userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户编号得到公司信息
|
||||
* @param userId 用户编号
|
||||
* @return
|
||||
*/
|
||||
public List<CompanyUser> getCompanyByUserId(String userId);
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.company.CompanyApplicationLicenseMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationLicense;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyApplicationLicenseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CompanyApplicationLicenseServiceImpl extends ServiceImpl<CompanyApplicationLicenseMapper, CompanyApplicationLicense> implements CompanyApplicationLicenseService {
|
||||
@Override
|
||||
public CompanyApplicationLicense license(String companyId, String applicationCode) {
|
||||
QueryWrapper<CompanyApplicationLicense> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("company_id",companyId).eq("application_code",applicationCode);
|
||||
return getOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.company.CompanyApplicationPopedomMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationPopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyApplicationPopedomService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CompanyApplicationPopedomServiceImpl extends ServiceImpl<CompanyApplicationPopedomMapper, CompanyApplicationPopedom> implements CompanyApplicationPopedomService {
|
||||
|
||||
@Override
|
||||
public List<CompanyApplicationPopedom> getApplicationPopedom(String companyId) {
|
||||
QueryWrapper<CompanyApplicationPopedom> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("company_id",companyId);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyApplicationPopedom> getApplicationPopedom() {
|
||||
return list();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.company.CompanyRolePopedomMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRolePopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyRolePopedomService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CompanyRolePopedomServiceImpl extends ServiceImpl<CompanyRolePopedomMapper, CompanyRolePopedom> implements CompanyRolePopedomService {
|
||||
|
||||
@Override
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId, String roleId) {
|
||||
QueryWrapper<CompanyRolePopedom> companyRolePopedomQueryWrapper = new QueryWrapper<>();
|
||||
companyRolePopedomQueryWrapper.eq("company_id", companyId).eq("role_id", roleId);
|
||||
return this.list(companyRolePopedomQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId, List<String> roleIds) {
|
||||
QueryWrapper<CompanyRolePopedom> companyRolePopedomQueryWrapper = new QueryWrapper<>();
|
||||
companyRolePopedomQueryWrapper.eq("company_id", companyId).in("role_id", roleIds);
|
||||
return this.list(companyRolePopedomQueryWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.company.CompanyRoleUserMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRoleUser;
|
||||
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyRoleUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CompanyRoleUserServiceImpl extends ServiceImpl<CompanyRoleUserMapper, CompanyRoleUser> implements CompanyRoleUserService {
|
||||
|
||||
@Override
|
||||
public List<CompanyRoleUser> getRoleByCompanyIdAndUserId(String companyId, String userId) {
|
||||
QueryWrapper<CompanyRoleUser> companyRoleUserQueryWrapper = new QueryWrapper<>();
|
||||
companyRoleUserQueryWrapper.eq("company_id", companyId).eq("user_id", userId);
|
||||
return this.list(companyRoleUserQueryWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.company.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.company.CompanyUserMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyUser;
|
||||
import com.springboot.cloud.sysadmin.organization.exception.UserNotFoundException;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyRoleUserService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CompanyUserServiceImpl extends ServiceImpl<CompanyUserMapper, CompanyUser> implements CompanyUserService {
|
||||
|
||||
@Override
|
||||
public CompanyUser getUserByCompanyIdAndUserId(String companyId, String userId) {
|
||||
QueryWrapper<CompanyUser> userQueryWrapper=new QueryWrapper<>();
|
||||
userQueryWrapper.eq("company_id",companyId).eq("user_id",userId);
|
||||
return this.getOne(userQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyUser> getCompanyByUserId(String userId) {
|
||||
QueryWrapper<CompanyUser> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id",userId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-31 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationLicense;
|
||||
import com.springboot.cloud.sysadmin.organization.service.ApplicationService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyApplicationLicenseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ApplicationServiceImpl implements ApplicationService {
|
||||
|
||||
@Autowired
|
||||
CompanyApplicationLicenseService companyApplicationLicenseService;
|
||||
|
||||
@Override
|
||||
public CompanyApplicationLicense license(String companyId, String applicationCode) {
|
||||
return companyApplicationLicenseService.license(companyId,applicationCode);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,112 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-29 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.User;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyApplicationPopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRolePopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyRoleUser;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.company.CompanyUser;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.vo.Popedom;
|
||||
import com.springboot.cloud.sysadmin.organization.service.CompanyService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.UserService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.application.ApplicationPopedomService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyApplicationPopedomService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyRolePopedomService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyRoleUserService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.company.CompanyUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CompanyServiceImpl implements CompanyService {
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
CompanyUserService companyUserService;
|
||||
|
||||
@Autowired
|
||||
CompanyRoleUserService companyRoleUserService;
|
||||
|
||||
@Autowired
|
||||
CompanyRolePopedomService companyRolePopedomService;
|
||||
|
||||
@Autowired
|
||||
ApplicationPopedomService applicationPopedomService;
|
||||
|
||||
@Autowired
|
||||
CompanyApplicationPopedomService companyApplicationPopedomService;
|
||||
|
||||
@Override
|
||||
public List<CompanyRoleUser> getCompanyRoleUser(String companyId, String userId) {
|
||||
return companyRoleUserService.getRoleByCompanyIdAndUserId(companyId, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyRoleUser> getCompanyRoleUser(String userId) {
|
||||
//找到用户对应的所有公司
|
||||
List<CompanyUser> companyUsers = companyUserService.getCompanyByUserId(userId);
|
||||
//找到用户默认的公司
|
||||
CompanyUser companyUser = companyUsers.stream().filter(a -> a.getIsDefault() == 1).findAny().orElseGet(CompanyUser::new);
|
||||
|
||||
//找到用户的所有角色
|
||||
return companyRoleUserService.getRoleByCompanyIdAndUserId(companyUser.getCompanyId(), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId, String roleId) {
|
||||
return companyRolePopedomService.getCompanyRolePopedom(companyId, roleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyRolePopedom> getCompanyRolePopedom(String companyId, List<String> roleIds) {
|
||||
return companyRolePopedomService.getCompanyRolePopedom(companyId, roleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationPopedom> getCompanyUserPopedom(String companyId, String username) {
|
||||
User user = userService.getUserByUsernameOrMobile(username);
|
||||
List<CompanyRoleUser> companyRoleUsers = getCompanyRoleUser(companyId, user.getId());
|
||||
List<String> roleIds = companyRoleUsers.stream().map(CompanyRoleUser::getRoleId).collect(Collectors.toList());
|
||||
List<CompanyRolePopedom> companyRolePopedoms = getCompanyRolePopedom(companyId, roleIds);
|
||||
List<String> popedomIds = companyRolePopedoms.stream().map(CompanyRolePopedom::getPopedomId).collect(Collectors.toList());
|
||||
return applicationPopedomService.getApplicationPopedom(popedomIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationPopedom> getCompanyAllPopedom(String companyId) {
|
||||
List<CompanyApplicationPopedom> companyApplicationPopedoms = companyApplicationPopedomService.getApplicationPopedom(companyId);
|
||||
List<String> popedomIds = companyApplicationPopedoms.stream().map(CompanyApplicationPopedom::getPopedomId).collect(Collectors.toList());
|
||||
return applicationPopedomService.getApplicationPopedom(popedomIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Popedom> getAllPopedom() {
|
||||
//先获取所有公司的功能
|
||||
List<CompanyApplicationPopedom> companyApplicationPopedoms = companyApplicationPopedomService.getApplicationPopedom();
|
||||
Map<String, List<String>> company2PopedomIds = companyApplicationPopedoms.stream().collect(Collectors.groupingBy(CompanyApplicationPopedom::getCompanyId, Collectors.mapping(CompanyApplicationPopedom::getPopedomId, Collectors.toList())));
|
||||
return company2PopedomIds.keySet().stream().flatMap(a -> applicationPopedomService.getApplicationPopedom(company2PopedomIds.get(a)).stream().map(b -> new Popedom(b, a))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyUser> getUserAllCompany(String userId) {
|
||||
return companyUserService.getCompanyByUserId(userId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.impl;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.GatewayRouteMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.GatewayRoute;
|
||||
import com.springboot.cloud.sysadmin.organization.service.GatewayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.gateway.filter.FilterDefinition;
|
||||
import org.springframework.cloud.gateway.handler.predicate.PredicateDefinition;
|
||||
import org.springframework.cloud.gateway.route.RouteDefinition;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class GatewayServiceImpl extends ServiceImpl<GatewayRouteMapper, GatewayRoute> implements GatewayService {
|
||||
|
||||
private static final String GATEWAY_ROUTES = "gateway_routes::";
|
||||
|
||||
/**
|
||||
* 将路由信息存入redis
|
||||
*/
|
||||
@CreateCache(name = GATEWAY_ROUTES, cacheType = CacheType.REMOTE)
|
||||
private Cache<String, RouteDefinition> gatewayRouteCache;
|
||||
|
||||
/**
|
||||
* 将数据库中json对象转换为网关需要的RouteDefinition对象
|
||||
*
|
||||
* @param gatewayRoute
|
||||
* @return RouteDefinition
|
||||
*/
|
||||
private RouteDefinition gatewayRouteToRouteDefinition(GatewayRoute gatewayRoute) {
|
||||
RouteDefinition routeDefinition = new RouteDefinition();
|
||||
routeDefinition.setId(gatewayRoute.getRouteId());
|
||||
routeDefinition.setOrder(gatewayRoute.getOrders());
|
||||
routeDefinition.setUri(URI.create(gatewayRoute.getUri()));
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
routeDefinition.setFilters(objectMapper.readValue(gatewayRoute.getFilters(), new TypeReference<List<FilterDefinition>>() {
|
||||
}));
|
||||
routeDefinition.setPredicates(objectMapper.readValue(gatewayRoute.getPredicates(), new TypeReference<List<PredicateDefinition>>() {
|
||||
}));
|
||||
} catch (IOException e) {
|
||||
log.error("网关路由对象转换失败", e);
|
||||
}
|
||||
return routeDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化加载进redis
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void overload() {
|
||||
List<GatewayRoute> gatewayRoutes = this.list(new QueryWrapper<>());
|
||||
gatewayRoutes.forEach(gatewayRoute ->
|
||||
gatewayRouteCache.put(gatewayRoute.getRouteId(), gatewayRouteToRouteDefinition(gatewayRoute))
|
||||
);
|
||||
log.info("全局初使化网关路由成功!");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2021-01-05 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.application.ApplicationPopedom;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.vo.Menu;
|
||||
import com.springboot.cloud.sysadmin.organization.service.CompanyService;
|
||||
import com.springboot.cloud.sysadmin.organization.service.MenuService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MenuServiceImpl implements MenuService {
|
||||
|
||||
|
||||
@Autowired
|
||||
CompanyService companyService;
|
||||
|
||||
@Override
|
||||
public List<Menu> index(String companyId) {
|
||||
|
||||
//得到公司对应的所有权限
|
||||
List<ApplicationPopedom> allPopedoms = companyService.getCompanyAllPopedom(companyId);
|
||||
|
||||
//先选出菜单
|
||||
List<ApplicationPopedom> popedoms = allPopedoms.stream().filter(a -> a.getIsMenu().equals("1") || a.getIsMenu().equals("2")).collect(Collectors.toList());
|
||||
|
||||
//转换节点到菜单
|
||||
List<Menu> menuList = popedoms.stream().map(a -> new Menu(a)).collect(Collectors.toList());
|
||||
|
||||
//构建菜单树
|
||||
List<Menu> result = buildMenuTree(menuList, null);
|
||||
|
||||
//添加默认显示
|
||||
result.add(new Menu("*", "/404", true));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//递归生成树
|
||||
private List<Menu> buildMenuTree(List<Menu> menuList, String pid) {
|
||||
List<Menu> treeList = new ArrayList<>();
|
||||
menuList.stream().forEach(menu -> {
|
||||
if (StringUtils.equals(pid, menu.getParentId())) {
|
||||
menu.setChildren(buildMenuTree(menuList, menu.getId()));
|
||||
treeList.add(menu);
|
||||
}
|
||||
});
|
||||
return treeList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.springboot.cloud.sysadmin.organization.service.impl;
|
||||
|
||||
/*
|
||||
**********************************************
|
||||
* DATE PERSON REASON
|
||||
* 2020-12-30 FXY Created
|
||||
**********************************************
|
||||
*/
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.springboot.cloud.sysadmin.organization.dao.UserMapper;
|
||||
import com.springboot.cloud.sysadmin.organization.entity.po.User;
|
||||
import com.springboot.cloud.sysadmin.organization.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
|
||||
/**
|
||||
* username用户账户,唯一
|
||||
* mobile 用户手机号,唯一
|
||||
*
|
||||
* @param payload
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public User getUserByUsernameOrMobile(String payload) {
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
|
||||
queryWrapper.eq("username", payload).or().eq("mobile", payload);
|
||||
return getOne(queryWrapper);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user