修改放行参数
This commit is contained in:
parent
5437d02aa0
commit
77656d2305
@ -41,11 +41,11 @@ public class AppTokenFilter extends GenericFilterBean implements InitializingBea
|
|||||||
/**
|
/**
|
||||||
* APP登录(用户名密码)
|
* APP登录(用户名密码)
|
||||||
*/
|
*/
|
||||||
private static final String URL_LOGIN_DEFAULT = "/**/app/sign/login";
|
private static final String URL_LOGIN_DEFAULT = "/**/app/sign/default";
|
||||||
/**
|
/**
|
||||||
* APP登录(手机验证码)
|
* APP登录(手机验证码)
|
||||||
*/
|
*/
|
||||||
private static final String URL_LOGIN_PHONE = "/**/app/sign/loginphone";
|
private static final String URL_LOGIN_PHONE = "/**/app/sign/phone";
|
||||||
/**
|
/**
|
||||||
* APP注册
|
* APP注册
|
||||||
*/
|
*/
|
||||||
|
@ -69,6 +69,7 @@ public class ErrorResult implements Serializable {
|
|||||||
ENCODE_ERROR(40002),
|
ENCODE_ERROR(40002),
|
||||||
DECODE_ERROR(40003),
|
DECODE_ERROR(40003),
|
||||||
APP_DEPENDENCY_ERROR(40004),
|
APP_DEPENDENCY_ERROR(40004),
|
||||||
|
PROPERTIES_ERROR(40005),
|
||||||
TEXT_ILLEGAL(40101),
|
TEXT_ILLEGAL(40101),
|
||||||
PARAMS_ERROR(40102),
|
PARAMS_ERROR(40102),
|
||||||
QUERY_ERROR(40101),
|
QUERY_ERROR(40101),
|
||||||
|
@ -0,0 +1,153 @@
|
|||||||
|
package ink.wgink.service.user.controller.app.api;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.exceptions.ParamsException;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.exceptions.UpdateException;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultData;
|
||||||
|
import ink.wgink.service.user.pojo.dtos.AppUserDTO;
|
||||||
|
import ink.wgink.service.user.pojo.vos.UpdatePasswordVO;
|
||||||
|
import ink.wgink.service.user.pojo.vos.UpdateUserVO;
|
||||||
|
import ink.wgink.service.user.service.IUserService;
|
||||||
|
import ink.wgink.util.ReflectUtil;
|
||||||
|
import ink.wgink.util.RegexUtil;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: UserAppController
|
||||||
|
* @Description: 用户
|
||||||
|
* @Author: WangGeng
|
||||||
|
* @Date: 2019-08-14 14:24
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "用户")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.APP_PREFIX + "/user")
|
||||||
|
public class UserAppController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUserService userService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改用户信息", notes = "修改用户信息接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update-info")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResultData<String> updateInfo(@RequestHeader("token") String token, @RequestBody UpdateUserVO updateUserVO) throws Exception {
|
||||||
|
if (StringUtils.isBlank(updateUserVO.getName())) {
|
||||||
|
throw new ParamsException("昵称不能为空");
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(updateUserVO.getPhone()) && !RegexUtil.isPhone(updateUserVO.getPhone())) {
|
||||||
|
throw new ParamsException("手机格式不正确");
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(updateUserVO.getEmail()) && !RegexUtil.isEmail(updateUserVO.getEmail())) {
|
||||||
|
throw new ParamsException("邮箱格式不正确");
|
||||||
|
}
|
||||||
|
return new SuccessResultData<>(userService.updateInfo(token, updateUserVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改头像", notes = "修改头像接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update-avatar")
|
||||||
|
public SuccessResultData<String> updateAvatar(@RequestHeader("token") String token, @RequestBody UpdateUserVO updateUserVO) throws Exception {
|
||||||
|
if (StringUtils.isBlank(updateUserVO.getAvatar())) {
|
||||||
|
throw new ParamsException("头像不能为空");
|
||||||
|
}
|
||||||
|
return new SuccessResultData<>(userService.updateInfo(token, updateUserVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改昵称", notes = "修改昵称接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update-name")
|
||||||
|
public SuccessResult updateName(@RequestHeader("token") String token, @RequestBody UpdateUserVO updateUserVO) throws Exception {
|
||||||
|
if (StringUtils.isBlank(updateUserVO.getName())) {
|
||||||
|
throw new ParamsException("昵称不能为空");
|
||||||
|
}
|
||||||
|
return new SuccessResultData<>(userService.updateInfo(token, updateUserVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改电话", notes = "修改电话接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update-phone")
|
||||||
|
public SuccessResult updatePhone(@RequestHeader("token") String token, @RequestBody UpdateUserVO updateUserVO) throws Exception {
|
||||||
|
if (StringUtils.isBlank(updateUserVO.getPhone())) {
|
||||||
|
throw new ParamsException("电话不能为空");
|
||||||
|
}
|
||||||
|
return new SuccessResultData<>(userService.updateInfo(token, updateUserVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改邮箱", notes = "修改邮箱接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update-email")
|
||||||
|
public SuccessResult updateEmail(@RequestHeader("token") String token, @RequestBody UpdateUserVO updateUserVO) throws Exception {
|
||||||
|
if (StringUtils.isBlank(updateUserVO.getEmail())) {
|
||||||
|
throw new ParamsException("邮箱不能为空");
|
||||||
|
}
|
||||||
|
return new SuccessResultData<>(userService.updateInfo(token, updateUserVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改密码", notes = "修改密码接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PutMapping("update-password")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public SuccessResult updatePassword(@RequestHeader("token") String token,
|
||||||
|
@RequestBody UpdatePasswordVO updatePasswordVO) throws ParamsException, SearchException, UpdateException, ReflectUtil.ReflectException {
|
||||||
|
if (updatePasswordVO.getNewPassword().length() < 6) {
|
||||||
|
throw new ParamsException("新密码长度必须大于6位");
|
||||||
|
}
|
||||||
|
userService.updatePassword(token, updatePasswordVO);
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取APP用户", notes = "获取APP用户接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("get-app-user")
|
||||||
|
public AppUserDTO getAppUser(@RequestHeader("token") String token) throws ReflectUtil.ReflectException {
|
||||||
|
return userService.getAppUser(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "下载用户头像", notes = "下载用户头像接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "userId", value = "用户Id", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("download-avatar/{userId}")
|
||||||
|
public void downLoadAvatar(@PathVariable("userId") String userId, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
userService.downLoadAvatar(userId, request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
package ink.wgink.service.user.controller.route;
|
package ink.wgink.service.user.controller.route;
|
||||||
|
|
||||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.interfaces.user.IUserExpandBaseService;
|
||||||
import ink.wgink.util.ResourceUtil;
|
import ink.wgink.util.ResourceUtil;
|
||||||
import ink.wgink.util.request.RequestUtil;
|
import ink.wgink.util.request.RequestUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -28,9 +30,16 @@ import java.io.IOException;
|
|||||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/user")
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/user")
|
||||||
public class UserRouteController {
|
public class UserRouteController {
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private IUserExpandBaseService userExpandBaseService;
|
||||||
|
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
public ModelAndView list() {
|
public ModelAndView list() {
|
||||||
return new ModelAndView("user/list");
|
ModelAndView mv = new ModelAndView("user/list");
|
||||||
|
if (userExpandBaseService != null) {
|
||||||
|
mv.addObject("userExpand", userExpandBaseService.getRoute());
|
||||||
|
}
|
||||||
|
return mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("save")
|
@GetMapping("save")
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
package ink.wgink.service.user.pojo.dtos;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: UserAppDTO
|
||||||
|
* @Description: APP用户
|
||||||
|
* @Author: WangGeng
|
||||||
|
* @Date: 2020/6/7 11:20
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class AppUserDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "userId", value = "用户ID")
|
||||||
|
private String userId;
|
||||||
|
@ApiModelProperty(name = "username", value = "用户名")
|
||||||
|
private String username;
|
||||||
|
@ApiModelProperty(name = "name", value = "昵称")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(name = "avatar", value = "头像")
|
||||||
|
private String avatar;
|
||||||
|
@ApiModelProperty(name = "phone", value = "手机")
|
||||||
|
private String phone;
|
||||||
|
@ApiModelProperty(name = "email", value = "邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId == null ? "" : userId.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username == null ? "" : username.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name == null ? "" : name.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar() {
|
||||||
|
return avatar == null ? "" : avatar.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatar(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone == null ? "" : phone.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email == null ? "" : email.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final StringBuilder sb = new StringBuilder("{");
|
||||||
|
sb.append("\"userId\":\"")
|
||||||
|
.append(userId).append('\"');
|
||||||
|
sb.append(",\"username\":\"")
|
||||||
|
.append(username).append('\"');
|
||||||
|
sb.append(",\"name\":\"")
|
||||||
|
.append(name).append('\"');
|
||||||
|
sb.append(",\"avatar\":\"")
|
||||||
|
.append(avatar).append('\"');
|
||||||
|
sb.append(",\"phone\":\"")
|
||||||
|
.append(phone).append('\"');
|
||||||
|
sb.append(",\"email\":\"")
|
||||||
|
.append(email).append('\"');
|
||||||
|
sb.append('}');
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package ink.wgink.service.user.pojo.vos;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When you feel like quitting. Think about why you started
|
||||||
|
* 当你想要放弃的时候,想想当初你为何开始
|
||||||
|
*
|
||||||
|
* @ClassName: AppUserVO
|
||||||
|
* @Description: app用户
|
||||||
|
* @Author: WangGeng
|
||||||
|
* @Date: 2019-08-15 18:29
|
||||||
|
* @Version: 1.0
|
||||||
|
**/
|
||||||
|
@ApiModel
|
||||||
|
public class UpdateUserVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "avatar", value = "头像")
|
||||||
|
private String avatar;
|
||||||
|
@ApiModelProperty(name = "name", value = "昵称")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(name = "phone", value = "联系电话")
|
||||||
|
private String phone;
|
||||||
|
@ApiModelProperty(name = "email", value = "邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
public String getAvatar() {
|
||||||
|
return avatar == null ? "" : avatar.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatar(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name == null ? "" : name.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
return phone == null ? "" : phone.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email == null ? "" : email.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final StringBuilder sb = new StringBuilder("{");
|
||||||
|
sb.append("\"avatar\":\"")
|
||||||
|
.append(avatar).append('\"');
|
||||||
|
sb.append(",\"name\":\"")
|
||||||
|
.append(name).append('\"');
|
||||||
|
sb.append(",\"phone\":\"")
|
||||||
|
.append(phone).append('\"');
|
||||||
|
sb.append(",\"email\":\"")
|
||||||
|
.append(email).append('\"');
|
||||||
|
sb.append('}');
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -5,12 +5,17 @@ import ink.wgink.exceptions.UpdateException;
|
|||||||
import ink.wgink.interfaces.user.IUserBaseService;
|
import ink.wgink.interfaces.user.IUserBaseService;
|
||||||
import ink.wgink.interfaces.user.IUserCheckService;
|
import ink.wgink.interfaces.user.IUserCheckService;
|
||||||
import ink.wgink.pojo.result.SuccessResult;
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.service.user.pojo.dtos.AppUserDTO;
|
||||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||||
import ink.wgink.service.user.pojo.vos.*;
|
import ink.wgink.service.user.pojo.vos.*;
|
||||||
import ink.wgink.pojo.result.UploadExcelResultDTO;
|
import ink.wgink.pojo.result.UploadExcelResultDTO;
|
||||||
|
import ink.wgink.util.ReflectUtil;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -65,6 +70,15 @@ public interface IUserService extends IUserBaseService, IUserCheckService {
|
|||||||
*/
|
*/
|
||||||
void save(UserVO userVO);
|
void save(UserVO userVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存用户
|
||||||
|
*
|
||||||
|
* @param userVO
|
||||||
|
* @param isRegister
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String saveAndReturnId(UserVO userVO, boolean isRegister);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户
|
* 注册用户
|
||||||
*
|
*
|
||||||
@ -90,6 +104,16 @@ public interface IUserService extends IUserBaseService, IUserCheckService {
|
|||||||
*/
|
*/
|
||||||
void update(String userId, UserVO userVO);
|
void update(String userId, UserVO userVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户,不包含密码,返回新token
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @param updateUserVO
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
String updateInfo(String token, UpdateUserVO updateUserVO) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置用户密码
|
* 重置用户密码
|
||||||
*
|
*
|
||||||
@ -115,6 +139,13 @@ public interface IUserService extends IUserBaseService, IUserCheckService {
|
|||||||
*/
|
*/
|
||||||
void updatePassword(UpdatePasswordVO updatePasswordVO);
|
void updatePassword(UpdatePasswordVO updatePasswordVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
void updatePassword(String token, UpdatePasswordVO updatePasswordVO) throws ReflectUtil.ReflectException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新过期时间
|
* 更新过期时间
|
||||||
*
|
*
|
||||||
@ -163,4 +194,20 @@ public interface IUserService extends IUserBaseService, IUserCheckService {
|
|||||||
*/
|
*/
|
||||||
Integer count(Map<String, Object> params);
|
Integer count(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户
|
||||||
|
*
|
||||||
|
* @param token
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AppUserDTO getAppUser(String token) throws ReflectUtil.ReflectException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载用户头像
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void downLoadAvatar(String userId, HttpServletRequest request, HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,17 @@ import com.alibaba.excel.EasyExcel;
|
|||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import ink.wgink.common.base.DefaultBaseService;
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.exceptions.FileException;
|
||||||
import ink.wgink.exceptions.SearchException;
|
import ink.wgink.exceptions.SearchException;
|
||||||
import ink.wgink.exceptions.UpdateException;
|
import ink.wgink.exceptions.UpdateException;
|
||||||
|
import ink.wgink.exceptions.base.SystemException;
|
||||||
|
import ink.wgink.interfaces.app.IAppSignBaseService;
|
||||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
import ink.wgink.interfaces.manager.ISystemConfigManager;
|
import ink.wgink.interfaces.manager.ISystemConfigManager;
|
||||||
import ink.wgink.module.file.excel.error.AbstractErrorExcelHandler;
|
import ink.wgink.module.file.excel.error.AbstractErrorExcelHandler;
|
||||||
import ink.wgink.module.file.service.IFileService;
|
import ink.wgink.module.file.service.IFileService;
|
||||||
import ink.wgink.pojo.ListPage;
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.app.AppTokenUser;
|
||||||
import ink.wgink.pojo.dtos.user.UserDTO;
|
import ink.wgink.pojo.dtos.user.UserDTO;
|
||||||
import ink.wgink.pojo.result.SuccessResultData;
|
import ink.wgink.pojo.result.SuccessResultData;
|
||||||
import ink.wgink.pojo.result.SuccessResultList;
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
@ -21,11 +25,14 @@ import ink.wgink.service.user.excel.UserExcel;
|
|||||||
import ink.wgink.service.user.excel.UserExcelError;
|
import ink.wgink.service.user.excel.UserExcelError;
|
||||||
import ink.wgink.service.user.excel.UserExcelListener;
|
import ink.wgink.service.user.excel.UserExcelListener;
|
||||||
import ink.wgink.service.user.pojo.bos.UserAdjustmentBO;
|
import ink.wgink.service.user.pojo.bos.UserAdjustmentBO;
|
||||||
|
import ink.wgink.service.user.pojo.dtos.AppUserDTO;
|
||||||
import ink.wgink.service.user.pojo.pos.UserPO;
|
import ink.wgink.service.user.pojo.pos.UserPO;
|
||||||
import ink.wgink.service.user.pojo.vos.*;
|
import ink.wgink.service.user.pojo.vos.*;
|
||||||
import ink.wgink.service.user.service.IUserAdjustmentService;
|
import ink.wgink.service.user.service.IUserAdjustmentService;
|
||||||
import ink.wgink.service.user.service.IUserService;
|
import ink.wgink.service.user.service.IUserService;
|
||||||
import ink.wgink.util.ArrayListUtil;
|
import ink.wgink.util.ArrayListUtil;
|
||||||
|
import ink.wgink.util.ReflectUtil;
|
||||||
|
import ink.wgink.util.ResourceUtil;
|
||||||
import ink.wgink.util.UUIDUtil;
|
import ink.wgink.util.UUIDUtil;
|
||||||
import ink.wgink.util.date.DateUtil;
|
import ink.wgink.util.date.DateUtil;
|
||||||
import ink.wgink.util.map.HashMapUtil;
|
import ink.wgink.util.map.HashMapUtil;
|
||||||
@ -39,7 +46,10 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -68,15 +78,17 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
private String defaultPassword;
|
private String defaultPassword;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IFileService fileService;
|
private IFileService fileService;
|
||||||
|
@Autowired(required = false)
|
||||||
|
private IAppSignBaseService appSignBaseService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(UserVO userVO) {
|
public void save(UserVO userVO) {
|
||||||
saveUser(userVO, false);
|
saveAndReturnId(userVO, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(UserVO userVO) {
|
public void register(UserVO userVO) {
|
||||||
saveUser(userVO, true);
|
saveAndReturnId(userVO, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +97,8 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
* @param userVO
|
* @param userVO
|
||||||
* @param isRegister 是否注册
|
* @param isRegister 是否注册
|
||||||
*/
|
*/
|
||||||
private void saveUser(UserVO userVO, boolean isRegister) {
|
@Override
|
||||||
|
public String saveAndReturnId(UserVO userVO, boolean isRegister) {
|
||||||
UserDTO userDTO = getByUsername(userVO.getUserUsername());
|
UserDTO userDTO = getByUsername(userVO.getUserUsername());
|
||||||
if (userDTO != null) {
|
if (userDTO != null) {
|
||||||
throw new SearchException("用户已经存在");
|
throw new SearchException("用户已经存在");
|
||||||
@ -101,6 +114,7 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
setSaveInfo(params);
|
setSaveInfo(params);
|
||||||
}
|
}
|
||||||
userDao.save(params);
|
userDao.save(params);
|
||||||
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -122,6 +136,19 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
userDao.update(params);
|
userDao.update(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String updateInfo(String token, UpdateUserVO updateUserVO) throws Exception {
|
||||||
|
if (appSignBaseService == null) {
|
||||||
|
throw new SystemException("未引入APP登录模块");
|
||||||
|
}
|
||||||
|
String userId = securityComponent.getAppTokenUser(token).getId();
|
||||||
|
Map<String, Object> params = HashMapUtil.beanToMap(updateUserVO);
|
||||||
|
params.put("userId", userId);
|
||||||
|
setAppUpdateInfo(token, params);
|
||||||
|
userDao.update(params);
|
||||||
|
return appSignBaseService.userIdSign(userId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetPassword(String userId, RestPasswordVO restPasswordVO) {
|
public void resetPassword(String userId, RestPasswordVO restPasswordVO) {
|
||||||
UserDTO userDTO = get(userId);
|
UserDTO userDTO = get(userId);
|
||||||
@ -190,6 +217,33 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
userAdjustmentService.save(userAdjustmentBO);
|
userAdjustmentService.save(userAdjustmentBO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePassword(String token, UpdatePasswordVO updatePasswordVO) throws ReflectUtil.ReflectException {
|
||||||
|
AppTokenUser appTokenUser = securityComponent.getAppTokenUser(token);
|
||||||
|
String oldPassword = DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(updatePasswordVO.getOldPassword())));
|
||||||
|
String newPassword = DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(updatePasswordVO.getNewPassword())));
|
||||||
|
UserPO userPO = getPO(appTokenUser.getId());
|
||||||
|
if (!passwordEncoder.matches(oldPassword, userPO.getUserPassword())) {
|
||||||
|
throw new UpdateException("旧密码错误");
|
||||||
|
}
|
||||||
|
Map<String, Object> params = getHashMap(4);
|
||||||
|
params.put("userPassword", passwordEncoder.encode(newPassword));
|
||||||
|
params.put("gmtPasswordModified", DateUtil.getTime());
|
||||||
|
params.put("userId", userPO.getUserId());
|
||||||
|
userDao.updatePassword(params);
|
||||||
|
|
||||||
|
// 日志
|
||||||
|
UserAdjustmentBO userAdjustmentBO = new UserAdjustmentBO();
|
||||||
|
userAdjustmentBO.setUserId(appTokenUser.getId());
|
||||||
|
userAdjustmentBO.setUserName(appTokenUser.getName());
|
||||||
|
userAdjustmentBO.setUpdateType(UserUpdateTypeEnum.PASSWORD.getValue());
|
||||||
|
userAdjustmentBO.setUpdateReason("修改密码");
|
||||||
|
userAdjustmentBO.setCreator(appTokenUser.getId());
|
||||||
|
userAdjustmentBO.setCreatorName(appTokenUser.getName());
|
||||||
|
userAdjustmentBO.setGmtCreate(DateUtil.getTime());
|
||||||
|
userAdjustmentService.save(userAdjustmentBO);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateExpiredDate(String userId, UpdateExpiredDateVO updateExpiredDateVO) {
|
public void updateExpiredDate(String userId, UpdateExpiredDateVO updateExpiredDateVO) {
|
||||||
UserDTO oldUserDTO = get(userId);
|
UserDTO oldUserDTO = get(userId);
|
||||||
@ -232,7 +286,7 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
userVO.setUserEmail(userEmail);
|
userVO.setUserEmail(userEmail);
|
||||||
userVO.setUserType(2);
|
userVO.setUserType(2);
|
||||||
userVO.setUserState(0);
|
userVO.setUserState(0);
|
||||||
saveUser(userVO, false);
|
saveAndReturnId(userVO, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
userExcelErrors.add(getUserExcelError(userExcel, e.getMessage()));
|
userExcelErrors.add(getUserExcelError(userExcel, e.getMessage()));
|
||||||
}
|
}
|
||||||
@ -330,6 +384,40 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
return count == null ? 0 : count;
|
return count == null ? 0 : count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AppUserDTO getAppUser(String token) throws ReflectUtil.ReflectException {
|
||||||
|
String userId = securityComponent.getAppTokenUser(token).getId();
|
||||||
|
UserPO userPO = getPO(userId);
|
||||||
|
if (userPO == null) {
|
||||||
|
throw new SearchException("用户不存在");
|
||||||
|
}
|
||||||
|
AppUserDTO appUserDTO = new AppUserDTO();
|
||||||
|
appUserDTO.setUserId(userPO.getUserId());
|
||||||
|
appUserDTO.setAvatar(userPO.getUserAvatar());
|
||||||
|
appUserDTO.setUsername(userPO.getUserUsername());
|
||||||
|
appUserDTO.setName(userPO.getUserName());
|
||||||
|
appUserDTO.setEmail(userPO.getUserEmail());
|
||||||
|
appUserDTO.setPhone(userPO.getUserPhone());
|
||||||
|
return appUserDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downLoadAvatar(String userId, HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
UserDTO userDTO = get(userId);
|
||||||
|
if (userDTO == null) {
|
||||||
|
throw new SearchException("用户不存在");
|
||||||
|
}
|
||||||
|
// 头像不存在,加载默认头像
|
||||||
|
if (StringUtils.isBlank(userDTO.getUserAvatar())) {
|
||||||
|
downloadDefaultAvatar(response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, Object> params = getHashMap(4);
|
||||||
|
params.put("fileId", userDTO.getUserAvatar());
|
||||||
|
params.put("isOpen", ISystemConstant.IS_TRUE);
|
||||||
|
fileService.downLoadFile(request, response, params);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int countDateRange(String startDate, String endDate) {
|
public int countDateRange(String startDate, String endDate) {
|
||||||
Map<String, Object> params = getHashMap(4);
|
Map<String, Object> params = getHashMap(4);
|
||||||
@ -482,4 +570,34 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
|||||||
userAdjustmentService.save(userAdjustmentBO);
|
userAdjustmentService.save(userAdjustmentBO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载默认用户头像
|
||||||
|
*
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
private void downloadDefaultAvatar(HttpServletResponse response) {
|
||||||
|
File file;
|
||||||
|
try {
|
||||||
|
file = ResourceUtil.getResourceFile("classpath:static/assets/images/profile-photo.jpg");
|
||||||
|
response.setHeader("Content-Length", String.valueOf(file.length()));
|
||||||
|
response.setHeader("Content-Disposition", "inline;fileName=" + URLEncoder.encode("profile-photo.jpg", "UTF-8"));
|
||||||
|
response.setContentType("image/jpeg");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new FileException("默认头像不存在");
|
||||||
|
}
|
||||||
|
try (
|
||||||
|
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(response.getOutputStream());
|
||||||
|
) {
|
||||||
|
int readSize;
|
||||||
|
for (byte[] buf = new byte[IFileService.INPUT_STREAM_SIZE]; (readSize = bufferedInputStream.read(buf)) > -1; ) {
|
||||||
|
System.out.println(readSize);
|
||||||
|
bufferedOutputStream.write(buf, 0, readSize);
|
||||||
|
}
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("默认头像不存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||||
|
<input type="hidden" id="userExpand" th:value="${userExpand}" th:if="${userExpand}">
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||||
</div>
|
</div>
|
||||||
@ -31,7 +32,7 @@
|
|||||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||||
<i class="fa fa-lg fa-search"></i> 搜索
|
<i class="fa fa-lg fa-search"></i> 搜索
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="layui-btn layui-btn-sm" id="uploadExcel">
|
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="uploadExcel">
|
||||||
<i class="fa fa-lg fa-cloud-upload"></i> 导入数据
|
<i class="fa fa-lg fa-cloud-upload"></i> 导入数据
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -76,21 +77,7 @@
|
|||||||
|
|
||||||
// 初始化表格
|
// 初始化表格
|
||||||
function initTable() {
|
function initTable() {
|
||||||
table.render({
|
var colsArray = [
|
||||||
elem: '#dataTable',
|
|
||||||
id: 'dataTable',
|
|
||||||
url: top.restAjax.path(tableUrl, []),
|
|
||||||
width: admin.screen() > 1 ? '100%' : '',
|
|
||||||
height: $win.height() - 90,
|
|
||||||
limit: 20,
|
|
||||||
limits: [20, 40, 60, 80, 100, 200],
|
|
||||||
toolbar: '#headerToolBar',
|
|
||||||
request: {
|
|
||||||
pageName: 'page',
|
|
||||||
limitName: 'rows'
|
|
||||||
},
|
|
||||||
cols: [
|
|
||||||
[
|
|
||||||
{type:'checkbox', fixed: 'left'},
|
{type:'checkbox', fixed: 'left'},
|
||||||
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||||
{field:'userUsername', width:140, title: '用户名', sort: true, align:'center',
|
{field:'userUsername', width:140, title: '用户名', sort: true, align:'center',
|
||||||
@ -144,7 +131,7 @@
|
|||||||
{field:'userExpiredDate', width:180, title: '账号过期时间', align:'center',
|
{field:'userExpiredDate', width:180, title: '账号过期时间', align:'center',
|
||||||
templet: function(item) {
|
templet: function(item) {
|
||||||
if(!item.userExpiredDate) {
|
if(!item.userExpiredDate) {
|
||||||
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="userExpiredDateEvent">' +
|
return '<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event="userExpiredDateEvent">' +
|
||||||
'<i class="fa fa-clock-o"></i> 设置时间' +
|
'<i class="fa fa-clock-o"></i> 设置时间' +
|
||||||
'</button>';
|
'</button>';
|
||||||
}
|
}
|
||||||
@ -175,14 +162,41 @@
|
|||||||
return item.gmtCreate;
|
return item.gmtCreate;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{field:'opition', width:110, title: '操作', fixed:'right', align:'center',
|
|
||||||
templet: function(item) {
|
];
|
||||||
|
if($('#userExpand') && $('#userExpand').val()) {
|
||||||
|
colsArray.push({
|
||||||
|
field:'opition', width:190, title: '操作', fixed:'right', align:'center', templet: function(item) {
|
||||||
|
return '<div class="layui-btn-group">' +
|
||||||
|
'<button type="button" class="layui-btn layui-btn-xs" lay-event="resetPasswordEvent"><i class="fa fa-key"></i> 重置密码</button>'+
|
||||||
|
'<button type="button" class="layui-btn layui-btn-xs layui-btn-primary" lay-event="userExpandEvent"><i class="fa fa-vcard"></i> 拓展属性</button>'+
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
colsArray.push({
|
||||||
|
field:'opition', width:110, title: '操作', fixed:'right', align:'center', templet: function(item) {
|
||||||
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="resetPasswordEvent">' +
|
return '<button type="button" class="layui-btn layui-btn-xs" lay-event="resetPasswordEvent">' +
|
||||||
'<i class="fa fa-key"></i> 重置密码' +
|
'<i class="fa fa-key"></i> 重置密码' +
|
||||||
'</button>';
|
'</button>';
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
table.render({
|
||||||
|
elem: '#dataTable',
|
||||||
|
id: 'dataTable',
|
||||||
|
url: top.restAjax.path(tableUrl, []),
|
||||||
|
width: admin.screen() > 1 ? '100%' : '',
|
||||||
|
height: $win.height() - 90,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
toolbar: '#headerToolBar',
|
||||||
|
request: {
|
||||||
|
pageName: 'page',
|
||||||
|
limitName: 'rows'
|
||||||
},
|
},
|
||||||
]
|
cols: [
|
||||||
|
colsArray
|
||||||
],
|
],
|
||||||
page: true,
|
page: true,
|
||||||
parseData: function(data) {
|
parseData: function(data) {
|
||||||
@ -353,6 +367,14 @@
|
|||||||
reloadTable();
|
reloadTable();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if(layEvent === 'userExpandEvent') {
|
||||||
|
top.dialog.open({
|
||||||
|
url: top.restAjax.path('{userExpand}?userId={userId}', [$('#userExpand').val(), data.userId]),
|
||||||
|
title: '【'+ data.userName +'】拓展属性',
|
||||||
|
width: '60%',
|
||||||
|
height: '80%',
|
||||||
|
onClose: function() {}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 事件-排序
|
// 事件-排序
|
||||||
|
Loading…
Reference in New Issue
Block a user