pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthFileManageMapper.java
New file @@ -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); } pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoOth/OthNetSerialAdapterFileMapper.java
File was deleted pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFileManage.java
New file @@ -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; } pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthNetSerialAdapterFile.java
File was deleted pms-parent/pms-global/src/main/resources/mapper/OthFileManageMapper.xml
New file @@ -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> pms-parent/pms-global/src/main/resources/mapper/OthNetSerialAdapterFileMapper.xml
File was deleted pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterCtrl.java
File was deleted pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/adapter/AdapterSv.java
File was deleted pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageCtrl.java
New file @@ -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); } } pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/FileManageSv.java
New file @@ -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; } } pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/fileManage/QueryVo.java
New file @@ -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; }