|
|
@ -4,15 +4,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.msdw.tms.common.utils.*; |
|
|
|
import com.msdw.tms.common.utils.*; |
|
|
|
|
|
|
|
import com.msdw.tms.config.CheckCodeUtils; |
|
|
|
|
|
|
|
import com.msdw.tms.config.EmailUtils; |
|
|
|
|
|
|
|
import com.msdw.tms.config.SendSMS; |
|
|
|
|
|
|
|
import com.msdw.tms.dao.UserDao; |
|
|
|
import com.msdw.tms.dao.UserInfoDao; |
|
|
|
import com.msdw.tms.dao.UserInfoDao; |
|
|
|
import com.msdw.tms.entity.StudentEntity; |
|
|
|
import com.msdw.tms.entity.StudentEntity; |
|
|
|
import com.msdw.tms.entity.UserInfoEntity; |
|
|
|
import com.msdw.tms.entity.UserInfoEntity; |
|
|
|
import com.msdw.tms.entity.response.CommonCode; |
|
|
|
import com.msdw.tms.entity.response.CommonCode; |
|
|
|
import com.msdw.tms.entity.response.ResponseResult; |
|
|
|
import com.msdw.tms.entity.response.ResponseResult; |
|
|
|
import com.msdw.tms.entity.response.ResultCode; |
|
|
|
import com.msdw.tms.entity.response.ResultCode; |
|
|
|
|
|
|
|
import com.msdw.tms.entity.vo.CheckVo; |
|
|
|
|
|
|
|
import com.msdw.tms.entity.vo.StaffVo; |
|
|
|
import com.msdw.tms.entity.vo.StudentVo; |
|
|
|
import com.msdw.tms.entity.vo.StudentVo; |
|
|
|
import com.msdw.tms.entity.vo.UserProsonalEntityVo; |
|
|
|
import com.msdw.tms.entity.vo.UserProsonalEntityVo; |
|
|
|
import com.msdw.tms.service.UserInfoService; |
|
|
|
import com.msdw.tms.service.UserInfoService; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -20,12 +27,15 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service("userInfoService") |
|
|
|
@Service("userInfoService") |
|
|
|
public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity> implements UserInfoService { |
|
|
|
public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity> implements UserInfoService { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private UserInfoDao userInfoDao; |
|
|
|
private UserInfoDao userInfoDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private UserDao userDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PageUtils queryPage(Map<String, Object> params) { |
|
|
|
public PageUtils queryPage(Map<String, Object> params) { |
|
|
@ -42,8 +52,8 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity |
|
|
|
public int add(UserInfoEntity userInfoEntity) { |
|
|
|
public int add(UserInfoEntity userInfoEntity) { |
|
|
|
UserInfoDao userDao = this.getBaseMapper(); |
|
|
|
UserInfoDao userDao = this.getBaseMapper(); |
|
|
|
userInfoEntity.setToken(new ConstantUtils().token); |
|
|
|
userInfoEntity.setToken(new ConstantUtils().token); |
|
|
|
int userId = userDao.add(userInfoEntity); |
|
|
|
int userId = userDao.add(userInfoEntity); |
|
|
|
return userId; |
|
|
|
return userId; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -133,4 +143,65 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity |
|
|
|
public void updateAccount( Integer userId) { |
|
|
|
public void updateAccount( Integer userId) { |
|
|
|
userInfoDao.setNUM(userId); |
|
|
|
userInfoDao.setNUM(userId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
|
|
|
public R findPassword(String account,Integer type) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
List<UserInfoEntity> vos = userInfoDao.queryUser(account); |
|
|
|
|
|
|
|
int size = vos.size(); |
|
|
|
|
|
|
|
UserInfoEntity entity = vos.get(0); |
|
|
|
|
|
|
|
if (vos.size()==0){ |
|
|
|
|
|
|
|
return R.error("账号不存在"); |
|
|
|
|
|
|
|
}else if (vos.size()>1){ |
|
|
|
|
|
|
|
log.info("存在多个相同账号"); |
|
|
|
|
|
|
|
return R.error("账号异常,请联系管理员!!!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CheckCodeUtils utils = new CheckCodeUtils(); |
|
|
|
|
|
|
|
String code = utils.sendCode(); |
|
|
|
|
|
|
|
CheckVo checkVo = new CheckVo(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type==1){//通过手机验证
|
|
|
|
|
|
|
|
EmailUtils.sendEmail(entity.getEmail(),code); |
|
|
|
|
|
|
|
checkVo.setCheckCode(code).setSetTime(utils.letTimes(5)).setUserId(entity.getUserId()); |
|
|
|
|
|
|
|
boolean result = userDao.saveCheckCode(checkVo); |
|
|
|
|
|
|
|
if (result) { |
|
|
|
|
|
|
|
return R.ok().put("data",entity); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return R.error("保存验证码异常"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else if (type==2){//通过邮箱验证
|
|
|
|
|
|
|
|
SendSMS.sendCode(entity.getPhone(),code); |
|
|
|
|
|
|
|
checkVo.setCheckCode(code).setSetTime(utils.letTimes(5)).setUserId(entity.getUserId()); |
|
|
|
|
|
|
|
boolean result = userDao.saveCheckPhoneCode(checkVo); |
|
|
|
|
|
|
|
if (result) { |
|
|
|
|
|
|
|
return R.ok().put("data",entity); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return R.error("保存验证码异常"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return R.error("请求验证类型不对!!!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}catch (RuntimeException e){ |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
return R.error("请求异常!!!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public R checkCode(CheckVo checkVo) { |
|
|
|
|
|
|
|
String checkCode = userInfoDao.checkCode(checkVo); |
|
|
|
|
|
|
|
if (checkCode.equals(checkVo.getCode())){ |
|
|
|
|
|
|
|
return R.ok(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.error(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
|
|
|
public R resetPassword(CheckVo checkVo) { |
|
|
|
|
|
|
|
userInfoDao.resetPassword(checkVo); |
|
|
|
|
|
|
|
return R.ok(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|