ソースを参照

用户中心 接口业务移植

lyhzzz 3 年 前
コミット
193c4aa3d6
60 ファイル変更4555 行追加198 行削除
  1. 15 0
      4dkankan-center-api/4dkankan-center-platform-api/pom.xml
  2. 1 0
      4dkankan-center-api/pom.xml
  3. 23 0
      4dkankan-center-platform/pom.xml
  4. 3 1
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/api/AgentAuditController.java
  5. 2 1
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/api/AgentLoginController.java
  6. 53 0
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/manager/ManagerAgentAuditController.java
  7. 19 0
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/request/RequestNote.java
  8. 17 0
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/request/RequestSearch.java
  9. 12 0
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/IAgentAuditService.java
  10. 100 2
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentAuditServiceImpl.java
  11. 4 3
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentFrameworkServiceImpl.java
  12. 2 1
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentNoticeServiceImpl.java
  13. 4 3
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentServiceImpl.java
  14. 78 0
      4dkankan-center-platform/src/main/java/com/fdkankan/agent/vo/AgentAuditVo.java
  15. 28 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/common/SSOLoginHelper.java
  16. 57 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/common/SSOLoginStore.java
  17. 54 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/LogoConfig.java
  18. 104 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/MatrixToImageWriterUtil.java
  19. 158 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/QiniuUpload.java
  20. 237 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/QiniuUtil.java
  21. 0 21
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/IncrementTypeController.java
  22. 0 21
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/IntercomMessageController.java
  23. 0 21
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/ManagerController.java
  24. 0 21
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/ProvinceController.java
  25. 0 21
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/ReceiverInfoController.java
  26. 0 21
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/UserController.java
  27. 0 21
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/UserIncrementController.java
  28. 154 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/api/SsoUserController.java
  29. 137 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/api/UserController.java
  30. 25 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/entity/SSOUser.java
  31. 89 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/request/RequestUser.java
  32. 10 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/IReceiverInfoService.java
  33. 3 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/IUserIncrementService.java
  34. 33 1
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/IUserService.java
  35. 198 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/LoginService.java
  36. 92 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/MsgService.java
  37. 131 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/RegisterService.java
  38. 69 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/impl/ReceiverInfoServiceImpl.java
  39. 16 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/impl/UserIncrementServiceImpl.java
  40. 236 2
      4dkankan-center-platform/src/main/java/com/fdkankan/user/service/impl/UserServiceImpl.java
  41. 44 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/vo/ReceiverInfoVo.java
  42. 98 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/vo/ResponseUser.java
  43. 9 0
      4dkankan-center-platform/src/main/java/com/fdkankan/user/vo/SSOUserVo.java
  44. 9 0
      4dkankan-center-platform/src/main/resources/static/apppro.html
  45. BIN
      4dkankan-center-platform/src/main/resources/static/img/logo.jpg
  46. 1125 0
      4dkankan-center-platform/src/main/resources/static/txt/SensitiveWord.txt
  47. 23 0
      4dkankan-common/pom.xml
  48. 39 0
      4dkankan-common/src/main/java/com/fdkankan/common/constant/ConstantFileName.java
  49. 28 0
      4dkankan-common/src/main/java/com/fdkankan/common/constant/ConstantUrl.java
  50. 13 34
      4dkankan-common/src/main/java/com/fdkankan/common/constant/ErrorCode.java
  51. 1 1
      4dkankan-common/src/main/java/com/fdkankan/common/constant/ServerCode.java
  52. 4 2
      4dkankan-common/src/main/java/com/fdkankan/common/exception/BusinessException.java
  53. 271 0
      4dkankan-common/src/main/java/com/fdkankan/common/sms/SendMailAcceUtils.java
  54. 228 0
      4dkankan-common/src/main/java/com/fdkankan/common/sms/SmsService.java
  55. 56 0
      4dkankan-common/src/main/java/com/fdkankan/common/util/Base64Converter.java
  56. 102 0
      4dkankan-common/src/main/java/com/fdkankan/common/util/PatternUtils.java
  57. 32 0
      4dkankan-common/src/main/java/com/fdkankan/common/util/SecurityUtil.java
  58. 152 0
      4dkankan-common/src/main/java/com/fdkankan/common/validation/SensitiveWord.java
  59. 131 0
      4dkankan-common/src/main/java/com/fdkankan/common/validation/SensitiveWordConfig.java
  60. 26 0
      4dkankan-common/src/main/java/com/fdkankan/common/validation/Variable.java

+ 15 - 0
4dkankan-center-api/4dkankan-center-platform-api/pom.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>4dkankan-center-api</artifactId>
+        <groupId>com.fdkankan</groupId>
+        <version>2.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>4dkankan-center-platform-api</artifactId>
+
+
+</project>

+ 1 - 0
4dkankan-center-api/pom.xml

@@ -13,6 +13,7 @@
     <packaging>pom</packaging>
     <modules>
         <module>4dkankan-center-scene-api</module>
+        <module>4dkankan-center-platform-api</module>
     </modules>
 
 

+ 23 - 0
4dkankan-center-platform/pom.xml

@@ -29,6 +29,29 @@
           <artifactId>4dkankan-pom</artifactId>
           <version>2.0.0</version>
       </dependency>
+
+<!--      二维码-->
+      <dependency>
+          <groupId>com.github.penggle</groupId>
+          <artifactId>kaptcha</artifactId>
+          <version>2.3.2</version>
+      </dependency>
+      <dependency>
+          <groupId>com.google.zxing</groupId>
+          <artifactId>core</artifactId>
+          <version>2.1</version>
+      </dependency>
+      <dependency>
+          <groupId>com.google.code.gson</groupId>
+          <artifactId>gson</artifactId>
+          <version>2.8.5</version>
+      </dependency>
+
+      <dependency>
+          <groupId>com.qiniu</groupId>
+          <artifactId>qiniu-java-sdk</artifactId>
+          <version>7.2.0</version>
+      </dependency>
   </dependencies>
 
 

+ 3 - 1
4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/api/AgentAuditController.java

@@ -20,9 +20,11 @@ public class AgentAuditController {
     @Autowired
     private IAgentAuditService agentAuditService;
 
+    /**
+     * 保存申请信息
+     */
     @PostMapping("/agentAduit/save")
     public String save(@RequestBody RequestAgentAudit param){
-
         return agentAuditService.saveByParam(param);
     }
 

+ 2 - 1
4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/api/AgentLoginController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.agent.request.RequestAgent;
 import com.fdkankan.agent.service.IAgentService;
 import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.JwtUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +46,6 @@ public class AgentLoginController  {
             throw new BusinessException(ErrorCode.TOKEN_ILLEGAL);
         }
         redisTemplate.delete(userName);
-        return "登出成功";
+        return ServerCode.SUCCESS.message();
     }
 }

+ 53 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/manager/ManagerAgentAuditController.java

@@ -0,0 +1,53 @@
+package com.fdkankan.agent.controller.manager;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdkankan.agent.entity.AgentAudit;
+import com.fdkankan.agent.request.RequestNote;
+import com.fdkankan.agent.request.RequestSearch;
+import com.fdkankan.agent.service.IAgentAuditService;
+import com.fdkankan.agent.vo.AgentAuditVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 经销商申请模块
+ */
+@RestController
+@RequestMapping("/api/manager/agentAudit")
+public class ManagerAgentAuditController {
+
+    @Autowired
+    private IAgentAuditService agentAuditService;
+    /**
+     * 获取申请经销商列表
+     */
+    @GetMapping("/list")
+    public Page<AgentAudit> list(@RequestParam(value="pageNum", defaultValue="1", required = false) Integer pageNum,
+                                 @RequestParam(value="pageSize", defaultValue="10", required = false) Integer pageSize){
+        return agentAuditService.getPageList(pageNum,pageSize);
+    }
+
+    /**
+     * 更新状态
+     */
+    @GetMapping("/update/active/{id}/{state}")
+    private String updateActive(@PathVariable("id") Long id, @PathVariable("state") String state){
+        return agentAuditService.updateStatus(id,state);
+    }
+
+    /**
+     * 更新备注信息
+     */
+    @PostMapping("/update/note")
+    private String updateNote(@RequestBody RequestNote param){
+        return agentAuditService.updateNote(param);
+    }
+
+    /**
+     * 搜索查询
+     */
+    @PostMapping("/search")
+    private Page<AgentAuditVo> search(@RequestBody RequestSearch param){
+        return agentAuditService.searchLike(param);
+    }
+}

+ 19 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/agent/request/RequestNote.java

@@ -0,0 +1,19 @@
+package com.fdkankan.agent.request;
+
+import lombok.Data;
+
+@Data
+public class RequestNote {
+
+    private Long id;
+
+    /**
+     * 备注等级
+     */
+    private Integer noteType;
+
+    /**
+     * 备注内容
+     */
+    private String noteContent;
+}

+ 17 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/agent/request/RequestSearch.java

@@ -0,0 +1,17 @@
+package com.fdkankan.agent.request;
+
+import com.fdkankan.common.request.RequestBase;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class RequestSearch extends RequestBase implements Serializable {
+    private String itemName;
+
+    private String startDate;
+
+    private String endDate;
+
+    private String type;
+}

+ 12 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/IAgentAuditService.java

@@ -1,8 +1,12 @@
 package com.fdkankan.agent.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.agent.entity.AgentAudit;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.agent.request.RequestAgentAudit;
+import com.fdkankan.agent.request.RequestNote;
+import com.fdkankan.agent.request.RequestSearch;
+import com.fdkankan.agent.vo.AgentAuditVo;
 
 /**
  * <p>
@@ -15,4 +19,12 @@ import com.fdkankan.agent.request.RequestAgentAudit;
 public interface IAgentAuditService extends IService<AgentAudit> {
 
     String saveByParam(RequestAgentAudit param);
+
+    Page<AgentAudit> getPageList(Integer pageNum, Integer pageSize);
+
+    String updateStatus(Long id, String state);
+
+    String updateNote(RequestNote param);
+
+    Page<AgentAuditVo> searchLike(RequestSearch param);
 }

+ 100 - 2
4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentAuditServiceImpl.java

@@ -1,15 +1,27 @@
 package com.fdkankan.agent.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.agent.entity.AgentAudit;
 import com.fdkankan.agent.mapper.IAgentAuditMapper;
 import com.fdkankan.agent.request.RequestAgentAudit;
+import com.fdkankan.agent.request.RequestNote;
+import com.fdkankan.agent.request.RequestSearch;
 import com.fdkankan.agent.service.IAgentAuditService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.agent.vo.AgentAuditVo;
+import com.fdkankan.common.constant.ConstantRegex;
 import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.validation.ValidationUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  * 代理商申请表 服务实现类
@@ -30,6 +42,92 @@ public class AgentAuditServiceImpl extends ServiceImpl<IAgentAuditMapper, AgentA
                 StringUtils.isEmpty(param.getPhone()) || StringUtils.isEmpty(param.getEmail())){
             throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
         }
-        return null;
+        if(!param.getEmail().matches(ConstantRegex.EMAIL_REGEX)){
+            throw new BusinessException(ErrorCode.EMAIL_ERROR);
+        }
+        AgentAudit agentAudit = new AgentAudit();
+        BeanUtils.copyProperties(param,agentAudit);
+        agentAudit.setNoteType(1);
+        agentAudit.setState(1);
+        if(!this.save(agentAudit)){
+            throw new BusinessException(ErrorCode.ERROR_MSG);
+        }
+        return ServerCode.SUCCESS.message();
+    }
+
+    @Override
+    public Page<AgentAudit> getPageList(Integer pageNum, Integer pageSize) {
+        QueryWrapper<AgentAudit> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().orderByDesc(AgentAudit::getCreateTime);
+        Page<AgentAudit> page = new Page<>();
+        page.setCurrent(pageNum);
+        page.setSize(pageSize);
+        return  this.page(page,queryWrapper);
+    }
+
+    @Override
+    public String updateStatus(Long id, String state) {
+        AgentAudit audit = this.getById(id);
+        Integer status = Integer.valueOf(state);
+        if (audit == null || !ValidationUtils.validateState(status)) {
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        audit.setState(status);
+        if(!this.updateById(audit)){
+            throw new BusinessException(ErrorCode.ERROR_MSG);
+        }
+        return ServerCode.SUCCESS.message();
+    }
+
+    @Override
+    public String updateNote(RequestNote param) {
+        if(param.getId() == null || param.getNoteType() == null){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        AgentAudit audit = this.getById(param.getId());
+        if(audit == null){
+            throw new BusinessException(ErrorCode.NOT_RECORD);
+        }
+        if (!ValidationUtils.validateInteger(param.getNoteType())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        audit.setNoteType(param.getNoteType());
+        audit.setNoteContent(param.getNoteContent());
+        this.updateById(audit);
+        return ServerCode.SUCCESS.message();
+    }
+
+    @Override
+    public Page<AgentAuditVo> searchLike(RequestSearch param) {
+        QueryWrapper<AgentAudit> queryWrapper = new QueryWrapper<>();
+        if(StringUtils.isNotBlank(param.getStartDate())){
+            queryWrapper.lambda().ge(AgentAudit::getCreateTime,param.getStartDate());
+        }
+        if(StringUtils.isNotBlank(param.getEndDate())){
+            queryWrapper.lambda().le(AgentAudit::getCreateTime,param.getEndDate());
+        }
+        if(StringUtils.isNotBlank(param.getItemName())){
+            queryWrapper.lambda().like(AgentAudit::getAuditName,param.getItemName());
+            queryWrapper.lambda().like(AgentAudit::getAddress,param.getItemName());
+            queryWrapper.lambda().like(AgentAudit::getNoteContent,param.getItemName());
+        }
+        queryWrapper.lambda().orderByDesc(AgentAudit::getCreateTime);
+        Page<AgentAudit> page = new Page<>();
+        page.setCurrent(param.getPageNum());
+        page.setSize(param.getPageSize());
+        Page<AgentAudit> auditPage = this.page(page, queryWrapper);
+
+        List<AgentAuditVo> voList = auditPage.getRecords().parallelStream().map(agentAudit -> {
+            AgentAuditVo agentAuditVo = new AgentAuditVo();
+            BeanUtils.copyProperties(agentAudit, agentAuditVo);
+            return agentAuditVo;
+        }).collect(Collectors.toList());
+
+        Page<AgentAuditVo> auditVoPage = new Page<>();
+        auditVoPage.setCurrent(page.getCurrent());
+        auditVoPage.setSize(page.getSize());
+        auditVoPage.setRecords(voList);
+        auditVoPage.setTotal(page.getTotal());
+        return auditVoPage;
     }
 }

+ 4 - 3
4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentFrameworkServiceImpl.java

@@ -7,6 +7,7 @@ import com.fdkankan.agent.request.RequestAgentFramework;
 import com.fdkankan.agent.service.IAgentFrameworkService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.user.entity.Manager;
 import com.fdkankan.user.service.IManagerService;
@@ -47,7 +48,7 @@ public class AgentFrameworkServiceImpl extends ServiceImpl<IAgentFrameworkMapper
         if(!this.save(agentFramework)){
             throw new BusinessException(ErrorCode.ERROR_MSG);
         }
-        return "操作成功";
+        return ServerCode.SUCCESS.message();
     }
 
     @Override
@@ -66,7 +67,7 @@ public class AgentFrameworkServiceImpl extends ServiceImpl<IAgentFrameworkMapper
         if(!this.saveOrUpdate(agentFramework)){
             throw new BusinessException(ErrorCode.ERROR_MSG);
         }
-        return "操作成功";
+        return ServerCode.SUCCESS.message();
     }
 
     @Override
@@ -81,6 +82,6 @@ public class AgentFrameworkServiceImpl extends ServiceImpl<IAgentFrameworkMapper
         if(!this.removeById(param.getId())){
             throw  new BusinessException(ErrorCode.ERROR_MSG);
         }
-        return "操作成功";
+        return ServerCode.SUCCESS.message();
     }
 }

+ 2 - 1
4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentNoticeServiceImpl.java

@@ -8,6 +8,7 @@ import com.fdkankan.agent.service.IAgentNoticeService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.agent.vo.AgentNoticeVo;
 import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -56,6 +57,6 @@ public class AgentNoticeServiceImpl extends ServiceImpl<IAgentNoticeMapper, Agen
         if(!this.save(agentNotice)){
             throw new BusinessException(ErrorCode.ERROR_MSG);
         }
-        return "发布成功";
+        return ServerCode.SUCCESS.message();
     }
 }

+ 4 - 3
4dkankan-center-platform/src/main/java/com/fdkankan/agent/service/impl/AgentServiceImpl.java

@@ -15,6 +15,7 @@ import com.fdkankan.agent.vo.AgentVo;
 import com.fdkankan.agent.vo.ResponseAgentCamera;
 import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.JwtUtil;
 import com.fdkankan.common.util.PasswordUtils;
@@ -130,7 +131,7 @@ public class AgentServiceImpl extends ServiceImpl<IAgentMapper, Agent> implement
                 }
             }
         }
-        return "操作成功";
+        return ServerCode.SUCCESS.message();
     }
 
     @Override
@@ -138,7 +139,7 @@ public class AgentServiceImpl extends ServiceImpl<IAgentMapper, Agent> implement
         if(!this.removeById(id)){
             throw new BusinessException(ErrorCode.ERROR_MSG);
         }
-        return "删除成功";
+        return ServerCode.SUCCESS.message();
     }
 
     @Override
@@ -151,7 +152,7 @@ public class AgentServiceImpl extends ServiceImpl<IAgentMapper, Agent> implement
         if(!this.saveOrUpdate(agent)){
             throw new BusinessException(ErrorCode.ERROR_MSG);
         }
-        return "更新成功";
+        return ServerCode.SUCCESS.message();
     }
 
     @Override

+ 78 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/agent/vo/AgentAuditVo.java

@@ -0,0 +1,78 @@
+package com.fdkankan.agent.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class AgentAuditVo {
+
+    private Long id;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    /**
+     * 经销商公司名称
+     */
+    private String name;
+    /**
+     * 国家
+     */
+    private String country;
+    /**
+     * 地区
+     */
+    private String region;
+    /**
+     * 地址
+     */
+    private String address;
+    /**
+     * 类型,1为线下,2为线上
+     */
+    private Integer type;
+    /**
+     * 线下门店地址或线上网站
+     */
+    private String storeAddress;
+    /**
+     * 申请人的姓
+     */
+    private String surName;
+    /**
+     * 状态, O:无效, 1:有效
+     */
+    private int state;
+    /**
+     * 申请人的名字
+     */
+    private String userName;
+    /**
+     * 申请人职位
+     */
+    private String post;
+    /**
+     * 区号
+     */
+    private String areaCode;
+    /**
+     * 手机号
+     */
+    private String phone;
+    /**
+     * 邮箱地址
+     */
+    private String email;
+
+    /**
+     * 备注等级
+     */
+    private Integer noteType;
+
+    /**
+     * 备注内容
+     */
+    private String noteContent;
+}

+ 28 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/common/SSOLoginHelper.java

@@ -0,0 +1,28 @@
+package com.fdkankan.user.common;
+
+import com.fdkankan.user.entity.SSOUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SSOLoginHelper {
+    @Autowired
+    private SSOLoginStore ssoLoginStore;
+    public  SSOUser loginCheck(String sessionId) {
+        if (sessionId != null && sessionId.trim().length() > 0) {
+            SSOUser ssoUser = ssoLoginStore.get(sessionId);
+            if (ssoUser != null) {
+                return ssoUser;
+            }
+        }
+        return null;
+    }
+
+    public void login(String token, SSOUser ssoUser) {
+        ssoLoginStore.put(token, ssoUser);
+    }
+
+    public  void logout(String sessionId) {
+        ssoLoginStore.remove(sessionId);
+    }
+}

+ 57 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/common/SSOLoginStore.java

@@ -0,0 +1,57 @@
+package com.fdkankan.user.common;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.util.SsoUtil;
+import com.fdkankan.user.entity.SSOUser;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class SSOLoginStore {
+
+    @Resource
+    private RedisTemplate<String,String> redisTemplate;
+    /**
+     * get
+     *
+     * @param sessionId
+     * @return
+     */
+    public  SSOUser get(String sessionId) {
+
+        String redisKey = redisKey(sessionId);
+        String objectValue = redisTemplate.opsForValue().get(redisKey);
+        if (objectValue != null) {
+            return JSONObject.parseObject(objectValue, SSOUser.class);
+        }
+        return null;
+    }
+
+    /**
+     * remove
+     *
+     * @param sessionId
+     */
+    public  void remove(String sessionId) {
+        String redisKey = redisKey(sessionId);
+        redisTemplate.delete(redisKey);
+    }
+
+    /**
+     * put
+     *
+     * @param sessionId
+     * @param ssoUser
+     */
+    public  void put(String sessionId, SSOUser ssoUser) {
+        String redisKey = redisKey(sessionId);
+        redisTemplate.opsForValue().set(redisKey, JSONObject.toJSONString(ssoUser), 216000, TimeUnit.SECONDS);
+    }
+
+    private static String redisKey(String sessionId){
+        return SsoUtil.SSO_SESSIONID.concat("#").concat(sessionId);
+    }
+}

+ 54 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/LogoConfig.java

@@ -0,0 +1,54 @@
+package com.fdkankan.user.common.util;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+public class LogoConfig {
+    /**
+     * 设置 logo
+     * @param matrixImage 源二维码图片
+     * @return 返回带有logo的二维码图片
+     * @throws IOException
+     * @author Administrator sangwenhao
+     */
+    public BufferedImage LogoMatrix(BufferedImage matrixImage, String logoPath) throws IOException{
+        /**
+         * 读取二维码图片,并构建绘图对象
+         */
+        Graphics2D g2 = matrixImage.createGraphics();
+
+        int matrixWidth = matrixImage.getWidth();
+        int matrixHeigh = matrixImage.getHeight();
+        /**
+         * 读取Logo图片
+         */
+        if(logoPath == null){
+            logoPath = this.getClass().getResource("/static/img/logo.png").getPath();
+        }
+        BufferedImage logo = ImageIO.read(new File(logoPath));
+
+        //开始绘制图片
+        g2.drawImage(logo,matrixWidth/5*2,matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5, null);//绘制
+        BasicStroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
+        g2.setStroke(stroke);// 设置笔画对象
+        //指定弧度的圆角矩形
+        RoundRectangle2D.Float round = new RoundRectangle2D.Float(matrixWidth/5*2, matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5,20,20);
+        g2.setColor(Color.white);
+        g2.draw(round);// 绘制圆弧矩形
+
+        //设置logo 有一道灰色边框
+        BasicStroke stroke2 = new BasicStroke(1,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
+        g2.setStroke(stroke2);// 设置笔画对象
+        RoundRectangle2D.Float round2 = new RoundRectangle2D.Float(matrixWidth/5*2+2, matrixHeigh/5*2+2, matrixWidth/5-4, matrixHeigh/5-4,20,20);
+        g2.setColor(new Color(128,128,128));
+        g2.draw(round2);// 绘制圆弧矩形
+
+        g2.dispose();
+        matrixImage.flush() ;
+        return matrixImage ;
+    }
+}

+ 104 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/MatrixToImageWriterUtil.java

@@ -0,0 +1,104 @@
+package com.fdkankan.user.common.util;
+
+import com.fdkankan.common.util.FileUtils;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Hashtable;
+
+public class MatrixToImageWriterUtil {
+    private static Logger log = LoggerFactory.getLogger("programLog");
+
+    private static final int BLACK = 0xFF000000;//用于设置图案的颜色
+    private static final int WHITE = 0xFFFFFFFF; //用于背景色
+
+    private MatrixToImageWriterUtil() {}
+
+    public static BufferedImage toBufferedImage(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        for (int x = 0; x < width; x++) {
+            for (int y = 0; y < height; y++) {
+                image.setRGB(x, y, (matrix.get(x, y) ? BLACK : WHITE));
+//              image.setRGB(x, y,  (matrix.get(x, y) ? Color.YELLOW.getRGB() : Color.CYAN.getRGB()));
+            }
+        }
+        return image;
+    }
+
+    public static boolean writeToFile(BitMatrix matrix, String format, File file, String logoPath) throws IOException {
+        BufferedImage image = toBufferedImage(matrix);
+        //设置logo图标
+        LogoConfig logoConfig = new LogoConfig();
+        image = logoConfig.LogoMatrix(image, logoPath);
+
+        File parFile = new File(file.getParent() + File.separator);
+        if (!parFile.exists()){
+            parFile.mkdirs();
+        }
+
+        if (!ImageIO.write(image, format, file)) {
+            //throw new IOException("Could not write an image of format " + format + " to " + file);
+            log.info("Could not write an image of format " + format + " to " + file);
+            return false;
+        } else {
+            log.info("二维码生成成功!");
+            return true;
+        }
+    }
+
+    public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException {
+        BufferedImage image = toBufferedImage(matrix);
+        //设置logo图标
+        LogoConfig logoConfig = new LogoConfig();
+        image = logoConfig.LogoMatrix(image, null);
+
+        if (!ImageIO.write(image, format, stream)) {
+            throw new IOException("Could not write an image of format " + format);
+        }
+    }
+
+    //url
+    public static boolean createQRCode(String url, String outPath, String logoPath) throws Exception {
+        // 生成二维码
+
+        int width = 3000; // 二维码图片宽度 300
+        int height = 3000; // 二维码图片高度300
+
+        String format = "jpg";// 二维码的图片格式 gif
+
+        Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
+        // 指定纠错等级,纠错级别(L 7%、M 15%、Q 25%、H 30%)
+        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+        // 内容所使用字符集编码
+        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
+//      hints.put(EncodeHintType.MAX_SIZE, 350);//设置图片的最大值
+//      hints.put(EncodeHintType.MIN_SIZE, 100);//设置图片的最小值
+        hints.put(EncodeHintType.MARGIN, 1);//设置二维码边的空度,非负数
+
+        BitMatrix bitMatrix = new MultiFormatWriter().encode(url,
+                //编码类型,目前zxing支持:Aztec 2D,CODABAR 1D format,Code 39 1D,Code 93 1D ,Code 128 1D,
+                //Data Matrix 2D , EAN-8 1D,EAN-13 1D,ITF (Interleaved Two of Five) 1D,
+                //MaxiCode 2D barcode,PDF417,QR Code 2D,RSS 14,RSS EXPANDED,UPC-A 1D,UPC-E 1D,UPC/EAN extension,UPC_EAN_EXTENSION
+                BarcodeFormat.QR_CODE,
+                width, //条形码的宽度
+                height, //条形码的高度
+                hints);//生成条形码时的一些配置,此项可选
+
+        //File outputFile = new File("d:" + File.separator + "new-1.gif");//指定输出路径
+        File outputFile = new File(outPath);//指定输出路径
+        FileUtils.deleteFile(outPath);
+        return writeToFile(bitMatrix, format, outputFile, logoPath);
+    }
+}

+ 158 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/QiniuUpload.java

@@ -0,0 +1,158 @@
+package com.fdkankan.user.common.util;
+
+import com.google.gson.Gson;
+import com.qiniu.cdn.CdnManager;
+import com.qiniu.common.QiniuException;
+import com.qiniu.http.Response;
+import com.qiniu.storage.BucketManager;
+import com.qiniu.storage.Configuration;
+import com.qiniu.storage.UploadManager;
+import com.qiniu.storage.model.DefaultPutRet;
+import com.qiniu.util.Auth;
+import com.qiniu.util.StringMap;
+import com.qiniu.util.UrlSafeBase64;
+
+import java.io.File;
+
+
+public class QiniuUpload {
+    //删除文件
+    public static void delete(String key) throws QiniuException{
+        Configuration cfg = new Configuration(QiniuUtil.zone);
+        Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
+        BucketManager bucketManager = new BucketManager(auth, cfg);
+        bucketManager.delete(QiniuUtil.bucket, key);
+    }
+
+    //刷新文件
+    public static void refresh(String url) throws QiniuException{
+        String [] urls = {url};
+        Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
+        CdnManager c = new CdnManager(auth);
+        Response response = c.refreshUrls(urls);
+    }
+
+
+    /**
+     * 上传单个文件到七牛云
+     * @param key
+     * @param localFilePath
+     */
+    public static boolean setFileToBucket(String key, String localFilePath){
+        Configuration cfg = new Configuration(QiniuUtil.zone);
+        Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
+        UploadManager uploadManager = new UploadManager(cfg);
+
+        String upToken = auth.uploadToken(QiniuUtil.bucket);
+
+        try {
+            Response response = uploadManager.put(localFilePath, key, upToken);
+            //解析上传成功的结果
+            DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
+            System.out.println(putRet.key);
+            System.out.println(putRet.hash);
+            return true;
+        } catch (QiniuException ex) {
+            Response r = ex.response;
+            System.err.println(r.toString());
+            try {
+                System.err.println(r.bodyString());
+            } catch (QiniuException ex2) {
+            }
+            return false;
+        }
+    }
+
+    /**
+     * 上传本地目录下所有文件到七牛云上
+     * @param remoteFolder
+     * @param localFolderPath
+     */
+    public static void setFilesToBucket(String remoteFolder, String localFolderPath) {
+        Configuration cfg = new Configuration(QiniuUtil.zone);
+        Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
+        UploadManager uploadManager = new UploadManager(cfg);
+
+        File file = new File(localFolderPath);
+        File[] files = file.listFiles();// 获取目录下的所有文件或文件夹
+        if (files == null) {// 如果目录为空,直接退出
+            return;
+        }
+
+        // 遍历,目录下的所有文件
+        for (File f : files) {
+            if (f.isFile()) {
+                String key = f.getName();
+                if (remoteFolder != null) {
+                    key = remoteFolder + key;
+                }
+                // 再上传文件
+                String upToken = auth.uploadToken(QiniuUtil.bucket);
+                try {
+                    Response res = uploadManager.put(f, key, upToken);
+                    System.out.println(res.bodyString());
+                } catch (QiniuException e) {
+                    Response r = e.response;
+                    System.err.println(r.toString());
+                    try {
+                        System.err.println(r.bodyString());
+                    } catch (QiniuException ex2) {
+                    }
+                }
+            } else if (f.isDirectory()) {
+                String key = f.getName() + "/";
+                if (remoteFolder != null) {
+                    key = remoteFolder + key;
+                }
+                setFilesToBucket(key, f.getAbsolutePath());
+            }
+        }
+    }
+
+    /**
+     * 测试七牛上传后,自动进行数据处理操作,并另存处理后的文件
+     * @param domain 存储空间所对应的域名
+     * @param file 上传文件
+     */
+    public static void testFops(String domain, File file) {
+        //通过AK,SK创建Auth 对象
+        Auth auth = Auth.create(QiniuUtil.accessKey, QiniuUtil.secretKey);
+        Configuration cfg = new Configuration(QiniuUtil.zone);
+        //上传对象
+        UploadManager uploadMgr = new UploadManager(cfg);
+        //私有队列
+        String pipeline = "av-pipeline";
+        //水印文字
+        String wmText = UrlSafeBase64.encodeToString("Word For Test");
+        //水印文字的颜色
+        String wmFontColor = UrlSafeBase64.encodeToString("#FFFF00");
+        //设置avthumb 接口
+        StringBuffer ops = new StringBuffer("");
+        ops.append("avthumb/mp4/wmText/" + wmText +"/wmGravityText/NorthEast/wmFontColor/" + wmFontColor);
+        String saveAs = UrlSafeBase64.encodeToString(QiniuUtil.bucket + ":" + "new_" + file.getName());
+        //通过管道符 "|" 拼接 saveas 接口, 保存 数据处理后的视频
+        ops.append("|saveas/" + saveAs);
+        //saveas 接口 需要签名 sign
+        String sign = domain + "/" + file.getName() + "?" + ops.toString();
+        String encodeSign = UrlSafeBase64.encodeToString(sign);
+        ops.append("/sign/" + encodeSign);
+        //指定 数据处理 的 上传策略, 当文件上传成功后,自定执行数据处理操作,即:ops 的接口,图片加水印,另存为 new_file.getName();
+        StringMap putPolicy = new StringMap();
+        putPolicy.put("persistentOps", ops.toString())      //数据处理接口及参数
+                .put("persistentPipeline", pipeline);      //私有数据处理队列
+
+        //获取上传凭证, 包含上传策略
+        String uploadToken = auth.uploadToken(QiniuUtil.bucket, file.getName(), 3600, putPolicy);
+
+        try {
+            //上传
+            Response resp = uploadMgr.put(file, file.getName(), uploadToken);
+            //查看结果
+            System.out.println(resp.statusCode + ":" + resp.bodyString());
+        } catch (QiniuException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+    }
+}

+ 237 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/common/util/QiniuUtil.java

@@ -0,0 +1,237 @@
+package com.fdkankan.user.common.util;
+
+import com.qiniu.common.Zone;
+import com.qiniu.util.Auth;
+import com.qiniu.util.UrlSafeBase64;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+
+public class QiniuUtil {
+
+    public static String accessKey = "dlPPwgZky_F-iP8CbSbJpiAtAcqw3BYwb9rdHMrS";
+    public static String secretKey = "YEtkLKDsImXB-8m1CT1zV_YwCwwGvrUvo2ktj9KZ";
+    public static Zone zone = Zone.zone1();
+    public static String bucket = "scene3d";
+    public static String remoteUrl = "https://4dkanzhan.4dkankan.com/";
+
+    /**
+     * 视频帧缩略图接口(vframe)用于从视频流中截取指定时刻的单帧画面并按指定大小缩放成图片
+     * @param key 文件名  a.mp4
+     * @param suffixName 输出的目标截图格式,支持jpg、png等。
+     * @param second 指定截取视频的时刻,单位:秒,精确到毫秒。
+     * @param width 缩略图宽度,单位:像素(px),取值范围为1-3840, 可不传。
+     * @param height 缩略图高度,单位:像素(px),取值范围为1-2160, 可不传。
+     * @param rotate 指定顺时针旋转的度数,可取值为90、180、270、auto,默认为不旋转,可不传。
+     * @param newKey 新文件名称
+     * @param notifyURL 回调地址
+     * @throws IOException
+     */
+    public static void getVideoFrame(String key, String suffixName, String second, Integer width, Integer height, Integer rotate, String newKey, String notifyURL) throws IOException {
+        StringBuffer sb = new StringBuffer("vframe/").append(suffixName).append("/offset/").append(second);
+        if (width != null){
+            sb.append("/w/").append(width);
+        }
+        if (height != null){
+            sb.append("/h/").append(height);
+        }
+        if (rotate != null){
+            sb.append("/rotate/").append(rotate);
+        }
+
+        String fop = URLEncoder.encode(sb.toString(), "utf-8");
+        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
+        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + newKey);
+        ops.append("|saveas/").append(saveAs);
+
+        ops.append("&notifyURL=").append(notifyURL);
+
+        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
+        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
+        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
+        entity.setContentType("application/x-www-form-urlencoded");
+        post.setEntity(entity);
+
+        Auth auth = Auth.create(accessKey, secretKey);
+        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
+        post.setHeader("Authorization", "QBox " + si);
+        HttpClient client = new DefaultHttpClient();
+        HttpResponse res = client.execute(post);
+        String ret = EntityUtils.toString(res.getEntity(), "UTF-8");
+        System.out.println(ret);
+
+    }
+
+    /**
+     * 给视频添加水印
+     * @param key a.mp4
+     * @param text  4dage
+     * @param fontColor #FFFF00
+     * @param newKey new_a.mp4
+     * @param notifyURL 回调地址
+     * @throws IOException
+     */
+    public static void waterMark(String key, String text, String fontColor, String newKey, String notifyURL) throws IOException {
+        String fop = "avthumb/mp4/";
+        fop = URLEncoder.encode(fop, "utf-8");
+        //水印文字
+        String wmText = UrlSafeBase64.encodeToString(text);
+        //水印文字的颜色
+        String wmFontColor = UrlSafeBase64.encodeToString(fontColor);
+        //设置avthumb 接口
+        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
+        ops.append("avthumb/mp4/wmText/").append(wmText).append("/wmGravityText/NorthEast/wmFontColor/").append(wmFontColor);
+        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + newKey);
+        ops.append("|saveas/").append(saveAs);
+        ops.append("&notifyURL=").append(notifyURL);
+
+        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
+        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
+        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
+        entity.setContentType("application/x-www-form-urlencoded");
+        post.setEntity(entity);
+
+        Auth auth = Auth.create(accessKey, secretKey);
+        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
+        post.setHeader("Authorization", "QBox " + si);
+        HttpClient client = new DefaultHttpClient();
+        HttpResponse res = client.execute(post);
+        String ret = EntityUtils.toString(res.getEntity(), "UTF-8");
+        System.out.println(ret);
+    }
+
+    /**
+     * 将4K图片裁剪成64张512*512
+     * @param key
+     * @param notifyURL  回调地址 "http://wwww.cn/qn/notify&force=1"
+     * @throws IOException
+     */
+    public static void crop4K(String key, String notifyURL) throws IOException {
+        String fop = "imageMogr2/auto-orient/";
+        fop = URLEncoder.encode(fop, "utf-8");
+
+        String fileName = key.substring(0, key.lastIndexOf("."));
+        String suffixName = key.substring(key.lastIndexOf("."));
+
+        Auth auth = Auth.create(accessKey, secretKey);
+
+        for (int i = 0; i < 8; i++) {
+            for (int j = 0; j < 8; j++) {
+                String ret = crop(key, notifyURL, fop, fileName, suffixName, auth, i, j);
+                System.out.println(ret);
+            }
+        }
+    }
+
+    /**
+     * 将2K图片裁剪成16张512*512
+     * @param key
+     * @param notifyURL 回调地址 "http://wwww.cn/qn/notify&force=1"
+     * @throws IOException
+     */
+    public static void crop2k(String key, String notifyURL) throws IOException {
+        String fop = "imageMogr2/auto-orient/";
+        fop = URLEncoder.encode(fop, "utf-8");
+
+        String fileName = key.substring(0, key.lastIndexOf("."));
+        String suffixName = key.substring(key.lastIndexOf("."));
+
+        Auth auth = Auth.create(accessKey, secretKey);
+
+        for (int i = 0; i < 4; i++) {
+            for (int j = 0; j < 4; j++) {
+                String ret = crop(key, notifyURL, fop, fileName, suffixName, auth, i, j);
+                System.out.println(ret);
+            }
+        }
+    }
+
+    /**
+     * 将1K图片裁剪成4张512*512
+     * @param key
+     * @param notifyURL 回调地址 "http://wwww.cn/qn/notify&force=1"
+     * @throws IOException
+     */
+    public static void crop1k(String key, String notifyURL) throws IOException {
+        String fop = "imageMogr2/auto-orient/";
+        fop = URLEncoder.encode(fop, "utf-8");
+
+        String fileName = key.substring(0, key.lastIndexOf("."));
+        String suffixName = key.substring(key.lastIndexOf("."));
+
+        Auth auth = Auth.create(accessKey, secretKey);
+
+        for (int i = 0; i < 2; i++) {
+            for (int j = 0; j < 2; j++) {
+                String ret = crop(key, notifyURL, fop, fileName, suffixName, auth, i, j);
+                System.out.println(ret);
+            }
+        }
+    }
+
+    private static String crop(String key, String notifyURL, String fop, String fileName, String suffixName, Auth auth, int i, int j) throws IOException {
+        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
+        ops.append("crop/!512x512a" + j * 512 + "a" + i * 512);
+
+        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + fileName + "_" + j + "_" + i + suffixName);
+        ops.append("|saveas/").append(saveAs);
+        ops.append("&notifyURL=").append(notifyURL);
+        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
+        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
+        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
+        entity.setContentType("application/x-www-form-urlencoded");
+        post.setEntity(entity);
+
+        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
+        post.setHeader("Authorization", "QBox " + si);
+        HttpClient client = new DefaultHttpClient();
+        HttpResponse res = client.execute(post);
+        return EntityUtils.toString(res.getEntity(), "UTF-8");
+    }
+
+    /**
+     * 将七牛云上的图片缩放成指定大小的图片
+     * @param key
+     * @param width
+     * @param height
+     * @param notifyURL
+     * @throws IOException
+     */
+    public static void thumb(String key, String width, String height, String notifyURL, String newKey) throws IOException {
+        String fop = "imageMogr2/auto-orient/";
+        fop = URLEncoder.encode(fop, "utf-8");
+
+        String fileName = key.substring(0, key.lastIndexOf("."));
+        String suffixName = key.substring(key.lastIndexOf("."));
+
+        Auth auth = Auth.create(accessKey, secretKey);
+
+        StringBuffer ops = new StringBuffer("bucket=").append(bucket).append("&key=").append(key).append("&fops=").append(fop);
+        ops.append("thumbnail/"+width+"x"+height+"!");
+
+        //saveAs新生成文件的名称
+        newKey = StringUtils.isNotEmpty(newKey) ? newKey : (fileName + "_thumb" + suffixName);
+        String saveAs = UrlSafeBase64.encodeToString(bucket + ":" + newKey);
+        ops.append("|saveas/").append(saveAs);
+        ops.append("&notifyURL=").append(notifyURL);
+        HttpPost post = new HttpPost("http://api.qiniu.com/pfop/");
+        post.setHeader(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded");
+        StringEntity entity = new StringEntity(ops.toString(), "utf-8");
+        entity.setContentType("application/x-www-form-urlencoded");
+        post.setEntity(entity);
+
+        String si = auth.signRequest("http://api.qiniu.com/pfop/", ops.toString().getBytes(), "application/x-www-form-urlencoded");
+        post.setHeader("Authorization", "QBox " + si);
+        HttpClient client = new DefaultHttpClient();
+        HttpResponse res = client.execute(post);
+        System.out.println(EntityUtils.toString(res.getEntity(), "UTF-8"));
+    }
+}

+ 0 - 21
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/IncrementTypeController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.user.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 会员权益类型 前端控制器
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@RestController
-@RequestMapping("/user/incrementType")
-public class IncrementTypeController {
-
-}
-

+ 0 - 21
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/IntercomMessageController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.user.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 咨询留言表 前端控制器
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@RestController
-@RequestMapping("/user/intercomMessage")
-public class IntercomMessageController {
-
-}
-

+ 0 - 21
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/ManagerController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.user.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 管理员表 前端控制器
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@RestController
-@RequestMapping("/user/manager")
-public class ManagerController {
-
-}
-

+ 0 - 21
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/ProvinceController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.user.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 中国省份表 前端控制器
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@RestController
-@RequestMapping("/user/province")
-public class ProvinceController {
-
-}
-

+ 0 - 21
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/ReceiverInfoController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.user.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 收货人信息表 前端控制器
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@RestController
-@RequestMapping("/user/receiverInfo")
-public class ReceiverInfoController {
-
-}
-

+ 0 - 21
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/UserController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.user.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 用户信息表 前端控制器
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@RestController
-@RequestMapping("/user/user")
-public class UserController {
-
-}
-

+ 0 - 21
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/UserIncrementController.java

@@ -1,21 +0,0 @@
-package com.fdkankan.user.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 用户增值权益表 前端控制器
- * </p>
- *
- * @author 
- * @since 2021-12-24
- */
-@RestController
-@RequestMapping("/user/userIncrement")
-public class UserIncrementController {
-
-}
-

+ 154 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/api/SsoUserController.java

@@ -0,0 +1,154 @@
+package com.fdkankan.user.controller.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.user.entity.User;
+import com.fdkankan.user.request.RequestUser;
+import com.fdkankan.user.service.IUserService;
+import com.fdkankan.user.service.LoginService;
+import com.fdkankan.user.service.MsgService;
+import com.fdkankan.user.vo.SSOUserVo;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 登陆管理-登陆模块
+ */
+@RestController
+@RequestMapping("/api/sso/user")
+public class SsoUserController {
+
+    @Autowired
+    private IUserService userService;
+    @Autowired
+    private MsgService msgService;
+    @Autowired
+    private LoginService loginService;
+
+    /**
+     * 登录
+     * phoneNum      用户名
+     * cameraType   相机类型,1双目,4八目
+     * msgAuthCode  验证码
+     */
+    @PostMapping(value = "/login")
+    public SSOUserVo login(@RequestBody RequestUser user) throws Exception {
+        return loginService.login(user);
+    }
+
+    /**
+     * 验证码登陆
+     */
+    @PostMapping(value = "/quickLogin")
+    public SSOUserVo quickLogin(@RequestBody RequestUser user) throws Exception {
+        return loginService.quickLogin(user);
+    }
+
+    @PostMapping(value = "/logout")
+    public String logout(@RequestHeader String token) {
+        return loginService.logout(token);
+    }
+
+    /**
+     * 注册
+     * phoneNum 用户名
+     * password 密码
+     * confirmPwd 确认密码
+     * msgAuthCode 验证码
+     * nickName 昵称
+     * country 国家
+     */
+    @PostMapping(value = "/register")
+    public String register(@RequestBody RequestUser user) throws Exception {
+        return userService.register(user);
+    }
+
+    /**
+     * 获取验证码
+     * areaNum  区号
+     * phoneNum 手机号
+     */
+    @PostMapping(value = "/getMsgAuthCode")
+    public String getMsgAuthCode(@RequestBody RequestUser user) throws Exception{
+        return msgService.getMsgAuthCode(user);
+    }
+
+    /**
+     * 发送邮件验证码
+     * email    邮箱地址
+     * country  国家,0中国,1海外
+     */
+    @PostMapping(value = "/getEmailAuthCode")
+    public String getEmailAuthCode(@RequestBody RequestUser user) throws Exception{
+        return msgService.getEmailAuthCode(user);
+    }
+
+    /**
+     * 创建快速登陆的二维码
+     */
+    @PostMapping("/createLoginQrCode")
+    public JSONObject createLoginQrCode() throws Exception {
+        return loginService.createLoginQrCode();
+    }
+
+    /**
+     * 校验扫码登陆
+     * uuid
+     */
+    @PostMapping(value = "/sendUserInfo")
+    public JSONObject sendUserInfo(@RequestBody RequestUser user) throws Exception {
+        return loginService.loginQrCode(user.getUuid());
+    }
+
+    /**
+     * 修改密码
+     */
+    @PostMapping(value = "/changePassword")
+    public String changePassword(@RequestBody RequestUser user){
+        return userService.changePassword(user);
+    }
+
+    /**
+     * 检验用户是否存在
+     */
+    @PostMapping(value = "/checkUser")
+    public String checkUser(@RequestBody RequestUser user){
+        if (StringUtils.isEmpty(user.getPhoneNum())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        User dbUser = userService.getUserByUserName(user.getPhoneNum());
+        if(dbUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_EXIST);
+        }
+        return ServerCode.SUCCESS.message();
+    }
+
+    /**
+     * 检验token是否过期
+     */
+    @PostMapping(value = "/checkToken")
+    public String checkToken(@RequestHeader String token){
+        return  loginService.loginCheck(token);
+    }
+
+    /**
+     * 检验验证码是否有效
+     * @return
+     */
+    @PostMapping(value = "/checkSms")
+    public String checkSms(@RequestBody RequestUser user,@RequestHeader String token){
+        return  loginService.checkSms(token,user.getMsgAuthCode());
+    }
+
+    /**
+     * 登录
+     */
+    @PostMapping(value = "/getToken")
+    public String getToken(@RequestBody RequestUser user) throws Exception {
+        return loginService.getToken(user.getPhoneNum(),user.getPassword());
+    }
+
+}

+ 137 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/controller/api/UserController.java

@@ -0,0 +1,137 @@
+package com.fdkankan.user.controller.api;
+
+import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.user.request.RequestUser;
+import com.fdkankan.user.service.IReceiverInfoService;
+import com.fdkankan.user.service.IUserService;
+import com.fdkankan.user.vo.ReceiverInfoVo;
+import com.fdkankan.user.vo.ResponseUser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 个人中心
+ */
+@RestController
+@RequestMapping("/api/user")
+public class UserController {
+
+    private static Logger log = LoggerFactory.getLogger("programLog");
+    @Autowired
+    private IUserService userService;
+    @Autowired
+    private IReceiverInfoService receiverInfoService;
+
+
+    @RequestMapping(value = "/checkToken", method = RequestMethod.POST)
+    public String checkToken() {
+        return ServerCode.SUCCESS.message();
+    }
+
+    /**
+     * 获取用户信息
+     */
+    @RequestMapping(value = "/getUserInfo", method = RequestMethod.POST)
+    public ResponseUser getUserInfo(@RequestBody RequestUser user, @RequestHeader String token) throws Exception {
+        return userService.getUserInfoByParam(user,token);
+    }
+
+    /**
+     * 修改密码
+     */
+    @RequestMapping(value = "/changePassword", method = RequestMethod.POST)
+    public String changePassword(@RequestBody RequestUser user){
+        return userService.changePassword(user);
+    }
+
+    /**
+     * 用户上传头像
+     * imgdata 图片的base64码
+     */
+    @RequestMapping(value = "/uploadHead", method = RequestMethod.POST)
+    public String uploadHead(@RequestBody RequestUser user,@RequestHeader String token) throws Exception {
+        return userService.uploadHead(user,token);
+    }
+
+    /**
+     * 用户新增收货地址
+     * shipAddress      收货地址-详细地址
+     * shipAreaPath     收货地址-省-市-区
+     * province         所在地区-省
+     * city             所在地区-市
+     * shipName         收货人
+     * shipMobile       收货人手机
+     */
+    @RequestMapping(value = "/insertAddress", method = RequestMethod.POST)
+    public String insertAddress(@RequestBody RequestUser user,@RequestHeader String token){
+        return userService.insertAddress(user,token);
+    }
+
+    /**
+     * 用户更新默认地址
+     * id
+     * shipAddress      收货地址-详细地址
+     * shipAreaPath     收货地址-省-市-区
+     * province         所在地区-省
+     * city             所在地区-市
+     * shipName         收货人
+     * shipMobile       收货人手机
+     * setDefault       1表示默认地址,0表示不是默认地址
+     */
+    @RequestMapping(value = "/updateAddress", method = RequestMethod.POST)
+
+    public String updateAddress(@RequestBody RequestUser user,@RequestHeader String token){
+        return userService.updateDefaultAddress(user,token);
+    }
+
+    /**
+     * 获取用户默认收货信息
+     */
+    @RequestMapping(value = "/getReceiverInfo", method = RequestMethod.POST)
+    public ReceiverInfoVo getReceiverInfo(@RequestHeader String token){
+        return  userService.getUserDefaultReceiver(token);
+    }
+
+    /**
+     * 获取用户收货信息列表
+     * @return
+     */
+    @RequestMapping(value = "/getReceiverList", method = RequestMethod.POST)
+    public List<ReceiverInfoVo> getReceiverList(@RequestHeader String token){
+        return userService.getReceiverList(token);
+    }
+
+    /**
+     * 用户删除默认地址
+     */
+    @RequestMapping(value = "/deleteAddress", method = RequestMethod.POST)
+    public String deleteAddress(@RequestBody RequestUser user){
+        return userService.removeAddress(user.getId());
+    }
+    /**
+     * 用户更新邮箱地址
+     */
+    @RequestMapping(value = "/updateEmail", method = RequestMethod.POST)
+    public String updateEmail(@RequestBody RequestUser user,@RequestHeader String token){
+        return userService.updateEmail(user,token);
+    }
+
+    /**
+     * 更改昵称
+     */
+    @RequestMapping(value = "/updateNickName", method = RequestMethod.POST)
+    public String updateNickName(@RequestBody RequestUser user){
+        return null;
+    }
+    /**
+     * 修改用户信息
+     */
+    @RequestMapping(value = "/updateUserDetail", method = RequestMethod.POST)
+    public String updateUserDetail(@RequestBody RequestUser user){
+        return null;
+    }
+}

+ 25 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/entity/SSOUser.java

@@ -0,0 +1,25 @@
+package com.fdkankan.user.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Set;
+
+@Data
+public class SSOUser implements Serializable {
+
+    private static final long serialVersionUID = -2560069033053679931L;
+
+    private Long id;
+
+    private String userName;
+
+    private String password;
+
+    private String email;
+
+    private Set<String> permissionSet;
+
+    private Set<String> roleSet;
+
+}

+ 89 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/request/RequestUser.java

@@ -0,0 +1,89 @@
+package com.fdkankan.user.request;
+
+import com.fdkankan.common.request.RequestBase;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+//用户对象 参数
+public class RequestUser extends RequestBase implements Serializable {
+    private static final long serialVersionUID = 4835988280504608525L;
+
+    private Long userId;
+
+    private int status;
+
+    private String password;
+
+    private String confirmPwd;
+
+    private String randomcode;
+
+    private String phoneNum;
+
+    private String msgAuthCode;
+
+    private String imgdata;
+
+    private String areaNum;
+
+    private String nickName;
+
+    private String country;
+
+    private boolean rememberMe = false;
+    //扫码登录凭证
+    private String uuid;
+
+    private String appUserName;
+
+    private String appPassword;
+
+    private String province;
+
+    private String city;
+    //收货地址
+    private String shipAddress;
+    //收货地址
+    private String shipAreaPath;
+    //收货人手机号
+    private String shipMobile;
+    //收货姓名
+    private String shipName;
+
+    private String email;
+
+    private String startDate;
+
+    private String endDate;
+
+    private String searchKey;
+
+    private String sceneNum;
+
+    private String unicode;
+
+    private String head;
+
+    private Integer cameraType;
+
+    private Long cameraId;
+
+    private Integer isNotice;
+
+    private Long id;
+
+    private Integer setDefault;
+
+    private String orderBy;
+
+    private Integer sceneType;
+
+    private String sceneName;
+
+    private String downloadUrl;
+
+    private Boolean isTiles;
+
+}

+ 10 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/IReceiverInfoService.java

@@ -2,6 +2,9 @@ package com.fdkankan.user.service;
 
 import com.fdkankan.user.entity.ReceiverInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.user.request.RequestUser;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IReceiverInfoService extends IService<ReceiverInfo> {
 
+    ReceiverInfo getDefaultByUserId(Long userId);
+
+    String saveByParam(RequestUser param, Long userId);
+
+    String updateDefaultAddress(RequestUser param, Long userId);
+
+    List<ReceiverInfo> getListByUserId(Long id);
 }

+ 3 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/IUserIncrementService.java

@@ -13,4 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IUserIncrementService extends IService<UserIncrement> {
 
+    Integer getCountByUserId(Long userId, int status);
+
+    Integer getCountBindByUserId(Long userId);
 }

+ 33 - 1
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/IUserService.java

@@ -1,7 +1,14 @@
 package com.fdkankan.user.service;
 
-import com.fdkankan.user.entity.User;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.user.entity.SSOUser;
+import com.fdkankan.user.entity.User;
+import com.fdkankan.user.request.RequestUser;
+import com.fdkankan.user.vo.ReceiverInfoVo;
+import com.fdkankan.user.vo.ResponseUser;
+import com.fdkankan.user.vo.SSOUserVo;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +20,29 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IUserService extends IService<User> {
 
+    String register(RequestUser user);
+
+    User getUserByUserName(String userName);
+
+    SSOUser getSsoUserByUserName(User user,String phoneNum);
+
+    String changePassword(RequestUser user);
+
+    SSOUserVo getUserInfoByUser(Integer cameraType, User dbUser, String token);
+
+    ResponseUser getUserInfoByParam(RequestUser user, String token);
+
+    String uploadHead(RequestUser user,String token)throws Exception;
+
+    String insertAddress(RequestUser user,String token);
+
+    String updateDefaultAddress(RequestUser user, String token);
+
+    ReceiverInfoVo getUserDefaultReceiver(String token);
+
+    String removeAddress(Long param);
+
+    List<ReceiverInfoVo> getReceiverList(String token);
+
+    String updateEmail(RequestUser param, String token);
 }

+ 198 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/LoginService.java

@@ -0,0 +1,198 @@
+package com.fdkankan.user.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.ConstantFilePath;
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.util.*;
+import com.fdkankan.user.common.SSOLoginHelper;
+import com.fdkankan.user.common.util.MatrixToImageWriterUtil;
+import com.fdkankan.user.entity.SSOUser;
+import com.fdkankan.user.entity.User;
+import com.fdkankan.user.request.RequestUser;
+import com.fdkankan.user.vo.SSOUserVo;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+public class LoginService {
+
+    @Resource
+    private RedisTemplate<String,String> redisTemplate;
+    @Autowired
+    private  IUserService userService;
+    @Autowired
+    private SSOLoginHelper ssoLoginHelper;
+    @Value("${main.url:https://test.4dkankan.com/}")
+    private String mainUrl;
+
+
+    public SSOUserVo login(RequestUser param) {
+        if (StringUtils.isEmpty(param.getPassword()) || StringUtils.isEmpty(param.getPhoneNum())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        User dbUser = userService.getUserByUserName(param.getPhoneNum());
+        SSOUser ssoUser = userService.getSsoUserByUserName(dbUser,param.getPhoneNum());
+        if(ssoUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_EXIST);
+        }
+        //对前端传的密码解密
+        String password = Base64Converter.decode(Base64Converter.subText(ssoUser.getPassword()));
+        ssoUser.setPassword(password);
+        String token = this.commonLogin(ssoUser);
+        this.removeTimeOutToken(param.getPhoneNum(),token);
+        return  userService.getUserInfoByUser(param.getCameraType(), dbUser,token);
+    }
+
+
+    public SSOUserVo quickLogin(RequestUser param) {
+        if(StringUtils.isEmpty(param.getPhoneNum()) || StringUtils.isEmpty(param.getMsgAuthCode())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        //验证码校验
+        String codeValue = redisTemplate.opsForValue().get(SsoUtil.PREFIX_MSG_AUTH_CODE + param.getPhoneNum());
+        if (StringUtils.isEmpty(codeValue)){
+            throw new BusinessException(ErrorCode.V_CODE_ERROR);
+        }
+        if (!codeValue.equals(param.getMsgAuthCode())){
+            throw new BusinessException(ErrorCode.V_CODE_ERROR);
+        }
+        User dbUser = userService.getUserByUserName(param.getPhoneNum());
+        SSOUser ssoUser = userService.getSsoUserByUserName(dbUser,param.getPhoneNum());
+        if(ssoUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_EXIST);
+        }
+        String token = JwtUtil.createJWT(-1, ssoUser.getUserName(),"user");
+        ssoLoginHelper.login(token, ssoUser);
+        removeTimeOutToken(param.getPhoneNum(),token);
+        return  userService.getUserInfoByUser( param.getCameraType(), dbUser,token);
+    }
+
+
+    private void removeTimeOutToken(String phone,String token){
+        JSONArray tokenArray = new JSONArray();
+        JSONArray removeArray = new JSONArray();
+        JSONObject tokenJson = new JSONObject();
+        Long time = 0L;
+        if(redisTemplate.hasKey(SsoUtil.USER_TOKEN + phone)){
+            tokenArray = JSONArray.parseArray(redisTemplate.opsForValue().get(SsoUtil.USER_TOKEN + phone));
+            for(int i = 0, len = tokenArray.size(); i < len; i++){
+                JSONObject json = tokenArray.getJSONObject(i);
+                time = json.getLong("time");
+                if((System.currentTimeMillis() - time) / (1000 * 3600 * 24) > 2){
+                    ssoLoginHelper.logout(json.getString("token"));
+                    removeArray.add(json);
+                }
+            }
+            if(removeArray.size() > 0){
+                tokenArray.remove(removeArray);
+            }
+            tokenJson.put("token", token);
+            tokenJson.put("time", System.currentTimeMillis());
+            tokenArray.add(tokenJson);
+            redisTemplate.opsForValue().set(SsoUtil.USER_TOKEN + phone, tokenArray.toString());
+        }else {
+            tokenJson.put("token", token);
+            tokenJson.put("time", System.currentTimeMillis());
+            tokenArray.add(tokenJson);
+            redisTemplate.opsForValue().set(SsoUtil.USER_TOKEN + phone, tokenArray.toString());
+        }
+    }
+
+    public String logout(String token) {
+        ssoLoginHelper.logout(token);
+        return ServerCode.SUCCESS.message();
+    }
+
+
+    public String loginCheck(String token) {
+        SSOUser ssoUser = ssoLoginHelper.loginCheck(token);
+        if (ssoUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
+        }
+        return  ServerCode.SUCCESS.message();
+    }
+
+
+    public String checkSms(String token, String msgAuthCode) {
+        SSOUser ssoUser = ssoLoginHelper.loginCheck(token);
+        if (ssoUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
+        }
+        String codeValue = redisTemplate.opsForValue().get(SsoUtil.PREFIX_MSG_AUTH_CODE + ssoUser.getUserName());
+        if (StringUtils.isEmpty(codeValue)){
+            throw new BusinessException(ErrorCode.V_CODE_ERROR);
+        }
+        if (!codeValue.equals(msgAuthCode)){
+            throw new BusinessException(ErrorCode.V_CODE_ERROR);
+        }
+        return ServerCode.SUCCESS.message();
+    }
+
+    public String getToken(String phoneNum, String password) {
+        if (StringUtils.isEmpty(phoneNum) || StringUtils.isEmpty(password)){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        User userByUserName = userService.getUserByUserName(phoneNum);
+        if (userByUserName == null){
+            throw new BusinessException(ErrorCode.USER_NOT_EXIST);
+        }
+        SSOUser ssoUser = userService.getSsoUserByUserName(userByUserName, phoneNum);
+
+        return this.commonLogin(ssoUser);
+    }
+
+
+    public JSONObject createLoginQrCode() throws Exception{
+        String uuid = NumberUtils.getUUID();
+        String filePath = ConstantFilePath.LOGIN_QR_CODE_PATH + uuid + ".png";
+        MatrixToImageWriterUtil.createQRCode(mainUrl + "app/index.html?m="+uuid, filePath, null);
+        JSONObject json = new JSONObject();
+        json.put("url", filePath.replace(ConstantFilePath.BASE_PATH, ""));
+        json.put("uuid", uuid);
+        return json;
+    }
+
+    public JSONObject loginQrCode(String uuid) {
+        if (StringUtils.isEmpty(uuid)){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        if (!redisTemplate.hasKey(uuid)){
+            throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
+        }
+        String childName = redisTemplate.opsForValue().get(uuid);
+        SSOUser dbUser = new SSOUser();
+        dbUser.setUserName(childName);
+
+        String token = JwtUtil.createJWT(-1, childName,"user");
+        ssoLoginHelper.login(token, dbUser);
+
+        JSONObject object = new JSONObject();
+        object.put("token", token);
+        object.put("childName", childName);
+        object.put("to", 1);
+        redisTemplate.delete(uuid);
+        //删除二维码图片
+        FileUtils.deleteFile(ConstantFilePath.LOGIN_QR_CODE_PATH + uuid + ".png");
+        return object;
+    }
+
+
+    private String commonLogin(SSOUser ssoUser){
+        String passwordCode = SecurityUtil.MD5(ssoUser.getPassword());
+        if (!passwordCode.equals(ssoUser.getPassword())){
+            throw new BusinessException(ErrorCode.PASSWORD_ERROR);
+        }
+
+        String token = JwtUtil.createJWT(-1, ssoUser.getUserName(),"user");
+        ssoLoginHelper.login(token, ssoUser);
+        return token;
+    }
+}

+ 92 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/MsgService.java

@@ -0,0 +1,92 @@
+package com.fdkankan.user.service;
+
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.sms.SendMailAcceUtils;
+import com.fdkankan.common.sms.SmsService;
+import com.fdkankan.common.util.PatternUtils;
+import com.fdkankan.common.util.SsoUtil;
+import com.fdkankan.user.request.RequestUser;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.concurrent.TimeUnit;
+
+@Service
+public class MsgService {
+
+    @Resource
+    private RedisTemplate<String,String> redisTemplate;
+    @Autowired
+    private IUserService userService;
+    @Autowired
+    private SmsService smsService;
+
+    @Value("${admin.register.validCode:2a22bac40f44af4d3b5fdc20ea706fc5}")
+    private  String registerValidCode;
+    @Value("${phone.code.cn:SMS_179150247}")
+    private String cnCode;
+    @Value("${phone.code.en:SMS_139242688}")
+    private String enCode;
+    @Value("${environment:dev}")
+    private String environment;
+
+
+    public String getMsgAuthCode(RequestUser param) throws Exception{
+        if(StringUtils.isBlank(param.getPhoneNum()) || StringUtils.isBlank(param.getAreaNum())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        String key = SsoUtil.PREFIX_MSG_NOT_CODE + param.getPhoneNum();
+        Long time = redisTemplate.opsForValue().getOperations().getExpire(key);
+        if(time!=null && time >0){
+            throw  new BusinessException(ErrorCode.V_CODE_TIME_NOT_OUT.code(),String.valueOf(time));
+        }
+        String code = String.valueOf((int)((Math.random()*9+1)*100000));
+        if ("86".equals(param.getAreaNum())){
+            if (!PatternUtils.isPhoneNumber(param.getPhoneNum())){
+                throw new BusinessException(ErrorCode.PHONE_VIOLATION);
+            }
+            String sendCode = smsService.sendSms(param.getPhoneNum(), "{\"code\":\"" + code + "\"}", cnCode);
+            if("isv.BUSINESS_LIMIT_CONTROL".equals(sendCode)){
+                throw new BusinessException(ErrorCode.PHONE_CODE_TO_MANY);
+            }
+        }else{
+            try{
+                smsService.sendSMSMessage(param.getAreaNum()+param.getPhoneNum(), code);
+            }catch (Exception e){
+                e.printStackTrace();
+                throw new BusinessException(ErrorCode.PHONE_VIOLATION);
+            }
+        }
+        //短信验证码,5分钟有效
+        redisTemplate.opsForValue().set(SsoUtil.PREFIX_MSG_AUTH_CODE + param.getPhoneNum(), code, 300, TimeUnit.SECONDS);
+        //短信60秒内不能重发
+        redisTemplate.opsForValue().set(SsoUtil.PREFIX_MSG_NOT_CODE + param.getPhoneNum(), code, 60, TimeUnit.SECONDS);
+        return ServerCode.SUCCESS.message();
+    }
+
+    public String getEmailAuthCode(RequestUser param)throws Exception {
+        if(StringUtils.isEmpty(param.getEmail())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        String code = String.valueOf((int)((Math.random()*9+1)*100000));
+        switch (param.getCountry()){
+            case "1" :
+                SendMailAcceUtils.sendMail(param.getEmail(), SendMailAcceUtils.EN_CODE_SUBJECT, SendMailAcceUtils.EN_CODE_MSG.replace("${code}", code), null);
+                break;
+            case "2" :
+                SendMailAcceUtils.sendMailUsa(param.getEmail(), SendMailAcceUtils.EN_CODE_SUBJECT_USA, SendMailAcceUtils.EN_CODE_MSG_USA.replace("${code}", code), null);
+                break;
+            default:
+                SendMailAcceUtils.sendMail(param.getEmail(), SendMailAcceUtils.CN_CODE_SUBJECT, SendMailAcceUtils.CN_CODE_MSG.replace("${code}", code), null);
+                break;
+        }
+        redisTemplate.opsForValue().set(SsoUtil.PREFIX_MSG_AUTH_CODE + param.getPhoneNum(), code, 300, TimeUnit.SECONDS);
+        return ServerCode.SUCCESS.message();
+    }
+}

+ 131 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/RegisterService.java

@@ -0,0 +1,131 @@
+package com.fdkankan.user.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.ConstantRegex;
+import com.fdkankan.common.constant.ConstantUrl;
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.util.Base64Converter;
+import com.fdkankan.common.util.SecurityUtil;
+import com.fdkankan.common.util.SsoUtil;
+import com.fdkankan.common.validation.Variable;
+import com.fdkankan.user.common.SSOLoginHelper;
+import com.fdkankan.user.entity.User;
+import com.fdkankan.user.request.RequestUser;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.Set;
+
+@Service
+public class RegisterService {
+
+    @Value("${admin.register.validCode:2a22bac40f44af4d3b5fdc20ea706fc5}")
+    private  String registerValidCode;
+    @Resource
+    private RedisTemplate<String,String> redisTemplate;
+    @Autowired
+    private  IUserService userService;
+    @Autowired
+    private SSOLoginHelper ssoLoginHelper;
+
+
+    private void checkParam(RequestUser param){
+        //正则判断密码是否符合规则(8位以上并且数字英文组合)
+        if(!param.getPassword().matches(ConstantRegex.PASSWORD_REGEX)){
+            throw new BusinessException(ErrorCode.PASSWORD_VIOLATION);
+        }
+        if (!param.getConfirmPwd().equals(param.getPassword())){
+            throw new BusinessException(ErrorCode.PASSWORD_TWO_VIOLATION);
+        }
+//        if ("86".equals(param.getCountry()) && !PatternUtils.isPhoneNumber(param.getPhoneNum())){
+//            throw new BusinessException(ErrorCode.PHONE_VIOLATION);
+//        }
+        //验证码校验
+        String msgAuthCode = param.getMsgAuthCode();
+        if (!StringUtils.equals(msgAuthCode, registerValidCode)) {
+            String codeValue = redisTemplate.opsForValue().get(SsoUtil.PREFIX_MSG_AUTH_CODE + param.getPhoneNum());
+            if (StringUtils.isEmpty(codeValue)) {
+                throw new BusinessException(ErrorCode.V_CODE_ERROR);
+            }
+            if (!codeValue.equals(param.getMsgAuthCode())) {
+                throw new BusinessException(ErrorCode.V_CODE_ERROR);            }
+        }
+
+    }
+
+
+    public void register(RequestUser param) {
+        if (StringUtils.isEmpty(param.getPassword()) || StringUtils.isEmpty(param.getPhoneNum()) ||
+                StringUtils.isEmpty(param.getMsgAuthCode()) || StringUtils.isEmpty(param.getNickName()) ||
+                StringUtils.isEmpty(param.getCountry()) || StringUtils.isEmpty(param.getConfirmPwd())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        User dbUser = userService.getUserByUserName(param.getPhoneNum());
+        if (dbUser != null){
+            throw new BusinessException(ErrorCode.PHONE_EXIST);
+        }
+        this.checkParam(param);
+        //检验昵称敏感词
+        Set<String> set = Variable.sensitiveWord.getSensitiveWord(param.getNickName(), 1);
+        if (set != null && set.size() > 0){
+            throw new BusinessException(ErrorCode.NICKNAME_ERROR);
+        }
+        //注册,新建注册用户信息
+        User userEntity = new User();
+        userEntity.setPassword(SecurityUtil.MD5(param.getPassword()));
+        userEntity.setEmail(param.getEmail());
+        userEntity.setUserName(param.getPhoneNum());
+        userEntity.setRegisterTime(new Date());
+        userEntity.setNickName(param.getNickName());
+        userEntity.setHead(ConstantUrl.DEFAULT_USER_HEAD);
+        userEntity.setCountry(param.getCountry());
+        userEntity.setStatus(1);
+        userEntity.setIsNotice(1);
+        userService.save(userEntity);
+        //删除验证码缓存
+        redisTemplate.delete(SsoUtil.PREFIX_MSG_AUTH_CODE + param.getPhoneNum());
+    }
+
+    public String changePassword(RequestUser param) {
+        if (StringUtils.isEmpty(param.getPassword()) || StringUtils.isEmpty(param.getConfirmPwd()) ||
+                StringUtils.isEmpty(param.getMsgAuthCode()) || StringUtils.isEmpty(param.getPhoneNum())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        User dbUser = userService.getUserByUserName(param.getPhoneNum());
+        if (dbUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_EXIST);
+        }
+        this.checkParam(param);
+        //对前端传的密码解密
+        String password = Base64Converter.decode(Base64Converter.subText(param.getPassword()));
+        dbUser.setPassword(SecurityUtil.MD5(password));
+        if(!userService.updateById(dbUser)){
+            throw new BusinessException(ErrorCode.ERROR_MSG);
+        }
+        this.removeAllToken(param.getPhoneNum());
+        return ServerCode.SUCCESS.message();
+    }
+
+    private void removeAllToken(String phone){
+        //删除缓存
+        redisTemplate.delete(SsoUtil.PREFIX_MSG_AUTH_CODE + phone);
+        JSONArray tokenArray = new JSONArray();
+        if(redisTemplate.hasKey(SsoUtil.USER_TOKEN + phone)){
+            tokenArray = JSONArray.parseArray(redisTemplate.opsForValue().get(SsoUtil.USER_TOKEN + phone));
+            for(int i = 0, len = tokenArray.size(); i < len; i++){
+                JSONObject json = tokenArray.getJSONObject(i);
+                ssoLoginHelper.logout(json.getString("token"));
+            }
+            redisTemplate.delete(SsoUtil.USER_TOKEN + phone);
+            redisTemplate.delete(SsoUtil.PREFIX_CACHE_CAMERA + phone);
+        }
+    }
+}

+ 69 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/impl/ReceiverInfoServiceImpl.java

@@ -1,11 +1,18 @@
 package com.fdkankan.user.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.user.entity.ReceiverInfo;
 import com.fdkankan.user.mapper.IReceiverInfoMapper;
+import com.fdkankan.user.request.RequestUser;
 import com.fdkankan.user.service.IReceiverInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 收货人信息表 服务实现类
@@ -17,4 +24,66 @@ import org.springframework.stereotype.Service;
 @Service
 public class ReceiverInfoServiceImpl extends ServiceImpl<IReceiverInfoMapper, ReceiverInfo> implements IReceiverInfoService {
 
+    @Override
+    public ReceiverInfo getDefaultByUserId(Long userId){
+        QueryWrapper<ReceiverInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ReceiverInfo::getUserId,userId);
+        queryWrapper.lambda().eq(ReceiverInfo::getSetDefault,1);
+        List<ReceiverInfo> list = this.list(queryWrapper);
+        if(list == null || list.size()<=0){
+            return null;
+        }
+        return list.get(0);
+    }
+
+    @Override
+    public String saveByParam(RequestUser param, Long userId) {
+        ReceiverInfo defaultEntity = getDefaultByUserId(userId);
+        ReceiverInfo receiverInfoEntity = new ReceiverInfo();
+        receiverInfoEntity.setSetDefault(0);
+        if(defaultEntity == null){
+            receiverInfoEntity.setSetDefault(1);
+        }
+        receiverInfoEntity.setUserId(userId);
+        receiverInfoEntity.setShipAreaPath(param.getShipAreaPath());
+        receiverInfoEntity.setShipAddress(param.getShipAddress());
+        receiverInfoEntity.setShipName(param.getShipName());
+        receiverInfoEntity.setShipMobile(param.getShipMobile());
+        if(!this.save(receiverInfoEntity)){
+            throw new BusinessException(ErrorCode.ERROR_MSG);
+        }
+        return ServerCode.SUCCESS.message();
+    }
+
+    @Override
+    public String updateDefaultAddress(RequestUser param, Long userId) {
+        if(param.getSetDefault() != null && param.getSetDefault() == 1){
+            ReceiverInfo defaultEntity = this.getDefaultByUserId(userId);
+            if(defaultEntity != null && defaultEntity.getId().intValue() != param.getId().intValue()){
+                defaultEntity.setSetDefault(0);
+                if(!this.updateById(defaultEntity)){
+                    throw new BusinessException(ErrorCode.ERROR_MSG);
+                }
+            }
+        }
+        ReceiverInfo receiverInfoEntity = this.getById(param.getId());
+        if(param.getSetDefault() != null){
+            receiverInfoEntity.setSetDefault(param.getSetDefault());
+        }
+        receiverInfoEntity.setShipAreaPath(param.getShipAreaPath());
+        receiverInfoEntity.setShipAddress(param.getShipAddress());
+        receiverInfoEntity.setShipName(param.getShipName());
+        receiverInfoEntity.setShipMobile(param.getShipMobile());
+        if(!this.updateById(receiverInfoEntity)){
+            throw new BusinessException(ErrorCode.ERROR_MSG);
+        }
+        return ServerCode.SUCCESS.message();
+    }
+
+    @Override
+    public List<ReceiverInfo> getListByUserId(Long userId) {
+        QueryWrapper<ReceiverInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ReceiverInfo::getUserId,userId);
+        return this.list(queryWrapper);
+    }
 }

+ 16 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/impl/UserIncrementServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fdkankan.user.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fdkankan.user.entity.UserIncrement;
 import com.fdkankan.user.mapper.IUserIncrementMapper;
 import com.fdkankan.user.service.IUserIncrementService;
@@ -17,4 +18,19 @@ import org.springframework.stereotype.Service;
 @Service
 public class UserIncrementServiceImpl extends ServiceImpl<IUserIncrementMapper, UserIncrement> implements IUserIncrementService {
 
+    @Override
+    public Integer getCountByUserId(Long userId, int status) {
+        QueryWrapper<UserIncrement> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(UserIncrement::getUserId,userId);
+        queryWrapper.lambda().eq(UserIncrement::getIsExpired,status);
+        return Math.toIntExact(this.count(queryWrapper));
+    }
+
+    @Override
+    public Integer getCountBindByUserId(Long userId) {
+        QueryWrapper<UserIncrement> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(UserIncrement::getUserId,userId);
+        queryWrapper.lambda().isNotNull(UserIncrement::getCameraId);
+        return Math.toIntExact(this.count(queryWrapper));
+    }
 }

+ 236 - 2
4dkankan-center-platform/src/main/java/com/fdkankan/user/service/impl/UserServiceImpl.java

@@ -1,20 +1,254 @@
 package com.fdkankan.user.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.common.constant.*;
+import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.util.Base64Converter;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.user.common.SSOLoginHelper;
+import com.fdkankan.user.common.util.QiniuUpload;
+import com.fdkankan.user.entity.ReceiverInfo;
+import com.fdkankan.user.entity.SSOUser;
 import com.fdkankan.user.entity.User;
 import com.fdkankan.user.mapper.IUserMapper;
+import com.fdkankan.user.request.RequestUser;
+import com.fdkankan.user.service.IReceiverInfoService;
+import com.fdkankan.user.service.IUserIncrementService;
 import com.fdkankan.user.service.IUserService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.user.service.RegisterService;
+import com.fdkankan.user.vo.ReceiverInfoVo;
+import com.fdkankan.user.vo.ResponseUser;
+import com.fdkankan.user.vo.SSOUserVo;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  * 用户信息表 服务实现类
  * </p>
  *
- * @author 
+ * @author
  * @since 2021-12-24
  */
 @Service
 public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements IUserService {
 
+    @Value("${admin.register.validCode:2a22bac40f44af4d3b5fdc20ea706fc5}")
+    private  String registerValidCode;
+    @Autowired
+    private RegisterService registerService;
+    @Autowired
+    private SSOLoginHelper ssoLoginHelper;
+    @Autowired
+    private IUserIncrementService userIncrementService;
+    @Autowired
+    private IReceiverInfoService receiverInfoService;
+
+    @Override
+    public String register(RequestUser user) {
+        if (!user.getMsgAuthCode().equals(registerValidCode)) {
+            //对前端传的密码解密
+            String password = Base64Converter.decode(Base64Converter.subText(user.getPassword()));
+            user.setPassword(password);
+
+            String confirPwd = Base64Converter.decode(Base64Converter.subText(user.getConfirmPwd()));
+            user.setConfirmPwd(confirPwd);
+        }else{
+            user.setCountry("86");
+        }
+        registerService.register(user);
+
+        return ServerCode.SUCCESS.message();
+    }
+
+    @Override
+    public String changePassword(RequestUser param) {
+        return registerService.changePassword(param);
+    }
+
+    @Override
+    public User getUserByUserName(String userName){
+        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(User::getUserName,userName);
+        List<User> list = this.list(queryWrapper);
+        if(list == null || list.size()<=0){
+            return null;
+        }
+        return list.get(0);
+    }
+
+    @Override
+    public SSOUser getSsoUserByUserName(User userEntity,String phoneNum) {
+        SSOUser user = null;
+        if (userEntity != null){
+            user = new SSOUser();
+            user.setId(userEntity.getId());
+            user.setUserName(userEntity.getUserName());
+            user.setEmail(userEntity.getEmail());
+            user.setPassword(userEntity.getPassword());
+        }
+        return user;
+    }
+
+    @Override
+    public SSOUserVo getUserInfoByUser(Integer cameraType, User dbUser,String token) {
+        ResponseUser vo = new ResponseUser();
+        BeanUtils.copyProperties(dbUser,vo);
+        if(cameraType != null){
+            //todo sceneCount  CameraCount
+        }else {
+
+        }
+        vo.setSceneCount(0);
+        vo.setCameraCount(0);
+        SSOUserVo ssoUserVo = new SSOUserVo();
+        ssoUserVo.setToken(token);
+        ssoUserVo.setResponseUser(vo);
+        return ssoUserVo;
+    }
+
+    @Override
+    public ResponseUser getUserInfoByParam(RequestUser param,String token) {
+        User dbUser = this.getDbUserByToken(token);
+        SSOUserVo ssoUserVo = this.getUserInfoByUser(param.getCameraType(), dbUser, token);
+        ResponseUser vo = ssoUserVo.getResponseUser();
+        Integer incrementCount = userIncrementService.getCountByUserId(dbUser.getId(),0);
+        Integer incrementBindCount = userIncrementService.getCountBindByUserId(dbUser.getId());
+        vo.setIncrementNum(incrementCount);
+        vo.setIncrementBindNum(incrementBindCount);
+        return vo;
+    }
+
+    @Override
+    public String uploadHead(RequestUser param,String token) throws Exception{
+        if (StringUtils.isEmpty(param.getImgdata())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        User dbUser = this.getDbUserByToken(token);
+
+        StringBuilder sb = new StringBuilder().append("head")
+                .append(File.separator).append(dbUser.getUserName()).append(File.separator)
+                .append("head").append("_").append(new Date().getTime()).append(".png");
+        StringBuilder qiniuPath = new StringBuilder().append("head")
+                .append("/").append(dbUser.getUserName()).append("/")
+                .append("head").append("_").append(new Date().getTime()).append(".png");
+        FileUtils.uploadImg(ConstantFilePath.USER_IMAGES_PATH + sb.toString(), param.getImgdata());
+        dbUser.setHead(ConstantUrl.PREFIX_QINIU + qiniuPath.toString()+"?m="+System.currentTimeMillis());
+        this.updateById(dbUser);
+        //上传头像到七牛云
+        try {
+            QiniuUpload.delete(qiniuPath.toString());
+        } catch (Exception e) { }
+        if (QiniuUpload.setFileToBucket(qiniuPath.toString(), ConstantFilePath.USER_IMAGES_PATH + sb.toString())) {
+            FileUtils.deleteFile(ConstantFilePath.USER_IMAGES_PATH + sb.toString());
+        }
+        QiniuUpload.refresh(dbUser.getHead());
+        return dbUser.getHead();
+    }
+    private User getDbUserByToken(String token){
+        SSOUser ssoUser = ssoLoginHelper.loginCheck(token);
+        if(ssoUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
+        }
+        User dbUser = this.getUserByUserName(ssoUser.getUserName());
+        if(dbUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
+        }
+        return dbUser;
+    }
+    private SSOUser getSSOUserByToken(String token){
+        SSOUser ssoUser = ssoLoginHelper.loginCheck(token);
+        if(ssoUser == null){
+            throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
+        }
+        return ssoUser;
+    }
+
+    @Override
+    public String insertAddress(RequestUser user,String token) {
+        if (StringUtils.isEmpty(user.getShipAddress()) || StringUtils.isEmpty(user.getShipAreaPath())
+                || StringUtils.isEmpty(user.getProvince()) || StringUtils.isEmpty(user.getCity())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        SSOUser ssoUser = getSSOUserByToken(token);
+        return receiverInfoService.saveByParam(user,ssoUser.getId());
+    }
+
+    @Override
+    public String updateDefaultAddress(RequestUser user, String token) {
+        if (user.getId() == null || StringUtils.isEmpty(user.getShipAddress()) || StringUtils.isEmpty(user.getShipAreaPath())
+                || StringUtils.isEmpty(user.getProvince()) || StringUtils.isEmpty(user.getCity())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        SSOUser ssoUser = getSSOUserByToken(token);
+        return receiverInfoService.updateDefaultAddress(user,ssoUser.getId());
+    }
+
+    @Override
+    public ReceiverInfoVo getUserDefaultReceiver(String token) {
+        SSOUser ssoUser = getSSOUserByToken(token);
+        ReceiverInfo receiverInfoEntity = receiverInfoService.getDefaultByUserId(ssoUser.getId());
+        ReceiverInfoVo responseReceiverInfo = new ReceiverInfoVo();
+        if(receiverInfoEntity!=null){
+            BeanUtils.copyProperties(receiverInfoEntity,responseReceiverInfo);
+        }
+        return responseReceiverInfo;
+    }
+
+    @Override
+    public String removeAddress(Long paramId) {
+        if (paramId == null ){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        if(!receiverInfoService.removeById(paramId)){
+            throw new BusinessException(ErrorCode.ERROR_MSG);
+        }
+        return ServerCode.SUCCESS.message();
+    }
+
+    @Override
+    public List<ReceiverInfoVo> getReceiverList(String token) {
+        SSOUser ssoUser = getSSOUserByToken(token);
+        List<ReceiverInfo> list = receiverInfoService.getListByUserId(ssoUser.getId());
+        List<ReceiverInfoVo> voList = list.parallelStream().map(receiverInfo -> {
+            ReceiverInfoVo receiverInfoVo = new ReceiverInfoVo();
+            BeanUtils.copyProperties(receiverInfo, receiverInfoVo);
+            return receiverInfoVo;
+        }).collect(Collectors.toList());
+        return voList;
+    }
+
+    @Override
+    public String updateEmail(RequestUser param, String token) {
+        if (StringUtils.isEmpty(param.getEmail())){
+            throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        if(param.getEmail() != null && !param.getEmail().matches(ConstantRegex.EMAIL_REGEX)){
+            throw new BusinessException(ErrorCode.EMAIL_ERROR);
+        }
+        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(User ::getEmail,param.getEmail());
+        List<User> list = this.list(queryWrapper);
+        SSOUser ssoUser = ssoLoginHelper.loginCheck(token);
+        if(list!=null && list.size()>0){
+            if(!list.get(0).getId().equals(ssoUser.getId())){
+                throw new BusinessException(ErrorCode.EMAIL_EXIST);
+            }
+        }
+        User dbUser = this.getById(ssoUser.getId());
+        dbUser.setEmail(param.getEmail());
+        if(!this.updateById(dbUser)){
+            throw new BusinessException(ErrorCode.ERROR_MSG);
+        }
+        return ServerCode.SUCCESS.message();
+    }
 }

+ 44 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/vo/ReceiverInfoVo.java

@@ -0,0 +1,44 @@
+package com.fdkankan.user.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class ReceiverInfoVo implements Serializable {
+
+    private static final long serialVersionUID = 8761116654561123300L;
+
+    private Long id;
+
+    //(value = "收货人姓名", name = "shipName")
+    private String shipName;
+
+    //(value = "收货人手机号", name = "shipMobile")
+    private String shipMobile;
+
+    //(value = "收货地区", name = "shipArea")
+    private String shipArea;
+
+    //(value = "收货地址", name = "shipAddress")
+    private String shipAddress;
+
+    //(value = "默认值", name = "setDefault")
+    private int setDefault;
+
+    //(value = "国家", name = "country")
+    private String country;
+
+    //(value = "收货地区路径", name = "shipAreaPath")
+    private String shipAreaPath;
+
+    //(value = "收货邮编", name = "shipZipCode")
+    private String shipZipCode;
+
+    //(value = "收货电话", name = "shipPhone")
+    private String shipPhone;
+
+    //(value = "用户id", name = "userId")
+    private Long userId;
+}
+

+ 98 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/vo/ResponseUser.java

@@ -0,0 +1,98 @@
+package com.fdkankan.user.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Date;
+
+@Data
+public class ResponseUser implements Serializable {
+
+    private static final long serialVersionUID = -3561681615377397861L;
+
+    private Long id;
+
+   //(value = "头像对应的链接地址", name = "head")
+    private String head;
+
+   //(value = "用户名", name = "userName")
+    private String userName;
+
+   //(value = "用户邮箱", name = "email")
+    private String email;
+
+   //(value = "昵称", name = "nickName")
+    private String nickName;
+
+   //(value = "注册时间", name = "registerTime")
+    private Date registerTime;
+
+   //(value = "0表示禁言(bbs)", name = "status")
+    private int status;
+
+   //(value = "机构名称", name = "organizationName")
+    private String organizationName;
+
+   //(value = "主页链接", name = "mainPage")
+    private String mainPage;
+
+   //(value = "所在国家,默认是中国", name = "country")
+    private String country;
+
+   //(value = "所在省份", name = "province")
+    private String province;
+
+   //(value = "所在城市", name = "city")
+    private String city;
+
+   //(value = "收货地区路径", name = "shipAreaPath")
+    private String shipAreaPath;
+
+   //(value = "收货地址", name = "shipAddress")
+    private String shipAddress;
+
+   //(value = "发帖数", name = "themeCount")
+    private int themeCount;
+
+   //(value = "回帖数", name = "replyCount")
+    private int replyCount;
+
+   //(value = "总容量", name = "totalSpace")
+    private BigInteger totalSpace;
+
+   //(value = "已使用容量", name = "usedSpace")
+    private BigInteger usedSpace;
+
+   //(value = "总场景数", name = "sceneCount")
+    private int sceneCount;
+
+   //(value = "已绑相机", name = "cameraCount")
+    private int cameraCount;
+
+   //(value = "可用空间", name = "availableSpace")
+    private double availableSpace;
+
+   //(value = "用户密码", name = "password")
+    private String password;
+
+    private long expansionTotal;
+
+    private Integer isNotice;
+
+   //(value = "会员权益数量", name = "incrementNum")
+    private Integer incrementNum;
+
+   //(value = "已绑定的会员权益数量", name = "incrementBindNum")
+    private Integer incrementBindNum;
+
+    /**
+     * 总的下载场景总数
+     */
+    private Integer downloadNumTotal;
+
+    /**
+     * 已下载场景总数
+     */
+    private Integer downloadNum;
+}

+ 9 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/user/vo/SSOUserVo.java

@@ -0,0 +1,9 @@
+package com.fdkankan.user.vo;
+
+import lombok.Data;
+
+@Data
+public class SSOUserVo {
+    private String token;
+    private ResponseUser responseUser;
+}

+ 9 - 0
4dkankan-center-platform/src/main/resources/static/apppro.html

@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+    <head>
+    <title>1</title>
+    </head>
+    <body >
+        4dage,app部门文件,请勿删除
+    </body>
+</html>

BIN
4dkankan-center-platform/src/main/resources/static/img/logo.jpg


ファイルの差分が大きいため隠しています
+ 1125 - 0
4dkankan-center-platform/src/main/resources/static/txt/SensitiveWord.txt


+ 23 - 0
4dkankan-common/pom.xml

@@ -121,6 +121,29 @@
             <version>2.9.9</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-core</artifactId>
+            <version>4.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.amazonaws</groupId>
+            <artifactId>aws-java-sdk</artifactId>
+            <version>1.11.327</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+            <version>1.5.4</version>
+        </dependency>
+
+
+
     </dependencies>
 
     <build>

+ 39 - 0
4dkankan-common/src/main/java/com/fdkankan/common/constant/ConstantFileName.java

@@ -0,0 +1,39 @@
+package com.fdkankan.common.constant;
+
+public class ConstantFileName {
+    //背景音乐
+    public static final String BACKGROUND_MUSIC = "bg.mp3";
+    //编辑页面,第二代
+    public static final String MODEL_DATAFILE = "modeldata.json";
+    public static final String HOT_DATAFILE = "hot.json";
+    public static final String MEDIA_DATAFILE = "mediaInfo.json";
+    public static final String SCREEN_CRP_DATAFILE = "screenCap";
+    //导览(一代)
+    public static final String GUIDE_DATAFILE = "tour.json";
+
+    //文件夹名称
+    public static final String GUIDE_MEDIA_FOLDER = "guide";
+    public static final String HOT_MEDIA_FOLDER = "hot";
+    public static final String OTHER_MEDIA_FOLDER = "other";
+
+    //论坛过滤文档
+    public static final String BBS_SENSITIVE = "SensitiveWord.txt";
+    public static final String LOGO_NAME = "logo.jpg";
+
+    //app部分
+    public static final String APP_FOLDER = "appupload";
+
+    public static final String FLOOR_LOGO_PIC_NAME = "floorLogoImg.png";
+
+    public static final String TOUR_LIST = "tourList.json";
+    public static final String VOICE_NAME = "201810";
+    public static final String WECHAT_VOICE_NAME = "wechat";
+    public static final String APP_VOICE_NAME = "app";
+
+    public static final String TOURLIST_FOLDER = "tour";
+    //public static final String TEMPFILES = "tempFiles";
+
+    public static final String modelUUID = "dacf7dfa24ae47fab8fcebfe4dc41ab9";
+
+    public static final String BUCKET_NAME = "4dkankan";
+}

+ 28 - 0
4dkankan-common/src/main/java/com/fdkankan/common/constant/ConstantUrl.java

@@ -0,0 +1,28 @@
+package com.fdkankan.common.constant;
+
+public class ConstantUrl {
+
+    //	public static final String MAIN_URL = "https://www.4dkankan.com/";
+//	public static final String MAIN_URL = "http://120.79.15.136:8086/";
+//	public static final String MAIN_URL2 = "https://www.4dkankan.com/";
+//	public static final String DEFAULT_USER_HEAD = "https://scene3d.4dage.com/head.png";
+    public static final String DEFAULT_USER_HEAD = "https://4dkk.4dage.com/newHead.png";
+    public static final String BBS_TOUPLOAD = "https://scene3d.4dage.com/model/upload/image/";
+    public static final String DEFAULT_PREFIX_QINIU_PIC = "http://orw69myb5.bkt.clouddn.com/";
+    public static final String DEFAULT_SCENE_PIC="https://4dkk.4dage.com/loading/thumb.jpg";
+//	public static final String SCENE_URL = MAIN_URL + "show.html?m=";
+//	public static final String SCENE_URL2 = MAIN_URL + "showV2.html?m=";
+
+    //	public static final String PRO_SCENE_URL = MAIN_URL + "showProMobile.html?m=";
+    public static final String PREFIX_ALI = "https://4dkk.4dage.com/";
+    //亚马逊S3
+    public static final String PREFIX_AWS = "https://testeurs3.4dkankan.com/";
+    public static final String PREFIX_QINIU = "https://scene3d.4dage.com/";
+    public static final String PREFIX_QINIU2 = "https://creator.4dkankan.com/";
+    public static final String WEIXIN_PAYURL = "https://www.4dkankan.com/weixinmobilepay/weixinInfo?orderId=";
+    public static final String WEIXIN_TOKEN_URL1 = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=";
+    public static final String WEIXIN_TOKEN_URL2 = "https://api.weixin.qq.com/sns/userinfo?access_token=";
+    public static final String WEIXIN_MOBILE_PAY_URL = "mobile.html#/pay?timeStamp=";
+    public static final String WEIXIN_NOTIFY_URL = "https://www.4dkankan.com/weixinpay/Notify";
+    public static final String WEIXIN_ORDER_URL="https://api.mch.weixin.qq.com/pay/unifiedorder";
+}

+ 13 - 34
4dkankan-common/src/main/java/com/fdkankan/common/constant/ErrorCode.java

@@ -11,7 +11,7 @@ public enum ErrorCode {
     TOKEN_NOT_FOUND(4003, "用户未登录"),
     APP_ID_ILLEGAL(4004 , "非法的APP ID"),
     USER_NOT_EXIST(4005,"用户不存在"),
-    PASSWORD_ERROR(4006,"密码错误"),
+    PASSWORD_ERROR(4006,"账号密码错误"),
     MISSING_REQUIRED_PARAMETERS(4007,"缺少必要参数"),
     USER_NOT_LOGIN(4008, "用户未登录"),
     NOT_RECORD(4009, "暂无记录"),
@@ -20,42 +20,21 @@ public enum ErrorCode {
     AGENT_EXIST(40012, "经销商已存在"),
     AGENT_NOT_EXIST(40012, "经销商已存在"),
     AGENT_SUB_EXIST(40013, "请先删除经销商下的用户"),
+    EMAIL_ERROR(40014, "邮箱格式不正确"),
+    PASSWORD_VIOLATION(40015, "密码需要包含英文大小写、数字,长度8-16字符"),
+    PASSWORD_TWO_VIOLATION(40016, "两次输入的密码不一致"),
+    PHONE_VIOLATION(40017, "手机号码格式错误"),
+    PHONE_EXIST(40018, "该手机已被注册"),
+    V_CODE_ERROR(40019, "验证码错误"),
+    NICKNAME_ERROR(40020, "昵称包含敏感词"),
+    V_CODE_TIME_NOT_OUT(40021, "60秒内不能重复获取验证码"),
+    PHONE_CODE_TO_MANY(40021, "手机验证码获取验证码次数过多,请明天再试"),
+    EMAIL_EXIST(40022, "手机验证码获取验证码次数过多,请明天再试"),
+
 
-    FAILURE_CODE_3001(3001, "缺少必要参数"),
-    FAILURE_CODE_3002(3002, "访问异常!"),
-    FAILURE_CODE_3003(3003, "非法访问!"),
-    FAILURE_CODE_3004(3004, "用户未登录"),
-    FAILURE_CODE_3005(3005, "验证码已过期"),
-    FAILURE_CODE_3006(3006, "验证码错误"),
-    FAILURE_CODE_3007(3007, "昵称已存在"),
-    FAILURE_CODE_3008(3008, "该手机已被注册"),
-    FAILURE_CODE_3009(3009, "两次输入的密码不一致"),
-    FAILURE_CODE_3010(3010, "昵称长度错误"),
-    FAILURE_CODE_3011(3011, "密码需要包含英文大小写、数字,长度8-16字符"),
-    FAILURE_CODE_3012(3012, "昵称包含敏感词"),
-    FAILURE_CODE_3013(3013, "手机号码格式错误"),
-    FAILURE_CODE_3014(3014, "账号或密码不正确"),
-    FAILURE_CODE_3015(3015, "用户不存在"),
-    FAILURE_CODE_3016(3016, "登录失败,账号无权访问"),
-    FAILURE_CODE_3017(3017, "空文件"),
-    FAILURE_CODE_3018(3018, "需要上传或使用的文件不存在"),
-    FAILURE_CODE_3019(3019, "邮箱格式不正确"),
-    FAILURE_CODE_3020(3020, "邮箱地址已存在"),
-    FAILURE_CODE_3021(3021, "账号不存在,请核对后重新输入。"),
-    FAILURE_CODE_3022(3022, "该场景已添加协作者,请先取消协作后再添加"),
-    FAILURE_CODE_3023(3023, "手机验证码获取验证码次数过多,请明天再试"),
-    FAILURE_CODE_3024(3024, "不能将场景协作给自己"),
-    FAILURE_CODE_3025(3025, "不能将相机分配给自己"),
-    FAILURE_CODE_3026(3026, "有部分场景已存在协作者,请先取消协作后再添加"),
-    FAILURE_CODE_3027(3027, "原密码错误"),
-    FAILURE_CODE_3028(3028, "角色已存在"),
-    FAILURE_CODE_3029(3029, "当前角色存在关联的用户,请先删除用户或修改用户所属角色"),
-    FAILURE_CODE_3030(3030, "当前增值权益不存在"),
-    FAILURE_CODE_3031(3031, "相机已绑定"),
-    FAILURE_CODE_3032(3032, "当前相机已被授权,请选择另外相机绑定"),
-    FAILURE_CODE_3033(3033, "60秒内不能重复获取验证码"),
 
 
+    FAILURE_CODE_3001(3001, "缺少必要参数"),
     FAILURE_CODE_5030(5030, "同级文件夹名称不能重复"),
 
 

+ 1 - 1
4dkankan-common/src/main/java/com/fdkankan/common/constant/ServerCode.java

@@ -2,7 +2,7 @@ package com.fdkankan.common.constant;
 
 public enum ServerCode {
 
-	SUCCESS(0, "成功"),
+	SUCCESS(0, "操作成功"),
 	SYSTEM_ERROR(-1, "服务器异常"),
 	PARAM_ERROR(-2, "解析请求参数出错"),
 	PARAM_REQUIRED(-3, "缺少必要参数"),

+ 4 - 2
4dkankan-common/src/main/java/com/fdkankan/common/exception/BusinessException.java

@@ -1,14 +1,12 @@
 package com.fdkankan.common.exception;
 
 import com.fdkankan.common.constant.ErrorCode;
-import lombok.AllArgsConstructor;
 import lombok.Data;
 
 /**
  * 自定义业务异常类
  */
 @Data
-@AllArgsConstructor
 public class BusinessException extends RuntimeException {
     private int code;
     private String message;
@@ -17,4 +15,8 @@ public class BusinessException extends RuntimeException {
         this.code = errorCode.code();
         this.message = errorCode.message();
     }
+    public BusinessException (int code,String msg){
+        this.code = code;
+        this.message = msg;
+    }
 }

ファイルの差分が大きいため隠しています
+ 271 - 0
4dkankan-common/src/main/java/com/fdkankan/common/sms/SendMailAcceUtils.java


+ 228 - 0
4dkankan-common/src/main/java/com/fdkankan/common/sms/SmsService.java

@@ -0,0 +1,228 @@
+package com.fdkankan.common.sms;
+
+import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
+import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.http.MethodType;
+import com.aliyuncs.profile.DefaultProfile;
+import com.aliyuncs.profile.IClientProfile;
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.AWSCredentialsProvider;
+import com.amazonaws.services.sns.AmazonSNS;
+import com.amazonaws.services.sns.AmazonSNSClientBuilder;
+import com.amazonaws.services.sns.model.MessageAttributeValue;
+import com.amazonaws.services.sns.model.PublishRequest;
+import com.amazonaws.services.sns.model.PublishResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+public class SmsService {
+
+    private static Logger log = LoggerFactory.getLogger("programLog");
+
+    //初始化ascClient需要的几个参数
+    private static final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改)
+    private static final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改)
+    private static final String accessKeyId = "LTAIUrvuHqj8pvry";//你的accessKeyId,参考本文档步骤2
+    private static final String accessKeySecret = "JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4";//你的accessKeySecret,参考本文档步骤2
+
+    private static final String EN_CODE_MSG = "Your vertification code is ${code}. Thank you for using 4DKanKan, please complete your identity verification by entering this code in 5 minutes. Please ignore this message if you don't operate by yourself.";
+
+
+    @Value("${phone.sign:四维看看}")
+    private String sign;
+
+    public String sendSms(String phoneNum, String templateParam, String templateCode) throws Exception {
+        log.info("cnCode:" + templateCode);
+        log.info("templateParam:" + templateParam);
+        log.info("sign:" + sign);
+        log.info("sign:" + new String(sign.getBytes("ISO-8859-1"),"utf-8"));
+        // 可自助调整超时时间
+        System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
+        System.setProperty("sun.net.client.defaultReadTimeout", "10000");
+        String result = null;
+        try {
+            // 初始化acsClient,暂不支持region化
+            IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
+            DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
+            IAcsClient acsClient = new DefaultAcsClient(profile);
+
+            // 组装请求对象-具体描述见控制台-文档部分内容
+            SendSmsRequest request = new SendSmsRequest();
+
+            // 必填:待发送手机号
+            request.setPhoneNumbers(phoneNum);
+            // 必填:短信签名-可在短信控制台中找到
+            request.setSignName(new String(sign.getBytes("ISO-8859-1"),"utf-8"));
+            // 必填:短信模板-可在短信控制台中找到
+            request.setTemplateCode(templateCode);
+
+            // 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
+            request.setTemplateParam(templateParam);
+
+            // 选填-上行短信扩展码(无特殊需求用户请忽略此字段)
+            // request.setSmsUpExtendCode("90997");
+
+            // 可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
+            // request.setOutId("yourOutId");
+
+            // hint 此处可能会抛出异常,注意catch
+            SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
+            if (sendSmsResponse != null
+                    && !StringUtils.isEmpty(sendSmsResponse.getCode())){
+
+                if("OK".equals(sendSmsResponse.getCode())){
+                    log.debug("阿里云短信发送成功");
+                }else {
+                    log.debug("阿里云短信发送失败:" + sendSmsResponse.getCode());
+                    log.debug("阿里云短信发送失败原因:" + sendSmsResponse.getMessage());
+                }
+                result = sendSmsResponse.getCode();
+            }
+        }catch (ClientException e){
+            log.error("阿里云短信发送失败:" + e);
+        }
+        return result;
+    }
+
+
+    public boolean sendBuildFailSms(String name, String scene,String userPhone) throws Exception{
+
+        //设置超时时间-可自行调整
+        System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
+        System.setProperty("sun.net.client.defaultReadTimeout", "10000");
+        //初始化ascClient需要的几个参数
+        final String product = "Dysmsapi";//短信API产品名称(短信产品名固定,无需修改)
+        final String domain = "dysmsapi.aliyuncs.com";//短信API产品域名(接口地址固定,无需修改)
+        //替换成你的AK
+        final String accessKeyId = "LTAIUrvuHqj8pvry";//你的accessKeyId,参考本文档步骤2
+        final String accessKeySecret = "JLOVl0k8Ke0aaM8nLMMiUAZ3EiiqI4";//你的accessKeySecret,参考本文档步骤2
+        //初始化ascClient,暂时不支持多region
+        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId,
+                accessKeySecret);
+        try {
+            DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
+        } catch (ClientException e1) {
+            // TODO Auto-generated catch block
+            e1.printStackTrace();
+        }
+        IAcsClient acsClient = new DefaultAcsClient(profile);
+        //组装请求对象
+        SendSmsRequest request = new SendSmsRequest();
+        //使用post提交
+        request.setMethod(MethodType.POST);
+        //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
+        request.setPhoneNumbers(userPhone);
+        //必填:短信签名-可在短信控制台中找到
+        request.setSignName(new String(sign.getBytes("ISO-8859-1"),"utf-8"));
+        //必填:短信模板-可在短信控制台中找到
+        request.setTemplateCode("SMS_199808901");
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("name", name);
+        jsonObject.put("scene", scene);
+        request.setTemplateParam(jsonObject.toJSONString());
+
+        SendSmsResponse sendSmsResponse = null;
+        try {
+            sendSmsResponse = acsClient.getAcsResponse(request);
+        } catch (ServerException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (ClientException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            //System.out.println("向阿里请求发短信失败");
+            log.error("sendSms:向阿里请求发短信失败");
+        }
+        if(sendSmsResponse == null)
+        {
+            log.error("sendSms:向阿里请求发短信失败");
+        }
+        if(sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
+            //请求成功
+            //System.out.println("向阿里请求发短信成功");
+            log.info("sendSms:向阿里请求发短信成功");
+            return true;
+
+        }else {
+            log.debug("阿里云短信发送失败:" + sendSmsResponse.getCode());
+            log.debug("阿里云短信发送失败原因:" + sendSmsResponse.getMessage());
+        }
+        return false;
+    }
+
+
+    //aws短信
+    private Map<String, MessageAttributeValue> smsAttributes;
+
+
+    public Map<String, MessageAttributeValue> getDefaultSMSAttributes() {
+        if (smsAttributes == null) {
+            smsAttributes = new HashMap<>();
+            smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue()
+                    .withStringValue("4dkankan")
+                    .withDataType("String"));
+            smsAttributes.put("AWS.SNS.SMS.MaxPrice", new MessageAttributeValue()
+                    .withStringValue("1.05")
+                    .withDataType("Number"));
+            smsAttributes.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue()
+                    .withStringValue("Transactional")
+                    .withDataType("String"));
+        }
+        return smsAttributes;
+    }
+
+    public PublishResult sendSMSMessage(String phoneNumber, String message) {
+        return sendSMSMessage(phoneNumber, message, getDefaultSMSAttributes());
+    }
+
+    public PublishResult sendSMSMessage(String phoneNumber, String message, Map<String, MessageAttributeValue> smsAttributes) {
+        AWSCredentials awsCredentials = new AWSCredentials() {
+            @Override
+            public String getAWSAccessKeyId() {
+                return "AKIAWCV5QFZ3ZQS7LBNL"; // 带有发短信权限的 IAM 的 ACCESS_KEY
+            }
+
+            @Override
+            public String getAWSSecretKey() {
+                return "NDzNp/5tqypSxxyPkkoixeJntn5W6dq0cLYV2FUH"; // 带有发短信权限的 IAM 的 SECRET_KEY
+            }
+        };
+        AWSCredentialsProvider provider = new AWSCredentialsProvider() {
+            @Override
+            public AWSCredentials getCredentials() {
+                return awsCredentials;
+            }
+
+            @Override
+            public void refresh() {
+            }
+        };
+        AmazonSNS amazonSNS = null;
+        try {
+            amazonSNS = AmazonSNSClientBuilder.standard().withCredentials(provider).withRegion("eu-central-1").build();
+        } catch (Exception e) {
+
+        }
+        return amazonSNS.publish(
+                new PublishRequest()
+                        .withMessage(EN_CODE_MSG.replace("${code}", message))
+                        .withPhoneNumber(phoneNumber)
+                        .withMessageAttributes(smsAttributes)
+        );
+    }
+
+
+
+}

+ 56 - 0
4dkankan-common/src/main/java/com/fdkankan/common/util/Base64Converter.java

@@ -0,0 +1,56 @@
+package com.fdkankan.common.util;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+
+public class Base64Converter {
+
+    final static Base64.Encoder encoder = Base64.getEncoder();
+    final static Base64.Decoder decoder = Base64.getDecoder();
+
+    /**
+     * 给字符串加密
+     * @param text
+     * @return
+     */
+    public static String encode(String text) {
+        byte[] textByte = new byte[0];
+        try {
+            textByte = text.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        String encodedText = encoder.encodeToString(textByte);
+        return encodedText;
+    }
+
+    /**
+     * 将加密后的字符串进行解密
+     * @param encodedText
+     * @return
+     */
+    public static String decode(String encodedText) {
+        String text = null;
+        try {
+            text = new String(decoder.decode(encodedText), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return text;
+    }
+
+    /**
+     * 根据逻辑截取加密后的密码
+     * @param text
+     * @return
+     */
+    public static String subText(String text){
+        //去掉前8位字符串
+        text = text.substring(8);
+        //去掉后8位字符串
+        text = text.substring(0, text.length() - 8);
+        //最后两个字符串换到前面,并且去掉剩下的后8位字符串
+        String result = text.substring(text.length() - 2) + text.substring(0, text.length() - 10);
+        return result;
+    }
+}

+ 102 - 0
4dkankan-common/src/main/java/com/fdkankan/common/util/PatternUtils.java

@@ -0,0 +1,102 @@
+package com.fdkankan.common.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class PatternUtils {
+
+    public static boolean isEmail(String email) {
+        // 1、\\w+表示@之前至少要输入一个匹配字母或数字或下划线
+        // \\w 单词字符:[a-zA-Z_0-9] // 2、(\\w+\\.)表示域名. 如新浪邮箱域名是sina.com.cn
+        // {1,3}表示可以出现一次或两次或者三次.
+        String reg = "\\w+@(\\w+\\.){1,3}\\w+";
+        Pattern pattern = Pattern.compile(reg);
+        boolean flag = false;
+        if (email != null) {
+            Matcher matcher = pattern.matcher(email);
+            flag = matcher.matches();
+        }
+        return flag;
+    }
+
+    /**
+     * 判断身份证格式
+     *
+     * @param idNum
+     * @return
+     */
+    public static boolean isIdNum(String idNum) {
+        if (idNum == null || "".equals(idNum)) {
+            return false;
+        }
+        // 定义判别用户身份证号的正则表达式(15位或者18位,最后一位可以为字母)
+        String regularExpression = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|" +
+                "(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)";
+        //假设18位身份证号码:41000119910101123X  410001 19910101 123X
+        //^开头
+        //[1-9] 第一位1-9中的一个      4
+        //\\d{5} 五位数字           10001(前六位省市县地区)
+        //(18|19|20)                19(现阶段可能取值范围18xx-20xx年)
+        //\\d{2}                    91(年份)
+        //((0[1-9])|(10|11|12))     01(月份)
+        //(([0-2][1-9])|10|20|30|31)01(日期)
+        //\\d{3} 三位数字            123(第十七位奇数代表男,偶数代表女)
+        //[0-9Xx] 0123456789Xx其中的一个 X(第十八位为校验值)
+        //$结尾
+
+        //假设15位身份证号码:410001910101123  410001 910101 123
+        //^开头
+        //[1-9] 第一位1-9中的一个      4
+        //\\d{5} 五位数字           10001(前六位省市县地区)
+        //\\d{2}                    91(年份)
+        //((0[1-9])|(10|11|12))     01(月份)
+        //(([0-2][1-9])|10|20|30|31)01(日期)
+        //\\d{3} 三位数字            123(第十五位奇数代表男,偶数代表女),15位身份证不含X
+        //$结尾
+        boolean matches = idNum.matches(regularExpression);
+        //判断第18位校验值
+        if (matches) {
+            if (idNum.length() == 18) {
+                try {
+                    char[] charArray = idNum.toCharArray();
+                    //前十七位加权因子
+                    int[] idCardWi = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
+                    //这是除以11后,可能产生的11位余数对应的验证码
+                    String[] idCardY = {"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"};
+                    int sum = 0;
+                    for (int i = 0; i < idCardWi.length; i++) {
+                        int current = Integer.parseInt(String.valueOf(charArray[i]));
+                        int count = current * idCardWi[i];
+                        sum += count;
+                    }
+                    char idCardLast = charArray[17];
+                    int idCardMod = sum % 11;
+                    if (idCardY[idCardMod].toUpperCase().equals(String.valueOf(idCardLast).toUpperCase())) {
+                        return true;
+                    } else {
+                        return false;
+                    }
+
+                } catch (Exception e) {
+                    return false;
+                }
+            }
+
+        }
+        return matches;
+    }
+
+    //验证手机号码
+    public static boolean isPhoneNumber(String number) {
+        String rgx = "^1(3|4|5|7|8)\\d{9}$";
+//        return isCorrect(rgx, number);
+        return true;
+    }
+
+    //正则验证
+    public static boolean isCorrect(String rgx, String res) {
+        Pattern p = Pattern.compile(rgx);
+        Matcher m = p.matcher(res);
+        return m.matches();
+    }
+}

+ 32 - 0
4dkankan-common/src/main/java/com/fdkankan/common/util/SecurityUtil.java

@@ -0,0 +1,32 @@
+package com.fdkankan.common.util;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class SecurityUtil {
+    public static String MD52(String md5){
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            byte[] digest = md.digest(md5.getBytes());
+            StringBuffer sb = new StringBuffer();
+            for (int i = 0; i < digest.length; i++) {
+                sb.append(Integer.toHexString((digest[i] & 0xFF) | 0x100).substring(1,3));
+            }
+            return sb.toString();
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static String MD5(String inStr){
+
+        char[] a = inStr.toCharArray();
+        for (int i = 0; i < a.length; i++){
+            a[i] = (char) (a[i] ^ 't');
+        }
+        String s = new String(a);
+        return s;
+
+    }
+}

+ 152 - 0
4dkankan-common/src/main/java/com/fdkankan/common/validation/SensitiveWord.java

@@ -0,0 +1,152 @@
+package com.fdkankan.common.validation;
+
+import com.fdkankan.common.constant.ConstantFileName;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *  敏感词过滤
+ */
+public class SensitiveWord {
+    @SuppressWarnings("rawtypes")
+    public Map sensitiveWordMap = null;
+    public static int minMatchTYpe = 1;      //最小匹配规则
+    public static int maxMatchType = 2;      //最大匹配规则
+
+    /**
+     * 构造函数,初始化敏感词库
+     */
+    public SensitiveWord(){
+        if (sensitiveWordMap == null){
+            String txtPath = this.getClass().getResource("/static/txt/"+ ConstantFileName.BBS_SENSITIVE).getPath();
+            sensitiveWordMap = new SensitiveWordConfig().initKeyWord(txtPath);
+        }
+    }
+
+    /**
+     * 判断文字是否包含敏感字符
+     * @author chenming
+     * @date 2014年4月20日 下午4:28:30
+     * @param txt  文字
+     * @param matchType  匹配规则&nbsp;1:最小匹配规则,2:最大匹配规则
+     * @return 若包含返回true,否则返回false
+     * @version 1.0
+     */
+    public boolean isContaintSensitiveWord(String txt,int matchType){
+        boolean flag = false;
+        for(int i = 0 ; i < txt.length() ; i++){
+            int matchFlag = this.CheckSensitiveWord(txt, i, matchType); //判断是否包含敏感字符
+            if(matchFlag > 0){    //大于0存在,返回true
+                flag = true;
+            }
+        }
+        return flag;
+    }
+
+    /**
+     * 获取文字中的敏感词
+     * @author chenming
+     * @date 2014年4月20日 下午5:10:52
+     * @param txt 文字
+     * @param matchType 匹配规则&nbsp;1:最小匹配规则,2:最大匹配规则
+     * @return
+     * @version 1.0
+     */
+    public Set<String> getSensitiveWord(String txt , int matchType){
+        Set<String> sensitiveWordList = new HashSet<String>();
+
+        for(int i = 0 ; i < txt.length() ; i++){
+            int length = CheckSensitiveWord(txt, i, matchType);    //判断是否包含敏感字符
+            if(length > 0){    //存在,加入list中
+                sensitiveWordList.add(txt.substring(i, i+length));
+                i = i + length - 1;    //减1的原因,是因为for会自增
+            }
+        }
+
+        return sensitiveWordList;
+    }
+
+    /**
+     * 替换敏感字字符
+     * @author chenming
+     * @date 2014年4月20日 下午5:12:07
+     * @param txt
+     * @param matchType
+     * @param replaceChar 替换字符,默认*
+     * @version 1.0
+     */
+    public String replaceSensitiveWord(String txt,int matchType,String replaceChar){
+        String resultTxt = txt;
+        Set<String> set = getSensitiveWord(txt, matchType);     //获取所有的敏感词
+        Iterator<String> iterator = set.iterator();
+        String word = null;
+        String replaceString = null;
+        while (iterator.hasNext()) {
+            word = iterator.next();
+            replaceString = getReplaceChars(replaceChar, word.length());
+            resultTxt = resultTxt.replaceAll(word, replaceString);
+        }
+
+        return resultTxt;
+    }
+
+    /**
+     * 获取替换字符串
+     * @author chenming
+     * @date 2014年4月20日 下午5:21:19
+     * @param replaceChar
+     * @param length
+     * @return
+     * @version 1.0
+     */
+    private String getReplaceChars(String replaceChar,int length){
+        String resultReplace = replaceChar;
+        for(int i = 1 ; i < length ; i++){
+            resultReplace += replaceChar;
+        }
+
+        return resultReplace;
+    }
+
+    /**
+     * 检查文字中是否包含敏感字符,检查规则如下:<br>
+     * @author chenming
+     * @date 2014年4月20日 下午4:31:03
+     * @param txt
+     * @param beginIndex
+     * @param matchType
+     * @return,如果存在,则返回敏感词字符的长度,不存在返回0
+     * @version 1.0
+     */
+    @SuppressWarnings({ "rawtypes"})
+    public int CheckSensitiveWord(String txt,int beginIndex,int matchType){
+        boolean  flag = false;    //敏感词结束标识位:用于敏感词只有1位的情况
+        int matchFlag = 0;     //匹配标识数默认为0
+        char word = 0;
+
+        Map nowMap = sensitiveWordMap;
+        for(int i = beginIndex; i < txt.length() ; i++){
+            word = txt.charAt(i);
+            nowMap = (Map) nowMap.get(word);     //获取指定key
+            if(nowMap != null){     //存在,则判断是否为最后一个
+                matchFlag++;     //找到相应key,匹配标识+1
+                if("1".equals(nowMap.get("isEnd"))){       //如果为最后一个匹配规则,结束循环,返回匹配标识数
+                    flag = true;       //结束标志位为true
+                    if(SensitiveWord.minMatchTYpe == matchType){    //最小规则,直接返回,最大规则还需继续查找
+                        break;
+                    }
+                }
+            }
+            else{     //不存在,直接返回
+                break;
+            }
+        }
+        if(matchFlag < 2 || !flag){        //长度必须大于等于1,为词
+            matchFlag = 0;
+        }
+        return matchFlag;
+    }
+}

+ 131 - 0
4dkankan-common/src/main/java/com/fdkankan/common/validation/SensitiveWordConfig.java

@@ -0,0 +1,131 @@
+package com.fdkankan.common.validation;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.*;
+
+/**
+ * 初始化敏感词库,将敏感词加入到HashMap中,构建DFA算法模型
+ */
+public class SensitiveWordConfig {
+    private String ENCODING = "utf-8";    //字符编码
+    @SuppressWarnings("rawtypes")
+    public HashMap sensitiveWordMap;
+
+    public SensitiveWordConfig(){
+        super();
+    }
+
+    /**
+     * @date 2014年4月20日 下午2:28:32
+     * @version 1.0
+     */
+    @SuppressWarnings("rawtypes")
+    public Map initKeyWord(String filePath){
+        try {
+            //读取敏感词库
+            Set<String> keyWordSet = readSensitiveWordFile(filePath);
+            //将敏感词库加入到HashMap中
+            addSensitiveWordToHashMap(keyWordSet);
+            //spring获取application,然后application.setAttribute("sensitiveWordMap",sensitiveWordMap);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return sensitiveWordMap;
+    }
+
+    /**
+     * 读取敏感词库,将敏感词放入HashSet中,构建一个DFA算法模型:<br>
+     * 中 = {
+     *      isEnd = 0
+     *      国 = {<br>
+     *      	 isEnd = 1
+     *           人 = {isEnd = 0
+     *                民 = {isEnd = 1}
+     *                }
+     *           男  = {
+     *           	   isEnd = 0
+     *           		人 = {
+     *           			 isEnd = 1
+     *           			}
+     *           	}
+     *           }
+     *      }
+     *  五 = {
+     *      isEnd = 0
+     *      星 = {
+     *      	isEnd = 0
+     *      	红 = {
+     *              isEnd = 0
+     *              旗 = {
+     *                   isEnd = 1
+     *                  }
+     *              }
+     *      	}
+     *      }
+     * @param keyWordSet  敏感词库
+     */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    private void addSensitiveWordToHashMap(Set<String> keyWordSet) {
+        sensitiveWordMap = new HashMap(keyWordSet.size());     //初始化敏感词容器,减少扩容操作
+        String key = null;
+        Map nowMap = null;
+        Map<String, String> newWorMap = null;
+        //迭代keyWordSet
+        Iterator<String> iterator = keyWordSet.iterator();
+        while(iterator.hasNext()){
+            key = iterator.next();    //关键字
+            nowMap = sensitiveWordMap;
+            for(int i = 0 ; i < key.length() ; i++){
+                char keyChar = key.charAt(i);       //转换成char型
+                Object wordMap = nowMap.get(keyChar);       //获取
+
+                if(wordMap != null){        //如果存在该key,直接赋值
+                    nowMap = (Map) wordMap;
+                }
+                else{     //不存在则,则构建一个map,同时将isEnd设置为0,因为他不是最后一个
+                    newWorMap = new HashMap<String,String>();
+                    newWorMap.put("isEnd", "0");     //不是最后一个
+                    nowMap.put(keyChar, newWorMap);
+                    nowMap = newWorMap;
+                }
+
+                if(i == key.length() - 1){
+                    nowMap.put("isEnd", "1");    //最后一个
+                }
+            }
+        }
+    }
+
+    /**
+     * 读取敏感词库中的内容,将内容添加到set集合中
+     */
+    @SuppressWarnings("resource")
+    private Set<String> readSensitiveWordFile(String path) throws Exception{
+        Set<String> set = null;
+        //File file = new File("E:\\2017\\4Dweb\\bug汇总\\过滤敏感词\\敏感词库\\敏感词库\\2012年最新敏感词列表\\论坛需要过滤的不良词语大全.txt");    //读取文件
+        //File file = new File("D:\\SensitiveWord.txt");    //读取文件
+        File file = new File(path);
+        InputStreamReader read = new InputStreamReader(new FileInputStream(file),ENCODING);
+        try {
+            if(file.isFile() && file.exists()){      //文件流是否存在
+                set = new HashSet<String>();
+                BufferedReader bufferedReader = new BufferedReader(read);
+                String txt = null;
+                while((txt = bufferedReader.readLine()) != null){    //读取文件,将文件内容放入到set中
+                    set.add(txt);
+                }
+            }
+            else{         //不存在抛出异常信息
+                throw new Exception("敏感词库文件不存在");
+            }
+        } catch (Exception e) {
+            throw e;
+        }finally{
+            read.close();     //关闭文件流
+        }
+        return set;
+    }
+}

+ 26 - 0
4dkankan-common/src/main/java/com/fdkankan/common/validation/Variable.java

@@ -0,0 +1,26 @@
+package com.fdkankan.common.validation;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class Variable {
+
+    //public static Map<String,String> gl_AppSession = new HashMap<String,String>();
+
+    //二维码登录
+    public static Map<String,String> globalCodeLogin = new HashMap<String,String>();
+
+    public static ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<String>();
+    //论坛过滤
+    public static SensitiveWord sensitiveWord = new SensitiveWord();
+
+    //更新浏览大场景次数
+    public static Map<String, Integer> globalViewCount = new ConcurrentHashMap<String, Integer>();
+
+    //微信支付,原始订单对应后面添加了随机数的订单
+    public static Map<String, String> globalOrders = new ConcurrentHashMap<String, String>();
+
+//	public static ComputerModel[] thread_computers = null;
+}