init
This commit is contained in:
@@ -34,6 +34,11 @@ public class RefreshTest {
|
||||
jobManager.updateAge();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshUserAreaCode(){
|
||||
jobManager.refreshUserAreaCode();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkBaseStatus(){
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@@ -96,11 +97,11 @@ public class AuthAppController {
|
||||
@PostMapping("/resetPassword/checkCode")
|
||||
@Operation(summary = "重置密码-验证码校验")
|
||||
@Log(title = "重置密码-验证码校验", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||
public R<String> resetPasswordCheck(@RequestBody RegisterCodeCheck code){
|
||||
String check = loginManager.resetPasswordCheck(code.getMobile(), code.getCode());
|
||||
R<String> ok = R.ok();
|
||||
ok.setData(check);
|
||||
return R.ok();
|
||||
public R<Map<String,String>> resetPasswordCheck(@RequestBody RegisterCodeCheck code){
|
||||
String token = loginManager.resetPasswordCheck(code.getMobile(), code.getCode());
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("token",token);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@PostMapping("/resetPassword")
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.ruoyi.xq.job;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.xq.domain.AreaCode;
|
||||
import com.ruoyi.xq.domain.User;
|
||||
import com.ruoyi.xq.service.AreaCodeService;
|
||||
import com.ruoyi.xq.service.UserService;
|
||||
import com.ruoyi.xq.util.AgeUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -14,6 +16,8 @@ import java.util.List;
|
||||
public class JobManager {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
|
||||
public void updateAge(){
|
||||
int current = 0;
|
||||
@@ -38,4 +42,43 @@ public class JobManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshUserAreaCode() {
|
||||
int current = 0;
|
||||
while (true){
|
||||
current++;
|
||||
IPage<User> page = new Page<>();
|
||||
page.setCurrent(current);
|
||||
page.setSize(100);
|
||||
IPage<User> userPage = userService.page(page);
|
||||
List<User> records = userPage.getRecords();
|
||||
if(records.isEmpty()){
|
||||
break;
|
||||
}
|
||||
for (User record : records) {
|
||||
boolean updateFlag = false;
|
||||
User update = new User();
|
||||
update.setId(record.getId());
|
||||
if(record.getAddressCode() != null){
|
||||
AreaCode areaCode = areaCodeService.getById(record.getAddressCode());
|
||||
if(areaCode != null){
|
||||
updateFlag = true;
|
||||
update.setAddressName(areaCode.getFullname());
|
||||
}
|
||||
}
|
||||
if(record.getResidenceCode() != null){
|
||||
AreaCode areaCode = areaCodeService.getById(record.getResidenceCode());
|
||||
if(areaCode != null){
|
||||
updateFlag = true;
|
||||
update.setResidenceName(areaCode.getFullname());
|
||||
update.setResidenceCityCode(areaCode.getPcode());
|
||||
update.setResidenceCityName(areaCode.getPname());
|
||||
}
|
||||
}
|
||||
if(updateFlag){
|
||||
userService.updateById(update);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ public class LoginManager {
|
||||
String key = String.format(RedisHttpConstant.RESET_PASSWORD_CHECK_REDIS, token);
|
||||
RBucket<String> bucket = redissonClient.getBucket(key);
|
||||
String value = bucket.get();
|
||||
if(StringUtils.isEmpty(value) || value.equals(mobile)){
|
||||
if(StringUtils.isEmpty(value) || !value.equals(mobile)){
|
||||
throw new ServiceException("验证码已过期");
|
||||
}
|
||||
userService.resetPassword(user.getId(),password);
|
||||
|
||||
Reference in New Issue
Block a user