init
This commit is contained in:
@@ -34,6 +34,11 @@ public class RefreshTest {
|
|||||||
jobManager.updateAge();
|
jobManager.updateAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refreshUserAreaCode(){
|
||||||
|
jobManager.refreshUserAreaCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkBaseStatus(){
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -96,11 +97,11 @@ public class AuthAppController {
|
|||||||
@PostMapping("/resetPassword/checkCode")
|
@PostMapping("/resetPassword/checkCode")
|
||||||
@Operation(summary = "重置密码-验证码校验")
|
@Operation(summary = "重置密码-验证码校验")
|
||||||
@Log(title = "重置密码-验证码校验", businessType = BusinessType.OTHER, isSaveDb = false)
|
@Log(title = "重置密码-验证码校验", businessType = BusinessType.OTHER, isSaveDb = false)
|
||||||
public R<String> resetPasswordCheck(@RequestBody RegisterCodeCheck code){
|
public R<Map<String,String>> resetPasswordCheck(@RequestBody RegisterCodeCheck code){
|
||||||
String check = loginManager.resetPasswordCheck(code.getMobile(), code.getCode());
|
String token = loginManager.resetPasswordCheck(code.getMobile(), code.getCode());
|
||||||
R<String> ok = R.ok();
|
Map<String,String> map = new HashMap<>();
|
||||||
ok.setData(check);
|
map.put("token",token);
|
||||||
return R.ok();
|
return R.ok(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/resetPassword")
|
@PostMapping("/resetPassword")
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.ruoyi.xq.job;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.xq.domain.AreaCode;
|
||||||
import com.ruoyi.xq.domain.User;
|
import com.ruoyi.xq.domain.User;
|
||||||
|
import com.ruoyi.xq.service.AreaCodeService;
|
||||||
import com.ruoyi.xq.service.UserService;
|
import com.ruoyi.xq.service.UserService;
|
||||||
import com.ruoyi.xq.util.AgeUtil;
|
import com.ruoyi.xq.util.AgeUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -14,6 +16,8 @@ import java.util.List;
|
|||||||
public class JobManager {
|
public class JobManager {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private AreaCodeService areaCodeService;
|
||||||
|
|
||||||
public void updateAge(){
|
public void updateAge(){
|
||||||
int current = 0;
|
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);
|
String key = String.format(RedisHttpConstant.RESET_PASSWORD_CHECK_REDIS, token);
|
||||||
RBucket<String> bucket = redissonClient.getBucket(key);
|
RBucket<String> bucket = redissonClient.getBucket(key);
|
||||||
String value = bucket.get();
|
String value = bucket.get();
|
||||||
if(StringUtils.isEmpty(value) || value.equals(mobile)){
|
if(StringUtils.isEmpty(value) || !value.equals(mobile)){
|
||||||
throw new ServiceException("验证码已过期");
|
throw new ServiceException("验证码已过期");
|
||||||
}
|
}
|
||||||
userService.resetPassword(user.getId(),password);
|
userService.resetPassword(user.getId(),password);
|
||||||
|
|||||||
Reference in New Issue
Block a user