|
@@ -2,10 +2,15 @@ package com.caimei.controller.admin.auth;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.caimei.annotation.CurrentUser;
|
|
|
|
+import com.caimei.components.RedisService;
|
|
|
|
+import com.caimei.mapper.cmMapper.SystemMapper;
|
|
import com.caimei.model.ResponseJson;
|
|
import com.caimei.model.ResponseJson;
|
|
import com.caimei.model.dto.ShopInfoDto;
|
|
import com.caimei.model.dto.ShopInfoDto;
|
|
|
|
+import com.caimei.model.po.SysUser;
|
|
import com.caimei.model.vo.*;
|
|
import com.caimei.model.vo.*;
|
|
import com.caimei.service.auth.ShopService;
|
|
import com.caimei.service.auth.ShopService;
|
|
|
|
+import com.caimei.utils.JwtUtil;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
@@ -14,9 +19,12 @@ import io.swagger.annotations.ApiOperation;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -36,6 +44,17 @@ public class ShopApi {
|
|
|
|
|
|
private final ShopService shopService;
|
|
private final ShopService shopService;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private RedisService redisService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ public void setRedisService(RedisService redisService) {
|
|
|
|
+ this.redisService = redisService;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SystemMapper systemMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 供应商列表
|
|
* 供应商列表
|
|
*/
|
|
*/
|
|
@@ -70,6 +89,7 @@ public class ShopApi {
|
|
@ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
|
|
@ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
|
|
@GetMapping("/form/data")
|
|
@GetMapping("/form/data")
|
|
public ResponseJson<ShopFormVo> getShopFormData(Integer authUserId) {
|
|
public ResponseJson<ShopFormVo> getShopFormData(Integer authUserId) {
|
|
|
|
+ // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
|
|
return shopService.getShopFormData(authUserId);
|
|
return shopService.getShopFormData(authUserId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -105,6 +125,7 @@ public class ShopApi {
|
|
@ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;", required = true)
|
|
@ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;", required = true)
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
public ResponseJson saveShop(@RequestBody String params) {
|
|
public ResponseJson saveShop(@RequestBody String params) {
|
|
|
|
+ // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
|
|
JSONObject paramsMap = JSONObject.parseObject(params);
|
|
JSONObject paramsMap = JSONObject.parseObject(params);
|
|
Integer authUserId = paramsMap.getInteger("authUserId");
|
|
Integer authUserId = paramsMap.getInteger("authUserId");
|
|
Integer shopType = paramsMap.getInteger("shopType");
|
|
Integer shopType = paramsMap.getInteger("shopType");
|
|
@@ -172,6 +193,7 @@ public class ShopApi {
|
|
@ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;status:供应商状态:0停用 1启用", required = true)
|
|
@ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;status:供应商状态:0停用 1启用", required = true)
|
|
@PostMapping("/update/status")
|
|
@PostMapping("/update/status")
|
|
public ResponseJson updateShopStatus(@RequestBody Map<String,Integer> params) {
|
|
public ResponseJson updateShopStatus(@RequestBody Map<String,Integer> params) {
|
|
|
|
+ // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
|
|
Integer authUserId = params.get("authUserId");
|
|
Integer authUserId = params.get("authUserId");
|
|
Integer status = params.get("status");
|
|
Integer status = params.get("status");
|
|
return shopService.updateShopStatus(authUserId, status);
|
|
return shopService.updateShopStatus(authUserId, status);
|
|
@@ -184,6 +206,7 @@ public class ShopApi {
|
|
@ApiImplicitParam(name = "params", value = "authUserId:供应商用户id", required = true)
|
|
@ApiImplicitParam(name = "params", value = "authUserId:供应商用户id", required = true)
|
|
@PostMapping("/reset/password")
|
|
@PostMapping("/reset/password")
|
|
public ResponseJson resetShopPassword(@RequestBody Map<String,Integer> params) {
|
|
public ResponseJson resetShopPassword(@RequestBody Map<String,Integer> params) {
|
|
|
|
+ // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
|
|
Integer authUserId = params.get("authUserId");
|
|
Integer authUserId = params.get("authUserId");
|
|
return shopService.resetShopPassword(authUserId);
|
|
return shopService.resetShopPassword(authUserId);
|
|
}
|
|
}
|
|
@@ -235,7 +258,6 @@ public class ShopApi {
|
|
|
|
|
|
@ApiOperation("用户反馈列表")
|
|
@ApiOperation("用户反馈列表")
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|
|
- @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id"),
|
|
|
|
@ApiImplicitParam(name = "clubName", required = false, value = "机构名称"),
|
|
@ApiImplicitParam(name = "clubName", required = false, value = "机构名称"),
|
|
@ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
|
|
@ApiImplicitParam(name = "mobile", required = false, value = "手机号"),
|
|
@ApiImplicitParam(name = "handleStatus", required = false, value = "处理状态:0未处理,1已处理"),
|
|
@ApiImplicitParam(name = "handleStatus", required = false, value = "处理状态:0未处理,1已处理"),
|
|
@@ -243,9 +265,18 @@ public class ShopApi {
|
|
@ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
|
|
@ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
|
|
})
|
|
})
|
|
@GetMapping("/feedback/list")
|
|
@GetMapping("/feedback/list")
|
|
- public ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(Integer authUserId, String clubName, String mobile, Integer handleStatus,
|
|
|
|
|
|
+ public ResponseJson<PageInfo<FeedbackVo>> getFeedbackList(@CurrentUser SysUser sysUser, String clubName, String mobile, Integer handleStatus,
|
|
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
|
+ if (null == sysUser) {
|
|
|
|
+ return ResponseJson.error("用户信息异常", null);
|
|
|
|
+ }
|
|
|
|
+ // 获取供应商用户id
|
|
|
|
+ Integer userIdentity = sysUser.getUserIdentity();
|
|
|
|
+ Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
|
|
|
|
+ if (null == authUserId) {
|
|
|
|
+ return ResponseJson.error("供应商用户id不能为空", null);
|
|
|
|
+ }
|
|
return shopService.getFeedbackList(authUserId, clubName, mobile, handleStatus, pageNum, pageSize);
|
|
return shopService.getFeedbackList(authUserId, clubName, mobile, handleStatus, pageNum, pageSize);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -276,11 +307,18 @@ public class ShopApi {
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation("修改手机号")
|
|
@ApiOperation("修改手机号")
|
|
- @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;oldMobile:旧手机号;verifyCode:验证码;newMobile:新手机号;", required = true)
|
|
|
|
|
|
+ @ApiImplicitParam(name = "params", value = "oldMobile:旧手机号;verifyCode:验证码;newMobile:新手机号;", required = true)
|
|
@PostMapping("/mobile/change")
|
|
@PostMapping("/mobile/change")
|
|
- public ResponseJson changeMobile(@RequestBody String params) {
|
|
|
|
|
|
+ public ResponseJson changeMobile(@CurrentUser SysUser sysUser, @RequestBody String params) {
|
|
|
|
+ if (null == sysUser) {
|
|
|
|
+ return ResponseJson.error("用户信息异常", null);
|
|
|
|
+ }
|
|
|
|
+ // 修改用户信息:供应商和子用户都可以修改个人信息,直接取id即可
|
|
|
|
+ Integer authUserId = sysUser.getId();
|
|
|
|
+ if (null == authUserId) {
|
|
|
|
+ return ResponseJson.error("供应商用户id不能为空", null);
|
|
|
|
+ }
|
|
JSONObject parseObject = JSONObject.parseObject(params);
|
|
JSONObject parseObject = JSONObject.parseObject(params);
|
|
- Integer authUserId = parseObject.getInteger("authUserId");
|
|
|
|
String verifyCode = parseObject.getString("verifyCode");
|
|
String verifyCode = parseObject.getString("verifyCode");
|
|
String oldMobile = parseObject.getString("oldMobile");
|
|
String oldMobile = parseObject.getString("oldMobile");
|
|
String newMobile = parseObject.getString("newMobile");
|
|
String newMobile = parseObject.getString("newMobile");
|
|
@@ -288,11 +326,18 @@ public class ShopApi {
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation("登录账号绑定")
|
|
@ApiOperation("登录账号绑定")
|
|
- @ApiImplicitParam(name = "params", value = "authUserId:供应商用户id;mobile:手机号;verifyCode:验证码;loginAccount:登录账号;", required = true)
|
|
|
|
|
|
+ @ApiImplicitParam(name = "params", value = "mobile:手机号;verifyCode:验证码;loginAccount:登录账号;", required = true)
|
|
@PostMapping("/account/bind")
|
|
@PostMapping("/account/bind")
|
|
- public ResponseJson bindLoginAccount(@RequestBody String params) {
|
|
|
|
|
|
+ public ResponseJson bindLoginAccount(@CurrentUser SysUser sysUser, @RequestBody String params) {
|
|
|
|
+ if (null == sysUser) {
|
|
|
|
+ return ResponseJson.error("用户信息异常", null);
|
|
|
|
+ }
|
|
|
|
+ // 修改用户信息:供应商和子用户都可以修改个人信息,直接取id即可
|
|
|
|
+ Integer authUserId = sysUser.getId();
|
|
|
|
+ if (null == authUserId) {
|
|
|
|
+ return ResponseJson.error("供应商用户id不能为空", null);
|
|
|
|
+ }
|
|
JSONObject parseObject = JSONObject.parseObject(params);
|
|
JSONObject parseObject = JSONObject.parseObject(params);
|
|
- Integer authUserId = parseObject.getInteger("authUserId");
|
|
|
|
String verifyCode = parseObject.getString("verifyCode");
|
|
String verifyCode = parseObject.getString("verifyCode");
|
|
String mobile = parseObject.getString("mobile");
|
|
String mobile = parseObject.getString("mobile");
|
|
String loginAccount = parseObject.getString("loginAccount");
|
|
String loginAccount = parseObject.getString("loginAccount");
|
|
@@ -300,14 +345,41 @@ public class ShopApi {
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation("一键更新机构授权牌")
|
|
@ApiOperation("一键更新机构授权牌")
|
|
- @ApiImplicitParam(name = "params",value = "authUserId:供应商用户id")
|
|
|
|
@PostMapping("/authImage/update/all")
|
|
@PostMapping("/authImage/update/all")
|
|
- public ResponseJson updateAllAuthImage(@RequestBody String params ){
|
|
|
|
- JSONObject parseObject = JSONObject.parseObject(params);
|
|
|
|
- Integer authUserId = parseObject.getInteger("authUserId");
|
|
|
|
|
|
+ public ResponseJson updateAllAuthImage(@CurrentUser SysUser sysUser){
|
|
|
|
+ if (null == sysUser) {
|
|
|
|
+ return ResponseJson.error("用户信息异常", null);
|
|
|
|
+ }
|
|
|
|
+ // 获取供应商用户id
|
|
|
|
+ Integer userIdentity = sysUser.getUserIdentity();
|
|
|
|
+ Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
|
|
if (null == authUserId) {
|
|
if (null == authUserId) {
|
|
- return ResponseJson.error("供应商用户id不能为空");
|
|
|
|
|
|
+ return ResponseJson.error("供应商用户id不能为空", null);
|
|
}
|
|
}
|
|
return shopService.updateAllAuthImage(authUserId);
|
|
return shopService.updateAllAuthImage(authUserId);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @ApiOperation("管理员生成供应商token")
|
|
|
|
+ @GetMapping("/token/generate")
|
|
|
|
+ public ResponseJson<String> generateShopToken(Integer authUserId, HttpServletRequest request) {
|
|
|
|
+ // 由管理员调用接口,无法通过@CurrentUser注解获取供应商用户id
|
|
|
|
+ // 对管理员身份进行校验
|
|
|
|
+ String token = request.getHeader("X-Token");
|
|
|
|
+ String cacheToken = null != token ? String.valueOf(redisService.get(token)) : null;
|
|
|
|
+ if (null != cacheToken && JwtUtil.isVerify(cacheToken)) {
|
|
|
|
+ int adminId = JwtUtil.parseTokenUid(cacheToken);
|
|
|
|
+ SysUser user = systemMapper.getUser(adminId);
|
|
|
|
+ if (null == user || 1 != user.getUserIdentity()) {
|
|
|
|
+ return ResponseJson.error("生成token失败", null);
|
|
|
|
+ } else {
|
|
|
|
+ // 生成token给用户
|
|
|
|
+ String shopToken = JwtUtil.createToken(authUserId);
|
|
|
|
+ // 为了过期续签,将token存入redis,并设置超时时间
|
|
|
|
+ redisService.set(shopToken, shopToken, JwtUtil.getExpireTime());
|
|
|
|
+ return ResponseJson.success(shopToken);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return ResponseJson.error("生成token失败", null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|