Commit dc99f16a authored by 付志忠's avatar 付志忠

--user=lsl 初始化项目

parents
Pipeline #135 failed with stages
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.gosingapore</groupId>
<artifactId>adviser</artifactId>
<version>1.0</version>
<name>adviser</name>
<description>顾问、中介</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.gosingapore.adviser;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AdviserApplication {
public static void main(String[] args) {
SpringApplication.run(AdviserApplication.class, args);
}
}
package com.gosingapore.adviser;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class AdviserApplicationTests {
@Test
void contextLoads() {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gosingapore</groupId>
<artifactId>gs-hiring</artifactId>
<version>1.0</version>
</parent>
<artifactId>api</artifactId>
<description>
api系统接口模块
</description>
<dependencies>
<dependency>
<groupId>com.gosingapore</groupId>
<artifactId>common</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.gosingapore.api;
import com.gosingapore.api.factory.RemoteCustomerFallbackFactory;
import com.cloud.gs.hiring.base.constants.ServiceNameConstants;
import com.cloud.gs.hiring.common.model.dto.CustomerEsDTO;
import com.cloud.gs.hiring.common.model.dto.JobDTO;
import com.cloud.gs.hiring.common.model.vo.CustomerIndustryVO;
import com.cloud.gs.hiring.common.model.vo.FilterCustomerVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author lsl
* @date 2021-04-09 18:57
*/
@FeignClient(contextId = "remoteCustomerService", value = ServiceNameConstants.ADVISER_SERVICE, fallbackFactory = RemoteCustomerFallbackFactory.class)
public interface RemoteCustomerService {
/**
* 查询客户期望职位
* @param archiveId
* @return
*/
@GetMapping("/customer/getCustomerIndustry/{archiveId}")
CustomerIndustryVO getCustomerIndustry(@PathVariable("archiveId") Integer archiveId);
/**
* 查询职位信息 保存到es中
* @param jobIdList
* @return
*/
@GetMapping("/job/getEsJobList")
List<JobDTO> getEsJobList(@RequestParam("jobIdList") List<Integer> jobIdList);
/**
* 查询客户信息 保存到es中
* @param archiveIdList archiveIdList
* @return java.util.List<com.cloud.gs.hiring.common.model.dto.CustomerEsDTO>
*/
@GetMapping("/customer/getEsCustomerList")
List<CustomerEsDTO> getEsCustomerList(@RequestParam("archiveIdList") List<Integer> archiveIdList);
/**
* 查询过滤用户列表
* @param jobId jobId
* @return java.util.List<java.lang.Integer>
*/
@GetMapping("/customer/getFilterCustomerList")
FilterCustomerVO getFilterCustomerList(@RequestParam("jobId") Integer jobId);
}
package com.gosingapore.api;
import com.gosingapore.api.factory.RemoteLogFallbackFactory;
import com.cloud.gs.hiring.base.constants.ServiceNameConstants;
import com.cloud.gs.hiring.base.util.ApiResult;
import com.cloud.gs.hiring.common.model.domain.ErpSysOperateLog;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 日志服务
*
* @author ziyi
*/
@FeignClient(contextId = "remoteLogService", value = ServiceNameConstants.OPERATE_SERVICE, fallbackFactory = RemoteLogFallbackFactory.class)
public interface RemoteLogService
{
/**
* 保存系统日志
*
* @param sysOperateLog 日志实体
* @return 结果
*/
@PostMapping("/log/saveOperateLog")
ApiResult<?> saveLog(@RequestBody ErpSysOperateLog sysOperateLog);
}
package com.gosingapore.api;
import com.gosingapore.api.factory.RemoteMessageFallbackFactory;
import com.cloud.gs.hiring.base.constants.ServiceNameConstants;
import com.cloud.gs.hiring.base.util.ApiResult;
import com.cloud.gs.hiring.common.model.domain.message.ErpMessage;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author ziyi
*/
@FeignClient(contextId = "remoteMessageService", value = ServiceNameConstants.ADVISER_SERVICE, fallbackFactory = RemoteMessageFallbackFactory.class)
public interface RemoteMessageService
{
/**
* 保存 消息以及状态
*
* @param message 消息实体
* @return 结果
*/
@PostMapping("/message/saveMessageAndMark")
ApiResult<?> saveMessageAndMark(@RequestBody ErpMessage message);
}
package com.gosingapore.api;
import com.gosingapore.api.factory.RemoteResourceFallbackFactory;
import com.cloud.gs.hiring.base.constants.ServiceNameConstants;
import com.cloud.gs.hiring.common.model.domain.ErpSysDict;
import com.cloud.gs.hiring.common.model.dto.ErpHometownDTO;
import com.cloud.gs.hiring.common.model.dto.ErpIndustryDTO;
import com.cloud.gs.hiring.common.model.dto.ErpRegionDTO;
import com.cloud.gs.hiring.common.model.dto.ErpSubwayDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
import java.util.Map;
/**
* @author copying
* @version 3.0
* @date 2021/3/18 8:28
*/
@FeignClient(contextId = "remoteResourceService",value = ServiceNameConstants.OPERATE_SERVICE,fallbackFactory = RemoteResourceFallbackFactory.class)
public interface RemoteResourceService {
/**
* 获取字典列表
* @param codeType 指定字典的类型
* @return 字典列表
*/
@GetMapping("/cache/data/getDict")
Map<Integer, List<ErpSysDict>> selectSysDict(Integer codeType);
/**
* 获取地铁列表
* @return 地铁列表
*/
@GetMapping("/cache/data/getSubway")
List<ErpSubwayDTO> selectSubway();
/**
* 获取 中国籍贯
* @return 中国籍贯
*/
@GetMapping("/cache/data/getRegion")
List<ErpRegionDTO> selectRegion();
/**
* 获取 马来家乡
* @return 马来家乡
*/
@GetMapping("/cache/data/getHometown")
List<ErpHometownDTO> selectHometown();
/**
* 获取 职位类别
* @return 职位类别
*/
@GetMapping("/cache/data/getIndustry")
List<ErpIndustryDTO> selectIndustry();
}
package com.gosingapore.api;
import com.gosingapore.api.factory.RemoteTokenFallbackFactory;
import com.cloud.gs.hiring.base.constants.ServiceNameConstants;
import com.cloud.gs.hiring.base.util.ApiResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 用户服务
*
* @author ziyi
*/
@FeignClient(contextId = "remoteTokenService", value = ServiceNameConstants.AUTH_SERVICE, fallbackFactory = RemoteTokenFallbackFactory.class)
public interface RemoteTokensService
{
/**
* 获取token
*
* @param username 用户登录账号(手机号mobile)
* @return 结果
*/
@GetMapping(value = "/token")
ApiResult<OAuth2AccessToken> getToken(@RequestParam String username);
/**
* 删除token
*
* @param token 登陆人token
* @return 结果
*/
@GetMapping(value = "/token/{token}")
ApiResult<?> removeAccessToken(@PathVariable("token") String token);
/**
* 根据用户名,删除erp用户的token
* @param username 用户名手机
*/
@PostMapping(value = "/token/remove/{username}")
void removeErpAccessToken(@PathVariable String username);
}
package com.gosingapore.api;
import com.gosingapore.api.factory.RemoteUserFallbackFactory;
import com.cloud.gs.hiring.base.constants.ServiceNameConstants;
import com.cloud.gs.hiring.base.util.ApiResult;
import com.cloud.gs.hiring.common.model.domain.ErpSysUser;
import com.cloud.gs.hiring.common.model.domain.ErpUserStorageCapacity;
import com.cloud.gs.hiring.common.model.dto.ErpLoginUser;
import com.cloud.gs.hiring.common.model.dto.ErpSysDepartmentTree;
import com.cloud.gs.hiring.common.model.dto.PageDto;
import com.cloud.gs.hiring.common.model.dto.UserBaseInfoDTO;
import com.cloud.gs.hiring.common.model.query.team.TeamUserQuery;
import com.cloud.gs.hiring.common.model.vo.LibUserInfoVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 用户服务
*
* @author ziyi
*/
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.OPERATE_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
/**
* 通过手机号查询用户信息
*
* @param mobile 手机号
* @return 结果
*/
@GetMapping(value = "/user/info/{mobile}")
ErpLoginUser selectUserByMobile(@PathVariable( value = "mobile") String mobile);
/**
* 根据用户id与角色id获取库容
*
* @param userId 用户id
* @return 结果
*/
@GetMapping(value = "/user/getStorageCapacityByUserId")
ErpUserStorageCapacity getStorageCapacityByUserId(@RequestParam("userId") Integer userId);
/**
* 查询用户实体信息
* @param userId 用户id
* @return 用户信息
*/
@GetMapping(value = "/user/entityInfo/{userId}")
ErpSysUser selectUserInfo(@PathVariable(value = "userId") Integer userId);
/**
* 获取当前登录人部门下的所有用户
* @param departmentId 部门id
* @return 用户列表
*/
@GetMapping(value = "/user/getDepartmentUsers/{departmentId}")
List<ErpSysUser> getDepartmentUsers(@PathVariable(value = "departmentId") Integer departmentId);
/**
* 获取部门下的子部门列表 (可附带 组员)
* @param departmentId 部门id
* @param getUserFlag true 获取用户信息,false 不获取用户信息
* @return 部门列表
*/
@GetMapping("/user/getDepartmentList/{departmentId}/{getUserFlag}")
List<ErpSysDepartmentTree> getDepartmentList(@PathVariable(value = "departmentId") Integer departmentId,@PathVariable(value = "getUserFlag")Boolean getUserFlag);
/**
* 修改用户密码
* @param dto 用户id,用户账号,用户密码
* @return 结果
*/
@PostMapping("/user/editPassword")
ApiResult<?> editPassword(@RequestBody UserBaseInfoDTO dto);
/**
* selectLibUserInfoList 组员库获取 组员信息
* @param query query
* @return com.cloud.gs.hiring.base.util.ApiResult<com.cloud.gs.hiring.common.model.dto.PageDto<com.cloud.gs.hiring.common.model.dto.LibUserInfo>>
*/
@PostMapping("/user/teamUserInfoList")
PageDto<LibUserInfoVO> selectTeamUserInfoList(@RequestBody TeamUserQuery query);
/**
* updateStorageCapacity 修改用户库容信息
* @param capacity capacity
* @return com.cloud.gs.hiring.base.util.ApiResult<?>
*/
@PostMapping("/user/updateCapacity")
ApiResult<?> updateStorageCapacity(@RequestBody ErpUserStorageCapacity capacity);
}
package com.gosingapore.api.factory;
import com.gosingapore.api.RemoteCustomerService;
import com.cloud.gs.hiring.common.model.dto.CustomerEsDTO;
import com.cloud.gs.hiring.common.model.dto.JobDTO;
import com.cloud.gs.hiring.common.model.vo.CustomerIndustryVO;
import com.cloud.gs.hiring.common.model.vo.FilterCustomerVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 日志服务降级处理
*
* @author ziyi
*/
@Component
@Slf4j
public class RemoteCustomerFallbackFactory implements FallbackFactory<RemoteCustomerService>
{
@Override
public RemoteCustomerService create(Throwable throwable)
{
log.error("客户服务调用失败:{}", throwable.getMessage());
return new RemoteCustomerService()
{
/**
* 查询客户期望职位
*
* @param archiveId
* @return
*/
@Override
public CustomerIndustryVO getCustomerIndustry(Integer archiveId) {
return null;
}
/**
* 查询职位信息 保存到es中
*
* @param jobIdList
* @return
*/
@Override
public List<JobDTO> getEsJobList(List<Integer> jobIdList) {
return null;
}
/**
* 查询客户信息 保存到es中
*
* @param archiveIdList archiveIdList
* @return java.util.List<com.cloud.gs.hiring.common.model.dto.CustomerEsDTO>
*/
@Override
public List<CustomerEsDTO> getEsCustomerList(List<Integer> archiveIdList) {
return null;
}
@Override
public FilterCustomerVO getFilterCustomerList(Integer jobId) {
return null;
}
};
}
}
package com.gosingapore.api.factory;
import com.gosingapore.api.RemoteLogService;
import com.cloud.gs.hiring.base.util.ApiResult;
import com.cloud.gs.hiring.common.model.domain.ErpSysOperateLog;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 日志服务降级处理
*
* @author ziyi
*/
@Component
@Slf4j
public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogService>
{
@Override
public RemoteLogService create(Throwable throwable)
{
log.error("日志服务调用失败:{}", throwable.getMessage());
return new RemoteLogService()
{
@Override
public ApiResult<?> saveLog(ErpSysOperateLog sysOperateLog)
{
return null;
}
};
}
}
package com.gosingapore.api.factory;
import com.gosingapore.api.RemoteMessageService;
import com.cloud.gs.hiring.base.util.ApiResult;
import com.cloud.gs.hiring.common.model.domain.ErpSysOperateLog;
import com.cloud.gs.hiring.common.model.domain.message.ErpMessage;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 日志服务降级处理
*
* @author ziyi
*/
@Component
@Slf4j
public class RemoteMessageFallbackFactory implements FallbackFactory<RemoteMessageService>
{
@Override
public RemoteMessageService create(Throwable throwable) {
log.error("消息服务调用失败:{}", throwable.getMessage());
return new RemoteMessageService() {
@Override
public ApiResult<?> saveMessageAndMark(ErpMessage message) {
return null;
}
};
}
}
package com.gosingapore.api.factory;
import com.gosingapore.api.RemoteResourceService;
import com.cloud.gs.hiring.common.model.domain.ErpSysDict;
import com.cloud.gs.hiring.common.model.dto.ErpHometownDTO;
import com.cloud.gs.hiring.common.model.dto.ErpIndustryDTO;
import com.cloud.gs.hiring.common.model.dto.ErpRegionDTO;
import com.cloud.gs.hiring.common.model.dto.ErpSubwayDTO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* 资源服务降级处理
*
* @author copying
* @version 3.0
* @date 2021/3/18 8:29
*/
@Component
@Slf4j
public class RemoteResourceFallbackFactory implements FallbackFactory<RemoteResourceService> {
@Override
public RemoteResourceService create(Throwable throwable) {
log.error("资源服务调用失败:{}", throwable.getMessage());
return new RemoteResourceService() {
@Override
public Map<Integer, List<ErpSysDict>> selectSysDict(Integer codeType) {
return null;
}
@Override
public List<ErpSubwayDTO> selectSubway() {
return null;
}
@Override
public List<ErpRegionDTO> selectRegion() {
return null;
}
@Override
public List<ErpHometownDTO> selectHometown() {
return null;
}
@Override
public List<ErpIndustryDTO> selectIndustry() {
return null;
}
};
}
}
package com.gosingapore.api.factory;
import com.gosingapore.api.RemoteTokensService;
import com.cloud.gs.hiring.base.util.ApiResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.stereotype.Component;
/**
* 用户服务降级处理
*
* @author lsl
*/
@Component
@Slf4j
public class RemoteTokenFallbackFactory implements FallbackFactory<RemoteTokensService>
{
@Override
public RemoteTokensService create(Throwable throwable)
{
log.error("服务调用失败:{}", throwable.getMessage());
return new RemoteTokensService(){
@Override
public ApiResult<OAuth2AccessToken> getToken(String username) {
return null;
}
@Override
public ApiResult<?> removeAccessToken(String token) {
return null;
}
@Override
public void removeErpAccessToken(String username) {
}
};
}
}
package com.gosingapore.api.factory;
import com.gosingapore.api.RemoteUserService;
import com.cloud.gs.hiring.base.util.ApiResult;
import com.cloud.gs.hiring.common.model.domain.ErpSysUser;
import com.cloud.gs.hiring.common.model.domain.ErpUserStorageCapacity;
import com.cloud.gs.hiring.common.model.dto.ErpLoginUser;
import com.cloud.gs.hiring.common.model.dto.ErpSysDepartmentTree;
import com.cloud.gs.hiring.common.model.dto.PageDto;
import com.cloud.gs.hiring.common.model.dto.UserBaseInfoDTO;
import com.cloud.gs.hiring.common.model.query.team.TeamUserQuery;
import com.cloud.gs.hiring.common.model.vo.LibUserInfoVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.validation.Valid;
import java.util.List;
/**
* 用户服务降级处理
*
* @author lsl
*/
@Component
@Slf4j
public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserService>
{
@Override
public RemoteUserService create(Throwable throwable)
{
log.error("服务调用失败:{}", throwable.getMessage());
return new RemoteUserService(){
@Override
public ErpLoginUser selectUserByMobile(String mobile) {
return null;
}
@Override
public ErpUserStorageCapacity getStorageCapacityByUserId(Integer userId) {
return null;
}
@Override
public ErpSysUser selectUserInfo(Integer userId) {
return null;
}
@Override
public List<ErpSysUser> getDepartmentUsers(Integer departmentId) {
return null;
}
@Override
public List<ErpSysDepartmentTree> getDepartmentList(Integer departmentId, Boolean getUserFlag) {
return null;
}
@Override
public ApiResult<?> editPassword(@Valid UserBaseInfoDTO dto) {
return null;
}
@Override
public PageDto<LibUserInfoVO> selectTeamUserInfoList(TeamUserQuery query) {
return null;
}
@Override
public ApiResult<?> updateStorageCapacity(ErpUserStorageCapacity capacity) {
return null;
}
};
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.gosingapore.api.factory.RemoteUserFallbackFactory,\
com.gosingapore.api.factory.RemoteTokenFallbackFactory,\
com.gosingapore.api.factory.RemoteLogFallbackFactory,\
com.gosingapore.api.factory.RemoteResourceFallbackFactory,\
com.gosingapore.api.factory.RemoteMessageFallbackFactory,\
com.gosingapore.api.factory.RemoteCustomerFallbackFactory
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.gosingapore</groupId>
<artifactId>auth</artifactId>
<version>1.0</version>
<name>auth</name>
<description>auth模块</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.gosingapore.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AuthApplication {
public static void main(String[] args) {
SpringApplication.run(AuthApplication.class, args);
}
}
package com.gosingapore.auth;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class AuthApplicationTests {
@Test
void contextLoads() {
}
}
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gosingapore</groupId>
<artifactId>gs-hiring</artifactId>
<version>1.0</version>
</parent>
<artifactId>common</artifactId>
<name>common</name>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.ibeetl/beetl-framework-starter -->
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetl-framework-starter</artifactId>
<version>1.2.28.RELEASE</version>
</dependency>
</dependencies>
</project>
package com.gosingapore.common.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 接口幂等性注解 再需要的controller上添加
* @author lsl
* @date 2021-04-29 14:54
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ApiIdempotent {
}
package com.gosingapore.common.aop;
import com.cloud.gs.hiring.base.util.ResponseCode;
import com.gosingapore.common.constants.CommonConstants;
import com.gosingapore.common.exception.CustomizeException;
import lombok.extern.slf4j.Slf4j;
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.data.redis.core.RedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* 切面
* @author lsl
* @date 2021/4/29 14:57
*/
@Aspect
@Component
@Slf4j
public class IdempotentApiAspect {
@Resource
private HttpServletRequest request;
@Resource
private RedisTemplate<String, String> redisTemplate;
@Pointcut("@annotation(com.cloud.gs.hiring.common.annotation.ApiIdempotent)")
private void pointCut(){}
@Around("pointCut()")
public Object handlerServiceMethod(ProceedingJoinPoint jp) throws Throwable {
String token = request.getHeader(CommonConstants.TOKEN);
if(StringUtils.isEmpty(token)){
throw new CustomizeException(ResponseCode.COMMON_MISS_PARAMETER,"缺少token请求头","Missed Idempotent header");
}
boolean hasKey = redisTemplate.hasKey(CommonConstants.IDEMPOTENT_API_KEY + token);
if(!hasKey){
throw new CustomizeException(ResponseCode.COMMON_NOT_ALLOW_REPEAT);
}
boolean flag = redisTemplate.delete(CommonConstants.IDEMPOTENT_API_KEY + token);
if(!flag){
throw new CustomizeException(ResponseCode.COMMON_NOT_ALLOW_REPEAT);
}
return jp.proceed();
}
}
package com.gosingapore.common.config;
import com.gosingapore.common.properties.BasicSecurityProperties;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import javax.annotation.Resource;
/**
* @author shuyan
*/
/*@Configuration*/
@Order(1)
public class BasicSecurityConfig extends WebSecurityConfigurerAdapter {
@Resource
private BasicSecurityProperties basicSecurityProperties;
@Override
protected void configure(HttpSecurity http) throws Exception {
HttpSecurity.RequestMatcherConfigurer requestMatchers = http.requestMatchers();
basicSecurityProperties.getPath().forEach(requestMatchers::antMatchers);
http
.authorizeRequests()
.anyRequest().authenticated()
.and().cors()
.and().httpBasic();
}
private UserDetailsService inMemoryUserDetailsService() {
PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
UserDetails user = User
.withUsername(basicSecurityProperties.getUsername())
.password(encoder.encode(basicSecurityProperties.getPassword()))
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
@Override
protected void configure(AuthenticationManagerBuilder auth) {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(inMemoryUserDetailsService());
auth.authenticationProvider(provider);
}
}
package com.gosingapore.common.config;
import com.gosingapore.common.properties.BeetlProperties;
import org.apache.commons.lang.StringUtils;
import org.beetl.core.resource.StringTemplateResourceLoader;
import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Properties;
/**
* @author: QiWenXiao
*/
@Configuration
public class BeetlConf {
@Autowired
BeetlProperties beetlProperties;
@Bean
public BeetlGroupUtilConfiguration beetlConfig() {
BeetlGroupUtilConfiguration beetlConf = new BeetlGroupUtilConfiguration();
beetlConf.setConfigProperties(getProperties());
// 必须调用此方法
beetlConf.init();
beetlConf.getGroupTemplate().setResourceLoader(new StringTemplateResourceLoader());
return beetlConf;
}
private Properties getProperties() {
Properties properties = new Properties();
String delimiterPlaceholderStart = beetlProperties.getDelimiterPlaceholderStart();
if (StringUtils.isNotBlank(delimiterPlaceholderStart)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_PLACEHOLDER_START, delimiterPlaceholderStart);
}
String delimiterPlaceholderEnd = beetlProperties.getDelimiterPlaceholderEnd();
if (StringUtils.isNotBlank(delimiterPlaceholderEnd)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_PLACEHOLDER_END, delimiterPlaceholderEnd);
}
String delimiterStatementStart = beetlProperties.getDelimiterStatementStart();
if (StringUtils.isNotBlank(delimiterStatementStart)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_STATEMENT_START, delimiterStatementStart);
}
String delimiterStatementEnd = beetlProperties.getDelimiterStatementEnd();
if (StringUtils.isNotBlank(delimiterStatementEnd)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_STATEMENT_END, delimiterStatementEnd);
}
String delimiterPlaceholderStart2 = beetlProperties.getDelimiterPlaceholderStart2();
if (StringUtils.isNotBlank(delimiterPlaceholderStart2)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_PLACEHOLDER_START2, delimiterPlaceholderStart2);
}
String delimiterPlaceholderEnd2 = beetlProperties.getDelimiterPlaceholderEnd2();
if (StringUtils.isNotBlank(delimiterPlaceholderEnd2)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_PLACEHOLDER_END2, delimiterPlaceholderEnd2);
}
String delimiterStatementStart2 = beetlProperties.getDelimiterStatementStart2();
if (StringUtils.isNotBlank(delimiterStatementStart2)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_STATEMENT_START2, delimiterStatementStart2);
}
String delimiterStatementEnd2 = beetlProperties.getDelimiterStatementEnd2();
if (StringUtils.isNotBlank(delimiterStatementEnd2)) {
properties.setProperty(org.beetl.core.Configuration.DELIMITER_STATEMENT_END2, delimiterStatementEnd2);
}
return properties;
}
}
package com.gosingapore.common.config;
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
import com.gosingapore.common.processor.HiringStatViewServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
/**
* @author shuyan
* @date 2020/8/5 9:34
*/
@Configuration
public class DruidStatViewServletConfiguration {
private static final String DEFAULT_ALLOW_IP = "127.0.0.1";
@Resource
private HiringStatViewServlet hiringStatViewServlet;
@Bean
public ServletRegistrationBean statViewServletRegistrationBean(DruidStatProperties properties) {
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
ServletRegistrationBean<HiringStatViewServlet> registrationBean = new ServletRegistrationBean<>();
registrationBean.setServlet(hiringStatViewServlet);
registrationBean.addUrlMappings(config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*");
if (config.getAllow() != null) {
registrationBean.addInitParameter("allow", config.getAllow());
} else {
registrationBean.addInitParameter("allow", DEFAULT_ALLOW_IP);
}
if (config.getDeny() != null) {
registrationBean.addInitParameter("deny", config.getDeny());
}
if (config.getLoginUsername() != null) {
registrationBean.addInitParameter("loginUsername", config.getLoginUsername());
}
if (config.getLoginPassword() != null) {
registrationBean.addInitParameter("loginPassword", config.getLoginPassword());
}
if (config.getResetEnable() != null) {
registrationBean.addInitParameter("resetEnable", config.getResetEnable());
}
return registrationBean;
}
}
package com.gosingapore.common.config;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
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;
/**
* 服务间调用权限问题
*
* @author lsl
* @date 2021-03-18 11:52
*/
@Configuration
@Slf4j
public class FeignConfiguration implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
.getRequestAttributes();
if(attributes == null){
return;
}
HttpServletRequest request = attributes.getRequest();
String authorization = request.getHeader("Authorization");
requestTemplate.header("Authorization", authorization);
}
}
package com.gosingapore.common.config;
import org.springframework.cloud.openfeign.FeignFormatterRegistrar;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import java.time.Instant;
/**
* feign 在将接口转换为http协议时默认不支持 instant 类型,自己加上转换器
* @author shuyan
*/
@Component
public class FeignFormatterRegister implements FeignFormatterRegistrar {
@Override
public void registerFormatters(@NonNull FormatterRegistry registry) {
registry.addConverter(Instant.class, String.class, new Instant2StringConverter());
}
private static class Instant2StringConverter implements Converter<Instant,String> {
@Override
public String convert(@NonNull Instant source) {
return source.toString();
}
}
}
package com.gosingapore.common.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author shuyan
*/
@Configuration
@MapperScan({"com.cloud.gs.hiring.**.mapper"})
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
package com.gosingapore.common.config;
import com.gosingapore.common.processor.AuthExceptionEntryPoint;
import com.gosingapore.common.processor.CustomAccessDeniedHandler;
import com.gosingapore.common.processor.CustomizeAuthenticationKeyGenerator;
import com.gosingapore.common.properties.IgnoreUrlProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationManager;
import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import javax.annotation.Resource;
/**
* @author C.K
* @date 2018/10/10 09:19
*/
@Configuration
@EnableResourceServer
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class Oauth2ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Resource
private IgnoreUrlProperties ignoreUrlProperties;
@Resource
private RedisConnectionFactory redisConnectionFactory;
@Bean
public RedisTokenStore redisTokenStore(){
RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory);
redisTokenStore.setAuthenticationKeyGenerator(new CustomizeAuthenticationKeyGenerator());
return redisTokenStore;
}
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder();
}
@Override
public void configure(HttpSecurity http) throws Exception {
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config = http.authorizeRequests();
ignoreUrlProperties.getUrls().forEach(e -> config.antMatchers(e).permitAll());
// 前后分离 先发出options 放行
config.anyRequest().authenticated()
.and().csrf().disable();
}
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
resources.authenticationManager(oauthAuthenticationManager())
.accessDeniedHandler(new CustomAccessDeniedHandler())
.authenticationEntryPoint(new AuthExceptionEntryPoint());
}
@Bean
public AuthenticationManager oauthAuthenticationManager() {
OAuth2AuthenticationManager oauthAuthenticationManager = new OAuth2AuthenticationManager();
String resourceId = "oauth2-resource";
oauthAuthenticationManager.setResourceId(resourceId);
oauthAuthenticationManager.setTokenServices(resourceTokenServices());
return oauthAuthenticationManager;
}
private ResourceServerTokenServices resourceTokenServices() {
DefaultTokenServices tokenServices = new DefaultTokenServices();
tokenServices.setTokenStore(redisTokenStore());
tokenServices.setSupportRefreshToken(true);
return tokenServices;
}
}
package com.gosingapore.common.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.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
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.StringRedisSerializer;
import java.time.Duration;
/**
* @author shuyan
*/
@EnableCaching
@Configuration
@AutoConfigureAfter(RedisAutoConfiguration.class)
public class RedisConfig {
/**
* 配置自定义redisTemplate
*
* @param connectionFactory redis 连接工厂
* @return redisTemplate
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
template.setValueSerializer(jackson2JsonRedisSerializer());
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jackson2JsonRedisSerializer());
return template;
}
/**
* json序列化
* @return 系列化器
*/
private Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer() {
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,ObjectMapper.DefaultTyping.NON_FINAL);
serializer.setObjectMapper(mapper);
return serializer;
}
/**
* 配置缓存管理器
* @param redisConnectionFactory redis 连接工厂类
* @return 缓存管理器
*/
@Bean
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
// 生成一个默认配置,通过config对象即可对缓存进行自定义配置
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
// 设置缓存的默认过期时间,也是使用Duration设置
config = config.entryTtl(Duration.ofDays(1))
// 设置 key为string序列化
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()))
// 设置value为json序列化
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer()))
// 不缓存空值
.disableCachingNullValues();
// 使用自定义的缓存配置初始化一个cacheManager
return RedisCacheManager.builder(redisConnectionFactory).cacheDefaults(config).transactionAware()
// 一定要先调用该方法设置初始化的缓存名,再初始化相关的配置
.build();
}
}
package com.gosingapore.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
/**
* redis监听器
* @author lsl
* @date 2021-03-26 16:18
*/
@Configuration
public class RedisListenerConfig {
@Bean
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
return container;
}
}
package com.gosingapore.common.config;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.lang.NonNull;
import javax.annotation.Resource;
/**
* @author shuyan
*/
@Configuration
public class SpringContextListener implements ApplicationListener<ContextRefreshedEvent> {
@Resource
private RabbitTemplate rabbitTemplate;
@Override
public void onApplicationEvent(@NonNull ContextRefreshedEvent contextRefreshedEvent) {
}
}
package com.gosingapore.common.config;
import com.gosingapore.common.properties.IgnoreUrlProperties;
import com.google.common.base.Predicates;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* @author C.K
* @date 2018/11/13 10:39
*/
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Resource
private IgnoreUrlProperties ignoreUrlProperties;
@Bean
public Docket createRestApi() {
ParameterBuilder languageParam = new ParameterBuilder();
List<Parameter> parameters = new ArrayList<>();
languageParam.name("Accept-Language")
.defaultValue("zh")
.description("选择语言:zh:中文、en:英文")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(false)
.build();
parameters.add(languageParam.build());
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build()
.globalOperationParameters(parameters)
.securitySchemes(Collections.singletonList(securityScheme()))
.securityContexts(Collections.singletonList(securityContext()));
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("ERP Service API")
.description("ERP Service 接口文档说明")
.contact(new Contact("hiring", "", ""))
.version("3.0")
.build();
}
private SecurityScheme securityScheme() {
GrantType grantType = new ResourceOwnerPasswordCredentialsGrant("/hiring-auth/oauth/token");
return new OAuthBuilder()
.name("spring_oauth")
.grantTypes(Collections.singletonList(grantType))
.scopes(Arrays.asList(scopes()))
.build();
}
@SuppressWarnings("all")
private SecurityContext securityContext() {
return SecurityContext.builder()
.securityReferences(Collections.singletonList(new SecurityReference("spring_oauth", scopes())))
.forPaths(Predicates.not(Predicates.in(ignoreUrlProperties.getUrls())))
.build();
}
private AuthorizationScope[] scopes() {
return new AuthorizationScope[]{
new AuthorizationScope("all", "All scope is trusted!")
};
}
}
package com.gosingapore.common.config;
import com.gosingapore.common.processor.MyResourceBundleMessageInterpolator;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
/**
* 自定义参数校验器
* @author shuyan
*/
@Configuration
public class ValidationConfig {
@Bean
public Validator validator(){
ValidatorFactory validatorFactory = Validation.byProvider( HibernateValidator.class )
.configure()
// 校验到1个未通过的参数就返回
.failFast(true)
// 使用自定义的资源绑定器,来根据语言返回信息
.messageInterpolator(new MyResourceBundleMessageInterpolator())
.buildValidatorFactory();
return validatorFactory.getValidator();
}
}
package com.gosingapore.common.config;
import com.gosingapore.common.processor.CustomizeArgumentResolverHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
/**
* @author shuyan
*/
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
/**
* 增加参数解析器
* 用于解决不使用注解直接接收某类型参数报没有无参构造方法的问题
* @param resolvers 已有解析器列表
*/
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new CustomizeArgumentResolverHandler.InstantArgumentResolverHandler());
}
}
package com.gosingapore.common.config.rabbitmq;
import com.rabbitmq.client.Channel;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 用于缓存消费端消费失败时的Channel对象, 以便于 进行手动ACK,NACK处理、
*
* @author lsl
* @date 2021-04-08 10:07
**/
public enum ChannelCache {
/**
* 单例对象
*/
INSTANCE;
private static final Map<String, Channel> CHANNEL_MAP = new ConcurrentHashMap<>();
public static final String MESSAGE_CORRELATION_ID = "spring_returned_message_correlation";
public static final String LISTENER_CORRELATION_ID = "spring_listener_return_correlation";
public Channel get(String id) {
return CHANNEL_MAP.get(id);
}
public void putIfAbsent(String id, Channel channel) {
CHANNEL_MAP.putIfAbsent(id, channel);
}
public void remove(String id) {
CHANNEL_MAP.remove(id);
}
public void put(String id, Channel channel) {
CHANNEL_MAP.put(id, channel);
}
}
package com.gosingapore.common.config.rabbitmq;
import com.gosingapore.common.constants.RabbitMqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 该类初始化创建队列、交换机,并把队列绑定到交换机
* 可以定义多个Queue, Exchange
*
* @author lsl
*/
@Configuration
public class RabbitQueueAndExchangeConfig {
@Bean
public Queue directQueue() {
return new Queue(RabbitMqConstants.ERP_MESSAGE_QUEUE, true);
}
@Bean
public Queue elasticsearchQueue() {
return new Queue(RabbitMqConstants.ERP_ES_JOB_QUEUE, true);
}
@Bean
public Queue elasticsearchCustomerQueue() {
return new Queue(RabbitMqConstants.ERP_ES_CUSTOMER_QUEUE, true);
}
/**
* exchange是交换机交换机的主要作用是接收相应的消息并且绑定到指定的队列.交换机有四种类型,分别为Direct,topic,headers,Fanout.
* <p>
*   Direct是RabbitMQ默认的交换机模式,也是最简单的模式.即创建消息队列的时候,指定一个BindingKey.当发送者发送消息的时候,指定对应的Key.当Key和消息队列的BindingKey一致的时候,消息将会被发送到该消息队列中.
* <p>
*   topic转发信息主要是依据通配符,队列和交换机的绑定主要是依据一种模式(通配符+字符串),而当发送消息的时候,只有指定的Key和该模式相匹配的时候,消息才会被发送到该消息队列中.
* <p>
*   headers也是根据一个规则进行匹配,在消息队列和交换机绑定的时候会指定一组键值对规则,而发送消息的时候也会指定一组键值对规则,当两组键值对规则相匹配的时候,消息会被发送到匹配的消息队列中.
* <p>
*   Fanout是路由广播的形式,将会把消息发给绑定它的全部队列,即便设置了key,也会被忽略.
*/
@Bean
DirectExchange directExchange() {
return new DirectExchange(RabbitMqConstants.ERP_MESSAGE_EXCHANGE, true, false);
}
@Bean
DirectExchange elasticsearchExchange() {
return new DirectExchange(RabbitMqConstants.ERP_ES_JOB_EXCHANGE, true, false);
}
@Bean
DirectExchange elasticsearchCustomerExchange() {
return new DirectExchange(RabbitMqConstants.ERP_ES_CUSTOMER_EXCHANGE, true, false);
}
/**
* 绑定 Queue 和 Exchange
*
* @param directQueue queue
* @param directExchange exchange
* @return
*/
@Bean
Binding bindingDirectExchange(Queue directQueue, DirectExchange directExchange) {
return BindingBuilder.bind(directQueue).to(directExchange).with(RabbitMqConstants.ERP_MESSAGE_ROUTING_KEY);
}
@Bean
Binding bindingElasticsearchExchange(Queue elasticsearchQueue, DirectExchange elasticsearchExchange) {
return BindingBuilder.bind(elasticsearchQueue).to(elasticsearchExchange).with(RabbitMqConstants.ERP_ES_JOB_ROUTING_KEY);
}
@Bean
Binding bindingElasticsearchCustomerExchange(Queue elasticsearchCustomerQueue, DirectExchange elasticsearchCustomerExchange) {
return BindingBuilder.bind(elasticsearchCustomerQueue).to(elasticsearchCustomerExchange).with(RabbitMqConstants.ERP_ES_CUSTOMER_ROUTING_KEY);
}
}
\ No newline at end of file
package com.gosingapore.common.config.rabbitmq;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author lsl
* @date 2021-04-08 15:29
**/
@Configuration
@Slf4j
public class RabbitTemplateConfig {
private final CachingConnectionFactory connectionFactory;
@Autowired
public RabbitTemplateConfig(CachingConnectionFactory connectionFactory) {
this.connectionFactory = connectionFactory;
}
@Bean
public RabbitTemplate rabbitTemplate() {
//若使用confirm-callback或return-callback,必须要配置publisherConfirms或publisherReturns为true
// 已过时:--> connectionFactory.setPublisherConfirms(true)
connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.CORRELATED);
// 使用return-callback时必须设置mandatory为true,或者在配置中设置mandatory-expression的值为true
connectionFactory.setPublisherReturns(true);
// channelCacheSize 一定要大于等于目前的 consumer 个数
connectionFactory.setChannelCacheSize(30);
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
// 发送消息时, 设置强制标志, 仅适用于已提供ReturnCallback的情况、
rabbitTemplate.setMandatory(true);
/**
* 如果消息没有到exchange, 则confirm回调, ack=false
* 如果消息到达exchange, 则confirm回调, ack=true
* exchange到queue成功, 则不回调return。
* exchange到queue失败, 则回调return(需设置mandatory=true, 否则不回回调, 消息丢失)。
*
* 配置错误的 routingKey, 可以触发ReturnCallback()、
* rabbitTemplate.convertAndSend("directExchange", "directAAA", msgString, correlationData);
* <p>
* 配置错误的 exchange, 可以触发ConfirmCallback(),并且 ack为false!
* rabbitTemplate.convertAndSend("directExchangeBBBBB", "direct", msgString, correlationData);
*/
// 每个rabbitTemplate只能有一个confirm-callback和return-callback,如果这里配置了,那么写生产者的时候不能再写confirm-callback和return-callback
rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> {
if (ack) {
log.info("消息发送成功--> 到达exchange:correlationData({}),cause({})", correlationData, cause);
} else {
log.info("消息发送失败--> 未到达exchange:correlationData({}),cause({})", correlationData, cause);
// 日志记录, 或者存入Redis、MySQL
}
});
rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> {
log.info("消息丢失:未从exchange发送到queue:exchange({}), routingKey({}), replyCode({}), replyText({}), message:{}", exchange, routingKey, replyCode, replyText, message);
// 日志记录, 或者存入Redis、MySQL
});
return rabbitTemplate;
}
}
package com.gosingapore.common.constants;
/**
* @author ZhangJinyu
* @since 2020-09-29
*/
public class CharConstants {
public static final char SLASH = '/';
public static final char BACKSLASH = '\\';
public static final char DOT = '.';
}
package com.gosingapore.common.constants;
/**
*
* ES存储实体公共字段
* @author lsl
*/
public class CommonColumnConstants {
public static final String ID = "id";
public static final String LANG = "lang";
public static final String FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String KEYWORD = "keyword";
public static final String UUID = "uuid";
public static final String FORMAT_YEAR = "yyyy";
public static final String FORMAT_DAY = "yyyy-MM-dd";
public static final String FORMAT_MONTH = "yyyy-MM";
public static final String FIELD = "field";
public static final int PAGENO = 1;
public static final int PAGESIZE = 10;
}
package com.gosingapore.common.constants;
import java.time.Instant;
/**
* @author guocong
* @date 2020/1/10 13:07
*/
public interface CommonConstants {
/**
* 地铁站数据缓存
*/
String SUBWAYS = "subways";
/**
* 开关数据缓存
*/
String SERVICE_SWITCH = "service_switch";
/**
* 省市县(区)缓存
*/
String CH_LIST = "ch_list";
/**
* 马来家乡缓存
*/
String ML_LIST = "ml_list";
/**
* 职位类别缓存
*/
String INDUSTRY_LIST = "industry_list";
/**
* 福利待遇
*/
String WELFARE_LIST = "welfare_list";
/**
* 短信相关
*/
String REDIS_SMS_CODE_PREFIX = "gs_sms_code_";
Integer REDIS_SMS_CODE_EXPIRE = 600;
Integer SMS_RESEND_TIME = 60;
/**
* 同一中介最大负责文员数量限制
*/
Integer WY_MAX_INTERMEDIARY_COUNT = 2;
Instant INSTANT_2000 = Instant.parse("2000-01-01T00:00:00Z");
/**
* 融云消息发送人
*/
String IM_SEND_LIST = "send_list";
/**
* 融云消息接收人
*/
String IM_RECEIVE_LIST = "receive_list";
/**
* 融云请求成功参数
*/
Integer RONG_RESULT_CODE = 200;
/**
* 字典表
*/
String GS_SYS_DICT = "gs_sys_dict";
/** redis 接口幂等key前缀 */
String IDEMPOTENT_API_KEY = "IDEMPOTENT_API_";
/**
* 提现积分校验
*/
Integer EXCHANGE_INTEGRAL = 200;
/**
* 体现积分整数校验
*/
Integer CASH_OUT_INTEGRAL = 100;
/**
* 雇主首页推荐的工人的id集合
*/
String CUSTOMER_RECOMMEND_IDS = "customer_recommend_ids";
/**
* app工人端首页推荐职位的id集合
*/
String COMMISSIONER_JOB_RECOMMEND_IDS = "commissioner_job_recommend_ids";
/**
* app工人端首页推荐职位的id集合
*/
String CUSTOMER_JOB_RECOMMEND_IDS = "customer_job_recommend_ids";
/**
* token 放到请求头 用于接口幂等
*/
String TOKEN = "token";
}
package com.gosingapore.common.constants;
/**
* @author ZhangJinyu
* @since 2020-09-29
*/
public interface FileTypeConstants {
String PDF = "pdf";
String XLSX = "xlsx";
String XLS = "xls";
String DOC = "doc";
String DOCX = "docx";
String JPG = "jpg";
String JPEG = "jpeg";
String PNG = "png";
}
package com.gosingapore.common.constants;
/**
* @author fangqiguang
* @date 2020/7/15
*/
public interface FinancialConstants {
/**
* NO_CONFIRMED 未确认
* CONFIRMED 已确认
* DISMISSED 忽略
*/
Integer NO_CONFIRMED = 0;
Integer CONFIRMED = 1;
Integer DISMISSED = 2;
/**
* 财务角色Code简写,判断用,不是真的角色code
* CASHIER 出纳
* ACCOUNTANT 会计
* CAIWU 财务经理
*/
String CASHIER = "CASHIER";
String ACCOUNTANT = "ACCOUNTANT";
String CAIWU = "CAIWU";
/**
* 业务和文员接收财务消息的 跳转页面
* CUSTOMER_CHARGE_LIST 工人总收费列表页面
* CUSTOMER_CHARGE_DETAIL 工人收费明细页面
* REFUND_INTERMEDIARY 文员发起赔偿页面
*/
String CUSTOMER_CHARGE_LIST = "customer-charge-list";
String CUSTOMER_CHARGE_DETAIL = "customer-charge-detail";
String REFUND_INTERMEDIARY = "refund-intermediary";
}
package com.gosingapore.common.constants;
/**
* @author fangqiguang
* @date 2020/6/18
*/
public interface PartnerConstants {
String COMPANY_NAME = "公司";
/**
* 请人状态0 已请人
*/
Integer INVITED_STATUS = 0;
/**
* 请人状态1 未请人
*/
Integer UNINVITED_STATUS = 1;
/**
* 雇主公司认证状态2为已认证
*/
Integer ENTER_TYPE = 2;
}
package com.gosingapore.common.constants;
/**
* @author shuyan
*/
public interface RabbitMqConstants {
/**
* rabbitMq延时队列的延时时间最大为:2^32 - 1 ms
*/
Long DELAY_MAX_MS = new Double(Math.pow(2, 32)).longValue() - 1;
/**
* 交换机延时类型key
*/
String EXCHANGE_X_DELAYED_TYPE = "x-delayed-type";
/**
* 交换机类型:direct
*/
String EXCHANGE_TYPE_DIRECT = "direct";
/**
* 交换机类型:direct
*/
String EXCHANGE_TYPE_DELAY_MSG = "x-delayed-message";
/**
* 延时消息请求头,用于设置延时多少毫秒
*/
String X_DELAY_HEADER = "x-delay";
/**
* 短信队列
*/
String SMS_QUEUE = "hiring_sms_queue";
/**
* websocket 消息推送交换机
*/
String ERP_MESSAGE_EXCHANGE = "erp_message_exchange";
/**
* websocket 消息推送队列
*/
String ERP_MESSAGE_QUEUE = "erp_message_queue";
/**
* websocket 路由键
*/
String ERP_MESSAGE_ROUTING_KEY = "erp_message_routing_key";
/**
* es 职位消息推送交换机
*/
String ERP_ES_JOB_EXCHANGE = "erp_es_job_exchange";
/**
* es 职位消息推送队列
*/
String ERP_ES_JOB_QUEUE = "erp_es_job_queue";
/**
* es队列 职位路由键
*/
String ERP_ES_JOB_ROUTING_KEY = "erp_es_job_routing_key";
/**
* es 职位消息推送交换机
*/
String ERP_ES_CUSTOMER_EXCHANGE = "erp_es_customer_exchange";
/**
* es 职位消息推送队列
*/
String ERP_ES_CUSTOMER_QUEUE = "erp_es_customer_queue";
/**
* es队列 职位路由键
*/
String ERP_ES_CUSTOMER_ROUTING_KEY = "erp_es_customer_routing_key";
/**
* 任务完成消息推送
*/
String TASK_COMPLETE = "hiring_task_complete_queue";
/**
* canal同步mysql(主从模式)
*/
String EXCHANGE_CANAL_QSC_SYNC = "hiring_canal_qsc_sync";
/**
* 去狮城bin log同步
*/
String QSC_BIN_LOG = "hiring_qsc_bin_log_queue";
/**
* can qsc 的 Routing Key
*/
String CANAL_QSC_ROUTING_KEY = "hiring_canal_qsc_routing_key";
/**
* 工人姓名IM同步
*/
String CUSTOMER_NAME_IM_SYNC = "customer_name_im_sync";
}
package com.gosingapore.common.constants;
/**
* @author copying
* @version 3.0
* @date 2021/3/11 9:27
*/
public class RedisConstants {
/**
* 用于 存储 字典信息的key
*/
public static final String ERP_SYS_DICT = "erp_sys_dict";
/**
* 用于 存储 新加坡 地铁信息的key
*/
public static final String ERP_SUBWAY = "erp_subway";
/**
* 用于 存储 中国 籍贯信息的key
*/
public static final String ERP_REGION = "erp_region";
/**
* 用于 存储 马来 家乡信息的key
*/
public static final String ERP_HOMETOWN = "erp_hometown";
/**
* 用于 存储 职位类别 信息的key
*/
public static final String ERP_INDUSTRY = "erp_industry";
/**
* 用于储存 工人个人简介模板
*/
public static final String ERP_CUSTOMER_PROFILE_TEMPLATE = "erp_customer_profile_template";
/**
* 用于储存 职位描述模板
*/
public static final String ERP_JOB_REMARK_TEMPLATE = "erp_job_remark_template";
/**
* 用于储存 通用标签
*/
public static final String ERP_GEN_TAG = "erp_gen_tag";
/**
* 用于储存 面试计划
*/
public static final String INTERVIEW_PLAN = "interview_plan";
/**
* 用于储存 企业微信 token
*/
public static final String ACCESS_TOKEN = "weChat:access_token";
/**
* 用于储存 每个文员的添加中介计数
*/
public static final String ERP_AGENCY_WY_CODE = "erp_agency_wy_code";
/**
* 用于储存敏感词信息
*/
public static final String ERP_SENSITIVE_WORDS = "erp_sensitive_words";
}
package com.gosingapore.common.constants;
/**
* @author shuyan
*/
public interface RegExpConstants {
/**
* 校验手机号必须为纯数字且长度在6-11位之间
*/
String MOBILE_FORMAT = "^[0-9]{7,11}$";
/**
* 校验CPF 长度仅为9或10位且同时包含数字和字母
*/
String CPF_FORMAT = "^(?=.*\\d)(?=.*[A-Za-z])(\\w{9,10})$";
/**
* 校验视频链接,必须以视频格式后缀结尾,扩展以已有格式增加
*/
String VIDEO = "^https?:\\/\\/.*?(?:swf|avi|flv|mpg|rm|mov|wav|asf|3gp|mkv|rmvb|mp4)$";
/**
* 校验图片格式,同上
*/
String PICTURE = "^https?:\\/\\/.*?(?:gif|png|jpg|jpeg|webp|svg|psd|bmp|tif)$";
/**
* 中国手机号
* 要求: +86 1开头11位
*/
String CHINA_MOBILE = "^1\\d{10}";
/**
* 新加坡手机号
* 要求: +65 8或9或6 开头 8位
*/
String SINGAPORE_MOBILE = "^[8,9,6]\\d{7}";
/**
* 新加坡手机号和固定电话混合
* 要求: 固定电话 6开头8位
*/
String SINGAPORE_FIXED_TELEPHONE = "^[6,8,9]\\d{7}";
/**
* 马来西亚手机号
* 要求: +60 不校验开头数字,手机号位数为9-11位;
*/
String MALAYSIA_MOBILE = "\\d{9,11}";
/**
* 越南手机号
* 要求: +84 不校验开头数字,手机号位数为9位;
*/
String VIETNAM_MOBILE = "\\d{9}";
/**
* 印度手机号
* 要求: +91 不校验开头数字,手机号位数为8位;
*/
String INDIA_MOBILE = "\\d{8}";
/**
* 其它国家的手机号
* 要求:其他区号只校验是数字即可
*/
String OTHER_COUNTRY_MOBILE = "\\d+";
/**
* ipv4
*/
String IPV4 = "^(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$";
/**
* URL合法性校验
*/
String URL = "^([hH][tT]{2}[pP]:/*|[hH][tT]{2}[pP][sS]:/*|[fF][tT][pP]:/*)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~/])+(\\??(([A-Za-z0-9-~]+=?)([A-Za-z0-9-~]*)&?)*)$";
/**
* Windows下文件名中的无效字符
*/
String FILE_NAME_INVALID_PATTERN_WIN = "[\\\\/:*?\"<>|]";
/**
* 日期
*/
String DATE_CH = "((19|20)[0-9]{2})-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])";
/**
* 文件格式xls
*/
String XLS_FILE_NAME = "^.+\\.(?i)(xls)$";
/**
* 文件格式xlsx
*/
String XLSX_FILE_NAME = "^.+\\.(?i)(xlsx)$";
}
package com.gosingapore.common.constants;
import java.util.regex.Pattern;
/**
* Regex 的 Pattern常量
* 为什么用常量: 在使用正则表达式时,利用好其预编译功能,可以有效加快正则匹配速度。
* 说明:不要在方法体内定义:Pattern pattern = Pattern.compile(规则);
*
* @author ZhangJinyu
* @since 2020-09-16
*/
public class RegexPatternConstants {
/**
* IPV4地址
*/
public static final Pattern PATTERN_IPV4 = Pattern.compile(RegExpConstants.IPV4);
/**
* 中国手机号
*/
public static final Pattern PATTERN_CHINA_MOBILE = Pattern.compile(RegExpConstants.CHINA_MOBILE);
/**
* 新加坡手机号
*/
public static final Pattern PATTERN_SINGAPORE_MOBILE = Pattern.compile(RegExpConstants.SINGAPORE_MOBILE);
/**
* 新加坡固定电话
*/
public static final Pattern PATTERN_SINGAPORE_FIXED_TELEPHONE = Pattern.compile(RegExpConstants.SINGAPORE_FIXED_TELEPHONE);
/**
* 马来西亚手机号
*/
public static final Pattern PATTERN_MALAYSIA_MOBILE = Pattern.compile(RegExpConstants.MALAYSIA_MOBILE);
/**
* 越南手机号
*/
public static final Pattern PATTERN_VIETNAM_MOBILE = Pattern.compile(RegExpConstants.VIETNAM_MOBILE);
/**
* 印度手机号
*/
public static final Pattern PATTERN_INDIA_MOBILE = Pattern.compile(RegExpConstants.INDIA_MOBILE);
/**
* 其它国家的
*/
public static final Pattern PATTERN_OTHER_COUNTRY_MOBILE = Pattern.compile(RegExpConstants.OTHER_COUNTRY_MOBILE);
/**
* url
*/
public static final Pattern PATTERN_URL = Pattern.compile(RegExpConstants.URL);
/**
* Windows下文件名中的无效字符
*/
public static final Pattern PATTERN_FILE_NAME_INVALID_PATTERN_WIN = Pattern.compile(RegExpConstants.FILE_NAME_INVALID_PATTERN_WIN);
}
package com.gosingapore.common.constants;
/**
* @author shuyan
*/
@SuppressWarnings("unused")
public interface RoleCodeConstants {
/** 基础用户 */
String ROLE_USER = "ROLE_USER";
/** 管理员 */
String ROLE_ADMIN = "ROLE_ADMIN";
//region 业务角色
/** 前程中国业务员 */
String QC_CH_YE_WU = "QC_CH_YE_WU";
/** 前程马来业务员 */
String QC_ML_YE_WU = "QC_ML_YE_WU";
/** 鸿跃业务员 */
String HY_YE_WU = "HY_YE_WU";
/** 业务管理员 */
String YEWU_ADMIN = "YEWU_ADMIN";
//endregion
//region 电文角色
/** 电文 */
String DIAN_WEN = "DIAN_WEN";
/** 电文 */
String DIAN_WEN_ADMIN = "DIAN_WEN_ADMIN";
//endregion
//region 文员角色
/** 文员 */
String WEN_YUAN = "WEN_YUAN";
/** 文员管理员 */
String WEN_YUAN_ADMIN = "WEN_YUAN_ADMIN";
//endregion
/** 客服 */
String KEFU = "KEFU";
/** 财务 */
String CAIWU = "CAIWU";
/** 前程出纳 */
String QC_CASHIER = "QC_CASHIER";
/** 前程会计 */
String QC_ACCOUNTANT = "QC_ACCOUNTANT";
/** 鸿跃出纳 */
String HY_CASHIER = "HY_CASHIER";
/** 鸿跃会计 */
String HY_ACCOUNTANT = "HY_ACCOUNTANT";
/** 马来财务 */
String ML_FINANCE = "ML_FINANCE";
/** 鸿跃人事 */
String HY_HR = "HY_HR";
/** 前程人事 */
String QC_HR = "QC_HR";
/** 鸿跃客服 */
String HY_KEFU = "HY_KEFU";
/** 前程客服 */
String QC_KEFU = "QC_KEFU";
/**运营客服*/
String OPERATE_KEFU = "OPERATE_KEFU";
}
package com.gosingapore.common.constants;
/**
* @author fangqiguang
* @date 2020/7/6
*/
public interface SaleAfterConstants {
/**
* 操作记录,备注角色区分
* YEWU 业务
* DIANWEN_OR_WENYUAN 电文
* KEFU 客服
*/
String YEWU = "YEWU";
String DIANWEN_OR_WENYUAN = "DIANWEN_OR_WENYUAN";
String KEFU = "KEFU";
String KEFU_NORMAL = "KEFU_NORMAL";
/**
* 经理审核状态
* DEFAULT 默认-1无意义
* PENDING 待审核
* AGREE 同意
* REJECT 驳回
*/
Integer DEFAULT = -1;
Integer PENDING = 0;
Integer AGREE = 1;
Integer REJECT = 2;
/**
* 售后单审批流程状态
* 0 不需要审核 ,1经理审核, 2财务退款 3财务退款完结 4完结
*/
Integer PROCESS_NO_AUDIT = 0;
Integer PROCESS_LEADER = 1;
Integer PROCESS_FINANCE = 2;
Integer PROCESS_FINANCE_END = 3;
Integer PROCESS_END = 4;
/**
* 售后单处理状态
* HAND_PENDING 待处理
* HAND_PROCESSING 处理中
* HAND_COMPLETED 完成
*/
Integer HAND_PENDING = 0;
Integer HAND_PROCESSING = 1;
Integer HAND_COMPLETED = 2;
/**
* 操作记录文案
* 上传售后文件文案
* 添加备注文案
*/
String UP_SALE_AFTER_FILE = "上传售后文件";
String ADD_REMARKS = "添加了一条备注";
/**
* 售后消息提醒跳转类型
* JUMP_LIST 跳转售后列表
* JUMP_DETAIL 跳转售后详情
*/
String SALE_AFTER_LIST = "sale-after-list";
String SALE_AFTER_DETAIL = "sale-after-detail";
/**
* 是否是提交售后单操作 0否,1是
*/
Integer NO_SUBMIT = 0;
Integer IS_SUBMIT = 1;
}
package com.gosingapore.common.constants;
/**
* 服务名称
*
* @author lsl
*/
public class ServiceNameConstants
{
/**
* operate模块的serviceid
*/
public static final String OPERATE_SERVICE = "hiring-operate";
/**
* auth模块的serviceid
*/
public static final String AUTH_SERVICE = "hiring-auth";
/**
* adviser模块的serviceid
*/
public static final String ADVISER_SERVICE = "hiring-adviser";
}
package com.gosingapore.common.constants;
/**
* 服务启动
* 仅用于服务启动相关数据的收集使用,与项目业务无关
*
* @author ZhangJinyu
* @since 2020-10-02
*/
public interface ServiceStartConstants {
/**
* 服务启动信息
*/
String SERVICE_START_INFO = "SERVICE_START_INFO";
}
package com.gosingapore.common.constants;
/**
* @author ZhangJinyu
* @since 2020-09-16
*/
public class StringContains {
/**
* 字符串数字0
*/
public static final String ZERO = "0";
/**
* 字符串加号
*/
public static final String ADD = "+";
/**
* 正则+号
*/
public static final String REG_ADD = "\\+";
/**
* 点
*/
public static final String DOT = ".";
/**
* 空字符串
*/
public static final String EMPTY = "";
public static final String SLASH = "/";
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author ZhangJinyu
* @since 2020-10-13
*/
@Getter
@AllArgsConstructor
public enum AdClientTypeEnum {
/**
* 未知的
*/
UNKNOWN(null, "未知的"),
/**
* 全部
*/
ALL(0, "全部"),
/**
* 工人
*/
CUSTOMER(1, "工人"),
/**
* 雇主
*/
EMPLOYER(2, "雇主"),
/**
* 专员
*/
COMMISSIONER(3, "专员");
final Integer clientType;
final String clientTypeName;
public static AdClientTypeEnum get(Integer clientType) {
for (AdClientTypeEnum value : values()) {
if (!value.equals(UNKNOWN)) {
if (value.clientType.equals(clientType)) {
return value;
}
}
}
return UNKNOWN;
}
}
package com.gosingapore.common.enums;
/**
* 预录入枚举
* @author shuyan
*/
@SuppressWarnings("unused")
public enum AdvanceStatusEnum {
/**
* ENTER: 录入
* REGISTER: 注册
* WEB_REGISTER: web页分享注册
*/
ENTER(0),
REGISTER(1),
WEB_REGISTER(2);
private Integer value;
AdvanceStatusEnum(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* APP客户端类型
*
* @author ZhangJinyu
* @since 2020-09-25
*/
@Getter
@Deprecated
@AllArgsConstructor
public enum AppClientTypeEnum {
/**
* 所有端
*/
ALL("ALL", "所有"),
/**
* 所有工人端
*/
WORKER("WORKER", "工人端"),
/**
* android 工人端
*/
WORKER_ANDROID("WORKER_ANDROID", "工人android端"),
/**
* IOS 工人端
*/
WORKER_IOS("WORKER_IOS", "工人ios端"),
/**
* 工人PC端
*/
WORKER_PC("WORKER_PC", "工人pc端"),
/**
* 所有雇主端
*/
EMPLOYER("EMPLOYER", "雇主端"),
/**
* 雇主android端
*/
EMPLOYER_ANDROID("EMPLOYER_ANDROID", "雇主android端"),
/**
* 雇主IOS端
*/
EMPLOYER_IOS("EMPLOYER_IOS", "雇主ios端"),
/**
* 雇主PC端
*/
EMPLOYER_PC("EMPLOYER_PC", "雇主pc端"),
;
/**
* app客户端类型
*/
final String appClientType;
/**
* app客户端类型名称
*/
final String appClientTypeName;
public static AppClientTypeEnum get(String appClientType) {
for (AppClientTypeEnum value : values()) {
if (value.appClientType.equalsIgnoreCase(appClientType)) {
return value;
}
}
return ALL;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* app消息推送导的跳转类型
*
* @author shuyan
* @date 2020/4/22 19:17
*/
@AllArgsConstructor
public enum AppMsgJumpTypeEnum {
/**
* DELIVERY 投递推送
* RECOMMEND 推荐推送
* INVITE 邀约推送
* INTERVIEW 发起面试时的推送
* RESUME_CONFIRM 确认简历的推送
* CHECKED 选中时发起的推送
* COMPLETE 手续完成时的推送
* JOB 职位审核通过
* JOB_DETAIL 职位详情内容
*/
DELIVERY("DELIVERY"),
RECOMMEND("RECOMMEND"),
INVITE("INVITE"),
INTERVIEW("INTERVIEW"),
RESUME_CONFIRM("RESUME_CONFIRM"),
CHECKED("CHECKED"),
PROCEDURE_ITEM_REVEAL("PROCEDURE_ITEM_REVEAL"),
PROCEDURE_COMPLETE("PROCEDURE_COMPLETE"),
JOB("JOB"),
JOB_DETAIL("JOB_DETAIL"),
;
@Getter
String code;
public static AppMsgJumpTypeEnum instanceOf(String code) {
for (AppMsgJumpTypeEnum typeEnum : AppMsgJumpTypeEnum.values()) {
if (typeEnum.getCode().equalsIgnoreCase(code)) {
return typeEnum;
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author guocong
* @date 2020/3/4 9:14
*/
@AllArgsConstructor
public enum AppPlayTypeEnum {
/**
* 活动
*/
PLAY(1),
/**
* 广告
*/
ADVERTISING(2);
@Getter
private Integer value;
public static AppPlayTypeEnum instanceOf(Integer value){
for (AppPlayTypeEnum typeEnum : AppPlayTypeEnum.values()){
if(typeEnum.value.equals(value)){
return typeEnum;
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 手续办理通知单独写
* 节日推送和系统维护通知没有加在这里
* @author zbw
*/
@Getter
@AllArgsConstructor
public enum AppPushNodeEnum {
/**
* 第二阶段补充的推送节点
*/
EMPLOYER_CUSTOMER_REFUSE(false,"邀约反馈", "Invitation feedback", "该求职者已经找到工作,请查看其他求职者信息,我们将继续为您匹配合适人选", "The job applicant has found a job, please check the information of other job applicants, we will continue to match you with suitable job applicants"),
EMPLOYER_INTERVIEW_FAIL(false,"面试结果通知", "Interview result notification", "求职者XXX未通过面试,请您继续搜索其他适岗人员", "Job applicant XXX failed the interview, please continue to search for other suitable job applicants"),
EMPLOYER_INTERVIEW_SUCCESS(false,"面试结果通知", "Interview result notification", "亲爱的,您面试的雇员已经面试通过,并开始办理手续,您可以查看他的办理进度哟!", "Dear, the employee you interviewed has passed the interview and started to handle the procedures, you can check his progress!"),
CUSTOMER_RESUME_REFUSE(false,"投递反馈", "Application feedback", "很抱歉的通知您,您的简历与当前职位不符,请选择其他职位投递", "I’m sorry to inform you that your resume does not match the current position, please choose another position to apply for"),
CUSTOMER_JOB_INVITE(false,"职位推送通知", "Job push notification", "【新的投递邀请】 JOB_INFO_CH,快看看是否适合您", "[New application invitation] JOB_INFO_EN, quickly see if it suits you"),
// 雇主邀约工人,现修正为直接推送,跳转页面:到雇主邀约记录
CUSTOMER_EMPLOYER_INVITE(false,"雇主邀约通知", "Employer invitation notice", "亲爱的,有雇主查看了您的简历,来看看他的职位是否符合你的要求吧.", "Dear, an employer has checked your resume, come to see if his position meets your requirements."),
// 业务员推荐职位给工人,立即推送给工人,跳转页面:到雇主邀约的顾问推荐列表
CUSTOMER_BUSINESS_INVITE(false,"顾问推荐通知", "Advisor recommendation notice", "亲爱的,你的顾问为你推荐了新职位,出国工作,机会多多,快来查看吧!", "Dear,your consultant has recommended a new position for you, Come back check it now!"),
// 工人自己投递/业务帮忙投递成功通知工人,跳转页面:到投递详情页面查看进度
CUSTOMER_DELIVERY(false,"投递成功通知", "Notification of successful delivery", "亲爱的,你已经成功投递了职位,请注意查看进度!", "Dear, you have successfully delivered your position, please check the progress! And related fees!"),
// 电文/文员填写/修改面试计划通知工人,跳转页面:到我的面试的那一天看面试计划列表
CUSTOMER_INTERVIEW(false,"面试安排通知", "Interview Arrangement Notice", "亲爱的,你的顾问发布新的面试计划啦!快来查看吧!面试勿紧张,你是最棒的!狮狮给你加油打气!", "Dear,your consultant has released a new interview plan! Come check it now! Don't be nervous during the interview, you are the best! We will cheer for you!"),
// 电文/文员点选中通知工人,每天4点以后面试通过的消息不要发给工人,第二天9点发通知,跳转页面:到投递详情查看进度
CUSTOMER_CHECKED(false,"面试结果通知", "Interview Pass Notification", "亲爱的,恭喜您面试通过!快来查看吧!", "Congratulations on your passing the interview, dear! Check it out!"),
// 投递流程中,雇主点击同意后,通知工人确认简历,准备面试,跳转页面:到投递详情页面点击确认简历按钮
CUSTOMER_CONFIRM_RESUME(false,"简历确认通知", "Resume confirmation notice", "亲爱的, 你的顾问帮你优化的简历已被雇主看好,请确认简历,商议面试计划,准备面试吧!","Dear, the resume that your consultant helped you optimize has been optimistic by the employer, please confirm your resume, discuss the interview plan, and prepare for the interview!"),
// 业务实名认证通知工人,不跳转
CUSTOMER_VERIFY(false,"实名认证通知", "Real-name authentication notice", "亲爱的,你已通过实名认证,贴心求职顾问服务,诸多优质职位,等你投递!", "Dear,your application has been approved!Exclusive consulting services, Thousands of high-quality positions, Just waiting for you!"),
// 注册成功通知,不跳转
CUSTOMER_REGISTER_SUCCESS(true,"注册成功通知", "Notification of successful registration", "亲爱的,恭喜您注册成功,抓紧完善您的个人信息吧!海量高薪工作等您来选!", "Dear, congratulations on your successful registration, and pay close attention to improving your personal information! Massive high-paying jobs are waiting for you to choose!"),
// 职位审核通过/修改成功,跳转页面:跳转到职位详情页面
EMPLOYER_JOB_PASS(false,"职位审核通知", "Job review notice", "亲爱的,你的顾问已为你审核/修改了职位信息,继续招聘雇员吧!", "Dear, your consultant has reviewed / modified the job information for you, continue to recruit employees!"),
// 电文同意某投递,立即通知雇主/负责人,跳转页面:到雇主的应聘详情
EMPLOYER_ADVISER_RECOMMEND(false,"顾问推荐通知", "Advisor recommendation notice", "亲爱的,你的顾问已为你推荐有意向的雇员,请注意查看是否合适吧!", "Dear, your consultant has recommended potential employees for you, please check to see if it is suitable!"),
// 电文/文员填写/修改面试计划通知通知雇主/负责人,跳转页面:到我的面试的那一天看面试计划列表
EMPLOYER_INTERVIEW(false,"面试安排通知", "Interview Arrangement Notice", "亲爱的,你的顾问已安排了合适的面试计划,要按时参加面试哟!", "Dear, your consultant has arranged a suitable interview plan, and you need to attend the interview on time!"),
// 电文/文员点选中通知雇主/负责人,跳转页面:到投递详情查看进度
EMPLOYER_CHECKED(false,"面试结果通知", "Interview Pass Notification", "亲爱的,你面试的雇员已经面试通过开始办理手续,你可以查看他的办理进度哟!", "Dear, the employee you interviewed has already passed the interview and started the process, you can check his progress !"),
// 电文/文员点此单办理完毕,跳转页面:到投递详情查看进度
EMPLOYER_COMPLETE(false,"办理成功通知", "Successful notification", "亲爱的,你邀请的雇员已经办理完毕,请注意查看!","Dear, the employees you have invited have been processed, please pay attention to check!"),
// 公司认证通过通知,不跳转
EMPLOYER_COMPANY_VERIFY(false,"公司认证通知", "Company certification notice", "亲爱的,你的公司已认证通过,贴心招聘顾问服务,诸多优质雇员,等你邀约面试!", "Dear, your company has been certified, intimate recruitment consultant services, many high-quality employees, waiting for you to invite an interview!"),
// 注册成功通知,不跳转
EMPLOYER_REGISTER_SUCCESS(true,"注册成功通知", "Notification of successful registration", "亲爱的,恭喜你注册成功,欢迎来到去狮城,狮狮为你配备了专业的招聘顾问,等待你的召唤!", "Dear, congratulations on your successful registration, welcome to \"goSingapore\", we have equipped you with a professional recruitment consultant. Waiting for your call!"),
;
private Boolean pushMust;
private String chTitle;
private String enTitle;
private String chContent;
private String enContent;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author guocong
* @date 2020/5/21 13:39
*/
@Getter
@AllArgsConstructor
public enum AppShareTypeEnum {
/*
单纯分享app
*/
SHARE_APP(1),
/*
邀请好友
*/
INVITE(2),
/*
分享职位
*/
SHARE_JOB(3);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author guocong
* @date 2020/5/5 13:02
*/
@AllArgsConstructor
public enum AppTypeEnum {
/**
* 未知
*/
NONE(0, "未知", "Unknown"),
/**
* 工人端
*/
CUSTOMER(1, "工人端", "Worker"),
/**
* 雇主端
*/
EMPLOYER(2, "雇主端", "Employer");
@Getter
private final Integer value;
private final String chName;
private final String enName;
public static AppTypeEnum get(Integer appType) {
for (AppTypeEnum value : values()) {
if (value.value.equals(appType)) {
return value;
}
}
return NONE;
}
public String getChName() {
return chName;
}
public String getEnName() {
return enName;
}
public String getName(boolean chineseLanguage) {
return chineseLanguage ? chName : enName;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
/**
* @author ljq
* @date 2020/03/13
*/
@AllArgsConstructor
public enum CommissionerRoleEnum {
/**
* ROLE_COMMISSIONER:专员
* ROLE_COMMISSIONER_ADMIN:代理管理员
*/
ROLE_COMMISSIONER("ROLE_COMMISSIONER"),
ROLE_COMMISSIONER_ADMIN("ROLE_COMMISSIONER_ADMIN");
@Getter
private String roleCode;
public static final int PARTY_CODE = 3;
public static List<String> getCommissionerRoleList() {
List<String> list = new ArrayList<>();
CommissionerRoleEnum[] values = CommissionerRoleEnum.values();
for (CommissionerRoleEnum item : values) {
list.add(item.getRoleCode());
}
return list;
}
}
package com.gosingapore.common.enums;
/**
* @author qiwenxiao
* @date 2020/9/22 17:50
*/
public interface ComplainablePartyId {
/**
* QSC:去狮城平台
* EMP:雇主
* YW:业务
* INTER:中介
* WY:文员
* DW:电文
* CUS:工人
* CP_DW:复合电文
*/
Integer QSC = 0;
Integer EMP = 1;
Integer YW = 2;
Integer INTER = 3;
Integer WY = 4;
Integer DW = 5;
Integer CUS = 6;
Integer CP_DW = 7;
}
package com.gosingapore.common.enums;
import lombok.Getter;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author ljq
* @date 2020/2/19
*/
public enum CpRoleEnum {
/**
* CP_BOSS:伙伴中介公司老板
* CP_ADMIN:中介公司管理员
* CP_DIANWEN:伙伴中介电文
* CP_CONTACT:合作中介负责人
* CP_UP_CONTACT:合作中介负责人升级后
* CP_CONTACT_ADMIN:合作中介管理员
*/
CP_BOSS("CP_BOSS"),
CP_ADMIN("CP_ADMIN"),
CP_CONTACT_ADMIN("CP_CONTACT_ADMIN"),
CP_DIANWEN("CP_DIANWEN"),
CP_CONTACT("CP_CONTACT"),
CP_UP_CONTACT("CP_UP_CONTACT"),
;
@Getter
private final String roleCode;
public static final int PARTY_CODE = 2;
private static List<String> ROLE_CODES = new ArrayList<>();
CpRoleEnum(String roleCode) {
this.roleCode = roleCode;
}
public static List<String> getCpRoleList() {
if (CollectionUtils.isEmpty(ROLE_CODES)) {
CpRoleEnum[] values = CpRoleEnum.values();
for (CpRoleEnum item : values) {
ROLE_CODES.add(item.getRoleCode());
}
}
return ROLE_CODES;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author shuyan
*/
@AllArgsConstructor
public enum Dict110ClientIdEnum {
/**
*
*/
ERP(1,"erp"),
CP(2,"cp"),
PC(3,"pc"),
APP_BUS(4,"app_bus"),
APP_CSM(5,"app_csm"),
PARTNER(6,"partner");
@Getter
private Integer code;
@Getter
private String client;
public static final int CODE_TYPE = 110;
public static Dict110ClientIdEnum instanceOf(String client){
for(Dict110ClientIdEnum dict110ClientIdEnum : Dict110ClientIdEnum.values()){
if(dict110ClientIdEnum.client.equals(client)){
return dict110ClientIdEnum;
}
}
return null;
}
public static Dict110ClientIdEnum instanceOf(Integer code){
for(Dict110ClientIdEnum dict110ClientIdEnum : Dict110ClientIdEnum.values()){
if(dict110ClientIdEnum.code.equals(code)){
return dict110ClientIdEnum;
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.Getter;
/**
* 售后费用类型字典
* @author guomeng
*/
@Getter
public enum DictAfterSaleTypeEnum {
/**
* AFTER_SALE_CUS: 工人售后
* AFTER_SALE_INTER: 中介售后
* AFTER_SALE_EMP: 雇主售后
*/
AFTER_SALE_CUS(0,"工人售后"),
AFTER_SALE_INTER(2,"中介售后"),
AFTER_SALE_EMP(1,"雇主售后");
private Integer code;
private String name;
DictAfterSaleTypeEnum(Integer code, String name){
this.code = code;
this.name = name;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 雇主公司等级枚举
*
* @author 白海波
* @date 2020/5/14 16:30
*/
@AllArgsConstructor
public enum DwLevelEnum {
/**
* ARCHIVE:雇主等级
* COMPANY:公司等级
*/
ARCHIVE(1),
COMPANY(2);
@Getter
private Integer code;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 是否在公海
*
* @author ljq
*/
@AllArgsConstructor
public enum EmployerLevelEnum {
/**
* MAIN:原雇主
* DUPLICATE:关联重复雇主
*/
MAIN(1),
DUPLICATE(2);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
/**
* @author ljq
* @date 2020/03/13
*/
@AllArgsConstructor
public enum EmployerRoleEnum {
/**
* ROLE_EMPLOYER:雇主
*/
ROLE_EMPLOYER("ROLE_EMPLOYER");
@Getter
private String roleCode;
public static final int PARTY_CODE = 4;
public static List<String> getEmployerRoleList() {
List<String> list = new ArrayList<>();
EmployerRoleEnum[] values = EmployerRoleEnum.values();
for (EmployerRoleEnum item : values) {
list.add(item.getRoleCode());
}
return list;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author shuyan
*/
@AllArgsConstructor
public enum ErpCollidePartEnum {
/**
* 发起方
*/
LAUNCHER(1),
/**
* 被撞方
*/
COLLIDE(2);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import com.gosingapore.common.exception.CustomizeException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import static com.cloud.gs.hiring.base.util.ResponseCode.COMMON_VALIDATE_ERROR;
/**
* @author will
*/
@AllArgsConstructor
public enum EsBusinessTypeEnum {
/**
*
*/
SEARCH_JOB(1),
SEARCH_CUSTOMER(2);
@Getter
private Integer value;
public static EsBusinessTypeEnum valueOf(Integer type){
EsBusinessTypeEnum[] values = EsBusinessTypeEnum.values();
for(EsBusinessTypeEnum item : values){
if(item.value.equals(type)){
return item;
}
}
throw new CustomizeException(COMMON_VALIDATE_ERROR,"EsBusinessTypeEnum type :不在允许值范围内","EsBusinessTypeEnum type :Not in allowed range");
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author shuyan
*/
@AllArgsConstructor
public enum EsThreadMqEventEnum {
/**
* INDEX:创建、更新文档
* DELETE:删除文档
*/
INDEX("index"),
DELETE("delete");
@Getter
private String value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.context.i18n.LocaleContextHolder;
/**
* @author GM
*/
@Getter
@AllArgsConstructor
public enum GsComplainTypeEnum {
/**
* QSC:去狮城平台
* EMP:雇主
* YW:业务
* INTER:中介
* WY:文员
* DW:电文
* CUS:工人
* CP_DW:复合电文
*/
QSC(0,"去狮城平台","Platform of go Singapore"),
EMP(1,"雇主","Employer"),
YW(2,"业务","Business"),
INTER(3,"中介","Intermediary"),
WY(4,"文员","Clerk"),
DW(5,"电文","Telegram"),
CUS(6,"工人","Worker"),
CP_DW(7,"复合电文","Compound Telegram");
private final Integer type;
private final String name;
private final String enName;
/**
* 根据 type 属性获取 name 属性
* @param type 要查找的 type 值
* @return type 对应的 name
*/
public static String getNameByType(Integer type) {
if (null == type || type < 0) {
return null;
}
String language = LocaleContextHolder.getLocale().getLanguage();
for (GsComplainTypeEnum member : GsComplainTypeEnum.values()) {
if (member.getType().equals(type)) {
return "en".equals(language) ? member.getEnName() : member.getName();
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author guomegn
*/
@AllArgsConstructor
public enum GsCompleteEnum {
/**
* TO_AUDIT 待审核
* BEING_PROCESSED 处理中
* OFF_THE_STOCKS 已完成
*/
TO_AUDIT(0),
BEING_PROCESSED(1),
OFF_THE_STOCKS(2);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
/**
* @author guocong
* @date 2020/1/16 10:14
*/
public enum GsDwEnum {
/**
* 前程中国电文
*/
QC_CH_DIANWEN("QC_CH_DIANWEN"),
/**
* 前程马来电文
*/
QC_ML_DIANWEN("QC_ML_DIANWEN"),
/**
* 前程越南电文
*/
QC_YN_DIANWEN("QC_YN_DIANWEN"),
/**
* 平台伙伴电文
*/
CP_DIANWEN("CP_DIANWEN");
@Getter
private String roleCode;
GsDwEnum(String roleCode) {
this.roleCode = roleCode;
}
public static List<String> getDwRoleList() {
List<String> list = new ArrayList<>();
GsDwEnum[] values = GsDwEnum.values();
for (GsDwEnum item : values) {
list.add(item.getRoleCode());
}
return list;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author guomegn
*/
@AllArgsConstructor
public enum GsHandlerEnum {
/**
* YW 业务
* WY 文员
* DW 电文
* KF 客服
*/
YW(0),
WY(1),
DW(2),
KF(3);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 节点类型
* @author ljq
*/
@AllArgsConstructor
public enum GsSysOrgNodeTypeEnum {
/**
* USER 用户
* GROUP 组
* DEPT 部门
* REGIONAL 大区
* COMPANY 公司
* HEAD_OFFICE 总公司
*/
USER(0),
GROUP(1),
DEPT(2),
REGIONAL(3),
COMPANY(4),
HEAD_OFFICE(5),
ALL_ORG(6);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 用户职级
*
* @author ljq
*/
@AllArgsConstructor
public enum GsSysOrgTypeEnum {
/**
* ADMINISTRATION 行政
* BUSINESS 业务
*/
ADMINISTRATION(0),
BUSINESS(1);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 融云消息回调,消息类型枚举类
*
* @author 白海波
* @date 2020/8/4 10:03
*/
@AllArgsConstructor
public enum ImMsgRoutingTypeEnum {
/**
* TXT_MSG:文本消息
* IMG_MSG:图片消息
* VC_MSG:语音消息
* LBS_MSG:位置消息
*/
TEXT_MSG("RC:TxtMsg"),
IMAGE_MSG("RC:ImgMsg"),
VOICE_MSG("RC:VcMsg"),
FILE_MSG("RC:FileMsg"),
LBS_MSG("RC:LBSMsg");
@Getter
private final String value;
public static ImMsgRoutingTypeEnum instantOf(String value) {
for (ImMsgRoutingTypeEnum imMsgRoutingTypeEnum : values()) {
if (imMsgRoutingTypeEnum.getValue().equals(value)) {
return imMsgRoutingTypeEnum;
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author 白海波
* @date 2020/5/13 13:21
*/
@AllArgsConstructor
public enum ImOnlineStatus {
/**
* ONLINE:在线
* OFFLINE:下线
*/
ONLINE("1"),
OFFLINE("0");
@Getter
private String value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 是否在公海
*
* @author ljq
*/
@AllArgsConstructor
public enum InSeaEnum {
/**
* PRIVATE:个人库
* IN_SEA:公海
*/
PRIVATE(0),
IN_SEA(1);
@Getter
private Integer value;
}
\ No newline at end of file
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 中介用户类型
*
* @author ljq
*/
@AllArgsConstructor
public enum IntermediaryUserTypeEnum {
/**
* USER 用户
* ADMIN 管理员
*/
USER(0),
ADMIN(1);
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
/**
* @author zbw
*/
@SuppressWarnings("unused")
public enum InviteTypeEnum {
/**
* WORKER_DELIVER: 业务主动投递,仅用于判断,数据库未使用该值
* EMPLOYER_INVITE: 雇主邀约
* ADVISER_RECOMMEND: 顾问推荐
*/
WORKER_DELIVER(0),
EMPLOYER_INVITE(1),
ADVISER_RECOMMEND(2);
private Integer value;
InviteTypeEnum(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
}
package com.gosingapore.common.enums;
/**
* @author zbw
*/
@SuppressWarnings("unused")
public enum InviteUserTypeEnum {
/**
* 推荐或邀约角色intermediary
* 1业务,2电文,3文员,4雇主,5中介
*/
BUSINESS(1),
TEL_CLERK(2),
CLERK(3),
EMPLOYER(4),
INTERMEDIARY(5);
private Integer value;
InviteUserTypeEnum(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 职位草稿状态
*
* @author ljq
*/
@AllArgsConstructor
public enum JobSyncStatusEnum {
/**
* DEFAULT:新增默认
* TO_BE_AUDIT:待审核
* AUDITED:已审核
*/
DEFAULT(0),
TO_BE_AUDIT(1),
AUDITED(2);
@Getter
private Integer value;
}
\ No newline at end of file
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 语言
* @author shuyan
*/
@SuppressWarnings("unused")
@AllArgsConstructor
public enum LanguageTypeEnum {
/**
* ZH: 中文
* EN: 英文
*/
ZH(1,"zh"),
EN(2,"en");
@Getter
private Integer value;
@Getter
private String local;
public static LanguageTypeEnum instanceOf(String local){
for(LanguageTypeEnum typeEnum : LanguageTypeEnum.values()){
if(typeEnum.getLocal().equals(local)){
return typeEnum;
}
}
return EN;
}
public static LanguageTypeEnum instanceOf(Integer value){
for(LanguageTypeEnum typeEnum : LanguageTypeEnum.values()){
if(typeEnum.getValue().equals(value)){
return typeEnum;
}
}
return EN;
}
}
package com.gosingapore.common.enums;
import com.gosingapore.common.constants.RegexPatternConstants;
import com.gosingapore.common.constants.StringContains;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* 手机号国家代码
*
* @author ZhangJinyu
* @since 2020-09-16
*/
@Getter
@AllArgsConstructor
public enum MobileCountryEnum {
/**
* 其它国家,为系统未收纳的规则
*/
OTHERS("", RegexPatternConstants.PATTERN_OTHER_COUNTRY_MOBILE, RegexPatternConstants.PATTERN_OTHER_COUNTRY_MOBILE),
/**
* 中国
*/
CHINA("86", RegexPatternConstants.PATTERN_CHINA_MOBILE, RegexPatternConstants.PATTERN_CHINA_MOBILE),
/**
* 新加坡
*/
SINGAPORE("65", RegexPatternConstants.PATTERN_SINGAPORE_MOBILE, RegexPatternConstants.PATTERN_SINGAPORE_FIXED_TELEPHONE),
/**
* 马来西亚
*/
MALAYSIA("60", RegexPatternConstants.PATTERN_MALAYSIA_MOBILE, RegexPatternConstants.PATTERN_MALAYSIA_MOBILE),
/**
* 越南
*/
VIETNAM("84", RegexPatternConstants.PATTERN_VIETNAM_MOBILE, RegexPatternConstants.PATTERN_VIETNAM_MOBILE),
/**
* 印度
*/
INDIA("91", RegexPatternConstants.PATTERN_INDIA_MOBILE, RegexPatternConstants.PATTERN_INDIA_MOBILE),
;
private final String mobileCountryCode;
private final Pattern mobilePattern;
private final Pattern fixedTelephonePattern;
public static MobileCountryEnum getByCode(String mobileCountryCode) {
if (StringUtils.isBlank(mobileCountryCode)) {
return OTHERS;
}
if (mobileCountryCode.startsWith(StringContains.ADD)) {
mobileCountryCode = mobileCountryCode.replaceFirst(StringContains.REG_ADD, "");
}
for (MobileCountryEnum value : values()) {
if (value.mobileCountryCode.equalsIgnoreCase(mobileCountryCode)) {
return value;
}
}
return OTHERS;
}
/**
* 是否有固定电话
*
* @return true:有 false:无
*/
public boolean hasFixedTelephone() {
return !Objects.isNull(fixedTelephonePattern);
}
@Getter
@AllArgsConstructor
public static class Mobile {
private final String mobileCountryCode;
private final String mobile;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* erp消息推送导的跳转类型
*
* @author lsl
* @date 2021/4/1 19:17
*/
@AllArgsConstructor
public enum MsgRemindJumpTypeEnum {
/**
* 投递详情
*/
DELIVERY_DETAILS("delivery_details"),
/**
* 客户黑名单
*/
CUSTOMER_BLACKLIST("customer_blacklist"),
/**
* 雇主黑名单
*/
EMPLOYER_BLACKLIST("employer_blacklist"),
/**
* 中介黑名单
*/
INTERMEDIARY_BLACKLIST("intermediary_blacklist"),
;
@Getter
String code;
public static MsgRemindJumpTypeEnum instanceOf(String code) {
for (MsgRemindJumpTypeEnum typeEnum : MsgRemindJumpTypeEnum.values()) {
if (typeEnum.getCode().equalsIgnoreCase(code)) {
return typeEnum;
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author guocong
* @date 2020/3/3 13:18
*/
@Getter
@AllArgsConstructor
public enum OrderSeqEnum {
/**
* 升降序
*/
ASC(1,"asc"),
DESC(2,"desc"),
;
private Integer value;
private String name;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author baihaibo 2020/2/10 13:20
*/
@Getter
@AllArgsConstructor
public enum PushDeviceTypeEnum {
/**
* IOS:IOS
* ANDROID:Android
*/
IOS(1,"IOS"),
ANDROID(2,"Android"),
;
private Integer typeId;
private String typeName;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author baihaibo 2020/3/17 15:38
*/
@AllArgsConstructor
@Getter
public enum ReportJobHallEnum {
/**
* YEWU_AGREE:报单
* INTERVIEW:面试
* CHECKED:选中
* UN_CHECKED:未选中
*/
YEWU_AGREE(24, "报单"),
INTERVIEW(52, "面试"),
CHECKED(60, "选中"),
UN_CHECKED(58, "未选中");
private Integer code;
private String value;
public static String getValueByCode(Integer code) {
for (ReportJobHallEnum reportJobHallEnum : values()) {
if (reportJobHallEnum.code.equals(code)) {
return reportJobHallEnum.value;
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author shuyan
* @date 2020/7/22 17:46
*/
@AllArgsConstructor
public enum SmsTypeEnum {
/**
* VERIFICATION_CODE: 验证码
* INITIAL_PASSWORD: 初始密码通知
* NONE_LOGIN 工人未登录通知
*/
VERIFICATION_CODE(1),
INITIAL_PASSWORD(2),
NONE_LOGIN(3);
@Getter
Integer value;
public static SmsTypeEnum instanceOf(Integer value) {
for (SmsTypeEnum typeEnum : SmsTypeEnum.values()) {
if (typeEnum.getValue().equals(value)) {
return typeEnum;
}
}
return null;
}
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 上限枚举
* @author guocong
* @date 2020/2/7 12:35
*/
@AllArgsConstructor
public enum UpperLimitEnum {
/**
* 浏览记录上限
*/
BROWSING(100),
/**
* 活动?广告上限
*/
PLAY(5),
/**
*
*/
JOB_VIDEO(1),
JOB_PHOTO(9),;
@Getter
private Integer value;
}
package com.gosingapore.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author dyh
* @date 2020/5/27
*/
@AllArgsConstructor
@Getter
public enum YesOrNoEnum {
/**
* 是否状态码
*/
YES(1,"是"),
NO(0,"否");
private Integer code;
private String value;
}
package com.gosingapore.common.enums.ai;
import java.math.BigDecimal;
/**
* @author ZhangJinyu
* @since 2020-02-15
*/
public enum BodySize implements ICalculateValue {
/**
* 大只
*/
BIG("big"),
/**
* 适中
*/
NORMAL("normal"),
/**
* 小只
*/
SMALL("small");
private static BigDecimal small = new BigDecimal("18.4");
private static BigDecimal big = new BigDecimal(28);
String bodySize;
BodySize(String bodySize) {
this.bodySize = bodySize;
}
public static BodySize getBodySize(double height, int weight) {
BigDecimal bni = new BigDecimal(weight).divide(new BigDecimal(height).multiply(new BigDecimal(height)), 2, BigDecimal.ROUND_HALF_UP);
System.out.println("计算bni:" + bni.toString());
int smallCompare = bni.compareTo(small);
int bigCompare = bni.compareTo(big);
if (smallCompare <= 0) {
return BodySize.SMALL;
} else if (bigCompare >= 0) {
return BodySize.BIG;
} else {
return BodySize.NORMAL;
}
}
@Override
public boolean canUsed() {
return true;
}
@Override
public String getValue() {
return bodySize;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment