Commit d418deb0 authored by liaoanyuan's avatar liaoanyuan

Merge remote-tracking branch 'origin/master'

parents b65cff5e 15fa52b7
...@@ -17,6 +17,7 @@ import java.util.Date; ...@@ -17,6 +17,7 @@ import java.util.Date;
* @ Description: 志愿实体类 * @ Description: 志愿实体类
* @ Author : 86187 * @ Author : 86187
* @ Date : 2021/1/7 15:15 * @ Date : 2021/1/7 15:15
* @author 86187
*/ */
@Data @Data
@Builder @Builder
......
package cn.wisenergy.model.enums;
/**
* 图片验证码业务类型
*
* @author zh
* @version v2.0
* @since v7.0
* 2018年3月19日 下午4:35:32
*/
public enum SceneType {
//验证码登录
LOGIN(1, "验证码登录"),
//手机注册
REGISTER(2, "手机注册"),
//修改密码
MODIFY_PASSWORD(3, "修改密码"),
//找回密码
FIND_PASSWORD(4, "找回密码"),
RESET_PASSWORD(5, "短信重置密码");
private Integer code;
private String desc;
SceneType(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public String getDescription() {
return desc;
}
public Integer getCode() {
return code;
}
public static String getNameByCode(Integer code) {
if (null == code) {
return null;
}
for (SceneType type : SceneType.values()) {
if (type.getCode().intValue() == code.intValue()) {
return type.name();
}
}
return null;
}
}
package cn.wisenergy.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ Description: 修改账户密码Vo
* @ Author : 86187
* @ Date : 2021/1/18 14:35
* @author 86187
*/
@Data
@ApiModel(value = "UpdatePasswordVo")
public class UpdatePasswordVo implements Serializable {
private static final long serialVersionUID = 5543462178133500983L;
/**
* 用户id
*/
@ApiModelProperty(value = "用户id", name = "userId")
private Integer userId;
/**
* 新密码
*/
@ApiModelProperty(value = "新密码", name = "newPassword")
private String newPassword;
/**
* 旧密码
*/
@ApiModelProperty(value = "旧密码", name = "oldPassword")
private String oldPassword;
}
...@@ -7,10 +7,11 @@ import lombok.Data; ...@@ -7,10 +7,11 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
/** /**
*@ Description: 用户登录Vo * @author 86187
*@ Author : 86187 * @ Description: 用户登录Vo
*@ Date : 2021/1/15 14:27 * @ Author : 86187
*/ * @ Date : 2021/1/15 14:27
*/
@Data @Data
@ApiModel(value = "UserLoginVo") @ApiModel(value = "UserLoginVo")
public class UserLoginVo implements Serializable { public class UserLoginVo implements Serializable {
...@@ -19,18 +20,30 @@ public class UserLoginVo implements Serializable { ...@@ -19,18 +20,30 @@ public class UserLoginVo implements Serializable {
/** /**
* 手机号码 * 手机号码
*/ */
@ApiModelProperty(value = "手机号码",name = "phone") @ApiModelProperty(value = "手机号码", name = "phone")
private String phone; private String phone;
/** /**
* 密码 * 密码
*/ */
@ApiModelProperty(value = "密码",name = "password") @ApiModelProperty(value = "密码", name = "password")
private String password; private String password;
/** /**
* 验证码 * 验证码
*/ */
@ApiModelProperty(value = "验证码",name = "smCode") @ApiModelProperty(value = "验证码", name = "code")
private String smCode; private String code;
/**
* 场景类型:1:验证码登录 2:手机注册 3:修改密码 4:找回密码
*/
@ApiModelProperty(value = "场景类型:1:验证码登录 2:手机注册 3:修改密码 4:找回密码 5:短信重置密码", name = "scene")
private Integer scene;
/**
* 来源: PC/APP
*/
@ApiModelProperty(value = "来源: PC/APP", name = "type")
private String type;
} }
...@@ -3,10 +3,47 @@ package cn.wisenergy.service.app; ...@@ -3,10 +3,47 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
/** /**
*@ Description: 短信验证码接口定义 * @author 86187
*@ Author : 86187 * @ Description: 短信验证码接口定义
*@ Date : 2021/1/15 15:44 * @ Author : 86187
*/ * @ Date : 2021/1/15 15:44
*/
public interface SendSmsSerVice { public interface SendSmsSerVice {
R<Object> getSmCode(String phone); /**
* 发送短信验证码
*
* @param phone 手机号
* @return true 成功 false 失败
*/
R<Boolean> sendSmCode(String phone);
/**
* 在缓存中记录验证码
*
* @param phone 手机号
* @param code 短信验证码
* @param type 场景类型 1:验证码登录 2:手机注册 3:修改密码 4:找回密码
* @return 是否成功
*/
R<String> record(String phone, String code, Integer type);
/**
* 验证手机验证码:外部调用
*
* @param phone 手机号码
* @param code 手机验证码
* @param type 场景类型 1:验证码登录 2:手机注册 3:修改密码 4:找回密码
* @return 是否通过校验 true通过,false不通过
*/
R<Boolean> valid(String phone, String code, Integer type);
/**
* 验证手机验证码 :内部调用
*
* @param phone 手机号码
* @param code 手机验证码
* @param type 场景类型 1:验证码登录 2:手机注册 3:修改密码 4:找回密码
* @return 是否通过校验 true通过,false不通过
*/
boolean validCode(String phone, String code, Integer type);
} }
package cn.wisenergy.service.app; package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.vo.UpdatePasswordVo;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserLoginVo; import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo; import cn.wisenergy.model.vo.UserRegisterVo;
...@@ -46,12 +47,10 @@ public interface UserLoginService { ...@@ -46,12 +47,10 @@ public interface UserLoginService {
/** /**
* 修改密码 * 修改密码
* *
* @param userId 用户id * @param updateVo 修改密码信息
* @param newPassword 新密码
* @param oldPassword 旧密码
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
R<Boolean> updatePassword(Integer userId, String newPassword, String oldPassword); R<Boolean> updatePassword(UpdatePasswordVo updateVo);
/** /**
* 重置密码 * 重置密码
...@@ -67,5 +66,5 @@ public interface UserLoginService { ...@@ -67,5 +66,5 @@ public interface UserLoginService {
* @param userLoginVo 登录信息 * @param userLoginVo 登录信息
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
R<Boolean> notePassword(UserLoginVo userLoginVo); R<Boolean> smsResetPassword(UserLoginVo userLoginVo);
} }
package cn.wisenergy.service.app.impl; package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.enums.SceneType;
import cn.wisenergy.service.app.SendSmsSerVice; import cn.wisenergy.service.app.SendSmsSerVice;
import cn.wisenergy.service.cache.Cache;
import cn.wisenergy.service.common.CachePrefix;
import cn.wisenergy.service.common.Common;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
*@ Description: 短信验证码接口实现 * @ Description: 短信验证码接口实现
*@ Author : 86187 * @ Author : 86187
*@ Date : 2021/1/15 15:45 * @ Date : 2021/1/15 15:45
*/ * @author 86187
*/
@Service @Service
@Slf4j @Slf4j
public class SendSmsSerViceImpl implements SendSmsSerVice { public class SendSmsSerViceImpl implements SendSmsSerVice {
@Autowired
private Cache cache;
@Override @Override
public R<Object> getSmCode(String phone) { public R<Boolean> sendSmCode(String phone) {
log.info("volunteer-service[]SendSmsSerViceImpl[]getSmCode[]input.param.phone:"+phone); log.info("volunteer-service[]SendSmsSerViceImpl[]sendSmCode[]input.param.phone:" + phone);
if(StringUtils.isBlank(phone)){ if (StringUtils.isBlank(phone)) {
return R.error("手机号码不能为空!"); return R.error("入参不能为空!");
} }
return null; return null;
} }
@Override
public R<String> record(String phone, String code, Integer scene) {
String value = SceneType.getNameByCode(scene);
cache.put(CachePrefix.SMS_CODE.getPrefix() + value + "_" + phone, code, Common.SMS_TIMEOUT);
return R.ok("缓存验证码成功!");
}
@Override
public R<Boolean> valid(String phone, String code, Integer type) {
String value = SceneType.getNameByCode(type);
//获取短信验证码key
String valCode = CachePrefix.SMS_CODE.getPrefix() + value + "_" + phone;
//redis中获取验证码
Object obj = cache.get(valCode);
if (obj != null && obj.equals(code)) {
//验证码存在,校验通过,清除验证码缓存
cache.remove(valCode);
return R.ok(0, true);
}
return R.ok(1, false);
}
@Override
public boolean validCode(String phone, String code, Integer type) {
//获取短信验证码key
String valCode = CachePrefix.SMS_CODE.getPrefix() + type + "_" + phone;
//redis中获取验证码
Object obj = cache.get(valCode);
if (obj != null && obj.equals(code)) {
//验证码存在,校验通过,清除验证码缓存
cache.remove(valCode);
return true;
}
return false;
}
} }
...@@ -7,10 +7,14 @@ import cn.wisenergy.mapper.UsersMapper; ...@@ -7,10 +7,14 @@ import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.LoginRecord; import cn.wisenergy.model.app.LoginRecord;
import cn.wisenergy.model.app.UserInfo; import cn.wisenergy.model.app.UserInfo;
import cn.wisenergy.model.enums.OperationTypeEnum; import cn.wisenergy.model.enums.OperationTypeEnum;
import cn.wisenergy.model.enums.SceneType;
import cn.wisenergy.model.vo.UpdatePasswordVo;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserLoginVo; import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo; import cn.wisenergy.model.vo.UserRegisterVo;
import cn.wisenergy.service.app.SendSmsSerVice;
import cn.wisenergy.service.app.UserLoginService; import cn.wisenergy.service.app.UserLoginService;
import cn.wisenergy.service.cache.Cache;
import cn.wisenergy.service.common.Common; import cn.wisenergy.service.common.Common;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -35,6 +39,12 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -35,6 +39,12 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
@Autowired @Autowired
private LoginRecordMapper loginRecordMapper; private LoginRecordMapper loginRecordMapper;
@Autowired
private SendSmsSerVice sendSmsSerVice;
@Autowired
private Cache cache;
@Override @Override
public R<Boolean> register(UserRegisterVo userVo) { public R<Boolean> register(UserRegisterVo userVo) {
log.info("volunteer-service[]UserLoginServiceImpl[]register[]input.param.userVo:" + userVo); log.info("volunteer-service[]UserLoginServiceImpl[]register[]input.param.userVo:" + userVo);
...@@ -85,8 +95,25 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -85,8 +95,25 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
} }
@Override @Override
public R<Boolean> loginCode(UserLoginVo userLoginVo) { public R<Boolean> loginCode(UserLoginVo userVo) {
return null; log.info("volunteer-service[]UserLoginServiceImpl[]loginCode[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getCode()) ||
StringUtils.isBlank(userVo.getType()) || null == userVo.getScene()) {
return R.error("入参为空!");
}
//1、判断手机号账户是否存在
QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("phone", userVo.getPhone());
queryWrapper.eq("is_delete", 0);
UserInfo userInfo = usersMapper.selectOne(queryWrapper);
if (null == userInfo) {
return R.error("该手机号未注册,请先注册!");
}
//2、判断验证码是否正确
boolean bool = sendSmsSerVice.validCode(userVo.getPhone(), userVo.getCode(), userVo.getScene());
return R.ok(bool);
} }
@Override @Override
...@@ -153,8 +180,33 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -153,8 +180,33 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
} }
@Override @Override
public R<Boolean> updatePassword(Integer userId, String newPassword, String oldPassword) { public R<Boolean> updatePassword(UpdatePasswordVo updateVo) {
return null; log.info("volunteer-service[]UserLoginServiceImpl[]loginOut[]input.param.updateVo:" + updateVo);
if (null == updateVo || null == updateVo.getUserId() || StringUtils.isBlank(updateVo.getNewPassword()) ||
StringUtils.isBlank(updateVo.getOldPassword())) {
return R.error("入参为空!");
}
//1、获取用户信息
UserInfo userInfo = usersMapper.selectById(updateVo.getUserId());
if (null == userInfo) {
return R.error("用户信息不存在,无法修改密码!");
}
//2、判断旧密码是否正确
String password = Md5Util.digestMD5(updateVo.getNewPassword() + userInfo.getPassword());
if (!userInfo.getPassword().equals(password)) {
return R.error("旧密码不正确,请从新输入!");
}
//3、修改用户密码为新密码
String newPassword = Md5Util.digestMD5(updateVo.getNewPassword() + userInfo.getPhone());
userInfo.setPassword(newPassword);
int count = usersMapper.edit(userInfo);
if (count == 0) {
return R.ok(1, false);
}
return R.ok(0, true);
} }
@Override @Override
...@@ -168,7 +220,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -168,7 +220,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
UserInfo userInfo = usersMapper.selectById(userId); UserInfo userInfo = usersMapper.selectById(userId);
//加密重置密码 //加密重置密码
String password = Md5Util.digestMD5(Common.RESET_PASSWORD_VALUE); String password = Md5Util.digestMD5(Common.RESET_PASSWORD_VALUE + userInfo.getPhone());
userInfo.setPassword(password); userInfo.setPassword(password);
int count = usersMapper.edit(userInfo); int count = usersMapper.edit(userInfo);
...@@ -179,8 +231,36 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp ...@@ -179,8 +231,36 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
} }
@Override @Override
public R<Boolean> notePassword(UserLoginVo userVo) { public R<Boolean> smsResetPassword(UserLoginVo userVo) {
return null; log.info("volunteer-service[]UserLoginServiceImpl[]smsResetPassword[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getCode()) ||
StringUtils.isBlank(userVo.getPassword()) || null == userVo.getScene()) {
return R.error("入参为空!");
}
//获取用户信息
QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("phone", userVo.getPhone());
queryWrapper.eq("is_delete", 0);
UserInfo userInfo = baseMapper.selectOne(queryWrapper);
if (null == userInfo) {
return R.error("用户信息不存在,无法重置密码!");
}
//验证验证码
boolean bool = sendSmsSerVice.validCode(userVo.getPhone(), userVo.getCode(), userVo.getScene());
if (!bool) {
return R.ok(1, false);
}
//3、设置新密码
String password = Md5Util.digestMD5(userVo.getPassword() + userVo.getPhone());
userInfo.setPassword(password);
int count = usersMapper.edit(userInfo);
if (count == 0) {
return R.ok(1, false);
}
return R.ok(0, true);
} }
private Boolean checkPhone(String phone, Integer userId) { private Boolean checkPhone(String phone, Integer userId) {
......
package cn.wisenergy.service.cache;
import java.util.Collection;
import java.util.Map;
/**
* @author 86187
*/
public interface Cache<T> {
/**
* Get an item from the cache, nontransactionally
* @param key
* @return the cached object or <tt>null</tt>
*/
Object get(Object key);
/**
* 批量set
* @param map
*/
void multiSet(Map map);
/**
* 批量删除
* @param keys 要删除的key集合
*/
void multiDel(Collection keys);
/**
* Add an item to the cache, nontransactionally, with
* failfast semantics
* @param key
* @param value
*/
void put(Object key, T value);
/**
* 往缓存中写入内容
* @param key
* @param value
* @param exp 超时时间,单位为秒
*/
void put(Object key, T value, long exp);
/**
* 删除
* @param key
*/
void remove(Object key);
/**
* 删除
* @param key
*/
void vagueDel(Object key);
/**
* Clear the cache
*/
void clear();
}
package cn.wisenergy.service.cache;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* @author 86187
* @ Description: redis的cache实现
* @ Author : 86187
* @ Date : 2021/1/18 11:03
*/
@Component
public class RedisCacheImpl implements Cache<T> {
@Autowired
private RedisTemplate redisTemplate;
public RedisCacheImpl() {
}
@Override
public Object get(Object key) {
return redisTemplate.opsForValue().get(key);
}
@Override
public void multiSet(Map map) {
redisTemplate.opsForValue().multiSet(map);
}
@Override
public void multiDel(Collection keys) {
redisTemplate.delete(keys);
}
@Override
public void put(Object key, T value) {
redisTemplate.opsForValue().set(key, value);
}
@Override
public void put(Object key, T value, long exp) {
redisTemplate.opsForValue().set(key, value, exp, TimeUnit.SECONDS);
}
@Override
public void remove(Object key) {
redisTemplate.delete(key);
}
/**
* 删除
*
* @param key
*/
@Override
public void vagueDel(Object key) {
Set<String> keys = redisTemplate.keys(key + "*");
redisTemplate.delete(keys);
}
@Override
public void clear() {
Set keys = redisTemplate.keys("*");
redisTemplate.delete(keys);
}
}
package cn.wisenergy.service.common;
/**
* @author 86187
*/
public enum CachePrefix {
/**
* 短信验证码
*/
SMS_CODE;
public String getPrefix() {
return this.name() + "_";
}
}
...@@ -17,4 +17,6 @@ public class Common { ...@@ -17,4 +17,6 @@ public class Common {
*/ */
public static final String SEND_SMS_URL = "http://dysmsapi.aliyuncs.com/?Signature="; public static final String SEND_SMS_URL = "http://dysmsapi.aliyuncs.com/?Signature=";
public static final Integer SMS_TIMEOUT = 300;
} }
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.service.app.SendSmsSerVice;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping; import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RestController; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/** /**
* @ Description: 短信管理 * @ Description: 短信管理
...@@ -15,6 +21,50 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -15,6 +21,50 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/user") @RequestMapping("/user")
@Slf4j @Slf4j
public class SendSmsController { public class SendSmsController {
@Autowired
private SendSmsSerVice sendSmsSerVice;
@ApiOperation(value = "发送短信验证码", notes = "发送短信验证码", httpMethod = "GET")
@ApiImplicitParam(name = "phone", value = "手机号码", dataType = "String", required = true)
@GetMapping("/sendSms")
public R<Boolean> sendSms(String phone) {
log.info("SendSmsController[]sendSms[]input.param:phone:" + phone);
if (StringUtils.isBlank(phone)) {
return R.error("入参为空!");
}
return sendSmsSerVice.sendSmCode(phone);
}
@ApiOperation(value = "在缓存中记录验证码", notes = "在缓存中记录验证码", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone", value = "手机号码", dataType = "String", required = true),
@ApiImplicitParam(name = "code", value = "短信验证码", dataType = "String", required = true),
@ApiImplicitParam(name = "scene", value = "场景类型 1:验证码登录 2:手机注册 3:修改密码 4:找回密码", dataType = "int", required = true)
})
@GetMapping("/recode")
public R<String> recode(String phone, String code, Integer scene) {
log.info("SendSmsController[]recode[]input.param:phone,code,type" + phone, code, scene);
if (StringUtils.isBlank(phone) || StringUtils.isBlank(code) || null == scene) {
return R.error("入参为空!");
}
return sendSmsSerVice.record(phone, code, scene);
}
@ApiOperation(value = "在缓存中记录验证码", notes = "在缓存中记录验证码", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "phone", value = "手机号码", dataType = "String", required = true),
@ApiImplicitParam(name = "code", value = "短信验证码", dataType = "String", required = true),
@ApiImplicitParam(name = "scene", value = "场景类型 1:验证码登录 2:手机注册 3:修改密码 4:找回密码", dataType = "int", required = true)
})
@GetMapping("/valid")
public R<Boolean> valid(String phone, String code, Integer scene) {
log.info("SendSmsController[]valid[]input.param:phone,code,type" + phone, code, scene);
if (StringUtils.isBlank(phone) || StringUtils.isBlank(code) || null == scene) {
return R.error("入参为空!");
}
return sendSmsSerVice.valid(phone, code, scene);
}
} }
...@@ -2,6 +2,8 @@ package cn.wisenergy.web.admin.controller.app; ...@@ -2,6 +2,8 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.Banner;
import cn.wisenergy.model.vo.UpdatePasswordVo;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserLoginVo; import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo; import cn.wisenergy.model.vo.UserRegisterVo;
...@@ -26,7 +28,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,7 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
@Api(tags = "PC-用户登录") @Api(tags = "PC-用户登录")
@RequestMapping("/user/login") @RequestMapping("/user/login")
@Slf4j @Slf4j
public class UserLongController { public class UserLoginController {
@Autowired @Autowired
private UserLoginService userLoginService; private UserLoginService userLoginService;
...@@ -41,13 +43,27 @@ public class UserLongController { ...@@ -41,13 +43,27 @@ public class UserLongController {
return R.error("入参为空!"); return R.error("入参为空!");
} }
if ( StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getPassword())) { if (StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getPassword())) {
return R.error("入参不能为空!"); return R.error("入参不能为空!");
} }
return userLoginService.register(userVo); return userLoginService.register(userVo);
} }
@ApiOperation(value = "用户验证码登录", notes = "用户验证码登录", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "用户信息", dataType = "UserLoginVo")
@PostMapping("/loginCode")
public R<Boolean> loginCode(@RequestBody UserLoginVo userVo) {
log.info("volunteer-service[]UserLongController[]loginCode[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) || StringUtils.isBlank(userVo.getCode()) ||
StringUtils.isBlank(userVo.getType()) || null == userVo.getScene()) {
return R.error("入参为空!");
}
return userLoginService.loginCode(userVo);
}
@ApiOperation(value = "用户账号密码登录", notes = "用户账号密码登录", httpMethod = "POST") @ApiOperation(value = "用户账号密码登录", notes = "用户账号密码登录", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "登录用户信息", dataType = "UserLoginVo") @ApiImplicitParam(name = "userVo", value = "登录用户信息", dataType = "UserLoginVo")
@PostMapping("/login") @PostMapping("/login")
...@@ -72,6 +88,19 @@ public class UserLongController { ...@@ -72,6 +88,19 @@ public class UserLongController {
return userLoginService.loginOut(userId); return userLoginService.loginOut(userId);
} }
@ApiOperation(value = "修改用户密码", notes = "修改用户密码", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "用户密码", dataType = "UpdatePasswordVo")
@PostMapping("/updatePassword")
public R<Boolean> updatePassword(@RequestBody UpdatePasswordVo userVo) {
log.info("volunteer-service[]UserLongController[]updatePassword[]input.param.userVo:" + userVo);
if (null == userVo || null == userVo.getUserId() || StringUtils.isBlank(userVo.getOldPassword()) ||
StringUtils.isBlank(userVo.getNewPassword())) {
return R.error("入参不能为空!");
}
return userLoginService.updatePassword(userVo);
}
@ApiOperation(value = "重置密码", notes = "重置密码", httpMethod = "POST") @ApiOperation(value = "重置密码", notes = "重置密码", httpMethod = "POST")
@PostMapping("/resetPassword") @PostMapping("/resetPassword")
public R<Boolean> resetPassword(Integer userId) { public R<Boolean> resetPassword(Integer userId) {
...@@ -82,4 +111,17 @@ public class UserLongController { ...@@ -82,4 +111,17 @@ public class UserLongController {
return userLoginService.resetPassword(userId); return userLoginService.resetPassword(userId);
} }
@ApiOperation(value = "短信重置密码", notes = "修改用户密码", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "用户密码", dataType = "UserLoginVo")
@PostMapping("/smsResetPassword")
public R<Boolean> smsResetPassword(@RequestBody UserLoginVo userVo) {
log.info("volunteer-service[]UserLongController[]smsResetPassword[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) ||
StringUtils.isBlank(userVo.getPassword()) || null == userVo.getScene()) {
return R.error("入参不能为空!");
}
return userLoginService.smsResetPassword(userVo);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment