NorthLan 6 rokov pred
rodič
commit
42841064e5

+ 15 - 0
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/mapper/SysUploadInfoMapper.kt

@@ -0,0 +1,15 @@
+package com.gxzc.zen.api.sys.mapper
+
+import com.gxzc.zen.api.sys.model.SysUploadInfo
+import com.gxzc.zen.common.base.BaseMapper
+import org.springframework.stereotype.Repository
+/**
+ * <p>
+ * 上传文件信息表 Mapper 接口
+ * </p>
+ *
+ * @author NorthLan
+ * @since 2018-06-01
+ */
+@Repository
+interface SysUploadInfoMapper : BaseMapper<SysUploadInfo>

+ 46 - 0
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/service/ISysUploadInfoService.kt

@@ -0,0 +1,46 @@
+package com.gxzc.zen.api.sys.service
+
+import com.gxzc.zen.api.sys.model.SysUploadInfo
+import com.gxzc.zen.common.base.BaseService
+import com.gxzc.zen.common.dto.ZenFileMetadata
+import java.io.File
+
+/**
+ * <p>
+ * 上传文件信息表 服务类
+ * </p>
+ *
+ * @author NorthLan
+ * @since 2018-06-01
+ */
+interface ISysUploadInfoService : BaseService<SysUploadInfo> {
+    /**
+     * 添加文件数据
+     */
+    fun addUploadFileInfo(fileMetadata: ZenFileMetadata, file: File)
+
+    /**
+     * 获取某上传批次所有文件数据
+     */
+    fun getUploadInfosByBatchId(batchId: String): MutableList<SysUploadInfo>
+
+    /**
+     * 通过id获取单条 文件数据
+     */
+    fun getUploadInfoById(id: Long): SysUploadInfo?
+
+    /**
+     * 通过ids获取 文件数据 列表
+     */
+    fun getUploadInfoListByIdList(ids: Collection<Long>): MutableList<SysUploadInfo>
+
+    /**
+     * 通过id修改文件信息
+     */
+    fun modifyFileInfo(entity: SysUploadInfo): SysUploadInfo
+
+    /**
+     * 通过id批量修改文件信息
+     */
+    fun modifyBatchFileInfo(entityList: MutableList<SysUploadInfo>): MutableList<SysUploadInfo>
+}

+ 90 - 0
zen-api/src/main/kotlin/com/gxzc/zen/api/sys/service/impl/SysUploadInfoServiceImpl.kt

@@ -0,0 +1,90 @@
+package com.gxzc.zen.api.sys.service.impl
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper
+import com.baomidou.mybatisplus.service.impl.ServiceImpl
+import com.gxzc.zen.api.sys.mapper.SysUploadInfoMapper
+import com.gxzc.zen.api.sys.model.SysUploadInfo
+import com.gxzc.zen.api.sys.service.ISysUploadInfoService
+import com.gxzc.zen.common.dto.ZenFileMetadata
+import org.apache.commons.io.FilenameUtils
+import org.springframework.stereotype.Service
+import java.io.File
+import java.util.*
+
+/**
+ * <p>
+ * 上传文件信息表 服务实现类
+ * </p>
+ *
+ * @author NorthLan
+ * @since 2018-06-01
+ */
+@Service
+class SysUploadInfoServiceImpl : ServiceImpl<SysUploadInfoMapper, SysUploadInfo>(), ISysUploadInfoService {
+    override fun addUploadFileInfo(fileMetadata: ZenFileMetadata, file: File) {
+        val entity = SysUploadInfo().apply {
+            // filename
+            this.filename = if (fileMetadata.rename.isNullOrEmpty()) {
+                fileMetadata.filename
+            } else {
+                "${FilenameUtils.removeExtension(fileMetadata.rename)}.${FilenameUtils.getExtension(fileMetadata.filename)}"
+            }
+            this.realFilename = file.name
+            this.originFilename = fileMetadata.filename
+            // infomation
+            this.relativePath = if (fileMetadata.repath.isNullOrEmpty()) fileMetadata.relativePath?.replace(this.originFilename!!, "") else fileMetadata.repath
+            this.batchId = fileMetadata.batchId
+            this.lastModified = Date(file.lastModified())
+            this.md5 = fileMetadata.md5
+            this.extension = FilenameUtils.getExtension(file.name)
+            this.filesize = fileMetadata.totalSize
+        }
+        baseMapper.insert(entity)
+    }
+
+    override fun getUploadInfosByBatchId(batchId: String): MutableList<SysUploadInfo> {
+        val condition = SysUploadInfo().apply { this.batchId = batchId }
+        val ret = baseMapper.selectWOLogic(EntityWrapper(condition))
+        ret.forEach {
+            generateURL(it)
+        }
+        return ret
+    }
+
+    private fun generateURL(it: SysUploadInfo?) {
+        if (it != null) {
+            it.url = "/${it.realFilename}"
+//            if (it.relativePath.isNullOrEmpty()) {
+//                it.url = FilenameUtils.normalize("/${it.filename}")
+//            } else {
+//                it.url = FilenameUtils.normalize("/${it.relativePath}/${it.filename}")
+//            }
+        }
+    }
+
+    override fun getUploadInfoById(id: Long): SysUploadInfo? {
+        val condition = SysUploadInfo().apply { this.id = id }
+        return baseMapper.selectOne(condition).apply {
+            generateURL(this)
+        }
+    }
+
+    override fun getUploadInfoListByIdList(ids: Collection<Long>): MutableList<SysUploadInfo> {
+        val ret = baseMapper.selectWOLogic(EntityWrapper<SysUploadInfo>().`in`("id", ids))
+        ret.forEach {
+            generateURL(it)
+        }
+        return ret
+    }
+
+    override fun modifyFileInfo(entity: SysUploadInfo): SysUploadInfo {
+        this.updateById(entity)
+        return getUploadInfoById(entity.id!!)!!
+    }
+
+    override fun modifyBatchFileInfo(entityList: MutableList<SysUploadInfo>): MutableList<SysUploadInfo> {
+        this.updateBatchById(entityList)
+        return getUploadInfoListByIdList(entityList.map { it.id!! }.toList())
+    }
+
+}

+ 19 - 0
zen-api/src/main/kotlin/com/gxzc/zen/rpc/api/sys/RParamService.kt

@@ -0,0 +1,19 @@
+package com.gxzc.zen.rpc.api.sys
+
+import com.gxzc.zen.api.sys.model.SysParam
+
+/**
+ * 系统参数 RPC 接口
+ * @author NorthLan
+ * @date 2018/7/10
+ * @url https://noahlan.com
+ */
+interface RParamService {
+
+    /**
+     * 通过Key获取SysParam
+     * @param key key
+     * @param enabled 是否启用(逻辑删)
+     */
+    fun getByKey(key: String, enabled: Boolean = true): SysParam?
+}

+ 19 - 0
zen-api/src/main/kotlin/com/gxzc/zen/rpc/api/sys/RUserService.kt

@@ -0,0 +1,19 @@
+package com.gxzc.zen.rpc.api.sys
+
+import com.gxzc.zen.rpc.model.sys.RUserInfo
+
+/**
+ *
+ * @author NorthLan
+ * @date 2018/7/12
+ * @url https://noahlan.com
+ */
+interface RUserService {
+
+    /**
+     * 获取指定角色的所有用户信息列表
+     * 通过 角色代码 获取用户列表
+     * @param code 角色代码
+     */
+    fun getUserListByRoleCode(code: String): MutableList<RUserInfo>
+}

+ 19 - 0
zen-api/src/main/kotlin/com/gxzc/zen/rpc/model/sys/RUserInfo.kt

@@ -0,0 +1,19 @@
+package com.gxzc.zen.rpc.model.sys
+
+import java.io.Serializable
+
+/**
+ *
+ * @author NorthLan
+ * @date 2018/7/12
+ * @url https://noahlan.com
+ */
+open class RUserInfo : Serializable {
+    companion object {
+        private val serialVersionUID = 10000000000002L
+    }
+
+    private var id: Long? = null
+    private var account: String? = null
+    private var username: String? = null
+}

+ 29 - 0
zen-api/src/main/resources/mapping/sys/SysUploadInfoMapper.xml

@@ -0,0 +1,29 @@
+<?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.gxzc.zen.api.sys.mapper.SysUploadInfoMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.gxzc.zen.api.sys.model.SysUploadInfo">
+    <result column="id" property="id" />
+    <result column="enable" property="enable" />
+    <result column="remark" property="remark" />
+    <result column="create_time" property="createTime" />
+    <result column="create_by" property="createBy" />
+    <result column="update_time" property="updateTime" />
+    <result column="update_by" property="updateBy" />
+        <result column="filename" property="filename" />
+        <result column="real_filename" property="realFilename" />
+        <result column="origin_filename" property="originFilename" />
+        <result column="relative_path" property="relativePath" />
+        <result column="batch_id" property="batchId" />
+        <result column="last_modified" property="lastModified" />
+        <result column="md5" property="md5" />
+        <result column="extension" property="extension" />
+        <result column="filesize" property="filesize" />
+        <result column="ext1" property="ext1" />
+        <result column="ext2" property="ext2" />
+        <result column="ext3" property="ext3" />
+        <result column="ext4" property="ext4" />
+    </resultMap>
+
+</mapper>