Переглянути джерело

逻辑删除与全局自动注入ok

NorthLan 7 роки тому
батько
коміт
ece98cc7d0

+ 1 - 0
.gitignore

@@ -136,6 +136,7 @@ rebel.xml
 log/
 logs/
 *.log
+*.log.*
 
 
 # IntelliJ IDEA

+ 1 - 1
build.gradle

@@ -17,7 +17,7 @@ buildscript {
         ehcache_core_version = '2.6.11'
         mysql_connector_version = '5.1.45'
         alidruid_version = '1.1.6'
-        mybatis_plus_version = '2.1.8'
+        mybatis_plus_version = '2.1.9'
         mybatis_plus_boot_version = '1.0.5'
         activiti_starter_version = '6.0.0'
 //        rabbitmq_version = '5.1.2'

+ 1 - 1
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/service/impl/SysUserRoleServiceImpl.kt

@@ -31,7 +31,7 @@ class SysUserRoleServiceImpl : ServiceImpl<SysUserRoleMapper, SysUserRole>(), IS
     }
 
     override fun getUserRoleList(): Map<Long, MutableList<SysRole>> {
-        val allSysUserRole = baseMapper.selectList(EntityWrapper<SysUserRole>())
+        val allSysUserRole = baseMapper.selectList(null)
         val groupUserRole = allSysUserRole.groupBy({ it.userId }, { it.roleId })
         val result = mutableMapOf<Long, MutableList<SysRole>>()
         for (item in groupUserRole) {

+ 9 - 0
zen-orm/src/main/kotlin/com/gxzc/zen/orm/config/MybatisPlusConfig.kt

@@ -1,5 +1,6 @@
 package com.gxzc.zen.orm.config
 
+import com.baomidou.mybatisplus.mapper.LogicSqlInjector
 import com.baomidou.mybatisplus.plugins.PaginationInterceptor
 import com.baomidou.mybatisplus.plugins.PerformanceInterceptor
 import org.mybatis.spring.annotation.MapperScan
@@ -33,4 +34,12 @@ class MybatisPlusConfig {
     fun paginationInterceptor(): PaginationInterceptor {
         return PaginationInterceptor()
     }
+//
+//    /**
+//     * 逻辑删插件
+//     */
+//    @Bean
+//    fun logicSqlInjector(): LogicSqlInjector {
+//        return LogicSqlInjector()
+//    }
 }

+ 4 - 2
zen-web/src/main/kotlin/com/gxzc/zen/web/sys/controller/TestController.kt

@@ -5,6 +5,7 @@ import com.baomidou.kisso.annotation.Login
 import com.gxzc.zen.api.sys.model.SysDic
 import com.gxzc.zen.api.sys.service.ISysDicService
 import com.gxzc.zen.common.base.BaseController
+import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.web.bind.annotation.GetMapping
 import org.springframework.web.bind.annotation.PutMapping
 import org.springframework.web.bind.annotation.RequestMapping
@@ -20,15 +21,16 @@ import org.springframework.web.bind.annotation.RestController
 @RequestMapping("test")
 class TestController : BaseController() {
 
+    @Autowired
     private lateinit var sysDicService: ISysDicService
 
     @GetMapping("logicDel")
     @Login(action = Action.Skip)
     fun testLogicDelete() {
-        sysDicService.deleteById(4)
+        sysDicService.deleteById(4L)
     }
 
-    @PutMapping
+    @PutMapping("metaObject")
     @Login(action = Action.Skip)
     fun testCustomMetaObjectHandler() {
         sysDicService.updateById(SysDic().apply {

+ 3 - 3
zen-web/src/main/resources/application-orm.yml

@@ -72,13 +72,13 @@ datasource:
 ###################  mybatis-plus配置  ###################
 mybatis-plus:
   mapper-locations: classpath*:mapping/**/*.xml
-  type-aliases-package: com.gxzc.zen.api.bus.mapper,com.gxzc.zen.api.sys.mapper
+  type-aliases-package: com.gxzc.zen.api.bus.mapper,com.gxzc.zen.api.sys.mapper,com.gxzc.zen.api.bus.mapper,com.gxzc.zen.api.bus.mapper
   global-config:
     id-type: 0  #0:数据库ID自增   1:用户输入id  2:全局唯一id(IdWorker)  3:全局唯一ID(uuid)
     db-column-underline: true
     refresh-mapper: true
-    # logic-delete-value: 0
-    # logic-not-delete-value: 1
+    logic-delete-value: 0
+    logic-not-delete-value: 1
     sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
     meta-object-handler: com.gxzc.zen.orm.CustomMetaObjectHandler
   configuration: