Преглед на файлове

正品联盟资料库优化part5

Aslee преди 3 години
родител
ревизия
ced3119f2e
променени са 31 файла, в които са добавени 222 реда и са изтрити 125 реда
  1. 1 1
      src/main/java/com/caimei/controller/AuthClubApi.java
  2. 5 3
      src/main/java/com/caimei/controller/FileApi.java
  3. 17 6
      src/main/java/com/caimei/controller/UploadApi.java
  4. 5 3
      src/main/java/com/caimei/controller/VideoApi.java
  5. 1 1
      src/main/java/com/caimei/mapper/ClubMapper.java
  6. 2 0
      src/main/java/com/caimei/mapper/ShopMapper.java
  7. 12 2
      src/main/java/com/caimei/model/po/FilePo.java
  8. 12 2
      src/main/java/com/caimei/model/po/VideoPo.java
  9. 8 2
      src/main/java/com/caimei/model/vo/FileListVo.java
  10. 8 2
      src/main/java/com/caimei/model/vo/VideoListVo.java
  11. 5 2
      src/main/java/com/caimei/model/vo/WxFileListVo.java
  12. 5 2
      src/main/java/com/caimei/model/vo/WxVideoListVo.java
  13. 4 2
      src/main/java/com/caimei/service/FileService.java
  14. 2 1
      src/main/java/com/caimei/service/LoginService.java
  15. 4 2
      src/main/java/com/caimei/service/VideoService.java
  16. 15 16
      src/main/java/com/caimei/service/impl/FileServiceImpl.java
  17. 19 5
      src/main/java/com/caimei/service/impl/LoginServiceImpl.java
  18. 1 1
      src/main/java/com/caimei/service/impl/ShopServiceImpl.java
  19. 15 16
      src/main/java/com/caimei/service/impl/VideoServiceImpl.java
  20. 6 1
      src/main/java/com/caimei/utils/OSSUtils.java
  21. 16 25
      src/main/java/com/caimei/utils/SmsUtils.java
  22. 2 1
      src/main/java/com/caimei/wxController/LoginApi.java
  23. 7 3
      src/main/resources/backup.sql
  24. 2 2
      src/main/resources/mapper/ArticleMapper.xml
  25. 1 0
      src/main/resources/mapper/AuthProductMapper.xml
  26. 6 2
      src/main/resources/mapper/ClubMapper.xml
  27. 16 9
      src/main/resources/mapper/FileMapper.xml
  28. 2 2
      src/main/resources/mapper/ImageMapper.xml
  29. 3 0
      src/main/resources/mapper/ShopMapper.xml
  30. 16 9
      src/main/resources/mapper/VideoMapper.xml
  31. 4 2
      src/test/java/com/caimei/AdminApplicationTests.java

+ 1 - 1
src/main/java/com/caimei/controller/AuthClubApi.java

@@ -54,7 +54,7 @@ public class AuthClubApi {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "authId", required = true, value = "机构id"),
             @ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
-            @ApiImplicitParam(name = "status", required = false, value = "状态:1未绑定,2已绑定,3已过期"),
+            @ApiImplicitParam(name = "status", required = false, value = "状态:0未绑定,1已绑定,2已过期"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })

+ 5 - 3
src/main/java/com/caimei/controller/FileApi.java

@@ -49,15 +49,17 @@ public class FileApi {
     }
 
     @ApiOperation("添加/编辑文件")
-    @ApiImplicitParam(name = "params", required = false, value = "fileId:文件id;authUserId:供应商用户id;fileTitle:文件标题;fileUrl:文件链接")
+    @ApiImplicitParam(name = "params", required = false, value = "fileId:文件id;authUserId:供应商用户id;fileTitle:文件标题;fileName:文件名称;filePreviewUrl:文件预览链接;fileDowloadUrl:文件下载链接")
     @PostMapping("/save")
     public ResponseJson saveFile(@RequestBody String params) {
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer fileId = paramsMap.getInteger("fileId");
         Integer authUserId = paramsMap.getInteger("authUserId");
         String fileTitle = paramsMap.getString("fileTitle");
-        String fileUrl = paramsMap.getString("fileUrl");
-        return fileService.saveFile(fileId, authUserId, fileTitle, fileUrl);
+        String fileName = paramsMap.getString("fileName");
+        String filePreviewUrl = paramsMap.getString("filePreviewUrl");
+        String fileDownloadUrl = paramsMap.getString("fileDownloadUrl");
+        return fileService.saveFile(fileId, authUserId, fileTitle, fileName, filePreviewUrl, fileDownloadUrl);
     }
 
     @ApiOperation("更新文件状态")

+ 17 - 6
src/main/java/com/caimei/controller/UploadApi.java

@@ -4,6 +4,7 @@ import com.caimei.config.FastDfsClient;
 import com.caimei.mapper.FileMapper;
 import com.caimei.model.po.FilePo;
 import com.caimei.service.UploadService;
+import com.caimei.utils.CodeUtil;
 import com.caimei.utils.OSSUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -11,6 +12,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -23,6 +25,8 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
@@ -73,6 +77,7 @@ public class UploadApi {
     public Map<String, Object> uploadFile(MultipartFile file) throws IOException {
         Map<String, Object> map = new HashMap<>(2);
         String fileAllName = file.getOriginalFilename();
+        String realName = fileAllName.substring(0, fileAllName.lastIndexOf("."));
         String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
         String fileName = file.getResource().getFilename();
         String uuid = UUID.randomUUID().toString().replaceAll("-", "");
@@ -81,14 +86,20 @@ public class UploadApi {
         log.info(">>>>>>>>>>>>>上传文件");
         //保存本地
         File uploadFile = OSSUtils.ossUpload(file);
-        //判断文件的唯一性,转换成16进制md5值
-        String md5Hex = DigestUtils.md5Hex(new FileInputStream(uploadFile));
         //将文件上传oss
-        String url = OSSUtils.ossUpload(filePath, uploadFile, contentType);
-        if (StringUtils.isNotEmpty(url)) {
-            map.put("fileUrl", url);
+        log.info("开始上传>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        log.info("开始时间" + format.format(new Date()));
+        String previewUrl = OSSUtils.ossUpload(realName + "-preview" + CodeUtil.generateCodeInt(6) + "." + fileType, uploadFile, contentType, null);
+        log.info("中间时间" + format.format(new Date()));
+        String downloadUrl = OSSUtils.ossUpload(realName + "-download" + CodeUtil.generateCodeInt(6) + "." + fileType, uploadFile, contentType, "attachment");
+        log.info("结束时间" + format.format(new Date()));
+        if (StringUtils.isNotEmpty(previewUrl)) {
+            map.put("previewUrl", previewUrl);
+            map.put("downloadUrl", downloadUrl);
+            map.put("fileName", fileName);
             map.put("msg", "上传成功");
-            logger.info(">>>>>>>>>>>>>>>>文件上传成功:" + url);
+            logger.info(">>>>>>>>>>>>>>>>文件上传成功:" + previewUrl);
         } else {
             map.put("msg", "上传失败");
             logger.info(">>>>>>>>>>>>>>>>文件上传失败:");

+ 5 - 3
src/main/java/com/caimei/controller/VideoApi.java

@@ -49,15 +49,17 @@ public class VideoApi {
     }
 
     @ApiOperation("添加/编辑视频")
-    @ApiImplicitParam(name = "params", required = false, value = "videoId:视频id;authUserId:供应商用户id;videoTitle:视频标题;videoUrl:视频链接")
+    @ApiImplicitParam(name = "params", required = false, value = "videoId:视频id;authUserId:供应商用户id;videoTitle:视频标题;videoName:视频名称;videoPreviewUrl:视频预览链接;videoDownloadUrl:视频下载链接")
     @PostMapping("/save")
     public ResponseJson saveVideo(@RequestBody String params) {
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer videoId = paramsMap.getInteger("videoId");
         Integer authUserId = paramsMap.getInteger("authUserId");
         String videoTitle = paramsMap.getString("videoTitle");
-        String videoUrl = paramsMap.getString("videoUrl");
-        return videoService.saveVideo(videoId, authUserId, videoTitle, videoUrl);
+        String videoName = paramsMap.getString("videoName");
+        String videoPreviewUrl = paramsMap.getString("videoPreviewUrl");
+        String videoDownloadUrl = paramsMap.getString("videoDownloadUrl");
+        return videoService.saveVideo(videoId, authUserId, videoTitle, videoName, videoPreviewUrl, videoDownloadUrl);
     }
 
     @ApiOperation("更新视频状态")

+ 1 - 1
src/main/java/com/caimei/mapper/ClubMapper.java

@@ -32,7 +32,7 @@ public interface ClubMapper {
 
     List<WxClubListVo> getWxClubList(@Param("authUserId") Integer authUserId, @Param("clubName") String clubName);
 
-    Integer checkMobile(String mobile);
+    Integer checkMobile(@Param("mobile") String mobile, @Param("appId") String appId);
 
     void insertFeedback(@Param("clubUserId") Integer clubUserId, @Param("content") String content);
 }

+ 2 - 0
src/main/java/com/caimei/mapper/ShopMapper.java

@@ -79,4 +79,6 @@ public interface ShopMapper {
     String getAppSecretByAppId(String appId);
 
     String getAppId(Integer authUserId);
+
+    String getShopNameByAppId(String appId);
 }

+ 12 - 2
src/main/java/com/caimei/model/po/FilePo.java

@@ -26,9 +26,19 @@ public class FilePo {
     private String title;
 
     /**
-     * 文件链接
+     * 文件名称
      */
-    private String url;
+    private String name;
+
+    /**
+     * 文件预览链接
+     */
+    private String previewUrl;
+
+    /**
+     * 文件下载链接
+     */
+    private String downloadUrl;
 
     /**
      * 审核状态:0审核未通过,1审核通过,2待审核

+ 12 - 2
src/main/java/com/caimei/model/po/VideoPo.java

@@ -26,9 +26,19 @@ public class VideoPo {
     private String title;
 
     /**
-     * 视频链接
+     * 视频名称
      */
-    private String url;
+    private String name;
+
+    /**
+     * 视频预览链接
+     */
+    private String previewUrl;
+
+    /**
+     * 视频下载链接
+     */
+    private String downloadUrl;
 
     /**
      * 审核状态:0审核未通过,1审核通过,2待审核

+ 8 - 2
src/main/java/com/caimei/model/vo/FileListVo.java

@@ -18,8 +18,14 @@ public class FileListVo {
     @ApiModelProperty("文件标题")
     private String fileTitle;
 
-    @ApiModelProperty("文件链接")
-    private String fileUrl;
+    @ApiModelProperty("文件名称")
+    private String fileName;
+
+    @ApiModelProperty("文件预览链接")
+    private String filePreviewUrl;
+
+    @ApiModelProperty("文件下载链接")
+    private String fileDownloadUrl;
 
     @ApiModelProperty("审核状态:0审核未通过,1审核通过,2待审核")
     private Integer auditStatus;

+ 8 - 2
src/main/java/com/caimei/model/vo/VideoListVo.java

@@ -18,8 +18,14 @@ public class VideoListVo {
     @ApiModelProperty("视频标题")
     private String videoTitle;
 
-    @ApiModelProperty("视频链接")
-    private String videoUrl;
+    @ApiModelProperty("视频名称")
+    private String videoName;
+
+    @ApiModelProperty("视频预览链接")
+    private String videoPreviewUrl;
+
+    @ApiModelProperty("视频下载链接")
+    private String videoDownloadUrl;
 
     @ApiModelProperty("审核状态:0审核未通过,1审核通过,2待审核")
     private Integer auditStatus;

+ 5 - 2
src/main/java/com/caimei/model/vo/WxFileListVo.java

@@ -18,8 +18,11 @@ public class WxFileListVo {
     @ApiModelProperty("文件标题")
     private String fileTitle;
 
-    @ApiModelProperty("文件链接")
-    private String fileUrl;
+    @ApiModelProperty("文件预览链接")
+    private String filePreviewUrl;
+
+    @ApiModelProperty("文件下载链接")
+    private String fileDownloadUrl;
 
     @ApiModelProperty("创建时间")
     private Date createTime;

+ 5 - 2
src/main/java/com/caimei/model/vo/WxVideoListVo.java

@@ -18,8 +18,11 @@ public class WxVideoListVo {
     @ApiModelProperty("视频标题")
     private String videoTitle;
 
-    @ApiModelProperty("视频链接")
-    private String videoUrl;
+    @ApiModelProperty("视频预览链接")
+    private String videoPreviewUrl;
+
+    @ApiModelProperty("视频下载链接")
+    private String videoDownloadUrl;
 
     @ApiModelProperty("创建时间")
     private Date createTime;

+ 4 - 2
src/main/java/com/caimei/service/FileService.java

@@ -32,10 +32,12 @@ public interface FileService {
      * @param fileId           文件id
      * @param authUserId        供应商用户id
      * @param fileTitle        文件标题
-     * @param fileUrl             文件链接
+     * @param fileName        文件名称
+     * @param filePreviewUrl      文件预览链接
+     * @param fileDownloadUrl       文件下载链接
      * @return  ResponseJson
      */
-    ResponseJson saveFile(Integer fileId, Integer authUserId, String fileTitle, String fileUrl);
+    ResponseJson saveFile(Integer fileId, Integer authUserId, String fileTitle, String fileName, String filePreviewUrl, String fileDownloadUrl);
 
     /**
      * 更新文件状态

+ 2 - 1
src/main/java/com/caimei/service/LoginService.java

@@ -22,9 +22,10 @@ public interface LoginService {
      * 发送登录验证码
      *
      * @param mobile
+     * @param appId
      * @return
      */
-    ResponseJson sendVerifyCode(String mobile);
+    ResponseJson sendVerifyCode(String mobile, String appId);
 
     /**
      * 邀请码登录

+ 4 - 2
src/main/java/com/caimei/service/VideoService.java

@@ -32,10 +32,12 @@ public interface VideoService {
      * @param videoId           视频id
      * @param authUserId        供应商用户id
      * @param videoTitle        视频标题
-     * @param videoUrl             视频链接
+     * @param videoName
+     * @param videoPreviewUrl             视频预览链接
+     * @param videoDownloadUrl  视频下载链接
      * @return  ResponseJson
      */
-    ResponseJson saveVideo(Integer videoId, Integer authUserId, String videoTitle, String videoUrl);
+    ResponseJson saveVideo(Integer videoId, Integer authUserId, String videoTitle, String videoName, String videoPreviewUrl, String videoDownloadUrl);
 
     /**
      * 更新视频状态

+ 15 - 16
src/main/java/com/caimei/service/impl/FileServiceImpl.java

@@ -5,7 +5,6 @@ import com.caimei.model.ResponseJson;
 import com.caimei.model.po.FilePo;
 import com.caimei.model.vo.FileListVo;
 import com.caimei.model.vo.WxFileListVo;
-import com.caimei.model.vo.WxVideoListVo;
 import com.caimei.service.FileService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -59,42 +58,42 @@ public class FileServiceImpl implements FileService {
     }
 
     @Override
-    public ResponseJson saveFile(Integer fileId, Integer authUserId, String fileTitle, String fileUrl) {
+    public ResponseJson saveFile(Integer fileId, Integer authUserId, String fileTitle, String fileName, String filePreviewUrl, String fileDownloadUrl) {
         if (null == fileId && null == authUserId) {
             return ResponseJson.error("参数异常,请输入供应商用户id");
         }
         if (StringUtils.isEmpty(fileTitle)) {
             return ResponseJson.error("参数异常,请输入文件标题");
         }
-        if (null == fileUrl) {
+        if (StringUtils.isEmpty(fileName)) {
+            return ResponseJson.error("参数异常,请输入文件名称");
+        }
+        if (null == filePreviewUrl || null == fileDownloadUrl) {
             return ResponseJson.error("参数异常,请上传文件");
         }
         /*
             组装文件数据
         */
         FilePo dataFile = new FilePo();
+        dataFile.setTitle(fileTitle);
+        dataFile.setPreviewUrl(filePreviewUrl);
+        dataFile.setDownloadUrl(fileDownloadUrl);
+        dataFile.setName(fileName);
+        // 上线状态默认为“待上线”,审核状态为“待审核”
+        dataFile.setStatus(2);
+        dataFile.setAuditStatus(2);
         if (null != fileId) {
             /*
                 更新文件
              */
             dataFile.setId(fileId);
-            dataFile.setTitle(fileTitle);
-            dataFile.setUrl(fileUrl);
-            // 上线状态默认为“待上线”,审核状态为“待审核”
-            dataFile.setStatus(2);
-            dataFile.setAuditStatus(2);
             fileMapper.updateFileSelective(dataFile);
         } else {
-                /*
-                    新增文件
-                 */
+            /*
+                新增文件
+             */
             dataFile.setAuthUserId(authUserId);
-            dataFile.setTitle(fileTitle);
-            dataFile.setUrl(fileUrl);
             dataFile.setCreateTime(new Date());
-            // 上线状态默认为“待上线”,审核状态为“待审核”
-            dataFile.setStatus(2);
-            dataFile.setAuditStatus(2);
             fileMapper.insertFile(dataFile);
         }
         return ResponseJson.success("保存文件成功");

+ 19 - 5
src/main/java/com/caimei/service/impl/LoginServiceImpl.java

@@ -83,21 +83,34 @@ public class LoginServiceImpl implements LoginService {
     }
 
     @Override
-    public ResponseJson sendVerifyCode(String mobile) {
+    public ResponseJson sendVerifyCode(String mobile, String appId) {
         if (StringUtils.isEmpty(mobile)) {
             return ResponseJson.error("参数异常,请输入手机号");
         }
-        Integer clubUserId = clubMapper.checkMobile(mobile);
+        if (StringUtils.isEmpty(appId)) {
+            return ResponseJson.error("参数异常,请输入appId");
+        }
+        Integer clubUserId = clubMapper.checkMobile(mobile, appId);
         if (null != clubUserId) {
             return ResponseJson.error("该手机号已使用,请重新输入");
         }
+        // 获取供应商名称
+        String shopName = shopMapper.getShopNameByAppId(appId);
+        if (StringUtils.isEmpty(shopName)) {
+            return ResponseJson.error("供应商不存在");
+        } else {
+            if (shopName.contains("上海品辉")) {
+                shopName = "上海品辉";
+            }
+        }
         String verifyCode = CodeUtil.generateCodeInt(6);
-        String content = "欢迎登录上海品辉会员,您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
-
+        String content = "欢迎登录" + shopName + "会员,您的短信验证码为:" + verifyCode + ",该验证码 5 分钟内有效,请勿泄漏于他人。";
         Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
         if (!sendSms) {
-            log.info("会员登录验证码发送失败,手机号>>>>" + mobile);
+            log.info("会员登录验证码发送失败,手机号:" + mobile);
             return ResponseJson.error("发送失败,请确认手机号无误");
+        } else {
+            log.info("会员登录验证码发送成功,手机号:" + mobile + ",验证码:" + verifyCode);
         }
         redisService.set("code:" + mobile, verifyCode, 300L);
         return ResponseJson.success("发送成功");
@@ -140,6 +153,7 @@ public class LoginServiceImpl implements LoginService {
         if (1 != clubPo.getStatus() || 1 != shopStatus) {
             return ResponseJson.error("登录失败", null);
         }
+        // 校验appId是否和机构所属供应商的appId相同
         String dbAppId = shopMapper.getAppId(clubPo.getAuthUserId());
         if (StringUtils.isEmpty(dbAppId) || !appId.equals(dbAppId)) {
             return ResponseJson.error("登录失败", null);

+ 1 - 1
src/main/java/com/caimei/service/impl/ShopServiceImpl.java

@@ -141,7 +141,7 @@ public class ShopServiceImpl implements ShopService {
                 CmBrandAuthFilePo sameFile = shopMapper.getStatementFile(searchFile);
                 if (null == sameFile) {
                     //将新文件上传oss
-                    OSSUtils.ossUpload(filePath, uploadFile, contentType);
+                    OSSUtils.ossUpload(filePath, uploadFile, contentType, null);
                 }
                 //删除本地文件
                 OSSUtils.deleteFile(uploadFile);

+ 15 - 16
src/main/java/com/caimei/service/impl/VideoServiceImpl.java

@@ -4,7 +4,6 @@ import com.caimei.mapper.VideoMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.VideoPo;
 import com.caimei.model.vo.VideoListVo;
-import com.caimei.model.vo.WxArticleListVo;
 import com.caimei.model.vo.WxVideoListVo;
 import com.caimei.service.VideoService;
 import com.github.pagehelper.PageHelper;
@@ -59,42 +58,42 @@ public class VideoServiceImpl implements VideoService {
     }
 
     @Override
-    public ResponseJson saveVideo(Integer videoId, Integer authUserId, String videoTitle, String videoUrl) {
+    public ResponseJson saveVideo(Integer videoId, Integer authUserId, String videoTitle, String videoName, String videoPreviewUrl, String videoDownloadUrl) {
         if (null == videoId && null == authUserId) {
             return ResponseJson.error("参数异常,请输入供应商用户id");
         }
         if (StringUtils.isEmpty(videoTitle)) {
             return ResponseJson.error("参数异常,请输入视频标题");
         }
-        if (null == videoUrl) {
+        if (StringUtils.isEmpty(videoName)) {
+            return ResponseJson.error("参数异常,请输入视频名称");
+        }
+        if (null == videoPreviewUrl || null == videoDownloadUrl) {
             return ResponseJson.error("参数异常,请上传视频");
         }
         /*
             组装视频数据
         */
         VideoPo video = new VideoPo();
+        video.setTitle(videoTitle);
+        video.setName(videoName);
+        video.setPreviewUrl(videoPreviewUrl);
+        video.setDownloadUrl(videoDownloadUrl);
+        // 上线状态默认为“待上线”,审核状态为“待审核”
+        video.setStatus(2);
+        video.setAuditStatus(2);
         if (null != videoId) {
             /*
                 更新视频
              */
             video.setId(videoId);
-            video.setTitle(videoTitle);
-            video.setUrl(videoUrl);
-            // 上线状态默认为“待上线”,审核状态为“待审核”
-            video.setStatus(2);
-            video.setAuditStatus(2);
             videoMapper.updateVideoSelective(video);
         } else {
-                /*
-                    新增视频
-                 */
+            /*
+                新增视频
+             */
             video.setAuthUserId(authUserId);
-            video.setTitle(videoTitle);
-            video.setUrl(videoUrl);
             video.setCreateTime(new Date());
-            // 上线状态默认为“待上线”,审核状态为“待审核”
-            video.setStatus(2);
-            video.setAuditStatus(2);
             videoMapper.insertVideo(video);
         }
         return ResponseJson.success("保存视频成功");

+ 6 - 1
src/main/java/com/caimei/utils/OSSUtils.java

@@ -4,6 +4,7 @@ import com.aliyun.oss.HttpMethod;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.model.*;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
@@ -51,13 +52,17 @@ public class OSSUtils {
         active = actives;
     }
 
-    public static String ossUpload(String fileName, File file, String contentType) {
+    public static String ossUpload(String fileName, File file, String contentType, String contentDisposition) {
         String url = null;
         try {
             OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
             ObjectMetadata meta = new ObjectMetadata();
             meta.setObjectAcl(CannedAccessControlList.PublicRead);
             meta.setContentType(contentType);
+            // 设置
+            if (StringUtils.isNotEmpty(contentDisposition)) {
+                meta.setContentDisposition(contentDisposition);
+            }
             fileName = active + "/authFile/" + fileName;
             UploadFileRequest uploadFileRequest = new UploadFileRequest(privateBucket, fileName);
             // 指定上传的本地文件。

+ 16 - 25
src/main/java/com/caimei/utils/SmsUtils.java

@@ -38,31 +38,22 @@ public class SmsUtils {
 
     public static Boolean sendSms(int martId, String mobile, String content) {
         try {
-            //测试环境手机号允许发短信
-            List<String> list = new ArrayList<>();
-            list.add("15917362709");
-            list.add("15814011616");
-            list.add("13100721916");
-            list.add("15113936829");
-            list.add("15872950940");
-            if ("prod".equals(active) || list.contains(mobile)) {
-                if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
-                    String regex = "^(1[3-9]\\d{9}$)";
-                    Pattern pattern = Pattern.compile(regex);
-                    Matcher matcher = pattern.matcher(mobile);
-                    if (matcher.matches()) {
-                        Map<String, Object> map = new HashMap<>(2);
-                        map.put("content", content);
-                        map.put("mobile", mobile);
-                        String url = core + "/tools/sms/send";
-                        String result = HttpRequest.sendPost(url, map);
-                        JSONObject parseObject = JSONObject.parseObject(result);
-                        Integer code = parseObject.getInteger("code");
-                        if (code != 0) {
-                            log.info("短信发送失败,手机号>>>>" + mobile);
-                        } else {
-                            return true;
-                        }
+            if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
+                String regex = "^(1[3-9]\\d{9}$)";
+                Pattern pattern = Pattern.compile(regex);
+                Matcher matcher = pattern.matcher(mobile);
+                if (matcher.matches()) {
+                    Map<String, Object> map = new HashMap<>(2);
+                    map.put("content", content);
+                    map.put("mobile", mobile);
+                    String url = core + "/tools/sms/send";
+                    String result = HttpRequest.sendPost(url, map);
+                    JSONObject parseObject = JSONObject.parseObject(result);
+                    Integer code = parseObject.getInteger("code");
+                    if (code != 0) {
+                        log.info("短信发送失败,手机号>>>>" + mobile);
+                    } else {
+                        return true;
                     }
                 }
             }

+ 2 - 1
src/main/java/com/caimei/wxController/LoginApi.java

@@ -50,7 +50,8 @@ public class LoginApi {
     public ResponseJson sendVerifyCode(@RequestBody String params) {
         JSONObject parseObject = JSONObject.parseObject(params);
         String mobile = parseObject.getString("mobile");
-        return loginService.sendVerifyCode(mobile);
+        String appId = parseObject.getString("appId");
+        return loginService.sendVerifyCode(mobile, appId);
     }
 
     @ApiOperation("邀请码登录")

+ 7 - 3
src/main/resources/backup.sql

@@ -158,7 +158,9 @@ CREATE TABLE `cm_brand_video` (
                                        `id` INT NOT NULL AUTO_INCREMENT,
                                        `authUserId` INT NULL COMMENT '供应商用户id',
                                        `title` VARCHAR(300) NULL COMMENT '视频标题',
-                                       `url` VARCHAR(300) NULL COMMENT '视频路径',
+                                       `name` VARCHAR(300) NULL COMMENT '视频名称',
+                                       `previewUrl` TEXT NULL COMMENT '视频预览链接',
+                                       `downloadUrl` TEXT NULL COMMENT '视频下载链接',
                                        `status` INT NULL COMMENT '上线状态:0已下线,1已上线,2待上线',
                                        `createTime` DATETIME NULL COMMENT '创建时间',
                                        `auditStatus` INT NULL COMMENT '审核状态:0审核未通过,1审核通过,2待审核',
@@ -171,8 +173,10 @@ CREATE TABLE `cm_brand_video` (
 CREATE TABLE `cm_brand_file` (
                                  `id` INT NOT NULL AUTO_INCREMENT,
                                  `authUserId` INT NULL COMMENT '供应商用户id',
-                                 `title` VARCHAR(300) NULL COMMENT '视频标题',
-                                 `url` VARCHAR(300) NULL COMMENT '文件链接',
+                                 `title` VARCHAR(300) NULL COMMENT '文件标题',
+                                 `name` VARCHAR(300) NULL COMMENT '文件名称',
+                                 `previewUrl` TEXT NULL COMMENT '文件预览链接',
+                                 `downloadUrl` TEXT NULL COMMENT '文件下载链接',
                                  `status` INT NULL COMMENT '上线状态:0已下线,1已上线,2待上线',
                                  `createTime` DATETIME NULL COMMENT '创建时间',
                                  `auditStatus` INT NULL COMMENT '审核状态:0审核未通过,1审核通过,2待审核',

+ 2 - 2
src/main/resources/mapper/ArticleMapper.xml

@@ -64,12 +64,12 @@
     <select id="getWxArticleList" resultType="com.caimei.model.vo.WxArticleListVo">
         select id as articleId, title as articleTitle, image as articleImage, date_format(createTime, '%Y-%m-%d') as
         createTime
-        from cm_brand_article
+        from cm_brand_article a
         where authUserId = #{authUserId}
         and status = 1
         <if test="articleTitle != null and articleTitle != ''">
             and title like concat('%',#{articleTitle},'%')
         </if>
-        order by createTime desc
+        order by a.createTime desc
     </select>
 </mapper>

+ 1 - 0
src/main/resources/mapper/AuthProductMapper.xml

@@ -145,5 +145,6 @@
         <if test="productName != null and productName != ''">
             and name like concat('%',#{productName},'%')
         </if>
+        order by createTime desc
     </select>
 </mapper>

+ 6 - 2
src/main/resources/mapper/ClubMapper.xml

@@ -54,7 +54,7 @@
             </if>
             <if test="status == 1">
                 and status = 1
-          </if>
+            </if>
         </if>
         order by addTime desc
     </select>
@@ -71,8 +71,12 @@
         <if test="clubName != null and clubName != ''">
             and authParty like concat('%',#{clubName},'%')
         </if>
+        order by createTime desc
     </select>
     <select id="checkMobile" resultType="java.lang.Integer">
-        select id as clubUserId from cm_brand_club_user where mobile = #{mobile} and delFlag = 0 limit 1
+        select cu.id as clubUserId from cm_brand_club_user cu
+        left join cm_brand_auth a on cu.authId = a.id
+        left join cm_brand_auth_user au on a.authUserId = au.authUserId
+        where cu.mobile = #{mobile} and au.appId = #{appId} and cu.delFlag = 0 limit 1
     </select>
 </mapper>

+ 16 - 9
src/main/resources/mapper/FileMapper.xml

@@ -2,8 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.FileMapper">
     <insert id="insertFile" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.FilePo" useGeneratedKeys="true">
-        insert into cm_brand_file(authUserId, title, url, auditStatus, status, createTime)
-        values (#{authUserId}, #{title}, #{url}, #{auditStatus}, #{status}, #{createTime})
+        insert into cm_brand_file(authUserId, title, name, previewUrl, downloadUrl, auditStatus, status, createTime)
+        values (#{authUserId}, #{title}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
+                #{createTime})
     </insert>
     <update id="updateFileByFileId">
         update cm_brand_file
@@ -32,8 +33,14 @@
             <if test="title != null and title != ''">
                 title = #{title},
             </if>
-            <if test="url != null and url != ''">
-                url = #{url},
+            <if test="previewUrl != null and previewUrl != ''">
+                previewUrl = #{previewUrl},
+            </if>
+            <if test="downloadUrl != null and downloadUrl != ''">
+                downloadUrl = #{downloadUrl},
+            </if>
+            <if test="name != null and name != ''">
+                name = #{name},
             </if>
             <if test="status != null">
                 status = #{status},
@@ -48,8 +55,8 @@
         delete from cm_brand_file where id = #{fileId}
     </delete>
     <select id="getFileList" resultType="com.caimei.model.vo.FileListVo">
-        select a.id as fileId,a.title as fileTitle,a.url as fileUrl,
-        a.auditStatus,a.invalidReason,a.status,a.createTime,
+        select a.id as fileId,a.title as fileTitle,a.name as fileName,a.previewUrl as filePreviewUrl,
+        a.downloadUrl as fileDownloadUrl, a.auditStatus,a.invalidReason,a.status,a.createTime,
         au.name as auditBy,a.auditTime
         from cm_brand_file a
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
@@ -73,13 +80,13 @@
         </choose>
     </select>
     <select id="getWxFileList" resultType="com.caimei.model.vo.WxFileListVo">
-        select id as fileId, title as fileTitle, url as fileUrl, date_format(createTime, '%Y-%m-%d') as createTime
-        from cm_brand_file
+        select id as fileId, title as fileTitle, previewUrl as filePreviewUrl, downloadUrl as fileDownloadUrl, date_format(createTime, '%Y-%m-%d') as createTime
+        from cm_brand_file a
         where authUserId = #{authUserId}
         and status = 1
         <if test="fileTitle != null and fileTitle != ''">
             and title like concat('%',#{fileTitle},'%')
         </if>
-        order by createTime desc
+        order by a.createTime desc
     </select>
 </mapper>

+ 2 - 2
src/main/resources/mapper/ImageMapper.xml

@@ -71,12 +71,12 @@
     <select id="getWxImageList" resultType="com.caimei.model.vo.WxImageListVo">
         select id as imageId, title as imageTitle, zipUrl as imageZipUrl, date_format(createTime, '%Y-%m-%d') as
         createTime
-        from cm_brand_image
+        from cm_brand_image a
         where authUserId = #{authUserId}
         and status = 1
         <if test="imageTitle != null and imageTitle != ''">
             and title like concat('%',#{imageTitle},'%')
         </if>
-        order by createTime desc
+        order by a.createTime desc
     </select>
 </mapper>

+ 3 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -280,5 +280,8 @@
     <select id="getAppId" resultType="java.lang.String">
         select appId from cm_brand_auth_user where authUserId = #{authUserId} and status = 1
     </select>
+    <select id="getShopNameByAppId" resultType="java.lang.String">
+        select name from cm_brand_auth_user where appId = #{appId} and status = 1
+    </select>
 
 </mapper>

+ 16 - 9
src/main/resources/mapper/VideoMapper.xml

@@ -2,8 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.VideoMapper">
     <insert id="insertVideo" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.VideoPo" useGeneratedKeys="true">
-        insert into cm_brand_video(authUserId, title, url, auditStatus, status, createTime)
-        values (#{authUserId}, #{title}, #{url}, #{auditStatus}, #{status}, #{createTime})
+        insert into cm_brand_video(authUserId, title, name, previewUrl, downloadUrl, auditStatus, status, createTime)
+        values (#{authUserId}, #{title}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
+                #{createTime})
     </insert>
     <update id="updateVideoByVideoId">
         update cm_brand_video
@@ -32,8 +33,14 @@
             <if test="title != null and title != ''">
                 title = #{title},
             </if>
-            <if test="url != null and url != ''">
-                url = #{url},
+            <if test="previewUrl != null and previewUrl != ''">
+                previewUrl = #{previewUrl},
+            </if>
+            <if test="downloadUrl != null and downloadUrl != ''">
+                downloadUrl = #{downloadUrl},
+            </if>
+            <if test="name != null and name != ''">
+                name = #{name},
             </if>
             <if test="status != null">
                 status = #{status},
@@ -48,8 +55,8 @@
         delete from cm_brand_video where id = #{videoId}
     </delete>
     <select id="getVideoList" resultType="com.caimei.model.vo.VideoListVo">
-        select a.id as videoId,a.title as videoTitle,a.url as videoUrl,
-        a.auditStatus,a.invalidReason,a.status,a.createTime,
+        select a.id as videoId,a.title as videoTitle,a.name as videoName, a.previewUrl as videoPreviewUrl, a.downloadUrl
+        as videoDownloadUrl,a.auditStatus,a.invalidReason,a.status,a.createTime,
         au.name as auditBy,a.auditTime
         from cm_brand_video a
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
@@ -73,13 +80,13 @@
         </choose>
     </select>
     <select id="getWxVideoList" resultType="com.caimei.model.vo.WxVideoListVo">
-        select id as videoId, title as videoTitle, url as videoUrl, date_format(createTime, '%Y-%m-%d') as createTime
-        from cm_brand_video
+        select id as videoId, title as videoTitle, previewUrl as videoPreviewUrl, downloadUrl as videoDownloadUrl, date_format(createTime, '%Y-%m-%d') as createTime
+        from cm_brand_video a
         where authUserId = #{authUserId}
         and status = 1
         <if test="videoTitle != null and videoTitle != ''">
             and title like concat('%',#{videoTitle},'%')
         </if>
-        order by createTime desc
+        order by a.createTime desc
     </select>
 </mapper>

+ 4 - 2
src/test/java/com/caimei/AdminApplicationTests.java

@@ -1,5 +1,6 @@
 package com.caimei;
 
+import com.alibaba.fastjson.JSONObject;
 import com.caimei.config.FastDfsClient;
 import com.caimei.service.AuthProductService;
 import com.caimei.utils.Base64Util;
@@ -46,8 +47,9 @@ public class AdminApplicationTests {
 
     @Test
     public void generateStr(){
-        String s = null;
-        s.toString();
+        JSONObject jsonObject = JSONObject.parseObject("{\"lng\":\"111\"}");
+        Integer lng = jsonObject.getInteger("lng");
+        System.out.println(lng);
     }