fix(*) 首次提交General项目

This commit is contained in:
2023-08-23 16:42:26 +08:00
parent a21f6803f9
commit 3204c89d6e
36 changed files with 2236 additions and 0 deletions

129
General/pom.xml Normal file
View File

@ -0,0 +1,129 @@
<?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>
<groupId>cn.crtech.cloud.general</groupId>
<artifactId>General</artifactId>
<version>1.0.1</version>
<!-- 父工程 -->
<parent>
<groupId>cn.crtech.cloud.dependencies</groupId>
<artifactId>Dependencies</artifactId>
<version>1.0.1</version>
<relativePath/>
</parent>
<!-- 依赖的版本锁定 -->
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<common.version>1.0.1</common.version>
<freemarker.version>2.3.31</freemarker.version>
</properties>
<dependencies>
<!-- nacos 客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<!--AOP-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- Common -->
<dependency>
<groupId>cn.crtech.cloud.common</groupId>
<artifactId>Common</artifactId>
<version>${common.version}</version>
</dependency>
<!-- 代码生成默认模板(必须) -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
package cn.crtech.cloud.general;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan;
@EnableDiscoveryClient
@SpringBootApplication
@EnableTransactionManagement
@MapperScan("cn.crtech.cloud.general.mapper")
public class GeneralApplication {
public static void main(String[] args) {
SpringApplication.run(GeneralApplication.class, args);
}
}

View File

@ -0,0 +1,17 @@
package cn.crtech.cloud.general.annotation;
import cn.crtech.cloud.general.config.DataSourceConstants;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface DataSourceAnnotation {
/**
* 数据源名称
*/
String value() default DataSourceConstants.MIS_DATASOURCE;
}

View File

@ -0,0 +1,10 @@
package cn.crtech.cloud.general.config;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
public class DataSource extends AbstractRoutingDataSource {
@Override
protected Object determineCurrentLookupKey() {
return DataSourceContextHolder.getContextKey();
}
}

View File

@ -0,0 +1,46 @@
package cn.crtech.cloud.general.config;
import cn.crtech.cloud.general.annotation.DataSourceAnnotation;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.util.Objects;
@Aspect
@Component
public class DataSourceAspect {
@Pointcut("@annotation(cn.crtech.cloud.general.annotation.DataSourceAnnotation)")
public void dataSourcePointCut() {
}
@Around("dataSourcePointCut()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
String dsKey = getDSAnnotation(joinPoint).value();
DataSourceContextHolder.setContextKey(dsKey);
try {
return joinPoint.proceed();
} finally {
DataSourceContextHolder.removeContextKey();
}
}
/**
* 根据类或方法获取数据源注解
*/
private DataSourceAnnotation getDSAnnotation(ProceedingJoinPoint joinPoint) {
Class<?> targetClass = joinPoint.getTarget().getClass();
DataSourceAnnotation dataSourceAnnotation = targetClass.getAnnotation(DataSourceAnnotation.class);
// 先判断类的注解,再判断方法注解
if (Objects.nonNull(dataSourceAnnotation)) {
return dataSourceAnnotation;
} else {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
return methodSignature.getMethod().getAnnotation(DataSourceAnnotation.class);
}
}
}

View File

@ -0,0 +1,71 @@
package cn.crtech.cloud.general.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import tk.mybatis.spring.annotation.MapperScan;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
@Configuration
@MapperScan(basePackages = "cn.crtech.cloud.general.mapper")
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
public class DataSourceConfig {
@Value("${service.datasource.MIS.url}")
private String misUrl;
@Value("${service.datasource.MIS.username}")
private String misUserName;
@Value("${service.datasource.MIS.password}")
private String misPassWord;
@Value("${service.datasource.MIS.driver}")
private String misDriver;
@Bean(DataSourceConstants.MIS_DATASOURCE)
public DataSource misDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(misDriver);
dataSource.setUrl(misUrl);
dataSource.setUsername(misUserName);
dataSource.setPassword(misPassWord);
return dataSource;
}
@Value("${service.datasource.TM.url}")
private String tmUrl;
@Value("${service.datasource.TM.username}")
private String tmUserName;
@Value("${service.datasource.TM.password}")
private String tmPassWord;
@Value("${service.datasource.TM.driver}")
private String tmDriver;
@Bean(DataSourceConstants.TM_DATASOURCE)
public DataSource tmDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(tmDriver);
dataSource.setUrl(tmUrl);
dataSource.setUsername(tmUserName);
dataSource.setPassword(tmPassWord);
return dataSource;
}
@Bean
@Primary
public DataSource dataSource() {
Map<Object, Object> dataSourceMap = new HashMap<>(2);
dataSourceMap.put(DataSourceConstants.MIS_DATASOURCE, misDataSource());
dataSourceMap.put(DataSourceConstants.TM_DATASOURCE, tmDataSource());
//设置动态数据源
cn.crtech.cloud.general.config.DataSource dynamicDataSource = new cn.crtech.cloud.general.config.DataSource();
dynamicDataSource.setTargetDataSources(dataSourceMap);
dynamicDataSource.setDefaultTargetDataSource(misDataSource());
return dynamicDataSource;
}
}

View File

@ -0,0 +1,6 @@
package cn.crtech.cloud.general.config;
public class DataSourceConstants {
public static final String TM_DATASOURCE = "TM";
public static final String MIS_DATASOURCE = "MIS";
}

View File

@ -0,0 +1,30 @@
package cn.crtech.cloud.general.config;
public class DataSourceContextHolder {
/**
* 动态数据源名称上下文
*/
private static final ThreadLocal<String> DATASOURCE_CONTEXT_KEY_HOLDER = new ThreadLocal<>();
/**
* 设置/切换数据源
*/
public static void setContextKey(String key) {
DATASOURCE_CONTEXT_KEY_HOLDER.set(key);
}
/**
* 获取数据源名称
*/
public static String getContextKey() {
String key = DATASOURCE_CONTEXT_KEY_HOLDER.get();
return key == null ? DataSourceConstants.MIS_DATASOURCE : key;
}
/**
* 删除当前数据源名称
*/
public static void removeContextKey() {
DATASOURCE_CONTEXT_KEY_HOLDER.remove();
}
}

View File

@ -0,0 +1,80 @@
package cn.crtech.cloud.general.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.time.Duration;
/**
* Author : yj
* Date : 2021-02-23
* Description:
*/
@Configuration
public class RedisConfig extends CachingConfigurerSupport {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
template.setConnectionFactory(factory);
//key序列化方式
template.setKeySerializer(redisSerializer);
//value序列化
template.setValueSerializer(jackson2JsonRedisSerializer);
//value hashmap序列化
template.setHashValueSerializer(jackson2JsonRedisSerializer);
return template;
}
@Bean
public CacheManager cacheManager(RedisConnectionFactory factory) {
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
//解决查询缓存转换异常的问题
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
//om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
// 配置序列化(解决乱码的问题),过期时间30秒
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig()
.entryTtl(Duration.ofSeconds(30))
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer))
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer))
.disableCachingNullValues();
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
.cacheDefaults(config)
.build();
return cacheManager;
}
}

View File

@ -0,0 +1,30 @@
package cn.crtech.cloud.general.config;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* Redis相关配置
*/
//@Configuration
//@EnableRedisRepositories
@Deprecated
public class RedisRepositoryConfig {
//@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(connectionFactory);
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringRedisSerializer);
redisTemplate.setHashKeySerializer(stringRedisSerializer);
Jackson2JsonRedisSerializer<?> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}

View File

@ -0,0 +1,51 @@
package cn.crtech.cloud.general.controller;
import cn.crtech.cloud.common.dto.Result;
import cn.crtech.cloud.general.dto.MisUserInfoDto;
import cn.crtech.cloud.general.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 获取登录用户信息接口
*/
@RestController
@RequestMapping("/user")
public class UserController {
private UserService baseService;
@Autowired
public UserController(UserService baseService) {
this.baseService = baseService;
}
/**
* 获取用户信息
*
* @param params 参数对象
* @return 返回查询结果
*/
@PostMapping("/info")
public Result getUserInfo(@RequestBody Map<String, Object> params) {
try {
MisUserInfoDto userInfo = baseService.getUserInfo(params);
return Result.success(userInfo);
} catch (Exception e) {
return Result.error(null, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
}
}
/**
* 权限校验
*
* @param applicationCode 产品标识
* @return 返回校验结果
*/
@GetMapping("/permissionVerification/{applicationCode}")
public Result permissionVerification(@PathVariable("applicationCode") String applicationCode) {
return baseService.permissionVerification(applicationCode);
}
}

View File

@ -0,0 +1,33 @@
package cn.crtech.cloud.general.controller;
import cn.crtech.cloud.common.dto.Result;
import cn.crtech.cloud.general.service.WxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@RequestMapping("/wx")
public class WxUserController {
private WxUserService wxUserService;
@Autowired
public WxUserController(WxUserService wxUserService) {
this.wxUserService = wxUserService;
}
/**
* 获取用户信息
*
* @param params 参数对象
* @return 返回查询结果
*/
@PostMapping("/getUserInfo")
public Result getWxUserInfo(@RequestBody Map<String, Object> params) {
return wxUserService.getWxUserInfo(params);
}
}

View File

@ -0,0 +1,51 @@
package cn.crtech.cloud.general.dto;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import java.io.Serializable;
import java.util.Date;
/**
* 授权产品实体DTO
*
* @author TYP
* @since 2023-08-08 10:43
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class MisAppDto implements Serializable {
@DataExportAnnotation("产品名称")
private String name;
@DataExportAnnotation("产品标识")
private String code;
@DataExportAnnotation("产品描述信息")
private String description;
@DataExportAnnotation("是否默认展示在产品展示列表")
private Boolean isShow;
@DataExportAnnotation("授权过期时间")
@JsonFormat(pattern = "YYYY-MM-dd", locale = "cn", timezone = "GMT+8")
private Date expireDate;
@DataExportAnnotation("授权产品系列ID")
private Integer seriesId;
@DataExportAnnotation("授权产品系列标识")
private String seriesCode;
@DataExportAnnotation("授权产品版本ID")
private Integer versionId;
@DataExportAnnotation("授权产品版本标识")
private String version;
}

View File

@ -0,0 +1,32 @@
package cn.crtech.cloud.general.dto;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import lombok.*;
import java.io.Serializable;
/**
* 角色授权菜单实体Dto
*
* @author TYP
* @since 2023-08-08 9:48
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class MisComRolePopedomDto implements Serializable {
@DataExportAnnotation("公司标识")
private String companyCode;
@DataExportAnnotation("角色ID")
private Integer roleId;
@DataExportAnnotation("菜单ID")
private Integer popedomId;
@DataExportAnnotation("产品标识")
private String applicationCode;
}

View File

@ -0,0 +1,56 @@
package cn.crtech.cloud.general.dto;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import lombok.*;
import java.io.Serializable;
/**
* desc
*
* @author TYP
* @since 2023-08-08 10:20
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class MisComUserDto implements Serializable {
@DataExportAnnotation("公司标识")
private String companyCode;
@DataExportAnnotation("公司名称")
private String companyName;
@DataExportAnnotation("公司图标")
private String logo;
@DataExportAnnotation("所在省地址")
private String provinceName;
@DataExportAnnotation("所在市地址")
private String cityName;
@DataExportAnnotation("所在区/县地址")
private String countyName;
@DataExportAnnotation("详细地址")
private String address;
@DataExportAnnotation("用户ID")
private Integer userId;
@DataExportAnnotation("是否公司所有人")
private Boolean isOwner;
@DataExportAnnotation("职位")
private String position;
@DataExportAnnotation("是否默认公司")
private Boolean isDefault;
@DataExportAnnotation("状态")
private Integer state;
}

View File

@ -0,0 +1,35 @@
package cn.crtech.cloud.general.dto;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import lombok.*;
import java.io.Serializable;
/**
* 菜单权限功能实体
*
* @author TYP
* @since 2023-07-17 14:42
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class MisPopedomAuthorityDto implements Serializable {
@DataExportAnnotation("主键id")
private Integer id;
@DataExportAnnotation("菜单ID")
private Integer popedomId;
@DataExportAnnotation("权限名称")
private String name;
@DataExportAnnotation("路由权限功能标识")
private String authorityCode;
@DataExportAnnotation("产品标识")
private String applicationCode;
}

View File

@ -0,0 +1,62 @@
package cn.crtech.cloud.general.dto;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import cn.crtech.cloud.common.pojo.Tree;
import lombok.*;
import org.apache.commons.lang3.ObjectUtils;
import java.io.Serializable;
import java.util.List;
/**
* 产品版本实体
*
* @author TYP
* @since 2023-07-14 14:48
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class MisPopedomDto extends Tree implements Serializable {
@DataExportAnnotation("主键id")
private Integer id;
@DataExportAnnotation("菜单名称")
private String name;
@DataExportAnnotation("父级菜单ID")
private Integer parentId;
@DataExportAnnotation("菜单路由跳转地址")
private String route;
@DataExportAnnotation("菜单图标")
private String icon;
@DataExportAnnotation("菜单图标(bootstrap专用)")
private String bIcon;
@DataExportAnnotation("菜单类型 0菜单目录 1跳转菜单")
private Integer menuType;
@DataExportAnnotation("菜单排序值")
private Integer orderNo;
@DataExportAnnotation("路由菜单类型")
private Integer isMenu;
@DataExportAnnotation("产品标识")
private String applicationCode;
@DataExportAnnotation("产品特殊权限")
private List<MisPopedomAuthorityDto> authorityList;
@Override
public Boolean isRoot() {
return ObjectUtils.isEmpty(this.parentId);
}
}

View File

@ -0,0 +1,61 @@
package cn.crtech.cloud.general.dto;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import lombok.*;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 用户信息实体DTO
*
* @author TYP
* @since 2023-08-08 9:59
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class MisUserInfoDto implements Serializable {
@DataExportAnnotation("用户ID")
private Integer id;
@DataExportAnnotation("用户名称")
private String name;
@DataExportAnnotation("用户邮箱地址")
private String email;
@DataExportAnnotation("用户手机号码")
private String mobile;
@DataExportAnnotation("用户所属公司标识")
private String companyCode;
@DataExportAnnotation("是否所属公司拥有人")
private Boolean isOwner;
@DataExportAnnotation("当前登录公司信息")
private MisComUserDto company;
@DataExportAnnotation("已授权角色名字集合")
private List<String> roles;
@DataExportAnnotation("用户所有公司数据集合")
private List<MisComUserDto> companys;
@DataExportAnnotation("当前选中产品")
private MisAppDto application;
@DataExportAnnotation("用户所有授权产品数据集合")
private List<MisAppDto> applications;
@DataExportAnnotation("用户应用授权路由菜单")
private List<MisPopedomDto> routes;
@DataExportAnnotation("用户其他信息放置内容")
private Map<String, Object> extraInfo;
}

View File

@ -0,0 +1,30 @@
package cn.crtech.cloud.general.dto;
import cn.crtech.cloud.general.pojo.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* Author : yj
* Date : 2021-01-14
* Description:
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class UserDto extends User {
private String companyCode;
private String companyName;
private String userName;
private Integer status;
private List<String> roles;
private String mobile;
private Boolean companyAdmin;
}

View File

@ -0,0 +1,61 @@
package cn.crtech.cloud.general.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class WxAppleUserInfo implements Serializable {
private String id;
private String name;
private String companyCode;
private String email;
private String mobile;
private String headImgUrl;
private MisComUserDto company;
private List<MisComUserDto> companys;
private Boolean isOwner;
private Boolean idCardRegister;
private String userName;
private String serialNo;
private String genderName;
private String organizationName;
private String nation;
private String birthday;
private String address;
private Integer cloudUserId;
private Boolean healthFlag;
private Boolean healthTaskFlag;
private Boolean isPositionManager;
private Boolean isUploadFaceRec;
private Boolean isOrganizationManager;
private String positionId;
private String positionName;
private Integer faceAuditStatus;
}

View File

@ -0,0 +1,43 @@
package cn.crtech.cloud.general.holder;
import cn.crtech.cloud.general.dto.UserDto;
import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/**
* 获取登录用户信息
* Created by macro on 2020/6/17.
*/
@Configuration
public class LoginUserHolder {
public UserDto getCurrentUser() {
//从Header中获取用户信息
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
String userStr = null;
try {
userStr = URLDecoder.decode(request.getHeader("user"), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
JSONObject userJsonObject = new JSONObject(userStr);
UserDto userDto = new UserDto();
userDto.setCompanyCode(userJsonObject.getStr("company_code"));
userDto.setUserName(userJsonObject.getStr("nick_name"));
userDto.setMobile(userJsonObject.getStr("mobile"));
userDto.setEmail(userJsonObject.getStr("email"));
userDto.setId(Integer.valueOf(userJsonObject.getStr("id")));
userDto.setCompanyAdmin(Boolean.valueOf(userJsonObject.getStr("company_admin")));
userDto.setRoles(Convert.toList(String.class, userJsonObject.get("authorities")));
return userDto;
}
}

View File

@ -0,0 +1,51 @@
package cn.crtech.cloud.general.launcher;
import com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration;
import com.alibaba.cloud.nacos.registry.NacosRegistration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.Query;
import javax.servlet.ServletContext;
import java.lang.management.ManagementFactory;
import java.util.Set;
//使用launcher启动时使用 begin
//@Component
//使用launcher启动时使用 end
public class NacosConfig implements ApplicationRunner {
@Autowired
private ServletContext servletContext;
@Autowired
private NacosRegistration registration;
@Autowired(required = false)
private NacosAutoServiceRegistration nacosAutoServiceRegistration;
public Integer getTomcatPort() throws MalformedObjectNameException {
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 new Integer(port);
}
@Override
public void run(ApplicationArguments args) throws Exception {
if (registration != null && servletContext != null) {
try {
Integer tomcatPort = getTomcatPort();
registration.setPort(tomcatPort);
registration.getMetadata().put("management.context-path", servletContext.getContextPath());
nacosAutoServiceRegistration.start();
} catch (MalformedObjectNameException e) {
e.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,229 @@
package cn.crtech.cloud.general.mapper;
import cn.crtech.cloud.general.annotation.DataSourceAnnotation;
import cn.crtech.cloud.general.config.DataSourceConstants;
import cn.crtech.cloud.general.dto.*;
import cn.crtech.cloud.general.pojo.MisApp;
import cn.crtech.cloud.general.pojo.MisComRoleUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public interface GlobalMapper {
@Select("select " +
"b.code , b.name , b.description , a.expire_date " +
"from mis_com_app a " +
"left join mis_app b on a.app_id = b.id " +
"left join mis_company c on a.company_id = c.id " +
"left join mis_app_series d on b.series_id = d.id " +
"where b.code = #{applicationCode} and c.code = #{companyCode} and b.state = 1 and a.expire_date >= now() and d.type in (1,2)")
@ResultType(MisApp.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisApp> queryCurrentCompanyApplicationByCode(@Param("companyCode") String companyCode,
@Param("applicationCode") String applicationCode);
@Select("select " +
"a.company_code,a.role_id,a.user_id " +
"from mis_com_role_user a " +
"where a.company_code = #{companyCode} and a.user_id = #{userId}")
@ResultType(MisComRoleUser.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisComRoleUser> queryCompanyRoleUserById(@Param("companyCode") String companyCode,
@Param("userId") Integer userId);
@Select("select " +
"f.code as companyCode , a.role_id as roleId , " +
"b.code as applicationCode , a.popedom_id as popedomId " +
"from mis_com_role_popedom a " +
"inner join mis_app b on b.id = a.app_id " +
"inner join mis_app_popedom c on c.id = a.popedom_id " +
"inner join " +
"( select " +
" d.app_id , e.code " +
" from mis_com_app d " +
" inner join mis_company e on d.company_id = e.id " +
" where d.state = 1 and e.state = 1 " +
") as f on a.app_id = f.app_id and f.code = #{companyCode} " +
"where b.code = #{applicationCode} and a.role_id = #{roleId} " +
"order by c.sort")
@ResultType(MisComRolePopedomDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisComRolePopedomDto> queryCompanyUserRolePopeDom(@Param("companyCode") String companyCode,
@Param("applicationCode") String applicationCode,
@Param("roleId") int roleId);
@Select("select " +
"a.code as companyCode , a.name as companyName , a.logo , " +
"a.province_name as provinceName , a.city_name as cityName , a.county_name as countyName , " +
"a.street as address, b.user_id AS userId, " +
"CASE WHEN a.owner_id = #{userId} then 1 ELSE 0 end as isOwner, " +
"IFNULL(b.position,'超级管理员') as position, " +
"IFNULL(b.is_default,1) AS isDefault, " +
"IFNULL(b.state,1) as state " +
"from mis_company a " +
"inner join mis_company_user b on b.company_code = a.code " +
"where b.user_id = #{userId} and b.state = 1 " +
"order by b.is_default desc ")
@ResultType(MisComUserDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisComUserDto> queryUserCompanyById(@Param("userId") int userId);
@Select("select " +
"a.code , a.name , a.description , a.is_show as isShow , b.expire_date as expireDate , d.type , " +
"d.code as seriesCode , d.id as seriesId , e.id as versionId , e.version " +
"from mis_app a " +
"inner join mis_com_app b on b.app_id = a.id " +
"inner join mis_company c on c.id = b.company_id " +
"inner join mis_app_series d on d.id = a.series_id " +
"inner join mis_app_grade e on e.id = b.app_version " +
"where c.code = #{companyCode} and d.type in (1,2) and a.is_show = 1 ")
@ResultType(MisAppDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisAppDto> queryCompanyApplicationByCode(@Param("companyCode") String companyCode);
@Select("select " +
"b.code as applicationCode , " +
"f.id ,f.`name` ,f.parent_id as parentId , f.route , f.menu_icon as icon , f.menu_b_icon as bIcon , " +
"f.sort as orderNo , f.menu_type as isMenu , f.id as realId , f.parent_id as realParentId " +
"from mis_com_app a " +
"inner join mis_app b on a.app_id = b.id " +
"inner join mis_app_grade c on a.app_version = c.id " +
"inner join mis_company d on d.id = a.company_id " +
"left join mis_app_grade_popedom e on e.grade_id = c.id " +
"inner join mis_app_popedom f on f.id = e.popedom_id " +
"where d.code = #{companyCode} and (b.code = #{clientId} or b.client_secret = #{clientId}) " +
"order by f.sort")
@ResultType(MisPopedomDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisPopedomDto> queryCompanyAdminRoutes(@Param("clientId") String clientId,
@Param("companyCode") String companyCode);
@Select("select " +
"b.code as applicationCode , " +
"f.id , f.popedom_id as popedomId , f.name , f.authority_code as authorityCode " +
"from mis_com_app a " +
"inner join mis_app b on a.app_id = b.id " +
"inner join mis_app_grade c on a.app_version = c.id " +
"inner join mis_company d on d.id = a.company_id " +
"left join mis_app_grade_popedom_authority e on e.grade_id = c.id " +
"inner join mis_app_popedom_authority f on f.id = e.authority_id " +
"where d.code = #{companyCode} and (b.code = #{clientId} or b.client_secret = #{clientId})")
@ResultType(MisPopedomAuthorityDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisPopedomAuthorityDto> queryCompanyPopAuthority(@Param("clientId") String clientId,
@Param("companyCode") String companyCode);
@Select("select " +
"f.code as applicationCode , " +
"e.id ,e.`name` ,e.parent_id as parentId , e.route , e.menu_icon as icon , e.menu_b_icon as bIcon , " +
"e.sort as orderNo , e.menu_type as isMenu , e.id as realId , e.parent_id as realParentId " +
"from mis_com_role_user a " +
"inner join mis_user b on a.user_id = b.id " +
"inner join mis_com_role c on c.id = a.role_id " +
"left join mis_com_role_popedom d on d.role_id = a.role_id " +
"inner join mis_app_popedom e on e.id = d.popedom_id " +
"inner join mis_app f on f.id = d.app_id " +
"where a.user_id = #{userId} and (f.code = #{clientId} or f.client_secret = #{clientId}) " +
"and a.company_code = #{companyCode} " +
"order by e.sort")
@ResultType(MisPopedomDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisPopedomDto> queryComRolePopedom(@Param("userId") Integer userId,
@Param("clientId") String clientId,
@Param("companyCode") String companyCode);
@Select("select " +
"f.code as applicationCode , " +
"e.id ,e.`name` ,e.parent_id as parentId , e.route , e.menu_icon as icon , e.menu_b_icon as bIcon , " +
"e.sort as orderNo , e.menu_type as isMenu , e.id as realId , e.parent_id as realParentId " +
"from mis_app_defaultrole_user a " +
"inner join mis_user b on a.user_id = b.id " +
"inner join mis_app_defaultrole c on c.id = a.role_id " +
"left join mis_app_defaultrole_popedom d on d.role_id = a.role_id " +
"inner join mis_app_popedom e on e.id = d.popedom_id " +
"inner join mis_app f on f.id = c.app_id " +
"where a.user_id = #{userId} and (f.code = #{clientId} or f.client_secret = #{clientId}) " +
"and a.company_code = #{companyCode} " +
"order by e.sort")
@ResultType(MisPopedomDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisPopedomDto> queryAppDefaultPopedom(@Param("userId") Integer userId,
@Param("clientId") String clientId,
@Param("companyCode") String companyCode);
@Select("select " +
"f.code as applicationCode , " +
"e.id , e.popedom_id as popedomId , e.name ,e.authority_code as authorityCode " +
"from mis_com_role_user a " +
"inner join mis_user b on a.user_id = b.id " +
"inner join mis_com_role c on c.id = a.role_id " +
"left join mis_com_role_popedom_authority d on d.role_id = a.role_id " +
"inner join mis_app_popedom_authority e on e.id = d.authority_id " +
"inner join mis_app f on f.id = d.app_id " +
"where a.user_id = #{userId} and (f.code = #{clientId} or f.client_secret = #{clientId}) " +
"and a.company_code = #{companyCode}")
@ResultType(MisPopedomAuthorityDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisPopedomAuthorityDto> queryComRolePopAuthority(@Param("userId") Integer userId,
@Param("clientId") String clientId,
@Param("companyCode") String companyCode);
@Select("select " +
"f.code as applicationCode , " +
"e.id , e.popedom_id as popedomId , e.name ,e.authority_code as authorityCode " +
"from mis_app_defaultrole_user a " +
"inner join mis_user b on a.user_id = b.id " +
"inner join mis_app_defaultrole c on c.id = a.role_id " +
"left join mis_app_defaultrole_popedom_authority d on d.role_id = a.role_id " +
"inner join mis_app_popedom_authority e on e.id = d.authority_id " +
"inner join mis_app f on f.id = c.app_id " +
"where a.user_id = #{userId} and (f.code = #{clientId} or f.client_secret = #{clientId}) " +
"and a.company_code = #{companyCode}")
@ResultType(MisPopedomAuthorityDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisPopedomAuthorityDto> queryDefaultRolePopAuthority(@Param("userId") Integer userId,
@Param("clientId") String clientId,
@Param("companyCode") String companyCode);
@Select("select " +
"a.company_code,a.role_id,a.user_id " +
"from mis_app_defaultrole_user a " +
"where a.company_code = #{companyCode} and a.user_id = #{userId}")
@ResultType(MisComRoleUser.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisComRoleUser> queryAppDefaultRoleUserById(@Param("companyCode") String companyCode,
@Param("userId") Integer userId);
@Select("select " +
"a.role_id as roleId , b.code as applicationCode , a.popedom_id as popedomId " +
"from mis_app_defaultrole_popedom a " +
"inner join mis_app_defaultrole b on b.id = a.role_id " +
"inner join mis_app_popedom c on c.id = a.popedom_id " +
"inner join mis_app d on d.id = c.app_id " +
"where a.role_id = 1 " +
"order by c.sort")
@ResultType(MisComRolePopedomDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisComRolePopedomDto> queryUserDefaultRolePopeDom(@Param("companyCode") String companyCode,
@Param("applicationCode") String applicationCode,
@Param("roleId") int roleId);
@Select("<script> " +
"SELECT " +
" ${extraSqlStr} " +
"FROM mis_user a " +
"left join mis_company_user b on a.id = b.user_id " +
"inner join mis_company c on c.code = b.company_code " +
"left join mis_chain_mechanism d on d.company_id = c.id " +
"left join mis_chain e on e.id = d.chain_id " +
"where a.id = #{userId} and c.code = #{companyCode} " +
"</script>")
Map<String, Object> loadUserExtraInfo(@Param("userId") Integer userId,
@Param("companyCode") String companyCode,
@Param("extraSqlStr") String extraSqlStr);
}

View File

@ -0,0 +1,112 @@
package cn.crtech.cloud.general.mapper;
import cn.crtech.cloud.general.annotation.DataSourceAnnotation;
import cn.crtech.cloud.general.config.DataSourceConstants;
import cn.crtech.cloud.general.dto.MisComUserDto;
import cn.crtech.cloud.general.pojo.Staff;
import cn.crtech.cloud.general.pojo.WxAppletUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface WxUserMapper {
@Select("select if(id_card is null or id_card ='',0,1) from mis_user where mobile = #{mobile}")
@ResultType(Boolean.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
Boolean checkUserIdCardRegister(@Param("mobile") String mobile);
@Select(" SELECT " +
" rs.*," +
" IF(rs.overTime IS NULL OR rs.overTime = '',FALSE,IF( rs.overTime >= CURDATE(), TRUE, FALSE )) AS healthFlag " +
" FROM " +
" (" +
" SELECT" +
" a.id," +
" a.serial_no AS serialNo," +
" a.user_name AS userName," +
" a.mobile," +
" a.birthday," +
" a.position_id AS positionId," +
" a.address," +
" a.marry_flag AS marryFlag," +
" a.native_place AS nativePlace," +
" a.contact_name AS contactName," +
" a.contact_mobile AS contactMobile," +
" a.hospital_name AS hospitalName," +
" a.STATUS," +
" a.created," +
" a.cloud_user_id as cloudUserId, " +
" a.is_upload_face_rec as isUploadFaceRec," +
" a.is_position_manager AS isPositionManager," +
" a.is_organization_manager as isOrganizationManager," +
" a.face_audit_status as faceAuditStatus," +
" b.NAME AS typeName," +
" c.NAME AS genderName," +
" d.NAME AS pharmacistLevelName," +
" e.position_name AS positionName," +
" f.NAME AS organizationName," +
" g.NAME AS nation," +
" IF(( " +
" SELECT" +
" COUNT( a.id ) " +
" FROM " +
" staff_health_task_record a" +
" left join staff_health_task b on a.staff_health_task_id = b.id" +
" WHERE " +
" a.STATUS = 0 AND a.staff_id = a.id and b.`status` =1 ) > 0, TRUE, FALSE ) AS healthTaskFlag," +
" ( " +
" SELECT " +
" rs.overTime" +
" FROM" +
" (" +
" SELECT b.staff_id AS staffId," +
" (SELECT date_add( sht.end_time, INTERVAL sht.expiration_date MONTH ) AS overTime FROM staff_health_task sht WHERE sht.id = a.id ) overTime " +
" FROM" +
" staff_health_task a " +
" INNER JOIN staff_health_task_record b ON a.id = b.staff_health_task_id " +
" WHERE b.STATUS = 2 " +
" )rs" +
" WHERE rs.staffId = a.id ORDER BY rs.overTime DESC LIMIT 1 " +
" ) AS overTime" +
" FROM" +
" staff a" +
" LEFT JOIN cr_dictionary_data b ON a.type_id = b.id" +
" LEFT JOIN cr_dictionary_data c ON a.gender_id = c.id" +
" LEFT JOIN cr_dictionary_data d ON a.pharmacist_level_id = d.id" +
" LEFT JOIN cr_dictionary_data g ON a.nation = g.id" +
" LEFT JOIN staff_position e ON a.position_id = e.id" +
" LEFT JOIN staff_organization f ON a.organization_id = f.id " +
" WHERE" +
" a.cloud_user_id = #{userId} " +
" and a.hospital_id = #{hospitalId} )rs"
)
@ResultType(Staff.class)
@DataSourceAnnotation(DataSourceConstants.TM_DATASOURCE)
Staff getTMStaffByUserId(@Param("userId") int userId, @Param("hospitalId") String hospitalId);
@Select("select * from wx_user where mobile = #{mobile} and company_code =#{companyCode}")
@ResultType(WxAppletUser.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
WxAppletUser getWxAppletUser(@Param("mobile") String mobile, @Param("companyCode") String companyCode);
@Select("select " +
"a.code as companyCode , a.name as companyName , a.logo , " +
"a.province_name as provinceName , a.city_name as cityName , a.county_name as countyName , " +
"a.street as address, b.user_id AS userId, " +
"CASE WHEN a.owner_id = #{userId} then 1 ELSE 0 end as isOwner, " +
"IFNULL(b.position,'超级管理员') as position, " +
"IFNULL(b.is_default,1) AS isDefault, " +
"IFNULL(b.state,1) as state " +
"from mis_company a " +
"inner join mis_company_user b on b.company_code = a.code " +
"where b.user_id = #{userId} and b.state = 1 " +
"order by b.is_default desc ")
@ResultType(MisComUserDto.class)
@DataSourceAnnotation(DataSourceConstants.MIS_DATASOURCE)
List<MisComUserDto> queryUserCompanyById(@Param("userId") int userId);
}

View File

@ -0,0 +1,111 @@
package cn.crtech.cloud.general.pojo;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
/**
* MIS授权产品实体对象
*
* @author TYP
* @since 2023-07-13 15:34
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "mis_app")
public class MisApp implements Serializable {
@Id
@DataExportAnnotation("主键id")
private Integer id;
@Column(name = "series_id")
@DataExportAnnotation("产品所属系列ID")
private Integer seriesId;
@Column(name = "name")
@DataExportAnnotation("产品名称")
private String name;
@Column(name = "code")
@DataExportAnnotation("产品标识")
private String code;
@Column(name = "description")
@DataExportAnnotation("产品描述信息")
private String description;
@Column(name = "logo")
@DataExportAnnotation("产品图标超链接")
private String logo;
@Column(name = "sort")
@DataExportAnnotation("产品排序")
private String sort;
@Column(name = "resource_ids")
private String resourceIds;
@Column(name = "client_secret")
@DataExportAnnotation("产品秘钥")
private String clientSecret;
@Builder.Default
@Column(name = "scope")
@DataExportAnnotation("产品授权范围")
private String scope = "all";
@Builder.Default
@Column(name = "authorized_grant_types")
@DataExportAnnotation("产品授权加密类型")
private String authorizedGrantTypes = "password,refresh_token";
@Builder.Default
@Column(name = "access_token_validity")
@DataExportAnnotation("访问授权TOKEN有效期")
private Integer accessTokenValidity = 86400;
@Builder.Default
@Column(name = "refresh_token_validity")
@DataExportAnnotation("TOKEN刷新有效期")
private Integer refreshTokenValidity = 86400;
@Column(name = "manager")
@DataExportAnnotation("产品管理产品经理ID")
private Integer manager;
@Column(name = "created")
@DataExportAnnotation("创建时间")
@JsonFormat(pattern = "YYYY-MM-dd HH:mm:ss", locale = "cn", timezone = "GMT+8")
private Date created;
@Column(name = "is_default_role")
@DataExportAnnotation("是否含有默认角色")
private Boolean isDefaultRole;
@Column(name = "is_show")
@DataExportAnnotation("是否默认展示在产品展示列表")
private Boolean isShow;
@Column(name = "state")
@DataExportAnnotation("状态 1正常 0停用 -1删除")
private Integer state;
@Transient
@DataExportAnnotation("查询结果 产品经理名称")
private String managerName;
@Transient
@DataExportAnnotation("查询结果 是否为当前公司已绑定产品")
private Integer isBindApp;
}

View File

@ -0,0 +1,35 @@
package cn.crtech.cloud.general.pojo;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import lombok.*;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 企业角色实体
*
* @author TYP
* @since 2023-08-01 9:24
*/
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "mis_com_role_user")
public class MisComRoleUser implements Serializable {
@Column(name = "company_code")
@DataExportAnnotation("所属公司标识")
private String companyCode;
@Column(name = "role_id")
@DataExportAnnotation("角色ID")
private Integer roleId;
@Column(name = "user_id")
@DataExportAnnotation("用户ID")
private Integer userId;
}

View File

@ -0,0 +1,112 @@
package cn.crtech.cloud.general.pojo;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
/**
* Created by lzjyzq2 on 2022-10-13 16:36:43
*/
@Data
@Table(name = "staff")
@DataExportAnnotation("职员")
public class Staff implements Serializable {
@DataExportAnnotation("主键")
private String id;
@DataExportAnnotation("胸牌号")
private String serialNo;
@DataExportAnnotation("姓名")
private String userName;
@Column(name = "type_id")
@DataExportAnnotation("人员类型(外聘人员、代培人员)")
private String typeId;
@DataExportAnnotation("手机号码")
private String mobile;
@DataExportAnnotation("性别(数据字典)")
private String genderId;
@DataExportAnnotation("出生日期")
private String birthday;
@DataExportAnnotation("现居住址")
private String address;
@DataExportAnnotation("是否结婚")
private Boolean marryFlag;
@DataExportAnnotation("民族")
private String nation;
@DataExportAnnotation("籍贯")
private String nativePlace;
@DataExportAnnotation("紧急联系人")
private String contactName;
@DataExportAnnotation("紧急联系电话")
private String contactMobile;
@DataExportAnnotation("药师等级(数据字典)")
private String pharmacistLevelId;
@DataExportAnnotation("岗位信息(关联position)")
private String positionId;
@DataExportAnnotation("组织架构(关联staff_organization)")
private String organizationId;
@DataExportAnnotation("证件信息(关联staff_certificate)")
private String certificateId;
@DataExportAnnotation("学历信息(关联staff_education)")
private String educationId;
@DataExportAnnotation("技能信息(关联staff_skill)")
private String skillId;
@DataExportAnnotation("医院id")
private String hospitalId;
@DataExportAnnotation("医院名称")
private String hospitalName;
@DataExportAnnotation("状态(在职、离职)与mis 系统状态一致")
private Integer status;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DataExportAnnotation("创建时间")
private Date created;
@DataExportAnnotation("是否上传人脸图片")
private Boolean isUploadFaceRec;
@DataExportAnnotation("云端用户ID")
private Integer cloudUserId;
@DataExportAnnotation("是否维护 0未维护 1部分维护 2已维护")
private Integer isHandler;
@DataExportAnnotation("是否为管理岗")
private Boolean isPositionManager;
@DataExportAnnotation("是否为部门管理")
private Boolean isOrganizationManager;
@DataExportAnnotation("微信openId")
private String wxOpenId;
@DataExportAnnotation("头像")
private String headImgUrl;
@DataExportAnnotation("人脸审核状态")
private Integer faceAuditStatus;
@Transient
private String typeName;
@Transient
private String genderName;
@Transient
private String pharmacistLevelName;
@Transient
private String positionName;
@Transient
private String organizationName;
@Transient
private String certificateName;
@Transient
private String educationName;
@Transient
private Boolean healthTaskFlag;
@Transient
private Boolean healthFlag;
@Transient
private String email;
}

View File

@ -0,0 +1,92 @@
package cn.crtech.cloud.general.pojo;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* Author : yj
* Date : 2021-01-14
* Description:
*/
@Data
@Table(name = "user")
@DataExportAnnotation("用户表")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@DataExportAnnotation("主键id")
private Integer id;
@Column(name = "name")
@DataExportAnnotation("姓名")
private String name;
@Column(name = "id_card")
@DataExportAnnotation("身份证")
private String idCard;
@Column(name = "nick_name")
@DataExportAnnotation("昵称")
private String nickName;
@Column(name = "lastModifier")
@DataExportAnnotation("最后修改人")
private Long lastModifier;
@Column(name = "lastModifyTime")
@DataExportAnnotation("最后修时间")
private Date lastModifyTime;
@Column(name = "state")
@DataExportAnnotation("状态")
private Integer state;
@Column(name = "mobile")
@DataExportAnnotation("手机号码")
private String mobile;
@Column(name = "email")
@DataExportAnnotation("邮箱")
private String email;
@Column(name = "avatar")
@DataExportAnnotation("头像")
private String avatar;
@Column(name = "password")
@DataExportAnnotation("密码")
private String password;
@Column(name = "id_card_prev")
@DataExportAnnotation("身份证正面")
private String idCardPrev;
@Column(name = "id_card_next")
@DataExportAnnotation("身份证反面")
private String idCardNext;
@Column(name = "real_name")
@DataExportAnnotation("真实姓名")
private String realName;
@Column(name = "reg_time")
@DataExportAnnotation("注册时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date regTime;
@Transient
private String companyCode;
@Transient
private String companyName;
public void setId(Integer id) {
this.id = id;
}
}

View File

@ -0,0 +1,90 @@
package cn.crtech.cloud.general.pojo;
import cn.crtech.cloud.common.annotation.DataExportAnnotation;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Data
@Table(name = "wx_user")
@DataExportAnnotation("小程序用户")
public class WxAppletUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@DataExportAnnotation("主键id")
private Integer id;
@Column(name = "nick_name")
@DataExportAnnotation("用户昵称")
private String nickName;
@Column(name = "avatar_url")
@DataExportAnnotation("用户头像")
private String avatarUrl;
@Column(name = "gender")
@DataExportAnnotation("性别")
private int gender;
@Column(name = "country")
@DataExportAnnotation("所在国家")
private String country;
@Column(name = "province")
@DataExportAnnotation("省份")
private String province;
@Column(name = "city")
@DataExportAnnotation("城市")
private String city;
@Column(name = "mobile")
@DataExportAnnotation("手机号码")
private String mobile;
@Column(name = "open_id")
@DataExportAnnotation("小程序openId")
private String openId;
@Column(name = "union_id")
@DataExportAnnotation("小程序unionId")
private String unionId;
@Column(name = "app_id")
@DataExportAnnotation("应用id")
private String appId;
@Column(name = "wx_open_id")
@DataExportAnnotation("微信openId")
private String wxOpenId;
@Column(name = "created")
@DataExportAnnotation("注册时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date created;
@Column(name = "updated")
@DataExportAnnotation("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updated;
@Column(name = "qr_open_id")
@DataExportAnnotation("扫二维码openId")
private String qrOpenId;
@Column(name = "company_code")
@DataExportAnnotation("企业标识")
private String companyCode;
@Column(name = "company_name")
@DataExportAnnotation("企业标识")
private String companyName;
@Transient
private String serialNo;
@Transient
private Integer cloudUserId;
}

View File

@ -0,0 +1,243 @@
package cn.crtech.cloud.general.service;
import cn.crtech.cloud.common.constant.RedisConstant;
import cn.crtech.cloud.common.dto.Result;
import cn.crtech.cloud.common.utils.OrganizeTree;
import cn.crtech.cloud.general.dto.*;
import cn.crtech.cloud.general.holder.LoginUserHolder;
import cn.crtech.cloud.general.mapper.GlobalMapper;
import cn.crtech.cloud.general.pojo.MisApp;
import cn.crtech.cloud.general.pojo.MisComRoleUser;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Author : yj
* Date : 2021-02-19
* Description:
*/
@Slf4j
@Service
public class UserService {
private GlobalMapper baseMapper;
private RedisTemplate redisTemplate;
private LoginUserHolder loginUserHolder;
@Autowired
public UserService(GlobalMapper baseMapper, RedisTemplate redisTemplate, LoginUserHolder loginUserHolder) {
this.baseMapper = baseMapper;
this.redisTemplate = redisTemplate;
this.loginUserHolder = loginUserHolder;
}
// 额外信息处理
private static Map<String, String> extraSqlMap = new HashMap<>();
static {
extraSqlMap.put("chainId", "d.chain_id as chainId");
extraSqlMap.put("isHeadOffice", "d.is_head_office as isHeadOffice");
extraSqlMap.put("mechanismCode", "d.mechanism_code as mechanismCode");
extraSqlMap.put("mechanismName", "d.mechanism_name as mechanismName");
extraSqlMap.put("chainCode", "e.chain_code as chainCode");
extraSqlMap.put("chainName", "e.chain_name as chainName");
extraSqlMap.put("userId", "a.id as userId");
extraSqlMap.put("nickName", "a.nick_name as nickName");
extraSqlMap.put("mobile", "a.mobile");
extraSqlMap.put("email", "a.email");
extraSqlMap.put("avatar", "a.avatar");
extraSqlMap.put("userName", "a.name as userName");
extraSqlMap.put("idCard", "a.idCard");
extraSqlMap.put("realName", "a.real_name as realName");
extraSqlMap.put("isSystemAdmin", "a.is_system_admin as isSystemAdmin");
}
/**
* 获取用户信息
*
* @param params 参数对象
* @return 返回查询结果
*/
public MisUserInfoDto getUserInfo(Map<String, Object> params) throws Exception {
UserDto currentUser = loginUserHolder.getCurrentUser();
// 创建返回用户信息对象
MisUserInfoDto userInfo = new MisUserInfoDto();
// 通用信息赋值
userInfo.setId(currentUser.getId());
userInfo.setName(currentUser.getUserName());
userInfo.setEmail(currentUser.getEmail());
userInfo.setMobile(currentUser.getMobile());
userInfo.setRoles(currentUser.getRoles());
// 判断是否为首次登录获取相关信息
userInfo.setCompanyCode(ObjectUtils.isNotEmpty(params.get("companyCode")) ? params.get("companyCode").toString() : currentUser.getCompanyCode());
log.info("当前登录用户 ===> {}", currentUser.getId());
// 查询用户所有的公司并赋值
List<MisComUserDto> companyList = baseMapper.queryUserCompanyById(currentUser.getId());
userInfo.setCompanys(companyList);
// 设定当前登录公司信息
if (StringUtils.isNotEmpty(userInfo.getCompanyCode())) {
companyList.stream().filter(company -> company.getCompanyCode().equals(userInfo.getCompanyCode())).forEach(userInfo::setCompany);
}
// 查询用户当前授权产品信息并授权
userInfo.setApplications(baseMapper.queryCompanyApplicationByCode(currentUser.getCompanyCode()));
// 判断设置是否为企业管理员
userInfo.setIsOwner(currentUser.getCompanyAdmin());
// 判断是否携带产品客户端秘钥
if (params.containsKey("clientId")) {
// 切换应用 更新用户信息
String clientId = params.get("clientId").toString();
// 判断设置当前授权产品
userInfo.getApplications().stream().filter(app -> app.getCode().equals(clientId))
.forEach(userInfo::setApplication);
if (ObjectUtil.isEmpty(userInfo.getApplication())) {
throw new Exception("当前用户无权操作此应用");
}
// 判断当前登录人是否为当前企业管理员
if (currentUser.getCompanyAdmin()) {
// 查询当前产品已授权的所有权限菜单数据
List<MisPopedomDto> popedomList = baseMapper.queryCompanyAdminRoutes(clientId, userInfo.getCompanyCode());
// 特殊权限内容查询赋值
List<MisPopedomAuthorityDto> authorityList = baseMapper.queryCompanyPopAuthority(clientId, userInfo.getCompanyCode());
popedomList.forEach(item -> {
item.setAuthorityList(authorityList.stream().filter(authority -> authority.getPopedomId().equals(item.getId())).collect(Collectors.toList()));
});
List<MisPopedomDto> treeList = new OrganizeTree<>(popedomList).buildTree();
userInfo.setRoutes(treeList);
} else {
// 查询用户绑定默认角色对应数据
List<MisPopedomDto> defaultRolePopList = baseMapper.queryAppDefaultPopedom(userInfo.getId(), clientId, userInfo.getCompanyCode());
// 查询用户绑定企业角色对应菜单权限
List<MisPopedomDto> comRolePopList = baseMapper.queryComRolePopedom(userInfo.getId(), clientId, userInfo.getCompanyCode());
// 菜单数据处理
List<MisPopedomDto> popedomList = new ArrayList<>();
popedomList.addAll(defaultRolePopList);
popedomList.addAll(comRolePopList);
popedomList = popedomList.stream().distinct().collect(Collectors.toList());
// 查询用户绑定默认角色相关权限
List<MisPopedomAuthorityDto> defaultRolePopAuthorityList = baseMapper.queryDefaultRolePopAuthority(userInfo.getId(), clientId, userInfo.getCompanyCode());
// 查询用户绑定企业角色相关权限
List<MisPopedomAuthorityDto> comRolePopAuthorityList = baseMapper.queryComRolePopAuthority(userInfo.getId(), clientId, userInfo.getCompanyCode());
// 权限数据处理
List<MisPopedomAuthorityDto> tempAuthorityList = new ArrayList<>();
tempAuthorityList.addAll(defaultRolePopAuthorityList);
tempAuthorityList.addAll(comRolePopAuthorityList);
List<MisPopedomAuthorityDto> authorityList = tempAuthorityList.stream().distinct().collect(Collectors.toList());
// 菜单权限内容赋值
popedomList.forEach(item -> {
item.setAuthorityList(authorityList.stream().filter(authority -> authority.getPopedomId().equals(item.getId())).collect(Collectors.toList()));
});
List<MisPopedomDto> treeList = new OrganizeTree<>(popedomList).buildTree();
userInfo.setRoutes(treeList);
}
}
// 判断是否有其他参数需要查询获取
if (params.containsKey("extra")) {
List<String> extraParamsList = (List<String>) params.get("extra");
StringBuilder extraSqlStr = new StringBuilder();
for (int i = 0; i <= (extraParamsList.size() - 1); i++) {
String keyword = extraParamsList.get(i);
String appendStr = extraSqlMap.get(keyword);
if (StringUtils.isNotBlank(extraSqlStr)) {
extraSqlStr.append((extraSqlStr.toString().endsWith(",")) ? "" : ",");
}
extraSqlStr.append(appendStr);
}
if (extraSqlStr.length() > 0) {
try {
Map<String, Object> info = baseMapper.loadUserExtraInfo(currentUser.getId(), currentUser.getCompanyCode(), extraSqlStr.toString());
if (ObjectUtils.isNotEmpty(info)) {
userInfo.setExtraInfo(info);
}
} catch (Exception e) {
log.error("用户额外信息查询获取失败,原因: {}", e.getMessage());
}
}
}
log.info("userInfo ===> {}", userInfo);
redisTemplate.opsForValue().set(RedisConstant.CURRENT_USREINFO + currentUser.getId(), JSONObject.toJSONString(userInfo));
return userInfo;
}
/**
* 权限校验
*
* @param applicationCode 产品标识
* @return 返回校验结果
*/
@Transactional(readOnly = true)
public Result permissionVerification(String applicationCode) {
// 参数非空校验
if (StringUtils.isBlank(applicationCode)) {
return Result.error("reject", "参数异常!");
}
UserDto currentUser = loginUserHolder.getCurrentUser();
// 校验当前公司是否存在此应用
List<MisApp> appList = baseMapper.queryCurrentCompanyApplicationByCode(currentUser.getCompanyCode(), applicationCode);
if (CollectionUtils.isEmpty(appList)) {
return Result.error("reject", "对应产品插查询结果为空!");
}
// 判断当前登录用户是否为企业管理员
if (currentUser.getCompanyAdmin()) {
return Result.success("pass");
}
// 校验用户是否含有角色权限路由
List<MisComRoleUser> roleUserList = baseMapper.queryCompanyRoleUserById(currentUser.getCompanyCode(), currentUser.getId());
for (int i = 0; i <= (roleUserList.size() - 1); i++) {
MisComRoleUser item = roleUserList.get(i);
List<MisComRolePopedomDto> popedomList = baseMapper.queryCompanyUserRolePopeDom(currentUser.getCompanyCode(), applicationCode, item.getRoleId());
if (!CollectionUtils.isEmpty(popedomList)) {
return Result.success("pass");
}
}
// 校验用户是否含有默认角色权限路由
List<MisComRoleUser> defaultRoleUserList = baseMapper.queryAppDefaultRoleUserById(currentUser.getCompanyCode(), currentUser.getId());
for (int i = 0; i <= (defaultRoleUserList.size() - 1); i++) {
MisComRoleUser item = defaultRoleUserList.get(i);
List<MisComRolePopedomDto> popedomList = baseMapper.queryUserDefaultRolePopeDom(currentUser.getCompanyCode(), applicationCode, item.getRoleId());
if (!CollectionUtils.isEmpty(popedomList)) {
return Result.success("pass");
}
}
return Result.error("reject", "授权路由内容为空!");
}
}

View File

@ -0,0 +1,99 @@
package cn.crtech.cloud.general.service;
import cn.crtech.cloud.common.constant.RedisConstant;
import cn.crtech.cloud.common.dto.Result;
import cn.crtech.cloud.general.dto.MisComUserDto;
import cn.crtech.cloud.general.dto.UserDto;
import cn.crtech.cloud.general.dto.WxAppleUserInfo;
import cn.crtech.cloud.general.holder.LoginUserHolder;
import cn.crtech.cloud.general.mapper.WxUserMapper;
import cn.crtech.cloud.general.pojo.Staff;
import cn.crtech.cloud.general.pojo.WxAppletUser;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class WxUserService {
private WxUserMapper wxUserMapper;
private RedisTemplate redisTemplate;
private LoginUserHolder loginUserHolder;
@Autowired
public WxUserService(LoginUserHolder loginUserHolder, WxUserMapper wxUserMapper, RedisTemplate redisTemplate) {
this.loginUserHolder = loginUserHolder;
this.wxUserMapper = wxUserMapper;
this.redisTemplate = redisTemplate;
}
/**
* 获取用户信息
*
* @param params 参数对象
* @return 返回查询结果
*/
@Transactional(readOnly = true)
public Result getWxUserInfo(Map<String, Object> params) {
UserDto currentUser = loginUserHolder.getCurrentUser();
// 创建微信用户并赋值相关数据
WxAppleUserInfo userInfo = new WxAppleUserInfo();
userInfo.setCloudUserId(currentUser.getId());
userInfo.setName(currentUser.getUserName());
userInfo.setEmail(currentUser.getEmail());
userInfo.setMobile(currentUser.getMobile());
userInfo.setUserName(currentUser.getUserName());
userInfo.setIsOwner(currentUser.getCompanyAdmin());
userInfo.setCompanyCode(params.containsKey("companyCode") ?
params.get("companyCode").toString() : currentUser.getCompanyCode());
// 判断设置用户是否身份证注册
userInfo.setIdCardRegister(wxUserMapper.checkUserIdCardRegister(currentUser.getMobile()));
// 获取相关团队管理职员信息数据
Staff staff = wxUserMapper.getTMStaffByUserId(currentUser.getId(), currentUser.getCompanyCode());
if (ObjectUtils.isNotEmpty(staff)) {
userInfo.setId(staff.getId());
userInfo.setSerialNo(staff.getSerialNo());
userInfo.setBirthday(StringUtils.isBlank(staff.getBirthday()) ? "" : staff.getBirthday());
userInfo.setNation(StringUtils.isBlank(staff.getNation()) ? "" : staff.getNation());
userInfo.setAddress(StringUtils.isBlank(staff.getAddress()) ? "" : staff.getAddress());
userInfo.setHealthFlag(staff.getHealthFlag() != null && staff.getHealthFlag());
userInfo.setHealthTaskFlag(staff.getHealthTaskFlag() != null && staff.getHealthTaskFlag());
userInfo.setPositionId(staff.getPositionId());
userInfo.setPositionName(StringUtils.isBlank(staff.getPositionName()) ? "" : staff.getPositionName());
userInfo.setGenderName(StringUtils.isBlank(staff.getGenderName()) ? "" : staff.getGenderName());
userInfo.setIsPositionManager(staff.getIsPositionManager() != null && staff.getIsPositionManager());
userInfo.setOrganizationName(StringUtils.isBlank(staff.getOrganizationName()) ? "" : staff.getOrganizationName());
userInfo.setIsOrganizationManager(staff.getIsOrganizationManager() != null && staff.getIsOrganizationManager());
userInfo.setIsUploadFaceRec(staff.getIsUploadFaceRec() != null && staff.getIsUploadFaceRec());
userInfo.setFaceAuditStatus(staff.getFaceAuditStatus());
}
// 查询微信用户信息
WxAppletUser appletUser = wxUserMapper.getWxAppletUser(currentUser.getMobile(), currentUser.getCompanyCode());
userInfo.setHeadImgUrl(appletUser.getAvatarUrl());
log.info("当前登录用户 ===> {}", currentUser.getId());
// 查询用户所有的公司并赋值
List<MisComUserDto> companyList = wxUserMapper.queryUserCompanyById(currentUser.getId());
userInfo.setCompanys(companyList);
//用户当前公司
if (StringUtils.isNotEmpty(userInfo.getCompanyCode())) {
companyList.stream().filter(company -> company.getCompanyCode().equals(userInfo.getCompanyCode())).forEach(userInfo::setCompany);
}
log.info("wxUserInfo ===> {}", userInfo);
redisTemplate.opsForValue().set(RedisConstant.CURRENT_WX_USREINFO + currentUser.getId(), userInfo);
return Result.success(userInfo);
}
}

View File

@ -0,0 +1,21 @@
server:
port: 8081
servlet:
encoding:
charset: utf-8
enabled: true
force: true
tomcat:
uri-encoding: UTF-8
mybatis:
mapper-locations: classpath:/mapping/*.xml
type-aliases-package: cn.crtech.cloud.common.pojo.mis,cn.crtech.cloud.common.dto.mis
#配置驼峰下划线
configuration:
map-underscore-to-camel-case: true
logging:
config: classpath:logback.xml
file:
path: logs/crtech-cloud-general.log
level:
com.crtech.cloud.general: debug

View File

@ -0,0 +1,24 @@
spring:
application:
name: crtech-cloud-general # 项目名称尽量用小写
cloud:
nacos:
discovery:
server-addr: localhost:8848
redis:
database: 0
port: 6379
host: localhost
password:
service:
datasource:
TM:
url: jdbc:mysql://chaoran.crtech.cn:9803/pivas_tm_dev?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
username: crtech
password: www.server41.com
driver: com.mysql.cj.jdbc.Driver
MIS:
url: jdbc:mysql://chaoran.crtech.cn:9803/cr_cloud_mis_dev?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
username: crtech
password: www.server41.com
driver: com.mysql.cj.jdbc.Driver

View File

@ -0,0 +1,6 @@
spring:
profiles:
active: test

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/crtech-cloud-general.%d{yyyy-MM-dd}.log
</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd_HH:mm:ss} %logger{18} -%msg%n
</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>1000</queueSize>
<appender-ref ref="FILE" />
</appender>
<logger name="org" level="info" additivity="false">
<appender-ref ref="FILE"></appender-ref>
<appender-ref ref="STDOUT"></appender-ref>
</logger>
<logger name="com" level="info" additivity="false">
<appender-ref ref="FILE"></appender-ref>
<appender-ref ref="STDOUT"></appender-ref>
</logger>
<logger name="net" level="info" additivity="false">
<appender-ref ref="FILE"></appender-ref>
<appender-ref ref="STDOUT"></appender-ref>
</logger>
<logger name="com.netflix" level="debug" additivity="false">
<appender-ref ref="STDOUT"></appender-ref>
<appender-ref ref="FILE"></appender-ref>
</logger>
<logger name="cn.crtech.cloud.general" level="debug" additivity="false">
<appender-ref ref="STDOUT"></appender-ref>
<appender-ref ref="FILE"></appender-ref>
</logger>
<root level="INFO">
<appender-ref ref="ASYNC" />
</root>
</configuration>