From 4988e04e82e530137da576c456871cc621483b12 Mon Sep 17 00:00:00 2001
From: 刘小明 <liuxm_a@163.com>
Date: 星期一, 14 十月 2024 15:51:18 +0800
Subject: [PATCH] 优化文件管理controller相关功能

---
 /dev/null                                                                             |   59 -------
 pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageCtrl.java |   69 ++++++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileManageMapper.java  |   37 ++++
 pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFileManage.java       |   38 ++++
 pms-parent/pms-global/src/main/resources/mapper/OthFileManageMapper.xml               |  130 ++++++++++++++++
 pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageSv.java   |  101 ++++++++++++
 pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/QueryVo.java        |   14 +
 7 files changed, 389 insertions(+), 59 deletions(-)

diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileManageMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileManageMapper.java
new file mode 100644
index 0000000..a936dbd
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileManageMapper.java
@@ -0,0 +1,37 @@
+package com.dy.pmsGlobal.daoOth;
+
+import com.dy.pmsGlobal.pojoOth.OthFileManage;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface OthFileManageMapper {
+    int deleteByPrimaryKey(@Param("id") Long id, @Param("userId") Long userId);
+
+    int insert(OthFileManage record);
+
+    int insertSelective(OthFileManage record);
+
+    OthFileManage selectByPrimaryKey(@Param("id") Long id, @Param("userId") Long userId);
+
+    int updateByPrimaryKeySelective(OthFileManage record);
+
+    int updateByPrimaryKey(OthFileManage record);
+
+    int deleteByPrimaryKey(Long id);
+    /**
+     * 閫昏緫鍒犻櫎
+     * @param id primaryKey
+     * @return update count
+     */
+    int deleteLogicById(Long id);
+
+    OthFileManage selectByPrimaryKey(Long id);
+
+    List<OthFileManage> selectSome(Map<String, Object> params);
+
+    Long selectSomeCount(Map<String, Object> params);
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthNetSerialAdapterFileMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthNetSerialAdapterFileMapper.java
deleted file mode 100644
index 74ae36d..0000000
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthNetSerialAdapterFileMapper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.dy.pmsGlobal.daoOth;
-
-import com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile;
-import org.apache.ibatis.annotations.Mapper;
-
-@Mapper
-public interface OthNetSerialAdapterFileMapper {
-    int deleteByPrimaryKey(Long id);
-
-    int insert(OthNetSerialAdapterFile record);
-
-    int insertSelective(OthNetSerialAdapterFile record);
-
-    OthNetSerialAdapterFile selectByPrimaryKey(Long id);
-
-    int updateByPrimaryKeySelective(OthNetSerialAdapterFile record);
-
-    int updateByPrimaryKey(OthNetSerialAdapterFile record);
-
-    OthNetSerialAdapterFile getAdapter();
-}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFileManage.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFileManage.java
new file mode 100644
index 0000000..5b14996
--- /dev/null
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFileManage.java
@@ -0,0 +1,38 @@
+package com.dy.pmsGlobal.pojoOth;
+
+import com.baomidou.mybatisplus.annotation.TableField;import java.util.Date;
+
+/**
+ * 鏂囦欢涓婁紶涓嬭浇鐢� 琛�
+ */
+public class OthFileManage {
+
+    public Long id;
+
+    public Long userId;
+
+    /**
+     * 鏂囦欢缂栧彿
+     */
+    public Long fileId;
+
+    /**
+     * 鏄惁鍒犻櫎锛�1鏄紝0鍚�
+     */
+    public Boolean deleted;
+
+    /**
+     * 涓婁紶鏃堕棿
+     */
+    public Date dt;
+
+    @TableField(exist = false)
+    public String webUrl;
+    @TableField(exist = false)
+    public String orgName;
+    @TableField(exist = false)
+    public String extName;
+    @TableField(exist = false)
+    public String userName;
+
+}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthNetSerialAdapterFile.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthNetSerialAdapterFile.java
deleted file mode 100644
index b1abc14..0000000
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthNetSerialAdapterFile.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.dy.pmsGlobal.pojoOth;
-
-import com.alibaba.fastjson2.annotation.JSONField;
-import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.dy.common.po.BaseEntity;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import jakarta.validation.constraints.NotNull;
-import lombok.*;
-
-import java.util.Date;
-
-/**
- * 缃戜覆涓棿浠朵笅杞借〃
- */
-@TableName(value="oth_net_serial_adapter_file", autoResultMap = true)
-@Data
-@Builder
-@ToString
-@NoArgsConstructor
-@AllArgsConstructor
-public class OthNetSerialAdapterFile implements BaseEntity {
-    @JSONField(serializeUsing= ObjectWriterImplToString.class)
-    public Long id;
-
-    /**
-    * 鏂囦欢缂栧彿
-    */
-    @JSONField(serializeUsing= ObjectWriterImplToString.class)
-    @NotNull
-    public Long fileId;
-
-    /**
-    * 涓婁紶鏃堕棿
-    */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public Date dt;
-
-    @TableField(exist = false)
-    public String webUrl;
-
-    @TableField(exist = false)
-    public String orgName;
-    @TableField(exist = false)
-    public String extName;
-}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/OthFileManageMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/OthFileManageMapper.xml
new file mode 100644
index 0000000..d7dc4e0
--- /dev/null
+++ b/pms-parent/pms-global/src/main/resources/mapper/OthFileManageMapper.xml
@@ -0,0 +1,130 @@
+<?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.dy.pmsGlobal.daoOth.OthFileManageMapper">
+  <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoOth.OthFileManage">
+    <!--@mbg.generated-->
+    <!--@Table oth_file_manage-->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <id column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="file_id" jdbcType="BIGINT" property="fileId" />
+    <result column="deleted" jdbcType="TINYINT" property="deleted" typeHandler="com.dy.common.mybatis.BooleanTypeHandler" />
+    <result column="dt" jdbcType="TIMESTAMP" property="dt" />
+    <association property="userName" column="user_id" javaType="java.lang.Long"
+                 select="com.dy.pmsGlobal.daoBa.BaUserMapper.selectNameByUserId" fetchType="eager"/>
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, user_id, file_id, deleted, dt
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="map" resultMap="BaseResultMap">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from oth_file_manage
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="map">
+    <!--@mbg.generated-->
+    delete from oth_file_manage
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthFileManage" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into oth_file_manage (user_id, file_id, deleted, dt)
+    values (#{userId,jdbcType=BIGINT}, #{fileId,jdbcType=BIGINT}, #{deleted,jdbcType=TINYINT}, 
+      #{dt,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthFileManage" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into oth_file_manage
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="userId != null">
+        user_id,
+      </if>
+      <if test="fileId != null">
+        file_id,
+      </if>
+      <if test="deleted != null">
+        deleted,
+      </if>
+      <if test="dt != null">
+        dt,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="userId != null">
+        #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="fileId != null">
+        #{fileId,jdbcType=BIGINT},
+      </if>
+      <if test="deleted != null">
+        #{deleted,jdbcType=TINYINT},
+      </if>
+      <if test="dt != null">
+        #{dt,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoOth.OthFileManage">
+    <!--@mbg.generated-->
+    update oth_file_manage
+    <set>
+      <if test="fileId != null">
+        file_id = #{fileId,jdbcType=BIGINT},
+      </if>
+      <if test="deleted != null">
+        deleted = #{deleted,jdbcType=TINYINT},
+      </if>
+      <if test="dt != null">
+        dt = #{dt,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoOth.OthFileManage">
+    <!--@mbg.generated-->
+    update oth_file_manage
+    set file_id = #{fileId,jdbcType=BIGINT},
+      deleted = #{deleted,jdbcType=TINYINT},
+      dt = #{dt,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+
+  <select id="selectSome" resultMap="BaseResultMap">
+    select
+    f.id, f.user_id, f.file_id, f.deleted, f.dt
+    from oth_file_manage f
+    left join ba_user bu on bu.id=f.user_id
+    where f.deleted!=1
+    <trim prefix="and" suffixOverrides="and">
+      <if test="userName != null and userName != ''">
+        bu.name like concat('%', #{userName}, '%') and
+      </if>
+    </trim>
+    order by id desc
+    <trim prefix="limit ">
+      <if test="start != null and count != null">
+        #{start}, #{count}
+      </if>
+    </trim>
+  </select>
+
+  <select id="selectSomeCount" resultType="java.lang.Long">
+    select count(1)
+    from oth_file_manage f
+    left join ba_user bu on bu.id=f.user_id
+    where f.deleted!=1
+    <trim prefix="and" suffixOverrides="and">
+      <if test="userName != null and userName != ''">
+        bu.name like concat('%', #{userName}, '%') and
+      </if>
+    </trim>
+
+  </select>
+
+  <delete id="deleteLogicById">
+    update oth_file_manage set deleted = 1
+    where id = #{id}
+  </delete>
+</mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/OthNetSerialAdapterFileMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/OthNetSerialAdapterFileMapper.xml
deleted file mode 100644
index 6ef0b9d..0000000
--- a/pms-parent/pms-global/src/main/resources/mapper/OthNetSerialAdapterFileMapper.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?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.dy.pmsGlobal.daoOth.OthNetSerialAdapterFileMapper">
-  <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile">
-    <!--@mbg.generated-->
-    <!--@Table oth_net_serial_adapter_file-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="file_id" jdbcType="BIGINT" property="fileId" />
-    <result column="dt" jdbcType="TIMESTAMP" property="dt" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, file_id, dt
-  </sql>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    <!--@mbg.generated-->
-    select 
-    <include refid="Base_Column_List" />
-    from oth_net_serial_adapter_file
-    where id = #{id,jdbcType=BIGINT}
-  </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-    <!--@mbg.generated-->
-    delete from oth_net_serial_adapter_file
-    where id = #{id,jdbcType=BIGINT}
-  </delete>
-  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile" useGeneratedKeys="true">
-    <!--@mbg.generated-->
-    insert into oth_net_serial_adapter_file (file_id, dt)
-    values (#{fileId,jdbcType=BIGINT}, #{dt,jdbcType=TIMESTAMP})
-  </insert>
-  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile" useGeneratedKeys="true">
-    <!--@mbg.generated-->
-    insert into oth_net_serial_adapter_file
-    <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="fileId != null">
-        file_id,
-      </if>
-      <if test="dt != null">
-        dt,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="fileId != null">
-        #{fileId,jdbcType=BIGINT},
-      </if>
-      <if test="dt != null">
-        #{dt,jdbcType=TIMESTAMP},
-      </if>
-    </trim>
-  </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile">
-    <!--@mbg.generated-->
-    update oth_net_serial_adapter_file
-    <set>
-      <if test="fileId != null">
-        file_id = #{fileId,jdbcType=BIGINT},
-      </if>
-      <if test="dt != null">
-        dt = #{dt,jdbcType=TIMESTAMP},
-      </if>
-    </set>
-    where id = #{id,jdbcType=BIGINT}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile">
-    <!--@mbg.generated-->
-    update oth_net_serial_adapter_file
-    set file_id = #{fileId,jdbcType=BIGINT},
-      dt = #{dt,jdbcType=TIMESTAMP}
-    where id = #{id,jdbcType=BIGINT}
-  </update>
-
-  <select id="getAdapter" resultMap="BaseResultMap">
-    select * from oth_net_serial_adapter_file limit 1
-  </select>
-</mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterCtrl.java b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterCtrl.java
deleted file mode 100644
index 1ebe4ff..0000000
--- a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterCtrl.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.dy.pmsOther.adapter;
-
-import com.alibaba.fastjson2.JSON;
-import com.dy.common.webUtil.BaseResponse;
-import com.dy.common.webUtil.BaseResponseUtils;
-import com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile;
-import jakarta.validation.Valid;
-import org.springframework.web.bind.annotation.*;
-
-@RestController
-@RequestMapping(value = "adapter")
-public class AdapterCtrl {
-    private AdapterSv sv;
-
-    public AdapterCtrl(AdapterSv sv) {
-        this.sv = sv;
-    }
-
-    @GetMapping(value = "/getAdapter")
-    public BaseResponse<OthNetSerialAdapterFile> getAdapter() {
-        OthNetSerialAdapterFile adapter = sv.getAdapter();
-        return BaseResponseUtils.buildSuccess(JSON.toJSON(adapter));
-    }
-
-    @PostMapping(value="saveOrUpdate")
-    public BaseResponse<OthNetSerialAdapterFile> saveOrUpdateAdapter(@RequestBody @Valid OthNetSerialAdapterFile adapter) {
-        int count =sv.saveOrUpdateAdapter(adapter);
-        if (count <= 0) {
-            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
-        }
-        return BaseResponseUtils.buildSuccess(true);
-    }
-
-}
diff --git a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterSv.java b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterSv.java
deleted file mode 100644
index ea22970..0000000
--- a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterSv.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.dy.pmsOther.adapter;
-
-import com.dy.pmsGlobal.daoOth.OthFileMapper;
-import com.dy.pmsGlobal.daoOth.OthNetSerialAdapterFileMapper;
-import com.dy.pmsGlobal.dyFile.FileOperate;
-import com.dy.pmsGlobal.dyFile.FileRestVo;
-import com.dy.pmsGlobal.pojoOth.OthFile;
-import com.dy.pmsGlobal.pojoOth.OthNetSerialAdapterFile;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-@Slf4j
-@Service
-public class AdapterSv {
-    private OthNetSerialAdapterFileMapper dao;
-    private FileOperate fileOperate;
-    private OthFileMapper othFileMapper;
-    @Value("${dy.webFile.fmUrl}")
-    private String fmUrl ;
-    @Autowired
-    public void setDao(OthNetSerialAdapterFileMapper dao) {
-        this.dao = dao;
-    }
-    @Autowired
-    public void setFileOperate(FileOperate fileOperate) {
-        this.fileOperate = fileOperate;
-    }
-    @Autowired
-    public void setOthFileMapper(OthFileMapper othFileMapper) {
-        this.othFileMapper = othFileMapper;
-    }
-
-
-    public OthNetSerialAdapterFile getAdapter() {
-        OthNetSerialAdapterFile adapter =dao.getAdapter();
-        if(adapter != null){
-            OthFile file = othFileMapper.selectByPrimaryKey(adapter.fileId);
-            if (file != null) {
-                FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
-                adapter.webUrl = fileRestVo.fileWebDownloadPath + adapter.fileId;
-                adapter.orgName = file.orgName;
-                adapter.extName = file.extName;
-            }
-        }
-        return adapter;
-    }
-
-    public int saveOrUpdateAdapter(OthNetSerialAdapterFile adapter) {
-        int count=0;
-        if(adapter.getId()==null){
-            count = dao.insertSelective(adapter);
-        }else{
-            count = dao.updateByPrimaryKeySelective(adapter);
-        }
-        return count;
-    }
-}
diff --git a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageCtrl.java b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageCtrl.java
new file mode 100644
index 0000000..e4cf064
--- /dev/null
+++ b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageCtrl.java
@@ -0,0 +1,69 @@
+package com.dy.pmsOther.fileManage;
+
+import com.alibaba.fastjson2.JSON;
+import com.dy.common.aop.SsoPowerAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.aop.Log;
+import com.dy.pmsGlobal.pojoOth.OthFileManage;
+import jakarta.validation.Valid;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 涓婁紶鏂囦欢绠$悊
+ */
+@RestController
+@RequestMapping(path = "fileManage")
+public class FileManageCtrl {
+    private FileManageSv sv;
+
+    public FileManageCtrl(FileManageSv sv) {
+        this.sv = sv;
+    }
+
+    @GetMapping(path = "/one")
+    @SsoPowerAop(power = "-1")
+    @Log("鏌ヨ鍗曚釜涓婁紶鏂囦欢")
+    public BaseResponse<OthFileManage> one(@RequestParam("id")Long id) {
+        OthFileManage file = sv.one(id);
+        return BaseResponseUtils.buildSuccess(JSON.toJSON(file));
+    }
+    /**
+     * 鍒嗛〉鏌ヨ
+     * @param vo
+     * @return
+     */
+    @PostMapping(path="some")
+    @SsoPowerAop(power = "-1")
+    @Log("鍒嗛〉鏌ヨ涓婁紶鏂囦欢")
+    public BaseResponse<QueryResultVo<List<OthFileManage>>> some(@RequestBody QueryVo vo){
+        QueryResultVo<List<OthFileManage>> list = sv.selectSome(vo) ;
+        return BaseResponseUtils.buildSuccess(list);
+    }
+
+    @PostMapping(path="save")
+    @SsoPowerAop(power = "-1")
+    @Log("淇濆瓨涓婁紶鏂囦欢")
+    public BaseResponse<OthFileManage> save(@RequestBody @Valid OthFileManage file) {
+        int count =sv.save(file);
+        if (count <= 0) {
+            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+        }
+        return BaseResponseUtils.buildSuccess(true);
+    }
+
+    @GetMapping(path="delete")
+    @SsoPowerAop(power = "-1")
+    @Log("鍒犻櫎涓婁紶鏂囦欢")
+    public BaseResponse<OthFileManage> delete(Long id) {
+        int count =sv.delete(id);
+        if (count <= 0) {
+            return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+        }
+        return BaseResponseUtils.buildSuccess(true);
+    }
+
+}
diff --git a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageSv.java b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageSv.java
new file mode 100644
index 0000000..dfa2a7d
--- /dev/null
+++ b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageSv.java
@@ -0,0 +1,101 @@
+package com.dy.pmsOther.fileManage;
+
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoOth.OthFileMapper;
+import com.dy.pmsGlobal.daoOth.OthFileManageMapper;
+import com.dy.pmsGlobal.dyFile.FileOperate;
+import com.dy.pmsGlobal.dyFile.FileRestVo;
+import com.dy.pmsGlobal.pojoOth.OthFile;
+import com.dy.pmsGlobal.pojoOth.OthFileManage;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class FileManageSv {
+    private OthFileManageMapper dao;
+    private FileOperate fileOperate;
+    private OthFileMapper othFileMapper;
+    @Value("${dy.webFile.fmUrl}")
+    private String fmUrl ;
+    @Autowired
+    public void setDao(OthFileManageMapper dao) {
+        this.dao = dao;
+    }
+    @Autowired
+    public void setFileOperate(FileOperate fileOperate) {
+        this.fileOperate = fileOperate;
+    }
+    @Autowired
+    public void setOthFileMapper(OthFileMapper othFileMapper) {
+        this.othFileMapper = othFileMapper;
+    }
+
+
+    public OthFileManage one(Long fileId) {
+        OthFileManage uploadFile =dao.selectByPrimaryKey(fileId);
+        addUrl(List.of(uploadFile));
+        return uploadFile;
+    }
+    private void addUrl(List<OthFileManage> fileList){
+        fileList.forEach(uploadFile -> {
+            if(uploadFile != null){
+                OthFile othFile = othFileMapper.selectByPrimaryKey(uploadFile.fileId);
+                if (othFile != null) {
+                    FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, othFile.hash);
+                    uploadFile.webUrl = fileRestVo.fileWebDownloadPath + uploadFile.fileId;
+                    uploadFile.orgName = othFile.orgName;
+                    uploadFile.extName = othFile.extName;
+                }
+            }
+        });
+    }
+
+    /**
+     * 鑾峰彇鍒楄〃
+     */
+    public QueryResultVo<List<OthFileManage>> selectSome(QueryVo queryVo) {
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+        //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+        Long itemTotal = dao.selectSomeCount(params);
+
+        QueryResultVo<List<OthFileManage>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
+        //璁$畻鍒嗛〉绛変俊鎭�
+        rsVo.calculateAndSet(itemTotal, params);
+
+        //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
+        rsVo.obj = dao.selectSome(params) ;
+        addUrl(rsVo.obj);
+        return rsVo ;
+    }
+
+    @Transactional
+    public int save(OthFileManage uploadFile) {
+        int count=0;
+        if(uploadFile.id==null){
+            uploadFile.deleted = false;
+            uploadFile.dt = new Date();
+            count = dao.insertSelective(uploadFile);
+        }else{
+            uploadFile.dt = new Date();
+            count = dao.updateByPrimaryKeySelective(uploadFile);
+        }
+        return count;
+    }
+
+    @Transactional
+    public int delete(Long id) {
+        int count=0;
+        count = dao.deleteLogicById(id);
+        return count;
+    }
+}
diff --git a/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/QueryVo.java b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/QueryVo.java
new file mode 100644
index 0000000..24f4e10
--- /dev/null
+++ b/pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/QueryVo.java
@@ -0,0 +1,14 @@
+package com.dy.pmsOther.fileManage;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import lombok.*;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class QueryVo extends QueryConditionVo {
+    public String userName;
+}

--
Gitblit v1.8.0