整合mybatis-plus

master
星期八 5 years ago
parent 02a15977ab
commit 411cd3f1b4
  1. 12
      pom.xml
  2. 27
      src/main/java/com/lq/cms/emun/BasicsPermissionKeyEnum.java
  3. 4
      src/main/java/com/lq/code/dto/QueueDto.java
  4. 4
      src/main/java/com/lq/code/entity/IdEntity.java
  5. 2
      src/main/java/com/lq/code/executor/processor/InstantiationTracingBeanPostProcessor.java
  6. 6
      src/main/resources/mybatis/mapping/SysUserDao.xml
  7. 2
      src/main/resources/mybatis/mybatis-config.xml
  8. 1
      src/main/webapp/WEB-INF/views/jsp/cms/sys/permission/index.jsp
  9. 10
      src/test/java/com/lq/BaseTest.java
  10. 57
      src/test/java/com/lq/SysPermissionServiceTest.java

@ -67,7 +67,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<!-- 表示开发的时候引入,发布的时候不会加载此包 -->
<scope>test</scope>
</dependency>
@ -512,6 +512,7 @@
<groupId>com.github.jsonzou</groupId>
<artifactId>jmockdata</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
@ -521,6 +522,15 @@
<version>2.6.2</version>
</dependency>
<!-- 国产工具类 hutool-->
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.6.3</version>
</dependency>
</dependencies>
<build>

@ -1,5 +1,8 @@
package com.lq.cms.emun;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: qi
* @Description:
@ -7,22 +10,25 @@ package com.lq.cms.emun;
*/
public enum BasicsPermissionKeyEnum {
SELECT_MENU_KEY("SELECT_MENU_KEY","查看菜单"),
SELECT_DATA_KEY("SELECT_DATA_KEY","查询全部数据"),
INSERT_KEY("INSERT_KEY","新增数据权限"),
UPDATE_key("UPDATE_key","更新数据权限"),
DELETE_KEY("DELETE_KEY","删除数据权限")
SELECT_MENU_KEY("SELECT_MENU_KEY","查看菜单","SELECT"),
SELECT_DATA_KEY("SELECT_DATA_KEY","查询全部数据","SELECT"),
INSERT_KEY("INSERT_KEY","新增数据","INSERT"),
UPDATE_key("UPDATE_key","更新数据","UPDATE"),
DELETE_KEY("DELETE_KEY","删除数据","DELETE")
;
BasicsPermissionKeyEnum(String value, String desc) {
BasicsPermissionKeyEnum(String value, String desc,String type) {
this.value = value;
this.desc = desc;
this.type = type;
}
private String value;
private String desc;
private String type;
public String getValue() {
return value;
}
@ -38,4 +44,11 @@ public enum BasicsPermissionKeyEnum {
public void setDesc(String desc) {
this.desc = desc;
}
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}}

@ -1,11 +1,7 @@
package com.lq.code.dto;
import com.github.jsonzou.jmockdata.JMockData;
import com.lq.entity.SysUser;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Author: qi

@ -1,9 +1,12 @@
package com.lq.code.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.lq.code.util.BeanUtil;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.List;
/**
@ -14,6 +17,7 @@ public class IdEntity implements Serializable {
/**
* 数据id
*/
@TableId(type = IdType.AUTO)
protected Long id;
/**
* 数据状态与业务逻辑无关

@ -45,7 +45,7 @@ public class InstantiationTracingBeanPostProcessor implements ApplicationListene
//扫描实体类
if (isUpdateDB) {
Set<Class> set = BeanUtil.getClassSet(packagePath);
QueueDto<Class> queueDto = BeanUtil.getQueueDto(packagePath);
// QueueDto<Class> queueDto = BeanUtil.getQueueDto(packagePath);
DbBuilerFactory dbBuilerFactory = new DefaultDbBuilerFactory();
AbstractDbBuiler dbBuiler = dbBuilerFactory.getSqlBuilder(SqlConstant.DB_TYPE_MYSQL);
String sql = dbBuiler.automaticUpdateDb(set);

@ -18,6 +18,12 @@
AND status = 1
</select>
<select id="findAll" resultType="SysUser">
select <include refid="column_list"/>
FROM sys_user
where status = 1
</select>
<select id="findByEmail" resultType="SysUser">
SELECT <include refid="column_list"/>
FROM sys_user

@ -23,6 +23,8 @@
<property name="dialect" value="mysql"/>
<property name="pageSqlId" value=".*ListPage.*"/>
</plugin>
<plugin interceptor="com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor">
</plugin>
</plugins>
</configuration>

@ -58,6 +58,7 @@
</body>
<script type="text/javascript">
function openEdit(title,id) {
console.log(id);
var url='edit';
if(id!=null){
url=url+'?id='+id;

@ -0,0 +1,10 @@
package com.lq;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(value = {"/spring-mybatis-config.xml","/spring-import.xml"})
public class BaseTest {
}

@ -0,0 +1,57 @@
package com.lq;
import com.lq.cms.emun.BasicsPermissionKeyEnum;
import com.lq.cms.emun.StatusTypeEnum;
import com.lq.dao.SysPermissionDao;
import com.lq.dao.SysResourceDao;
import com.lq.dao.SysUserDao;
import com.lq.entity.SysPermission;
import com.lq.entity.SysResource;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class SysPermissionServiceTest extends BaseTest {
@Autowired
private SysUserDao sysUserDao;
@Autowired
private SysPermissionDao sysPermissionDao;
@Autowired
private SysResourceDao sysResourceDao;
@Test
public void test(){
//1.查询所有菜单
List<SysResource> sysResourceList = sysResourceDao.findAll();
//2.构建基本的权限
// List<SysPermission> sysPermissionList = new ArrayList<>();
BasicsPermissionKeyEnum[] basicsPermissionKeyEnums = BasicsPermissionKeyEnum.values();
sysResourceList.forEach((sysResource)->{
for (BasicsPermissionKeyEnum basicsPermissionKeyEnum:basicsPermissionKeyEnums){
SysPermission sysPermission = new SysPermission();
sysPermission.setStatus(StatusTypeEnum.STATUS_ACTIVITY_YES.getValue());
sysPermission.setSysResourceId(sysResource.getId());
sysPermission.setName(basicsPermissionKeyEnum.getDesc());
sysPermission.setPermissionKey(basicsPermissionKeyEnum.getValue());
sysPermission.setPermissionType(basicsPermissionKeyEnum.getType());
sysPermission.setCreateTime(new Date());
sysPermission.setCreateUserId(1L);
sysPermission.setUpdateTime(new Date());
sysPermission.setUpdateUserId(1L);
// sysPermissionList.add(sysPermission);
sysPermissionDao.save(sysPermission);
}
});
//3.权限入库
// sysPermissionDao.batchSave(sysPermissionList);
}
}
Loading…
Cancel
Save