Explorar el Código

解决数据库严格模式问题,新增封禁记录,通用文件上传接口

LeoN hace 5 años
padre
commit
a91b5b703e

+ 2 - 0
src/main/java/com/mokamrp/privates/config/OSSConfiguration.java

@@ -14,6 +14,8 @@ public class OSSConfiguration {
 
     public static final String DOWN_DIR = "mochat/down/";
 
+    public static final String UPLOAD_DIR = "hera/upload/";
+
     private volatile static OSS ossClient;
 
     private volatile static OSSClientBuilder ossClientBuilder;

+ 30 - 0
src/main/java/com/mokamrp/privates/controller/FileContorller.java

@@ -0,0 +1,30 @@
+package com.mokamrp.privates.controller;
+
+import com.aliyun.oss.model.PutObjectRequest;
+import com.aliyun.oss.model.PutObjectResult;
+import com.mokamrp.privates.help.AjaxResult;
+import com.mokamrp.privates.service.FileService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @author leon 通用上传
+ */
+@Controller
+@RequestMapping("/file")
+public class FileContorller {
+    @Autowired
+    public FileService fileService;
+
+    @PostMapping("upload")
+    public Object upload(@RequestParam("file") MultipartFile zipFile){
+        String url = fileService.uploadToOss(zipFile);
+        return AjaxResult.success(url);
+    }
+
+
+}

+ 1 - 0
src/main/java/com/mokamrp/privates/entity/PostWorkEmployee.java

@@ -18,4 +18,5 @@ public class PostWorkEmployee {
     private Integer groupId;
     private String mobile;
     private Integer privateTagId;
+    private Integer privateForbbidenStatus;
 }

+ 1 - 1
src/main/java/com/mokamrp/privates/mapper/GroupMapper.xml

@@ -102,7 +102,7 @@
             mc_work_employee AS a
         LEFT JOIN mc_corp AS b ON b.id = a.corp_id
         LEFT JOIN private_group_corp AS c ON b.id = c.corp_id
-        LEFT JOIN private_tag AS D ON a.private_tag_id = d.id
+        LEFT JOIN private_tag AS d ON a.private_tag_id = d.id
         where d.tag_name != '' AND ${ew.sqlSegment}
         GROUP BY
             c.group_id,

+ 2 - 2
src/main/java/com/mokamrp/privates/mapper/WorkEmployeeMapper.xml

@@ -80,14 +80,14 @@
         <where>
             ${ew.sqlSegment}
         </where>
-        group by a.id
+        group by A.id
     </select>
 
 
     <select id="getVoListTotal" resultType="Integer">
 
         SELECT
-        count(distinct(a.id))
+        count(distinct(A.id))
         FROM
         mc_work_employee AS A
         LEFT JOIN private_group_corp AS D ON A.corp_id = D.corp_id

+ 3 - 11
src/main/java/com/mokamrp/privates/mapper/vo/WorkEmployeeVo.java

@@ -25,7 +25,7 @@ public class WorkEmployeeVo {
     private Integer privateSwitchStatus;
     private Integer privateTagId;
     private String privatePhoneCode;
-    private Integer privateForbiddenStatus; //.1正常 2封禁中 3永封 4解封待确认
+    private Integer privateForbbidenStatus; //.1正常 2封禁中 3永封 4解封待确认
     private Integer privateUserId;
     private Integer custCnt;
     private Integer groupCnt;
@@ -37,8 +37,8 @@ public class WorkEmployeeVo {
     private Integer groupId;
     private String tagName;
     private String thumbAvatar;
-    private Date prohibitStartAt;
-    private Date prohibitEndAt;
+    private Date forbbidenStartAt;
+    private Date forbbidenEndAt;
 
     public String getThumbAvatar() {
         return thumbAvatar;
@@ -188,14 +188,6 @@ public class WorkEmployeeVo {
         this.privatePhoneCode = privatePhoneCode;
     }
 
-    public Integer getPrivateForbiddenStatus() {
-        return privateForbiddenStatus;
-    }
-
-    public void setPrivateForbiddenStatus(Integer privateForbiddenStatus) {
-        this.privateForbiddenStatus = privateForbiddenStatus;
-    }
-
     public Integer getPrivateUserId() {
         return privateUserId;
     }

+ 19 - 0
src/main/java/com/mokamrp/privates/service/FileService.java

@@ -0,0 +1,19 @@
+package com.mokamrp.privates.service;
+
+import com.aliyun.oss.model.PutObjectResult;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.mokamrp.privates.mapper.pojo.ChatTool;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * <p>
+ * 通用上传文件 服务类
+ * </p>
+ *
+ * @author leon
+ * @since 2021-06-01
+ */
+public interface FileService {
+    //.上传文件到oss
+    public String uploadToOss(MultipartFile zipFile);
+}

+ 48 - 0
src/main/java/com/mokamrp/privates/service/impl/FileServiceImpl.java

@@ -0,0 +1,48 @@
+package com.mokamrp.privates.service.impl;
+
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.model.PutObjectRequest;
+import com.aliyun.oss.model.PutObjectResult;
+import com.mokamrp.privates.config.OSSConfiguration;
+import com.mokamrp.privates.service.FileService;
+import com.mokamrp.privates.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.ByteArrayInputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 企业 服务实现类
+ * </p>
+ *
+ * @author leon
+ * @since 2021-04-19
+ */
+@Service
+public class FileServiceImpl implements FileService {
+    @Autowired
+    public OSSConfiguration ossConfiguration;
+    @Autowired
+    public OSS oss;
+
+    public String uploadToOss(MultipartFile zipFile){
+        String originalFileName = zipFile.getOriginalFilename();
+        String exland = originalFileName.substring(originalFileName.lastIndexOf("."));
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        Date currentTime = new Date();
+        String dateStr = formatter.format(currentTime);
+        String randStr = StringUtils.getRandomString(10);
+        String filePath = ossConfiguration.UPLOAD_DIR + dateStr+"/"+randStr+"."+exland;
+        PutObjectResult res = oss.putObject(ossConfiguration.getBucketName(),filePath,new ByteArrayInputStream(zipFile.toString().getBytes()));
+        String url = ossConfiguration.getHost() + filePath;
+        return url;
+    }
+}

+ 7 - 20
src/main/java/com/mokamrp/privates/service/impl/WorkEmployeeServiceImpl.java

@@ -123,8 +123,6 @@ public class WorkEmployeeServiceImpl extends ServiceImpl<WorkEmployeeMapper, Wor
 
         Integer pagesize = handle.getPagesize();
         Integer page = handle.getPage();
-        System.out.println(pagesize);
-        System.out.println(page);
         Page<WorkEmployeeVo> pageObj = new Page<WorkEmployeeVo>(page, pagesize);
         Map<String, Object> resMap = new HashMap<String, Object>();
         resMap.put("list", null);
@@ -211,43 +209,32 @@ public class WorkEmployeeServiceImpl extends ServiceImpl<WorkEmployeeMapper, Wor
         Integer groupId = handle.getGroupId();
         String mobile = handle.getMobile();
         Integer privateTagId = handle.getPrivateTagId();
-
+        Integer privateFrobbidenStatus = handle.getPrivateForbbidenStatus();
         QueryWrapper<WorkEmployeeVo> obj = new QueryWrapper<WorkEmployeeVo>();
-
         obj.in("A.corp_id", authCorpIds);
-
         if (name != null && !"".equals(name)) {
             obj.like("A.name", name);
         }
-
         if (gender != null) {
             obj.eq("A.gender", gender);
         }
-
-        /*
-        if (privateTagId != null) {
-            obj.eq("A.private_tag_id", privateTagId);
-        }
-         */
-
         if (groupId != null) {
             obj.eq("D.group_id", groupId);
         }
-
         if (mobile != null && !mobile.isEmpty()) {
             obj.eq("A.mobile", mobile);
         }
-
         if (corp_id != null) {
-            obj.eq("a.corp_id", corp_id);
+            obj.eq("A.corp_id", corp_id);
         }
-
         if (privateTagId != null) {
-            obj.eq("a.private_tag_id", privateTagId);
+            obj.eq("A.private_tag_id", privateTagId);
         }
-
         if (authCorpIds != null || authCorpIds.size() >= 1) {
-            obj.in("a.corp_id", authCorpIds);
+            obj.in("A.corp_id", authCorpIds);
+        }
+        if (privateFrobbidenStatus != null){
+            obj.eq("A.private_forbbiden_status",privateFrobbidenStatus);
         }
 
         return obj;

+ 3 - 2
src/main/resources/application-local.properties

@@ -1,18 +1,19 @@
 server.port=8085
 
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.url=jdbc:mysql://rm-uf618jc32u2o80g55oo.mysql.rds.aliyuncs.com:3306/mochat?serverTimezone=GMT%2b8
+spring.datasource.url=jdbc:mysql://172.18.71.27:3306/mochat?serverTimezone=GMT%2b8
 spring.datasource.username=typer
 spring.datasource.password=jch9sh_shl
 spring.datasource.max-idle=10
 spring.datasource.max-wait=10000
 spring.datasource.min-idle=5
 spring.datasource.initial-size=5
+spring.datasource.strict = false
 
 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 mybatis-plus.configuration.map-underscore-to-camel-case=true
 
-spring.redis.host=r-uf633f3f27aa2174pd.redis.rds.aliyuncs.com
+spring.redis.host=172.18.71.26
 spring.redis.port=6379
 spring.redis.password=Jch9shshl
 spring.redis.database=7