|
|
@@ -1,16 +1,22 @@
|
|
|
package com.uas.sso.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.sso.entity.*;
|
|
|
import com.uas.sso.service.ChangeAdminAppealService;
|
|
|
import com.uas.sso.service.ResetPwdAppealService;
|
|
|
import com.uas.sso.service.UserService;
|
|
|
import com.uas.sso.service.ValidAccountAppealService;
|
|
|
+import com.uas.sso.support.SystemSession;
|
|
|
+import com.uas.sso.util.FastjsonUtils;
|
|
|
+import com.uas.sso.util.FileUrl;
|
|
|
+import com.uas.sso.util.HttpUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
|
* @author wangmh
|
|
|
@@ -21,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("/appeal")
|
|
|
public class AppealController extends BaseController {
|
|
|
|
|
|
+ private static final int IMAGE_MAX_SIZE = 5 * 1024 * 1024;
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
|
@@ -61,7 +68,7 @@ public class AppealController extends BaseController {
|
|
|
* @param code 验证码
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/checkMobile", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/check/mobile", method = RequestMethod.POST)
|
|
|
public ModelMap checkMobile(String mobile, @RequestParam String token, String code) {
|
|
|
Token existToken = tokenService.findOne(token);
|
|
|
if (existToken == null || existToken.isExpired()) {
|
|
|
@@ -83,7 +90,8 @@ public class AppealController extends BaseController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/resetPwd", method = RequestMethod.POST)
|
|
|
- public ModelMap resetPwd(ResetPwdAppeal resetPwdAppeal, String token, String code) {
|
|
|
+ public ModelMap resetPwd(ResetPwdAppeal resetPwdAppeal, @RequestParam String token, String code) {
|
|
|
+ // 校验token
|
|
|
Token existToken = tokenService.findOne(token);
|
|
|
if (existToken == null || existToken.isExpired()) {
|
|
|
return error("验证码已过期,请重新获取");
|
|
|
@@ -100,7 +108,14 @@ public class AppealController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/changeAdmin", method = RequestMethod.POST)
|
|
|
- public ModelMap changeAdmin(ChangeAdminAppeal changeAdminAppeal, String token, String code) {
|
|
|
+ public ModelMap changeAdmin(ChangeAdminAppeal changeAdminAppeal, @RequestParam String token, String code, MultipartFile businessImage) throws Exception {
|
|
|
+ // 校验用户是否登录
|
|
|
+ UserAccount userAccount = SystemSession.getUserAccount();
|
|
|
+ if (userAccount == null) {
|
|
|
+ return error("用户未登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验token
|
|
|
Token existToken = tokenService.findOne(token);
|
|
|
if (existToken == null || existToken.isExpired()) {
|
|
|
return error("验证码已过期,请重新获取");
|
|
|
@@ -111,13 +126,36 @@ public class AppealController extends BaseController {
|
|
|
// 校验验证码
|
|
|
checkMobileCode(token, changeAdminAppeal.getMobile(), code);
|
|
|
|
|
|
+ // 上传营业执照
|
|
|
+ if (!(businessImage == null || businessImage.isEmpty())) {
|
|
|
+ if (businessImage.getSize() > IMAGE_MAX_SIZE) {
|
|
|
+ return error("营业执照附件大小不要超过5M");
|
|
|
+ }
|
|
|
+ HttpUtils.Response response = HttpUtils.upload(FileUrl.FILE_UPLOAD, businessImage, null);
|
|
|
+ JSONObject obj = FastjsonUtils.parseObject(response.getResponseText());
|
|
|
+ String path = (String) obj.get("path");
|
|
|
+ if (path != null) {
|
|
|
+ changeAdminAppeal.setBusinessCodeImage(path);
|
|
|
+ } else {
|
|
|
+ return error("请检查您的营业执照附件");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 保存申述信息
|
|
|
+ changeAdminAppeal.setSubmitterUU(userAccount.getUserUU());
|
|
|
changeAdminAppealService.submit(changeAdminAppeal);
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/account", method = RequestMethod.POST)
|
|
|
public ModelMap validAccount(ValidAccountAppeal validAccountAppeal, String token, String code) {
|
|
|
+ // 校验用户是否登录
|
|
|
+ UserAccount userAccount = SystemSession.getUserAccount();
|
|
|
+ if (userAccount == null) {
|
|
|
+ return error("用户未登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验token
|
|
|
Token existToken = tokenService.findOne(token);
|
|
|
if (existToken == null || existToken.isExpired()) {
|
|
|
return error("验证码已过期,请重新获取");
|
|
|
@@ -129,6 +167,7 @@ public class AppealController extends BaseController {
|
|
|
checkMobileCode(token, validAccountAppeal.getMobile(), code);
|
|
|
|
|
|
// 保存申述信息
|
|
|
+ validAccountAppeal.setSubmitterUU(userAccount.getUserUU());
|
|
|
validAccountAppealService.submit(validAccountAppeal);
|
|
|
return success();
|
|
|
}
|