Browse Source

add 回访功能

周箭河 5 years ago
parent
commit
f9586eb20e

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentVisit.java

@@ -3,6 +3,8 @@ package com.ym.mec.biz.dal.entity;
 import com.ym.mec.common.enums.BaseEnum;
 import com.ym.mec.common.enums.BaseEnum;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.PastOrPresent;
 import java.util.Date;
 import java.util.Date;
 
 
 public class StudentVisit {
 public class StudentVisit {
@@ -43,6 +45,7 @@ public class StudentVisit {
     * 乐团id
     * 乐团id
     */
     */
     @ApiModelProperty(value = "乐团id",required = true)
     @ApiModelProperty(value = "乐团id",required = true)
+    @NotBlank(message = "乐团id不能为空")
     private String musicGroupId;
     private String musicGroupId;
 
 
     /**
     /**
@@ -73,12 +76,14 @@ public class StudentVisit {
     * 回访类型
     * 回访类型
     */
     */
     @ApiModelProperty(value = "回访类型",required = true)
     @ApiModelProperty(value = "回访类型",required = true)
+    @NotBlank(message = "回访类型不能为空")
     private String type;
     private String type;
 
 
     /**
     /**
     * 回访目的
     * 回访目的
     */
     */
     @ApiModelProperty(value = "回访目的",required = true)
     @ApiModelProperty(value = "回访目的",required = true)
+    @NotBlank(message = "回访目的不能为空")
     private String purpose;
     private String purpose;
 
 
     /**
     /**
@@ -97,6 +102,7 @@ public class StudentVisit {
     * 回访日期
     * 回访日期
     */
     */
     @ApiModelProperty(value = "回访日期",required = true)
     @ApiModelProperty(value = "回访日期",required = true)
+    @PastOrPresent(message = "回访日期不能大于当天")
     private Date visitTime;
     private Date visitTime;
 
 
     /**
     /**

+ 2 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentVisitServiceImpl.java

@@ -19,10 +19,7 @@ import com.ym.mec.util.date.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 @Service
 @Service
 public class StudentVisitServiceImpl extends BaseServiceImpl<Integer, StudentVisit> implements StudentVisitService {
 public class StudentVisitServiceImpl extends BaseServiceImpl<Integer, StudentVisit> implements StudentVisitService {
@@ -50,6 +47,7 @@ public class StudentVisitServiceImpl extends BaseServiceImpl<Integer, StudentVis
             throw new BizException("选择的乐团不存在");
             throw new BizException("选择的乐团不存在");
         }
         }
         studentVisit.setOrganId(musicGroup.getOrganId());
         studentVisit.setOrganId(musicGroup.getOrganId());
+        studentVisit.setCreateTime(new Date());
         studentVisitDao.insert(studentVisit);
         studentVisitDao.insert(studentVisit);
         return studentVisit;
         return studentVisit;
     }
     }

+ 6 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/controller/BaseController.java

@@ -6,12 +6,15 @@ import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.support.DefaultMessageSourceResolvable;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.AccessDeniedException;
 import org.springframework.security.access.AccessDeniedException;
+import org.springframework.validation.BindException;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import java.util.stream.Collectors;
 
 
 @ControllerAdvice
 @ControllerAdvice
 public class BaseController {
 public class BaseController {
@@ -74,6 +77,9 @@ public class BaseController {
 			return failed(e.getMessage());
 			return failed(e.getMessage());
 		} else if (e instanceof AccessDeniedException) {
 		} else if (e instanceof AccessDeniedException) {
 			return failed("禁止访问");
 			return failed("禁止访问");
+		}else if(e instanceof BindException){
+			String errors = ((BindException) e).getFieldErrors().stream().map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining("\n"));
+			return failed(errors);
 		}
 		}
 		return failed("系统繁忙");
 		return failed("系统繁忙");
 	}
 	}

+ 2 - 1
mec-web/src/main/java/com/ym/mec/web/controller/VisitController.java

@@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -63,7 +64,7 @@ public class VisitController extends BaseController {
     @ApiOperation(value = "添加回访")
     @ApiOperation(value = "添加回访")
     @PostMapping(value = "/add")
     @PostMapping(value = "/add")
     @PreAuthorize("@pcs.hasPermissions('visit/add')")
     @PreAuthorize("@pcs.hasPermissions('visit/add')")
-    public HttpResponseResult<StudentVisit> add(StudentVisit studentVisit) {
+    public HttpResponseResult<StudentVisit> add(@Validated StudentVisit studentVisit) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         studentVisit.setTeacherId(sysUser.getId());
         studentVisit.setTeacherId(sysUser.getId());
         studentVisit.setVisiterType(StudentVisit.VisiterTypeEnum.EDU_TEACHER);
         studentVisit.setVisiterType(StudentVisit.VisiterTypeEnum.EDU_TEACHER);