浏览代码

Merge remote-tracking branch 'origin/saas' into saas

zouxuan 3 年之前
父节点
当前提交
f86fa4193d

+ 2 - 7
mec-common/common-core/src/main/java/com/ym/mec/common/controller/BaseController.java

@@ -6,14 +6,12 @@ import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import com.ym.mec.util.http.HttpUtil;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.support.DefaultMessageSourceResolvable;
-import org.springframework.dao.DataIntegrityViolationException;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.AccessDeniedException;
 import org.springframework.validation.BindException;
@@ -25,7 +23,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 import javax.servlet.http.HttpServletRequest;
-
 import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.Map;
@@ -111,8 +108,6 @@ public class BaseController {
                     .map(FieldError::getDefaultMessage)
                     .collect(Collectors.joining());
             return failed(errorMsg);
-        } else if(e instanceof DataIntegrityViolationException){
-        	return failed("数据库异常:" + e.getMessage());
         }
 		try {
 			Map<String,Object> paramMap = new HashMap<>(2);
@@ -126,8 +121,8 @@ public class BaseController {
 		}catch (Exception exception){
 			logger.error("System Error", exception);
 		}
-        if (StringUtils.isNotBlank(ex.getMessage())) {
-            return failed(ex.getMessage());
+        if (StringUtils.isNotBlank(e.getMessage())) {
+            return failed(e.getMessage());
         }
 		return failed("系统繁忙");
 	}

+ 24 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentController.java

@@ -2,14 +2,21 @@ package com.ym.mec.student.controller;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+
 import javax.annotation.Resource;
+
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.dal.entity.StudentPreRegistration;
 import com.ym.mec.biz.service.StudentService;
 import com.ym.mec.common.controller.BaseController;
@@ -37,4 +44,21 @@ public class StudentController extends BaseController {
         return studentService.register(studentPreRegistration) ? succeed() : failed();
     }
 
+	@ApiOperation("更换声部")
+	@PostMapping(value = "/updateSubject")
+	public Object updateSubject(Integer subjectId) {
+		SysUser user = sysUserFeignService.queryUserInfo();
+		if (user == null || user.getId() == null) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		Student student = studentService.get(user.getId());
+
+		if (student != null) {
+			student.setSubjectIdList(subjectId + "");
+			student.setUpdateTime(new Date());
+			studentService.update(student);
+		}
+		return succeed();
+	}
+
 }