Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

lizhenhao 2 éve
szülő
commit
83029a3c72

+ 5 - 0
jeeplus-module/jeeplus-test/pom.xml

@@ -35,6 +35,11 @@
             <version>${project.parent.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.28</version>
+        </dependency>
 
     </dependencies>
 

+ 43 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/oss/controller/OssFileController.java

@@ -0,0 +1,43 @@
+package com.jeeplus.test.oss.controller;
+
+import com.jeeplus.test.oss.domain.WorkAttachment;
+import com.jeeplus.test.oss.service.OssService;
+import com.jeeplus.test.oss.service.dto.OssServiceDto;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Slf4j
+@Api(tags ="oss")
+@RestController
+@RequestMapping(value = "/oss/file")
+public class OssFileController {
+
+    @Resource
+    private OssService ossService;
+
+    @ApiOperation(value = "保存数据")
+    @PostMapping("/saveMsg")
+    public void saveMsg(@RequestBody List<OssServiceDto> dtos) {
+        ossService.saveMsg(dtos);
+    }
+
+    @GetMapping("/deleteMsgByFileName")
+    @ApiOperation(value = "删除数据")
+    public void deleteMsgByFileName(@RequestParam String url) {
+        ossService.deleteMsgByFileName(url);
+    }
+
+    @GetMapping("/findFileList")
+    @ApiOperation(value = "查询数据")
+    public ResponseEntity<List<WorkAttachment>> findFileList(@RequestParam("attachmentId") String attachmentId) {
+        List<WorkAttachment> list = ossService.findFileList(attachmentId);
+        return ResponseEntity.ok(list);
+    }
+}

+ 60 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/oss/domain/WorkAttachment.java

@@ -0,0 +1,60 @@
+package com.jeeplus.test.oss.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+@TableName("work_attachment")
+public class WorkAttachment extends BaseEntity {
+
+    /**
+     * 附件地址
+     */
+    private String url;
+
+    /**
+     * 文件类型(文件后缀名)
+     */
+    private String type;
+
+    /**
+     * 附件对应父节点id(记录是谁的id)
+     */
+    private String attachmentId;
+
+    /**
+     * 文件名
+     */
+    private String attachmentName;
+
+    /**
+     * 文件所属业务模块(数据字典配置)
+     */
+    private String attachmentFlag;
+
+    /**
+     * 所属模块子模块
+     */
+    private String moduleType;
+
+    /**
+     * 附件类型
+     */
+    private String attachmentType;
+
+    /**
+     * 附件大小
+     */
+    private String fileSize;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 文件描述
+     */
+    private String description;
+}

+ 7 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/oss/mapper/OssServiceMapper.java

@@ -0,0 +1,7 @@
+package com.jeeplus.test.oss.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jeeplus.test.oss.domain.WorkAttachment;
+
+public interface OssServiceMapper extends BaseMapper<WorkAttachment> {
+}

+ 102 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/oss/service/OssService.java

@@ -0,0 +1,102 @@
+package com.jeeplus.test.oss.service;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.utils.UserUtils;
+import com.jeeplus.test.oss.domain.WorkAttachment;
+import com.jeeplus.test.oss.mapper.OssServiceMapper;
+import com.jeeplus.test.oss.service.dto.OssServiceDto;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+
+@Slf4j
+@Service
+public class OssService {
+
+    @Resource
+    private OssServiceMapper ossServiceMapper;
+
+    /**
+     * 保存数据
+     * @param dtos
+     * @return
+     */
+    public void saveMsg(List<OssServiceDto> dtos) {
+        if (CollectionUtil.isNotEmpty(dtos)) {
+            //若数据有修改,先删除原有数据,再执行保存操作
+            String attachmentId = dtos.get(0).getAttachmentId();
+            log.info("开始执行删除操作,条件attachmentId值:{}" , attachmentId);
+            if (StringUtils.isNotEmpty(attachmentId)) {
+                LambdaQueryWrapper<WorkAttachment> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                lambdaQueryWrapper.eq(WorkAttachment::getAttachmentId, attachmentId);
+                int delete = ossServiceMapper.delete(lambdaQueryWrapper);
+                log.info("删除操作完成,共删除{}条数据" , attachmentId);
+            }
+            log.info("开始执行保存操作,入参:{}" , JSONObject.toJSONString(dtos));
+            //TODO:获取当前登录人信息
+            String id = UserUtils.getCurrentUserDTO().getId();
+            int i = 1;
+            for (OssServiceDto dto : dtos) {
+                WorkAttachment workAttachment = new WorkAttachment();
+                BeanUtils.copyProperties(dto,workAttachment);
+                //文件后缀名赋值
+                List<String> strings = Arrays.asList(dto.getUrl().split("\\."));
+                workAttachment.setType(strings.get(strings.size()-1));
+                workAttachment.setId(UUID.randomUUID().toString().replace("-",""));
+                //排序赋值
+                workAttachment.setSort(i);
+                //基础信息赋值
+                workAttachment.setCreateBy(id);
+                workAttachment.setCreateDate(new Date());
+                workAttachment.setUpdateBy(id);
+                workAttachment.setUpdateDate(new Date());
+                workAttachment.setDelFlag(0);
+                i++;
+                ossServiceMapper.insert(workAttachment);
+            }
+            log.info("保存操作执行完成");
+        }
+    }
+
+    /**
+     * 根据文件路径删除文件
+     * @param url
+     */
+    public void deleteMsgByFileName(String url) {
+        log.info("开始执行删除操作,入参:{}" , url);
+        Map<String,Object> map = new HashMap<>();
+        map.put("url", url);
+        int i = ossServiceMapper.deleteByMap(map);
+        log.info("删除操作完成,共删除{}条数据" , i);
+    }
+
+    /**
+     * 根据附件对应父节点id查询文件列表
+     * @param attachmentId
+     * @return
+     */
+    public List<WorkAttachment> findFileList(String attachmentId) {
+        log.info("文件查询开始,入参:{}" , attachmentId);
+        LambdaQueryWrapper<WorkAttachment> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(WorkAttachment::getAttachmentId, attachmentId);
+        lambdaQueryWrapper.orderByAsc(WorkAttachment::getSort);
+        List<WorkAttachment> list = ossServiceMapper.selectList(lambdaQueryWrapper);
+        //创建人和文件名称处理
+        if (CollectionUtil.isNotEmpty(list)) {
+            for (WorkAttachment workAttachment : list) {
+                UserDTO userDTO = UserUtils.get(workAttachment.getCreateBy());
+                workAttachment.setCreateBy(userDTO.getName());
+                workAttachment.setAttachmentName(workAttachment.getAttachmentName()+"."+workAttachment.getType());
+            }
+        }
+        log.info("文件查询结束,查询结果:{}" , JSONObject.toJSONString(list));
+        return list;
+    }
+}

+ 6 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/oss/service/dto/OssServiceDto.java

@@ -0,0 +1,6 @@
+package com.jeeplus.test.oss.service.dto;
+
+import com.jeeplus.test.oss.domain.WorkAttachment;
+
+public class OssServiceDto extends WorkAttachment {
+}

+ 9 - 11
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/controller/UserController.java

@@ -210,8 +210,6 @@ public class UserController {
         EasyPoiUtil.exportExcel ( result, "用户数据",  options.getSheetName ( ), UserDTO.class, fileName, response );
     }
 
-    private int successNum;
-    private int failureNum;
 
     /**
      * 导入用户数据
@@ -224,8 +222,8 @@ public class UserController {
     @ApiOperation(value = "导入用户excel")
     public ResponseEntity importFile(MultipartFile file) {
         try {
-            this.successNum = 0;
-            this.failureNum = 0;
+            Integer successNum = 0;
+            Integer failureNum = 0;
             StringBuilder failureMsg = new StringBuilder ( );
             List <UserDTO> list = EasyPoiUtil.importExcel ( file, 1, 2, UserDTO.class );
             for (UserDTO user : list) {
@@ -263,27 +261,27 @@ public class UserController {
                         UserDTO userDTO = UserWrapper.INSTANCE.toDTO(user1);
                         userDTO.setRoleDTOList(roleDTOList);
                         userService.saveOrUpdate(userDTO);
-                        this.successNum++;
+                        successNum++;
                     } else {
                         failureMsg.append ( "<br/>登录名 " + user.getLoginName ( ) + " 已存在; " );
-                        this.failureNum++;
+                        failureNum++;
                     }
                 } catch (ConstraintViolationException ex) {
                     failureMsg.append ( "<br/>登录名 " + user.getLoginName ( ) + " 导入失败:" );
                     List <String> messageList = BeanValidators.extractPropertyAndMessageAsList ( ex, ": " );
                     for (String message : messageList) {
                         failureMsg.append ( message + "; " );
-                        this.failureNum++;
+                        failureNum++;
                     }
                 } catch (Exception ex) {
-                    this.failureNum++;
+                    failureNum++;
                     failureMsg.append ( "<br/>登录名 " + user.getLoginName ( ) + " 导入失败:" + ex.getMessage ( ) );
                 }
             }
-            if ( this.failureNum > 0 ) {
-                failureMsg.insert ( 0, ",失败 " + this.failureNum + " 条用户,导入信息如下:" );
+            if ( failureNum > 0 ) {
+                failureMsg.insert ( 0, ",失败 " + failureNum + " 条用户,导入信息如下:" );
             }
-            return ResponseEntity.ok ( "已成功导入 " + this.successNum + " 条用户" + failureMsg );
+            return ResponseEntity.ok ( "已成功导入 " + successNum + " 条用户" + failureMsg );
         } catch (Exception e) {
             return ResponseEntity.badRequest().body ( "导入用户失败!失败信息:" + e.getMessage ( ) );
         }

+ 0 - 82
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/dto/OfficeDTO.java

@@ -110,14 +110,6 @@ public class OfficeDTO extends TreeDTO <OfficeDTO> {
 	private boolean disabled = false;
 
 	/**
-	 * 登录名
-	 */
-	@Length(min = 1, max = 100)
-	@Excel (name = "登录名")
-	@Query
-	private String loginName;
-
-	/**
 	 * 父级部门
 	 */
 	@Length(min = 1, max = 100)
@@ -125,78 +117,4 @@ public class OfficeDTO extends TreeDTO <OfficeDTO> {
 	@Query
 	private String parentName;
 
-	/**
-	 * 密码
-	 */
-	@JsonIgnore
-	@Length(min = 1, max = 100)
-	private String password;
-
-
-	/**
-	 * 工号
-	 */
-	@Length(min = 1, max = 100)
-	@Excel (name = "工号")
-	private String no;
-
-	/**
-	 * 手机
-	 */
-	@Length(min = 0, max = 100)
-	@Excel(name = "手机")
-	private String mobile;
-
-	/**
-	 * 最后登录IP
-	 */
-	@ApiModelProperty(hidden = true)
-	private String loginIp;
-
-	/**
-	 * 最后登录日期
-	 */
-	@ApiModelProperty(hidden = true)
-	private Date loginDate;
-
-	/**
-	 * 是否允许登录
-	 */
-	private String loginFlag;
-
-	/**
-	 * 头像
-	 */
-	private String photo;
-
-	/**
-	 * 二维码
-	 */
-	private String qrCode;
-
-	/**
-	 * 原登录名
-	 */
-	private String oldLoginName;
-
-	/**
-	 * 新密码
-	 */
-	private String newPassword;
-
-	/**
-	 * 签名
-	 */
-	private String sign;
-
-	/**
-	 * 超级管理员标志
-	 */
-	private boolean isAdmin;
-
-	/**
-	 * 是否可用
-	 */
-	private boolean typeFlag = false;
-
 }