Quellcode durchsuchen

Merge branch 'feature-V2.0' of http://git.mooctest.com/crowd-2019/crowd-test-service-backend into feature-V2.0

xuxuan vor 5 Jahren
Ursprung
Commit
c242111e0a

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
core/src/main/java/com/mooctest/crowd/domain/controller/TestUserController.java


+ 11 - 4
site/src/main/java/com/mooctest/crowd/site/anticorruption/impl/data/UserCommon.java

@@ -1,7 +1,7 @@
 package com.mooctest.crowd.site.anticorruption.impl.data;
 
 import com.mooctest.crowd.domain.domainobject.User;
-import com.mooctest.crowd.site.command.ModifyEmailCommand;
+import com.mooctest.crowd.site.command.ModifyCommand;
 import com.mooctest.crowd.site.command.RestPasswordCommand;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -43,9 +43,16 @@ public class UserCommon extends UserInfo {
       super(user);
    }
 
-   public void obtainValue(ModifyEmailCommand command) {
+   public void obtainValue(ModifyCommand command) {
       super.setId(command.getId());
-      super.setEmail(command.getEmail());
-      this.verifyCode = command.getVerifyCode();
+      if(command.getVerifyCode() != null) {
+         this.verifyCode = command.getVerifyCode();
+      }
+      if(command.getEmail() != null){
+         super.setEmail(command.getEmail());
+      }
+      if(command.getMobile() != null){
+         super.setMobile(command.getMobile());
+      }
    }
 }

+ 2 - 1
site/src/main/java/com/mooctest/crowd/site/command/ModifyEmailCommand.java → site/src/main/java/com/mooctest/crowd/site/command/ModifyCommand.java

@@ -11,8 +11,9 @@ import lombok.NoArgsConstructor;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
-public class ModifyEmailCommand {
+public class ModifyCommand {
     private Long id;
+    private String mobile;
     private String email;
     private String verifyCode;
 }

+ 1 - 3
site/src/main/java/com/mooctest/crowd/site/controller/CrowTestSquareController.java

@@ -61,7 +61,6 @@ public class CrowTestSquareController extends BaseSearchController {
      */
     @PostMapping("/project/list")
     public ResponseVO findAllprojectByPage(@RequestBody SearchConditionVO searchConditionVO) {
-//        Map<String, String> extraCondition = searchConditionVO.getColumnFilters() == null ? new HashMap<>() : super.getExtraCondition(searchConditionVO);
         Pageable pageable = this.getPageable(searchConditionVO);
         List<CrowdTestProjectVO> list = crowdProjectService.findAll(pageable);
         Page<CrowdTestProjectVO> page = DataUtils.listToPage(list, pageable);
@@ -71,9 +70,8 @@ public class CrowTestSquareController extends BaseSearchController {
     /**
      * 众测任务分页查询接口
      */
-    @GetMapping("/task/list")
+    @PostMapping("/task/list")
     public ResponseVO<Page<CrowdTaskVO>> getAllTaskByPage(@RequestBody SearchConditionVO searchConditionVO) {
-//        Map<String, String> extraCondition = searchConditionVO.getColumnFilters() == null ? new HashMap<>() : super.getExtraCondition(searchConditionVO);
         Pageable pageable = this.getPageable(searchConditionVO);
         Page<CrowdTaskVO> page = commonService.getTaskinfo(pageable, null, 0);
         return new ResponseVO<>(ServerCode.SUCCESS, page);

+ 28 - 5
site/src/main/java/com/mooctest/crowd/site/controller/UserController.java

@@ -4,7 +4,6 @@ import com.mooctest.crowd.domain.exception.*;
 import com.mooctest.crowd.site.annotation.LoginRequired;
 import com.mooctest.crowd.site.annotation.SysAdminRequired;
 import com.mooctest.crowd.site.anticorruption.impl.data.UserCommon;
-import com.mooctest.crowd.site.anticorruption.impl.data.UserInfo;
 import com.mooctest.crowd.site.command.*;
 import com.mooctest.crowd.site.data.dto.UserDTO;
 import com.mooctest.crowd.site.data.response.ResponseVO;
@@ -83,16 +82,40 @@ public class UserController extends BaseController {
      * 获取邮箱验证码
      */
     @RequestMapping(value = "/verify/email", method = RequestMethod.PUT)
-    public ResponseVO<Boolean> verifyMail(@RequestBody UserInfo userInfo) {
-        return new ResponseVO<>(ServerCode.SUCCESS, userService.verifyMail(userInfo.getEmail()));
+    public ResponseVO<Object> verifyMail(@RequestBody ModifyCommand modifyCommand, HttpServletRequest request) throws InvocationTargetException, IllegalAccessException {
+        return userService.verifyMail(modifyCommand, request);
     }
 
     /**
      * 绑定邮箱
      */
     @RequestMapping(value = "/user/email", method = RequestMethod.PUT)
-    public ResponseVO<UserCommon> updateEmail(@RequestBody ModifyEmailCommand modifyEmailCommand, HttpServletRequest request) throws InvocationTargetException, IllegalAccessException {
-        return new ResponseVO<>(ServerCode.SUCCESS, userService.updateEmail(modifyEmailCommand, request));
+    public ResponseVO<Object> updateEmail(@RequestBody ModifyCommand modifyCommand, HttpServletRequest request) throws InvocationTargetException, IllegalAccessException {
+        return userService.updateEmail(modifyCommand, request);
+    }
+
+    /**
+     * 获取手机验证码(新旧手机号)
+     */
+    @RequestMapping(value = "/verify/mobile", method = RequestMethod.PUT)
+    public ResponseVO<Object> verifyMobile(@RequestBody ModifyCommand mobileCommand, HttpServletRequest request) throws InvocationTargetException, IllegalAccessException {
+        return userService.getVerifyMobileCode(mobileCommand, request);
+    }
+
+    /**
+     * 验证旧手机验证码
+     */
+    @RequestMapping(value = "/verify/old/mobile", method = RequestMethod.PUT)
+    public ResponseVO<Object> verifyOldMobile(@RequestBody ModifyCommand mobileCommand, HttpServletRequest request) throws InvocationTargetException, IllegalAccessException {
+        return userService.verifyOldMobile(mobileCommand, request);
+    }
+
+    /**
+     * 修改手机号
+     */
+    @RequestMapping(value = "/user/mobile", method = RequestMethod.PUT)
+    public ResponseVO<Object> updateMobile(@RequestBody ModifyCommand mobileCommand, HttpServletRequest request) throws InvocationTargetException, IllegalAccessException {
+        return userService.updateMobile(mobileCommand, request);
     }
 
     /**

+ 2 - 0
site/src/main/java/com/mooctest/crowd/site/data/response/ServerCode.java

@@ -7,6 +7,8 @@ public enum ServerCode {
 
     SUCCESS(20000,"OK"),
 
+    ERROR(50000,"ERROR"),
+
     //通用错误状态码,30000-39999
     PARAM_WRONG(30000,"参数错误"),
     ENTITY_NOT_A_COURSE(30001, "找不到该课程相关信息"),

+ 35 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/TechnicalArticlesVO.java

@@ -6,6 +6,10 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 @Data
 @NoArgsConstructor
@@ -16,6 +20,7 @@ public class TechnicalArticlesVO {
     private String  articlesUrl;
     private String author;
     private String source;
+    private String time_interval;
 
     public Long getId() {
         return id;
@@ -97,5 +102,35 @@ public class TechnicalArticlesVO {
         this.source=project.getSource();
         this.reading=project.getReading();
         this.createTime=project.getCreateTime();
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        try {
+            Date date = df.parse(df.format(project.getCreateTime()));
+            long[] times = getDistanceTimes(date);
+            if(times[0]>0){
+                this.time_interval=times[0]+"天前发布";
+            }else if(times[1]>0){
+                this.time_interval=times[1]+"小时前发布";
+            }else if(times[2]>0){
+                this.time_interval=times[2]+"分钟前发布";
+            }else{
+                this.time_interval=times[3]+"秒前发布";
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+    }
+    public static long[] getDistanceTimes(Date date) {
+        long day = 0;
+        long hour = 0;
+        long min = 0;
+        long sec = 0;
+        long diff;
+        diff = System.currentTimeMillis() - date.getTime();
+        day = diff / (24 * 60 * 60 * 1000);
+        hour = (diff / (60 * 60 * 1000) - day * 24);
+        min = ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60);
+        sec = (diff/1000-day*24*60*60-hour*60*60-min*60);
+        long[] times = {day, hour, min, sec};
+        return times;
     }
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/service/UserService.java


Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
site/src/main/java/com/mooctest/crowd/site/service/impl/UserServiceImpl.java


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.