27 changed files with 764 additions and 310 deletions
@ -1,42 +0,0 @@ |
|||
package com.base.springcloud.aspect.annotation; |
|||
|
|||
import java.lang.annotation.*; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Target({ElementType.METHOD}) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
@Inherited |
|||
public @interface Rlock { |
|||
|
|||
/** |
|||
* 分布式锁的key前缀 |
|||
*/ |
|||
String prefix() default "redisLockPrefix::"; |
|||
|
|||
/** |
|||
* 分布式锁的key动态参数 |
|||
*/ |
|||
String suffix() default "lockDynamicKey"; |
|||
|
|||
/** |
|||
* 等待时间 默认五秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
long waitTime() default 5; |
|||
|
|||
/** |
|||
* 锁释放时间 默认十秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
long leaseTime() default 10; |
|||
|
|||
/** |
|||
* 时间格式 默认:秒 |
|||
* |
|||
* @return |
|||
*/ |
|||
TimeUnit timeUnit() default TimeUnit.SECONDS; |
|||
} |
|||
@ -1,118 +0,0 @@ |
|||
package com.base.springcloud.aspect.aspect; |
|||
|
|||
import com.base.springcloud.aspect.annotation.Rlock; |
|||
import com.base.springcloud.handle.RBSQueueHandler; |
|||
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.redisson.api.RLock; |
|||
import org.redisson.api.RedissonClient; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.DefaultParameterNameDiscoverer; |
|||
import org.springframework.expression.EvaluationContext; |
|||
import org.springframework.expression.Expression; |
|||
import org.springframework.expression.spel.standard.SpelExpressionParser; |
|||
import org.springframework.expression.spel.support.StandardEvaluationContext; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.lang.reflect.Method; |
|||
|
|||
@Aspect |
|||
@Component |
|||
@Slf4j |
|||
public class RlockAspect { |
|||
|
|||
Logger logger = LoggerFactory.getLogger(RBSQueueHandler.class); |
|||
|
|||
@Autowired |
|||
private RedissonClient redissonClient; |
|||
|
|||
/** |
|||
* 用于SpEL表达式解析. |
|||
*/ |
|||
private SpelExpressionParser parser = new SpelExpressionParser(); |
|||
/** |
|||
* 用于获取方法参数定义名字. |
|||
*/ |
|||
private DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer(); |
|||
|
|||
|
|||
|
|||
@Pointcut("@annotation(com.base.springcloud.aspect.annotation.Rlock)") |
|||
public void RlockAspect() { |
|||
} |
|||
|
|||
@Around("RlockAspect()") |
|||
public Object arround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { |
|||
Object object = null; |
|||
RLock lock = null; |
|||
try { |
|||
// 获取注解信息
|
|||
Rlock rlockInfo = getRlockInfo(proceedingJoinPoint); |
|||
String key = getLocalKey(proceedingJoinPoint, rlockInfo); |
|||
// 根据名字获取锁实例
|
|||
lock = redissonClient.getLock(key); |
|||
if (lock != null) { |
|||
final boolean status = lock.tryLock(rlockInfo.waitTime(), rlockInfo.leaseTime(), rlockInfo.timeUnit()); |
|||
if (status) { |
|||
logger.info("锁获取成功,加锁成功 : {}........",key); |
|||
object = proceedingJoinPoint.proceed(); |
|||
} else { |
|||
logger.info("锁被占用,加锁失败 : {} .........",key); |
|||
throw new RuntimeException("加锁失败"); |
|||
} |
|||
} |
|||
} finally { |
|||
// 方法执行完成释放锁
|
|||
if (lock != null && lock.isHeldByCurrentThread()) { |
|||
lock.unlock(); |
|||
} |
|||
} |
|||
return object; |
|||
} |
|||
|
|||
public Rlock getRlockInfo(ProceedingJoinPoint proceedingJoinPoint) { |
|||
MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature(); |
|||
return methodSignature.getMethod().getAnnotation(Rlock.class); |
|||
} |
|||
|
|||
/** |
|||
* @param proceedingJoinPoint |
|||
* @return |
|||
*/ |
|||
public String getLocalKey(ProceedingJoinPoint proceedingJoinPoint, Rlock rlockInfo) { |
|||
StringBuilder localKey = new StringBuilder(); |
|||
//获取注解参数值
|
|||
String prefix = rlockInfo.prefix(); |
|||
String spELString = rlockInfo.suffix(); |
|||
String key = generateKeyBySpEL(spELString,proceedingJoinPoint); |
|||
localKey.append(prefix).append(key); |
|||
logger.info("加锁 key :{}",localKey.toString()); |
|||
return localKey.toString(); |
|||
} |
|||
|
|||
public String generateKeyBySpEL(String spELString, ProceedingJoinPoint joinPoint) { |
|||
// 通过joinPoint获取被注解方法
|
|||
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); |
|||
Method method = methodSignature.getMethod(); |
|||
// 使用spring的DefaultParameterNameDiscoverer获取方法形参名数组
|
|||
String[] paramNames = nameDiscoverer.getParameterNames(method); |
|||
// 解析过后的Spring表达式对象
|
|||
Expression expression = parser.parseExpression(spELString); |
|||
// spring的表达式上下文对象
|
|||
EvaluationContext context = new StandardEvaluationContext(); |
|||
// 通过joinPoint获取被注解方法的形参
|
|||
Object[] args = joinPoint.getArgs(); |
|||
// 给上下文赋值
|
|||
for(int i = 0 ; i < args.length ; i++) { |
|||
context.setVariable(paramNames[i], args[i]); |
|||
} |
|||
// 表达式从上下文中计算出实际参数值
|
|||
return expression.getValue(context).toString(); |
|||
} |
|||
} |
|||
@ -1,61 +0,0 @@ |
|||
package com.base.springcloud.aspect.config; |
|||
|
|||
|
|||
import com.base.springcloud.constant.FastJson2JsonRedisSerializer; |
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|||
import com.fasterxml.jackson.annotation.PropertyAccessor; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.redisson.Redisson; |
|||
import org.redisson.config.Config; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.cache.annotation.CachingConfigurerSupport; |
|||
import org.springframework.cache.annotation.EnableCaching; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.data.redis.connection.RedisConnectionFactory; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.serializer.StringRedisSerializer; |
|||
|
|||
@Configuration |
|||
@EnableCaching |
|||
public class RedisConfig extends CachingConfigurerSupport { |
|||
|
|||
@Value("${spring.redis.host}") |
|||
private String host; |
|||
|
|||
@Value("${spring.redis.port}") |
|||
private String port; |
|||
|
|||
@Value("${spring.redis.password}") |
|||
private String password; |
|||
|
|||
@Bean |
|||
@SuppressWarnings(value = {"unchecked", "rawtypes"}) |
|||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { |
|||
RedisTemplate<Object, Object> template = new RedisTemplate<>(); |
|||
template.setConnectionFactory(redisConnectionFactory); |
|||
|
|||
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); |
|||
|
|||
ObjectMapper mapper = new ObjectMapper(); |
|||
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
|||
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); |
|||
serializer.setObjectMapper(mapper); |
|||
|
|||
template.setValueSerializer(serializer); |
|||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
|||
template.setKeySerializer(new StringRedisSerializer()); |
|||
template.afterPropertiesSet(); |
|||
return template; |
|||
} |
|||
|
|||
@Bean |
|||
public Redisson redisson() { |
|||
Config config = new Config(); |
|||
config.useSingleServer().setAddress("redis://" + host + ":" + port); |
|||
config.useSingleServer().setPassword(password); |
|||
// 设置1秒钟ping一次来维持连接
|
|||
config.useSingleServer().setPingConnectionInterval(1000); |
|||
return (Redisson) Redisson.create(config); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.base.springcloud.bo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class DepartBO { |
|||
|
|||
// 创建人Id
|
|||
private String createId; |
|||
|
|||
// 商户支付配置Id
|
|||
private String merchantConfigureId; |
|||
|
|||
// 部门id集合
|
|||
private List<String> departIdList; |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.entity.Depart; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Repository |
|||
public interface DepartMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(Depart record); |
|||
|
|||
int insertSelective(Depart record); |
|||
|
|||
Depart selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(Depart record); |
|||
|
|||
int updateByPrimaryKey(Depart record); |
|||
|
|||
List<String> getUserDepart(@Param("userId")String useId); |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package com.base.springcloud.dao; |
|||
|
|||
import com.base.springcloud.entity.PayDepartConfig; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public interface PayDepartConfigMapper { |
|||
int deleteByPrimaryKey(String id); |
|||
|
|||
int insert(PayDepartConfig record); |
|||
|
|||
int insertSelective(PayDepartConfig record); |
|||
|
|||
PayDepartConfig selectByPrimaryKey(String id); |
|||
|
|||
int updateByPrimaryKeySelective(PayDepartConfig record); |
|||
|
|||
int updateByPrimaryKey(PayDepartConfig record); |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class Depart { |
|||
private String id; |
|||
|
|||
private String parentId; |
|||
|
|||
private String departName; |
|||
|
|||
private String departNameEn; |
|||
|
|||
private String departNameAbbr; |
|||
|
|||
private Integer departOrder; |
|||
|
|||
private String description; |
|||
|
|||
private String orgCategory; |
|||
|
|||
private String orgType; |
|||
|
|||
private String orgCode; |
|||
|
|||
private String mobile; |
|||
|
|||
private String fax; |
|||
|
|||
private String address; |
|||
|
|||
private String memo; |
|||
|
|||
private String status; |
|||
|
|||
private String delFlag; |
|||
|
|||
private String createBy; |
|||
|
|||
private Date createTime; |
|||
|
|||
private String updateBy; |
|||
|
|||
private Date updateTime; |
|||
|
|||
private String ctCompanyId; |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
package com.base.springcloud.entity; |
|||
|
|||
import java.util.Date; |
|||
|
|||
public class PayDepartConfig { |
|||
private String id; |
|||
|
|||
private String mechantConfigId; |
|||
|
|||
private String departId; |
|||
|
|||
private String createId; |
|||
|
|||
private Date createTime; |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getMechantConfigId() { |
|||
return mechantConfigId; |
|||
} |
|||
|
|||
public void setMechantConfigId(String mechantConfigId) { |
|||
this.mechantConfigId = mechantConfigId; |
|||
} |
|||
|
|||
public String getDepartId() { |
|||
return departId; |
|||
} |
|||
|
|||
public void setDepartId(String departId) { |
|||
this.departId = departId; |
|||
} |
|||
|
|||
public String getCreateId() { |
|||
return createId; |
|||
} |
|||
|
|||
public void setCreateId(String createId) { |
|||
this.createId = createId; |
|||
} |
|||
|
|||
public Date getCreateTime() { |
|||
return createTime; |
|||
} |
|||
|
|||
public void setCreateTime(Date createTime) { |
|||
this.createTime = createTime; |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package com.base.springcloud.service; |
|||
|
|||
import com.base.springcloud.bo.DepartBO; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface DepartService { |
|||
|
|||
/** |
|||
* 获取用户部门 |
|||
* @param userId |
|||
* @return |
|||
*/ |
|||
List<String> getUserDepart(String userId); |
|||
|
|||
/** |
|||
* 保存商户部门信息 |
|||
* @param departBO |
|||
*/ |
|||
void savePayDepart(DepartBO departBO); |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
package com.base.springcloud.service.imp; |
|||
|
|||
import com.base.springcloud.aspect.annotation.BusinessException; |
|||
import com.base.springcloud.bo.DepartBO; |
|||
import com.base.springcloud.constant.ErrorConstant; |
|||
import com.base.springcloud.dao.DepartMapper; |
|||
import com.base.springcloud.dao.PayDepartConfigMapper; |
|||
import com.base.springcloud.entity.PayDepartConfig; |
|||
import com.base.springcloud.service.DepartService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Optional; |
|||
import java.util.UUID; |
|||
|
|||
@Service |
|||
public class DepartServiceImp implements DepartService { |
|||
|
|||
Logger logger = LoggerFactory.getLogger(DepartServiceImp.class); |
|||
|
|||
@Autowired |
|||
private DepartMapper departMapper; |
|||
|
|||
@Autowired |
|||
private PayDepartConfigMapper payDepartConfigMapper; |
|||
|
|||
/** |
|||
* 获取用户部门 |
|||
* @param userId |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<String> getUserDepart(String userId) { |
|||
return departMapper.getUserDepart(userId); |
|||
} |
|||
|
|||
/** |
|||
* 保存商户部门信息 |
|||
* @param departBO |
|||
*/ |
|||
@Override |
|||
public void savePayDepart(DepartBO departBO) { |
|||
List<String> departIdList = departBO.getDepartIdList(); |
|||
if(!Optional.ofNullable(departIdList).isPresent()) |
|||
throw new BusinessException(ErrorConstant.USER_DEPART_RELATION_NEED); |
|||
for (String depart : departIdList){ |
|||
PayDepartConfig payDepartConfig = new PayDepartConfig(); |
|||
payDepartConfig.setId(UUID.randomUUID().toString().replace("-", "")); |
|||
payDepartConfig.setCreateId(departBO.getCreateId()); |
|||
payDepartConfig.setCreateTime(new Date()); |
|||
payDepartConfig.setDepartId(depart); |
|||
payDepartConfig.setMechantConfigId(departBO.getMerchantConfigureId()); |
|||
int count = payDepartConfigMapper.insert(payDepartConfig); |
|||
if(count < 1) |
|||
throw new BusinessException(ErrorConstant.SAVE_PAY_DEPART_CONFIG_FAIL); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,292 @@ |
|||
<?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.base.springcloud.dao.DepartMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.Depart"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="parent_id" jdbcType="VARCHAR" property="parentId" /> |
|||
<result column="depart_name" jdbcType="VARCHAR" property="departName" /> |
|||
<result column="depart_name_en" jdbcType="VARCHAR" property="departNameEn" /> |
|||
<result column="depart_name_abbr" jdbcType="VARCHAR" property="departNameAbbr" /> |
|||
<result column="depart_order" jdbcType="INTEGER" property="departOrder" /> |
|||
<result column="description" jdbcType="VARCHAR" property="description" /> |
|||
<result column="org_category" jdbcType="VARCHAR" property="orgCategory" /> |
|||
<result column="org_type" jdbcType="VARCHAR" property="orgType" /> |
|||
<result column="org_code" jdbcType="VARCHAR" property="orgCode" /> |
|||
<result column="mobile" jdbcType="VARCHAR" property="mobile" /> |
|||
<result column="fax" jdbcType="VARCHAR" property="fax" /> |
|||
<result column="address" jdbcType="VARCHAR" property="address" /> |
|||
<result column="memo" jdbcType="VARCHAR" property="memo" /> |
|||
<result column="status" jdbcType="VARCHAR" property="status" /> |
|||
<result column="del_flag" jdbcType="VARCHAR" property="delFlag" /> |
|||
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
|||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
|||
<result column="ct_company_id" jdbcType="VARCHAR" property="ctCompanyId" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, parent_id, depart_name, depart_name_en, depart_name_abbr, depart_order, description, |
|||
org_category, org_type, org_code, mobile, fax, address, memo, status, del_flag, create_by, |
|||
create_time, update_by, update_time, ct_company_id |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from sys_depart |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from sys_depart |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.Depart"> |
|||
insert into sys_depart (id, parent_id, depart_name, |
|||
depart_name_en, depart_name_abbr, depart_order, |
|||
description, org_category, org_type, |
|||
org_code, mobile, fax, |
|||
address, memo, status, |
|||
del_flag, create_by, create_time, |
|||
update_by, update_time, ct_company_id |
|||
) |
|||
values (#{id,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{departName,jdbcType=VARCHAR}, |
|||
#{departNameEn,jdbcType=VARCHAR}, #{departNameAbbr,jdbcType=VARCHAR}, #{departOrder,jdbcType=INTEGER}, |
|||
#{description,jdbcType=VARCHAR}, #{orgCategory,jdbcType=VARCHAR}, #{orgType,jdbcType=VARCHAR}, |
|||
#{orgCode,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{fax,jdbcType=VARCHAR}, |
|||
#{address,jdbcType=VARCHAR}, #{memo,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, |
|||
#{delFlag,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
|||
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{ctCompanyId,jdbcType=VARCHAR} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.Depart"> |
|||
insert into sys_depart |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="parentId != null"> |
|||
parent_id, |
|||
</if> |
|||
<if test="departName != null"> |
|||
depart_name, |
|||
</if> |
|||
<if test="departNameEn != null"> |
|||
depart_name_en, |
|||
</if> |
|||
<if test="departNameAbbr != null"> |
|||
depart_name_abbr, |
|||
</if> |
|||
<if test="departOrder != null"> |
|||
depart_order, |
|||
</if> |
|||
<if test="description != null"> |
|||
description, |
|||
</if> |
|||
<if test="orgCategory != null"> |
|||
org_category, |
|||
</if> |
|||
<if test="orgType != null"> |
|||
org_type, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
org_code, |
|||
</if> |
|||
<if test="mobile != null"> |
|||
mobile, |
|||
</if> |
|||
<if test="fax != null"> |
|||
fax, |
|||
</if> |
|||
<if test="address != null"> |
|||
address, |
|||
</if> |
|||
<if test="memo != null"> |
|||
memo, |
|||
</if> |
|||
<if test="status != null"> |
|||
status, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
del_flag, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
create_by, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
update_by, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
update_time, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
ct_company_id, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="parentId != null"> |
|||
#{parentId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departName != null"> |
|||
#{departName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameEn != null"> |
|||
#{departNameEn,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameAbbr != null"> |
|||
#{departNameAbbr,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departOrder != null"> |
|||
#{departOrder,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="description != null"> |
|||
#{description,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCategory != null"> |
|||
#{orgCategory,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgType != null"> |
|||
#{orgType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
#{orgCode,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="mobile != null"> |
|||
#{mobile,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="fax != null"> |
|||
#{fax,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="address != null"> |
|||
#{address,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="memo != null"> |
|||
#{memo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="status != null"> |
|||
#{status,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
#{delFlag,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
#{createBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
#{updateBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
#{updateTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
#{ctCompanyId,jdbcType=VARCHAR}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.Depart"> |
|||
update sys_depart |
|||
<set> |
|||
<if test="parentId != null"> |
|||
parent_id = #{parentId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departName != null"> |
|||
depart_name = #{departName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameEn != null"> |
|||
depart_name_en = #{departNameEn,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departNameAbbr != null"> |
|||
depart_name_abbr = #{departNameAbbr,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departOrder != null"> |
|||
depart_order = #{departOrder,jdbcType=INTEGER}, |
|||
</if> |
|||
<if test="description != null"> |
|||
description = #{description,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCategory != null"> |
|||
org_category = #{orgCategory,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgType != null"> |
|||
org_type = #{orgType,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="orgCode != null"> |
|||
org_code = #{orgCode,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="mobile != null"> |
|||
mobile = #{mobile,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="fax != null"> |
|||
fax = #{fax,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="address != null"> |
|||
address = #{address,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="memo != null"> |
|||
memo = #{memo,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="status != null"> |
|||
status = #{status,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="delFlag != null"> |
|||
del_flag = #{delFlag,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createBy != null"> |
|||
create_by = #{createBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updateBy != null"> |
|||
update_by = #{updateBy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="updateTime != null"> |
|||
update_time = #{updateTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="ctCompanyId != null"> |
|||
ct_company_id = #{ctCompanyId,jdbcType=VARCHAR}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.Depart"> |
|||
update sys_depart |
|||
set parent_id = #{parentId,jdbcType=VARCHAR}, |
|||
depart_name = #{departName,jdbcType=VARCHAR}, |
|||
depart_name_en = #{departNameEn,jdbcType=VARCHAR}, |
|||
depart_name_abbr = #{departNameAbbr,jdbcType=VARCHAR}, |
|||
depart_order = #{departOrder,jdbcType=INTEGER}, |
|||
description = #{description,jdbcType=VARCHAR}, |
|||
org_category = #{orgCategory,jdbcType=VARCHAR}, |
|||
org_type = #{orgType,jdbcType=VARCHAR}, |
|||
org_code = #{orgCode,jdbcType=VARCHAR}, |
|||
mobile = #{mobile,jdbcType=VARCHAR}, |
|||
fax = #{fax,jdbcType=VARCHAR}, |
|||
address = #{address,jdbcType=VARCHAR}, |
|||
memo = #{memo,jdbcType=VARCHAR}, |
|||
status = #{status,jdbcType=VARCHAR}, |
|||
del_flag = #{delFlag,jdbcType=VARCHAR}, |
|||
create_by = #{createBy,jdbcType=VARCHAR}, |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
update_by = #{updateBy,jdbcType=VARCHAR}, |
|||
update_time = #{updateTime,jdbcType=TIMESTAMP}, |
|||
ct_company_id = #{ctCompanyId,jdbcType=VARCHAR} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<select id="getUserDepart" parameterType="java.lang.String" resultType="java.lang.String"> |
|||
select id |
|||
from sys_depart |
|||
where id in ( |
|||
select dep_id |
|||
from sys_user_depart |
|||
where user_id = #{userId,jdbcType=VARCHAR} |
|||
) |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,93 @@ |
|||
<?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.base.springcloud.dao.PayDepartConfigMapper"> |
|||
<resultMap id="BaseResultMap" type="com.base.springcloud.entity.PayDepartConfig"> |
|||
<id column="id" jdbcType="VARCHAR" property="id" /> |
|||
<result column="mechant_config_id" jdbcType="VARCHAR" property="mechantConfigId" /> |
|||
<result column="depart_id" jdbcType="VARCHAR" property="departId" /> |
|||
<result column="create_id" jdbcType="VARCHAR" property="createId" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
id, mechant_config_id, depart_id, create_id, create_time |
|||
</sql> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from pay_depart_config |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String"> |
|||
delete from pay_depart_config |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</delete> |
|||
<insert id="insert" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
insert into pay_depart_config (id, mechant_config_id, depart_id, |
|||
create_id, create_time) |
|||
values (#{id,jdbcType=VARCHAR}, #{mechantConfigId,jdbcType=VARCHAR}, #{departId,jdbcType=VARCHAR}, |
|||
#{createId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
insert into pay_depart_config |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="mechantConfigId != null"> |
|||
mechant_config_id, |
|||
</if> |
|||
<if test="departId != null"> |
|||
depart_id, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="mechantConfigId != null"> |
|||
#{mechantConfigId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departId != null"> |
|||
#{departId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
#{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
update pay_depart_config |
|||
<set> |
|||
<if test="mechantConfigId != null"> |
|||
mechant_config_id = #{mechantConfigId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="departId != null"> |
|||
depart_id = #{departId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createId != null"> |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="createTime != null"> |
|||
create_time = #{createTime,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.base.springcloud.entity.PayDepartConfig"> |
|||
update pay_depart_config |
|||
set mechant_config_id = #{mechantConfigId,jdbcType=VARCHAR}, |
|||
depart_id = #{departId,jdbcType=VARCHAR}, |
|||
create_id = #{createId,jdbcType=VARCHAR}, |
|||
create_time = #{createTime,jdbcType=TIMESTAMP} |
|||
where id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
</mapper> |
|||
Loading…
Reference in new issue