init
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.newyetai.usercenter.common.constant;
|
||||
|
||||
import com.newyetai.codegenerator.pojo.CodeParam;
|
||||
|
||||
/**
|
||||
* 编码类型
|
||||
* @author sr on 2019-12-06
|
||||
*/
|
||||
public enum CodeTypeEnum {
|
||||
|
||||
ORG(CodeParam.builder().type("O").build()),
|
||||
|
||||
;
|
||||
private CodeParam codeParam;
|
||||
|
||||
private CodeTypeEnum(CodeParam codeParam) {
|
||||
this.codeParam = codeParam;
|
||||
}
|
||||
|
||||
public CodeParam getCodeParam() {
|
||||
return this.codeParam;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.newyetai.usercenter.common.constant;
|
||||
|
||||
/**
|
||||
* 任务调度常量类
|
||||
*
|
||||
* @author sr on 2020-11-25
|
||||
*/
|
||||
public interface XxlJobHandlerConstants {
|
||||
|
||||
/**
|
||||
* 统计机构最近登录时间 HCY
|
||||
**/
|
||||
String STATISTIC_ORG_LAST_LOGIN_TIME = "statisticOrgLastLoginTimeHandler";
|
||||
|
||||
/**
|
||||
* 授权订阅用户列表
|
||||
**/
|
||||
String AUTH_SUBSCRIBE_USER_LIST = "authSubscribeUserListHandler";
|
||||
/**
|
||||
* 用户注销通知工作
|
||||
*/
|
||||
String USER_CANCEL_NOTIFY_JOB = "userCancelNotifyHandler";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.newyetai.usercenter.common.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.tkmybatis.pojo.Page;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamCreateDTO;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamDTO;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamQueryDTO;
|
||||
import com.newyetai.usercenter.common.service.SlickParamService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("slick_param")
|
||||
@Api(tags = "圆滑的参数")
|
||||
public class SlickParamController {
|
||||
|
||||
@Autowired
|
||||
private SlickParamService slickParamService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建")
|
||||
public AlitaResult<SlickParamDTO> create(
|
||||
@Validated @RequestBody SlickParamCreateDTO slickParamCreateDTO){
|
||||
return AlitaResult.success(slickParamService.create(slickParamCreateDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/remove/{id}")
|
||||
@ApiOperation("删除")
|
||||
public AlitaResult<Boolean> remove(@PathVariable Long id){
|
||||
slickParamService.remove(id);
|
||||
return AlitaResult.success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("分页查询")
|
||||
public AlitaResult<Page<SlickParamDTO>> page(SlickParamQueryDTO slickParamQueryDTO){
|
||||
slickParamService.page(slickParamQueryDTO);
|
||||
return AlitaResult.success(slickParamQueryDTO.getPageResult());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.newyetai.usercenter.common.controller;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.usercenter.user.phone.dto.PhoneCodeDTO;
|
||||
import com.newyetai.usercenter.user.phone.dto.PhoneCodeSmsDTO;
|
||||
import com.newyetai.usercenter.user.phone.dto.SmsSimpleSendDTO;
|
||||
import com.newyetai.usercenter.user.phone.provider.simple.ISimpleSms;
|
||||
import com.newyetai.usercenter.user.phone.util.PhoneCodeUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author sr on 2022-09-26
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "短信")
|
||||
public class SmsController {
|
||||
|
||||
@Autowired
|
||||
private ISimpleSms simpleSms;
|
||||
|
||||
@PostMapping("sms/send/simple/async")
|
||||
@ApiOperation("发送短信")
|
||||
public AlitaResult<Void> simpleSms(@Validated @RequestBody SmsSimpleSendDTO sendDTO) {
|
||||
simpleSms.sendAsync(sendDTO);
|
||||
return AlitaResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("anon/sms/send")
|
||||
@ApiOperation("获取验证码-不同类型")
|
||||
public AlitaResult<Void> sms(@Validated @RequestBody PhoneCodeSmsDTO phoneCodeSmsDTO) {
|
||||
PhoneCodeUtils.send(phoneCodeSmsDTO);
|
||||
return AlitaResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("sms/match")
|
||||
@ApiOperation("获取验证码-匹配验证")
|
||||
public AlitaResult<Void> match(@Validated @RequestBody PhoneCodeDTO phoneCodeDTO) {
|
||||
PhoneCodeUtils.matchBiz(phoneCodeDTO);
|
||||
return AlitaResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.newyetai.usercenter.common.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.newyetai.usercenter.common.dto.SlickParamDTO;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamQueryDTO;
|
||||
import com.newyetai.usercenter.common.entity.SlickParam;
|
||||
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||
|
||||
/**
|
||||
* 圆滑的参数
|
||||
*
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
public interface SlickParamMapper extends MyMapper<SlickParam> {
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param slickParamQueryDTO
|
||||
* @return
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
List<SlickParamDTO> listSlickParamDTO(@Param("param") SlickParamQueryDTO slickParamQueryDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.newyetai.usercenter.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.newyetai.common.dto.BaseOperateDTO;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@ApiModel(description = "圆滑的参数创建")
|
||||
public class SlickParamCreateDTO extends BaseOperateDTO implements Serializable{
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("参数属性")
|
||||
@NotNull(message = "参数属性不能为空")
|
||||
private Object paramData;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.newyetai.usercenter.common.dto;
|
||||
|
||||
import com.newyetai.common.dto.BaseDTO;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@ApiModel(description = "圆滑的参数")
|
||||
public class SlickParamDTO extends BaseDTO {
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("唯一码-uuid")
|
||||
private String uniqueCode;
|
||||
@ApiModelProperty("query升序值(格式:**=**&**=**)")
|
||||
private String queryValue;
|
||||
@ApiModelProperty("json数据")
|
||||
private String paramData;
|
||||
@ApiModelProperty("哈希值")
|
||||
private Integer hashCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.newyetai.usercenter.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
import com.newyetai.common.dto.PageQueryDTO;
|
||||
|
||||
/**
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@ApiModel(description = "圆滑的参数查询条件")
|
||||
public class SlickParamQueryDTO extends PageQueryDTO<SlickParamDTO> implements Serializable{
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private Long id;
|
||||
@ApiModelProperty("唯一码-uuid")
|
||||
private String uniqueCode;
|
||||
@ApiModelProperty("query升序值(格式:**=**&**=**)")
|
||||
private String queryValue;
|
||||
@ApiModelProperty("哈希值")
|
||||
private Integer hashCode;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.newyetai.usercenter.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.newyetai.common.entity.BaseEntity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 圆滑的参数
|
||||
*
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
@TableName("uc_slick_param")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@SuperBuilder
|
||||
@Data
|
||||
public class SlickParam extends BaseEntity {
|
||||
|
||||
/** **/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 唯一码-uuid **/
|
||||
private String uniqueCode;
|
||||
/** query升序值(格式:**=**&**=**) **/
|
||||
private String queryValue;
|
||||
/** json数据 **/
|
||||
private String paramData;
|
||||
/** 哈希值 **/
|
||||
private Integer hashCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.newyetai.usercenter.common.dao.SlickParamMapper">
|
||||
<select id="listSlickParamDTO" resultType="com.newyetai.usercenter.common.dto.SlickParamDTO">
|
||||
select
|
||||
*
|
||||
from uc_slick_param
|
||||
where
|
||||
deleted = 0
|
||||
<if test="param.id != null">
|
||||
and id = #{param.id}
|
||||
</if>
|
||||
<if test="param.uniqueCode != null and param.uniqueCode != ''">
|
||||
and unique_code = #{param.uniqueCode}
|
||||
</if>
|
||||
<if test="param.queryValue != null and param.queryValue != ''">
|
||||
and query_value = #{param.queryValue}
|
||||
</if>
|
||||
<if test="param.hashCode != null">
|
||||
and hash_code = #{param.hashCode}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.newyetai.usercenter.common.mapstruct;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import com.newyetai.usercenter.common.dto.SlickParamDTO;
|
||||
import com.newyetai.usercenter.common.entity.SlickParam;
|
||||
|
||||
/**
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
@Mapper
|
||||
public interface SlickParamMapMapper {
|
||||
|
||||
SlickParamMapMapper INSTANCE =
|
||||
Mappers.getMapper(SlickParamMapMapper.class);
|
||||
|
||||
/**
|
||||
* dto to entity
|
||||
*
|
||||
* @param slickParamDto
|
||||
* @return
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
SlickParam toEntity(
|
||||
SlickParamDTO slickParamDto);
|
||||
|
||||
SlickParamDTO toDto(SlickParam slickParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.newyetai.usercenter.common.mq.constant;
|
||||
|
||||
import com.newyetai.common.constant.CommonConstants;
|
||||
import com.newyetai.common.constant.SystemCodeEnum;
|
||||
|
||||
/**
|
||||
* mq常量类(routingkey)
|
||||
* @author sr on 2021-01-05
|
||||
*/
|
||||
public interface UcMqConstants {
|
||||
|
||||
/** 用户中心系统mq前缀 **/
|
||||
String MQ_PREFIX = SystemCodeEnum.ALITA_USER_CENTER.getName() + CommonConstants.POINT;
|
||||
|
||||
/** 站内信(websocket消费) **/
|
||||
String ROUTING_KEY_SITE_NOTICE = UcMqConstants.MQ_PREFIX + "site_notice";
|
||||
|
||||
/**
|
||||
* 阶梯费率单子创建
|
||||
*/
|
||||
String LADDER_RATE_ORDER_NOTICE = UcMqConstants.MQ_PREFIX + "ladder_rate_order_notice";
|
||||
|
||||
|
||||
/** 企业产品能力开通 **/
|
||||
String ROUTING_KEY_UNION_PROD_ABILITY_CREATE = UcMqConstants.MQ_PREFIX + "prod_ability_create";
|
||||
|
||||
/** 修改手机号 **/
|
||||
String CHANGE_PHONE = UcMqConstants.MQ_PREFIX + "change_phone";
|
||||
|
||||
/** 修改手机号 关联简历 **/
|
||||
String CHANGE_PHONE_RESUME = UcMqConstants.MQ_PREFIX + "change_phone_resume";
|
||||
|
||||
/** 用户活动记录处理 **/
|
||||
String ROUTING_KEY_USER_ACTIVITY_RECORD_DEAL = UcMqConstants.MQ_PREFIX + "user_activity_record_deal";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.newyetai.usercenter.common.mybatis;
|
||||
|
||||
import com.newyetai.mybatis.handle.BaseEnumTypeHandler;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: chenyun.huang
|
||||
* @create: 2020-04-13 14:53
|
||||
**/
|
||||
@Configuration
|
||||
public class MyBatisConfig {
|
||||
|
||||
@Autowired
|
||||
public void myInterceptor(SqlSessionFactory sqlSessionFactory) {
|
||||
// 取得类型转换注册器
|
||||
TypeHandlerRegistry typeHandlerRegistry = sqlSessionFactory.getConfiguration().getTypeHandlerRegistry();
|
||||
// 注册默认枚举转换器
|
||||
typeHandlerRegistry.setDefaultEnumTypeHandler(BaseEnumTypeHandler.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.newyetai.usercenter.common.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.newyetai.usercenter.common.dto.SlickParamQueryDTO;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamCreateDTO;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamDTO;
|
||||
|
||||
/**
|
||||
* 圆滑的参数
|
||||
*
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
public interface SlickParamService {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param slickParamCreateDTO
|
||||
* @return
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
SlickParamDTO create(SlickParamCreateDTO slickParamCreateDTO);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
void remove(Long id);
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
* @param slickParamQueryDTO
|
||||
* @return
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
List<SlickParamDTO> list(SlickParamQueryDTO slickParamQueryDTO);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param slickParamQueryDTO
|
||||
* @return
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
void page(SlickParamQueryDTO slickParamQueryDTO);
|
||||
|
||||
/**
|
||||
* 单个查询
|
||||
*
|
||||
* @param slickParamQueryDTO
|
||||
* @return
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
SlickParamDTO find(SlickParamQueryDTO slickParamQueryDTO);
|
||||
|
||||
/**
|
||||
* 转换参数对象
|
||||
* @param <T>
|
||||
* @param uniqueCode
|
||||
* @param clazz
|
||||
* @return
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
<T> T parseCode(String uniqueCode, Class<T> clazz);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.newyetai.usercenter.common.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.newyetai.common.exception.util.Assert;
|
||||
import com.newyetai.common.util.JsonUtils;
|
||||
import com.newyetai.common.util.ListUtil;
|
||||
import com.newyetai.common.util.RandomUtils;
|
||||
import com.newyetai.common.util.StrUtils;
|
||||
import com.newyetai.common.util.UserContextHolder;
|
||||
import com.newyetai.usercenter.common.dao.SlickParamMapper;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamCreateDTO;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamDTO;
|
||||
import com.newyetai.usercenter.common.dto.SlickParamQueryDTO;
|
||||
import com.newyetai.usercenter.common.entity.SlickParam;
|
||||
import com.newyetai.usercenter.common.mapstruct.SlickParamMapMapper;
|
||||
import com.newyetai.usercenter.common.service.SlickParamService;
|
||||
|
||||
/**
|
||||
* @author sr on 2022-01-11
|
||||
*/
|
||||
@Service
|
||||
public class SlickParamServiceImpl implements SlickParamService {
|
||||
|
||||
@Autowired
|
||||
private SlickParamMapper slickParamMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public SlickParamDTO create(SlickParamCreateDTO slickParamCreateDTO) {
|
||||
Object paramData = slickParamCreateDTO.getParamData();
|
||||
String queryValue = StrUtils.buildAscQueryValue(paramData);
|
||||
Assert.notNull(queryValue, "无有效参数");
|
||||
Integer hashCode = queryValue.hashCode();
|
||||
SlickParamQueryDTO slickParamQueryDTO =
|
||||
SlickParamQueryDTO.builder().queryValue(queryValue).hashCode(hashCode).build();
|
||||
SlickParamDTO slickParamDTO = find(slickParamQueryDTO);
|
||||
if (slickParamDTO != null) {
|
||||
return slickParamDTO;
|
||||
}
|
||||
SlickParam slickParam = SlickParam.builder().queryValue(queryValue)
|
||||
.paramData(JsonUtils.toJsonString(paramData)).hashCode(hashCode)
|
||||
.uniqueCode(RandomUtils.generateUUID()).build();
|
||||
slickParamMapper.saveEntity(slickParam);
|
||||
return SlickParamMapMapper.INSTANCE.toDto(slickParam);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void remove(Long id) {
|
||||
slickParamMapper.deleteEntity(SlickParam.builder().id(id).build(),
|
||||
UserContextHolder.getLoginUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SlickParamDTO> list(SlickParamQueryDTO slickParamQueryDTO) {
|
||||
slickParamQueryDTO.disablePage();
|
||||
return slickParamMapper.listSlickParamDTO(slickParamQueryDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void page(SlickParamQueryDTO slickParamQueryDTO) {
|
||||
slickParamMapper.listSlickParamDTO(slickParamQueryDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SlickParamDTO find(SlickParamQueryDTO slickParamQueryDTO) {
|
||||
List<SlickParamDTO> slickParamDTOs = this.list(slickParamQueryDTO);
|
||||
return slickParamDTOs.isEmpty() ? null : ListUtil.first(slickParamDTOs);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T parseCode(String uniqueCode, Class<T> clazz) {
|
||||
if (StringUtils.isBlank(uniqueCode)) {
|
||||
return null;
|
||||
}
|
||||
SlickParamDTO slickParamDTO = find(SlickParamQueryDTO.builder().uniqueCode(uniqueCode).build());
|
||||
Assert.notNull(slickParamDTO, "无效码");
|
||||
return JsonUtils.toObject(slickParamDTO.getParamData(), clazz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.newyetai.usercenter.common.threadPools;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
|
||||
/**
|
||||
* 外部方法线程池配置
|
||||
*
|
||||
* @author on 2019-11-05
|
||||
*/
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class AsyncExecutorConfig {
|
||||
|
||||
@Value("${async-executor.core_pool_size:10}")
|
||||
private int corePoolSize;
|
||||
@Value("${async-executor.max_pool_size:50}")
|
||||
private int maxPoolSize;
|
||||
@Value("${async-executor.queue-capacity:1000}")
|
||||
private int queueCapacity;
|
||||
@Value("${async-executor.name-prefix:async-}")
|
||||
private String namePrefix;
|
||||
|
||||
|
||||
@Bean("asyncExecutor")
|
||||
public Executor asyncExecutor() {
|
||||
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
|
||||
taskExecutor.setCorePoolSize(corePoolSize);// 线程池核心线程数
|
||||
taskExecutor.setMaxPoolSize(maxPoolSize);// 线程池最大线程数
|
||||
taskExecutor.setQueueCapacity(queueCapacity);// 缓冲队列
|
||||
taskExecutor.setThreadNamePrefix(namePrefix);// 线程名称前缀
|
||||
taskExecutor.setKeepAliveSeconds(60);// 线程空闲后的最大存活时间
|
||||
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
|
||||
// CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
|
||||
// 对拒绝task的处理策略
|
||||
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// 执行初始化
|
||||
taskExecutor.initialize();
|
||||
return taskExecutor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.newyetai.usercenter.common.validate;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @description: 参数校验配置
|
||||
* @author: chenyun.huang
|
||||
* @create: 2020-04-11 10:09
|
||||
**/
|
||||
@Configuration
|
||||
public class ValidatorConf {
|
||||
@Bean
|
||||
public Validator validator() {
|
||||
return Validation.byProvider(HibernateValidator.class)
|
||||
.configure()
|
||||
.failFast(true)
|
||||
.buildValidatorFactory().getValidator();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user