Browse Source

Merge branch 'dev' of http://git.elinkit.com.cn:7070/r/epmet-cloud into pingyin_master

 Conflicts:
	epmet-user/epmet-user-server/src/main/java/com/epmet/util/MySequence.java
master
jianjun 3 years ago
parent
commit
52b2034261
  1. 27
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java
  2. 17
      epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java

27
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/config/MybatisPlusConfig.java

@ -1,29 +1,38 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* <p>
* https://www.renren.io
*
* <p>
* 版权所有侵权必究
*/
package com.epmet.commons.mybatis.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.epmet.commons.mybatis.interceptor.DataFilterInterceptor;
import com.epmet.commons.tools.redis.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import java.util.Random;
/**
* mybatis-plus配置
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Slf4j
@Configuration
public class MybatisPlusConfig {
@Autowired
private RedisUtils redisUtils;
/**
* 配置数据权限
@ -45,4 +54,18 @@ public class MybatisPlusConfig {
return interceptor;
}
/**
* id生成器指定2个参数 防止id重复
*/
@Bean
@Order(0)
public DefaultIdentifierGenerator myIdentifierGenerator() {
Random random = new Random();
int workerId = random.nextInt(30) + 1;
int dataCenterId = random.nextInt(30) + 1;
DefaultIdentifierGenerator interceptor = new DefaultIdentifierGenerator(workerId, dataCenterId);
log.info("workerId:{},dataCenterId:{}", workerId, dataCenterId);
return interceptor;
}
}

17
epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/UserControllerTest.java

@ -1,7 +1,10 @@
package com.epmet.epmetuser.test;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.dao.UserDao;
import com.epmet.dto.result.LoginUserDetailsResultDTO;
import com.epmet.entity.UserEntity;
import com.epmet.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -15,11 +18,25 @@ public class UserControllerTest {
@Autowired
private UserService userService;
@Autowired
private UserDao userDao;
@Test
public void getLoginUserDetails() {
LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, "4aaab913d9f11d90a2cb4dd21b075259");
System.out.println(loginUserDetails);
}
@Test
public void insertUser() {
UserEntity entity = new UserEntity();
entity.setCustomerId("test_ljj");
String idStr = IdWorker.getIdStr();
System.out.println(idStr);
//int insert = userDao.insert(entity);
//System.out.println(insert);
}
}

Loading…
Cancel
Save