@@ -11,6 +11,7 @@ import org.springframework.context.annotation.ComponentScan; | |||||
import org.springframework.context.annotation.EnableAspectJAutoProxy; | import org.springframework.context.annotation.EnableAspectJAutoProxy; | ||||
import org.springframework.scheduling.annotation.EnableAsync; | import org.springframework.scheduling.annotation.EnableAsync; | ||||
import org.springframework.scheduling.annotation.EnableScheduling; | import org.springframework.scheduling.annotation.EnableScheduling; | ||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | |||||
import org.springframework.transaction.annotation.EnableTransactionManagement; | import org.springframework.transaction.annotation.EnableTransactionManagement; | ||||
/** | /** | ||||
@@ -20,9 +21,10 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; | |||||
@EnableAsync | @EnableAsync | ||||
@MapperScan(App.MAPPER_PACKAGES) | @MapperScan(App.MAPPER_PACKAGES) | ||||
@EnableScheduling | @EnableScheduling | ||||
@EnableGlobalMethodSecurity(prePostEnabled = true) | |||||
@EnableTransactionManagement | @EnableTransactionManagement | ||||
@EnableAspectJAutoProxy(exposeProxy = true) | @EnableAspectJAutoProxy(exposeProxy = true) | ||||
@ComponentScan(basePackages = {"com.ningdatech.kqapi","com.ningdatech.kqapi.common"}) | |||||
@ComponentScan(basePackages = {"com.ningdatech.kqapi", "com.ningdatech.kqapi.common"}) | |||||
public class App { | public class App { | ||||
protected static final String MAPPER_PACKAGES = "com.ningdatech.kqapi.**.mapper"; | protected static final String MAPPER_PACKAGES = "com.ningdatech.kqapi.**.mapper"; | ||||
@@ -6,6 +6,7 @@ import com.ningdatech.kqapi.common.model.Status; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.context.support.DefaultMessageSourceResolvable; | import org.springframework.context.support.DefaultMessageSourceResolvable; | ||||
import org.springframework.http.HttpStatus; | import org.springframework.http.HttpStatus; | ||||
import org.springframework.security.access.AccessDeniedException; | |||||
import org.springframework.validation.BindException; | import org.springframework.validation.BindException; | ||||
import org.springframework.web.bind.MethodArgumentNotValidException; | import org.springframework.web.bind.MethodArgumentNotValidException; | ||||
import org.springframework.web.bind.annotation.ControllerAdvice; | import org.springframework.web.bind.annotation.ControllerAdvice; | ||||
@@ -70,8 +71,15 @@ public class GlobalExceptionHandler { | |||||
} | } | ||||
@ResponseBody | @ResponseBody | ||||
@ExceptionHandler(value = AccessDeniedException.class) | |||||
public ApiResponse<Void> accessDeniedException(AccessDeniedException e) { | |||||
printLog(e); | |||||
return ApiResponse.of(Status.BAD_REQUEST.getCode(), "暂无操作权限"); | |||||
} | |||||
@ResponseBody | |||||
@ExceptionHandler(value = BizException.class) | @ExceptionHandler(value = BizException.class) | ||||
public ApiResponse<Void> bizException(Exception e) { | |||||
public ApiResponse<Void> bizException(BizException e) { | |||||
printLog(e); | printLog(e); | ||||
return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage()); | return ApiResponse.of(Status.BAD_REQUEST.getCode(), e.getMessage()); | ||||
} | } | ||||
@@ -74,7 +74,7 @@ public class TaskController { | |||||
@ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据") | @ApiOperation(value = "同步菜单链接数据", notes = "同步菜单链接数据") | ||||
@GetMapping("/syn-menu") | @GetMapping("/syn-menu") | ||||
public String synMenuData() throws UnknownHostException { | |||||
public String synMenuData() { | |||||
synTask.synMenu(); | synTask.synMenu(); | ||||
return "同步成功"; | return "同步成功"; | ||||
} | } | ||||
@@ -7,10 +7,9 @@ import com.github.benmanes.caffeine.cache.LoadingCache; | |||||
import com.ningdatech.kqapi.common.constant.BizConst; | import com.ningdatech.kqapi.common.constant.BizConst; | ||||
import com.ningdatech.kqapi.common.enumeration.CommonEnum; | import com.ningdatech.kqapi.common.enumeration.CommonEnum; | ||||
import com.ningdatech.kqapi.common.helper.MatterCacheHelper; | import com.ningdatech.kqapi.common.helper.MatterCacheHelper; | ||||
import com.ningdatech.kqapi.zzsfw.manage.MatterManage; | |||||
import com.ningdatech.kqapi.zzsfw.model.entity.*; | import com.ningdatech.kqapi.zzsfw.model.entity.*; | ||||
import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; | import com.ningdatech.kqapi.zzsfw.service.ComponentsMatterEliminateService; | ||||
import com.ningdatech.kqapi.zzsfw.model.entity.KqZzsfwMenu; | |||||
import com.ningdatech.kqapi.zzsfw.manage.MatterManage; | |||||
import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; | import com.ningdatech.kqapi.zzsfw.service.IDscSxAdsShareItemQltQlsxCommonIDVKqService; | ||||
import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; | import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMatterDeduplicateService; | ||||
import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; | import com.ningdatech.kqapi.zzsfw.service.IKqZzsfwMenuService; | ||||
@@ -70,86 +69,74 @@ public class SynTask { | |||||
*/ | */ | ||||
@Scheduled(cron = "0 30 8 * * ?") | @Scheduled(cron = "0 30 8 * * ?") | ||||
public void synData() throws UnknownHostException { | public void synData() throws UnknownHostException { | ||||
// if (!HOST.equals(InetAddress.getLocalHost().getHostName())) { | |||||
// log.info("定时器没开启或者host不对! {}:{}", | |||||
// HOST,InetAddress.getLocalHost().getHostName()); | |||||
// return; | |||||
// } | |||||
// if(!TaskContant.PROD.equals(active)){ | |||||
// log.info("非正式环境不用运行同步任务!"); | |||||
// return; | |||||
// } | |||||
log.info("政务数据 ===================== 同步开始"); | log.info("政务数据 ===================== 同步开始"); | ||||
StopWatch stopWatch = new StopWatch(); | StopWatch stopWatch = new StopWatch(); | ||||
stopWatch.start(); | stopWatch.start(); | ||||
//1.处理 去重数据 | //1.处理 去重数据 | ||||
if(matterCacheHelper.refreshAll()){ | |||||
if (matterCacheHelper.refreshAll()) { | |||||
matterManage.removeAllDup(); | matterManage.removeAllDup(); | ||||
List<KqZzsfwMattersDeduplicate> allDup = matterCacheHelper.all(); | List<KqZzsfwMattersDeduplicate> allDup = matterCacheHelper.all(); | ||||
matterDeduplicateService.saveBatch(allDup); | matterDeduplicateService.saveBatch(allDup); | ||||
//2. 事项 | //2. 事项 | ||||
List<KqZzsfwMenu> menus = menuService.list(); | List<KqZzsfwMenu> menus = menuService.list(); | ||||
for(KqZzsfwMenu menu : menus){ | |||||
for (KqZzsfwMenu menu : menus) { | |||||
String url = matterCacheHelper.getUrl(menu.getItemName()); | String url = matterCacheHelper.getUrl(menu.getItemName()); | ||||
if(StringUtils.isBlank(url)){ | |||||
if (StringUtils.isBlank(url)) { | |||||
menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | ||||
.eq(KqZzsfwMenu::getId,menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl,null) | |||||
.eq(KqZzsfwMenu::getId, menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl, null) | |||||
.set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); | .set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); | ||||
}else{ | |||||
} else { | |||||
menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | ||||
.eq(KqZzsfwMenu::getId,menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl,url) | |||||
.set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); | |||||
.eq(KqZzsfwMenu::getId, menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl, url) | |||||
.set(KqZzsfwMenu::getHasUrl, CommonEnum.YES.getCode())); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
stopWatch.stop(); | stopWatch.stop(); | ||||
log.info("政务数据 ===================== 同步总共耗时 :{} s",stopWatch.getTotalTimeSeconds()); | |||||
log.info("政务数据 ===================== 同步总共耗时 :{} s", stopWatch.getTotalTimeSeconds()); | |||||
} | } | ||||
public void synMenu() { | public void synMenu() { | ||||
//2. 事项 | //2. 事项 | ||||
List<KqZzsfwMenu> menus = menuService.list(); | List<KqZzsfwMenu> menus = menuService.list(); | ||||
for(KqZzsfwMenu menu : menus){ | |||||
for (KqZzsfwMenu menu : menus) { | |||||
String url = matterCacheHelper.getUrl(menu.getItemName()); | String url = matterCacheHelper.getUrl(menu.getItemName()); | ||||
log.info("当前缓存的数据 : {},{}",menu.getItemName(),url); | |||||
if(StringUtils.isBlank(url)){ | |||||
log.info("当前缓存的数据 : {},{}", menu.getItemName(), url); | |||||
if (StringUtils.isBlank(url)) { | |||||
menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | ||||
.eq(KqZzsfwMenu::getId,menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl,null) | |||||
.eq(KqZzsfwMenu::getId, menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl, null) | |||||
.set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); | .set(KqZzsfwMenu::getHasUrl, CommonEnum.NO.getCode())); | ||||
}else{ | |||||
} else { | |||||
menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | ||||
.eq(KqZzsfwMenu::getId,menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl,url) | |||||
.set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); | |||||
.eq(KqZzsfwMenu::getId, menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl, url) | |||||
.set(KqZzsfwMenu::getHasUrl, CommonEnum.YES.getCode())); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public String synEliminate(List<String> keys){ | |||||
// kqService.remove(new LambdaQueryWrapper<DscSxAdsShareItemQltQlsxCommonIDVKq>() | |||||
// .in(DscSxAdsShareItemQltQlsxCommonIDVKq::getQlName, keys)); | |||||
public String synEliminate(List<String> keys) { | |||||
// 添加剔除信息 | // 添加剔除信息 | ||||
List<ComponentsMatterEliminateEntity> entityList = new ArrayList<>(); | List<ComponentsMatterEliminateEntity> entityList = new ArrayList<>(); | ||||
keys.forEach(key ->{ | |||||
keys.forEach(key -> { | |||||
ComponentsMatterEliminateEntity one = componentsMatterEliminateService.getOne(Wrappers.lambdaQuery(ComponentsMatterEliminateEntity.class) | ComponentsMatterEliminateEntity one = componentsMatterEliminateService.getOne(Wrappers.lambdaQuery(ComponentsMatterEliminateEntity.class) | ||||
.eq(ComponentsMatterEliminateEntity::getQlName, key)); | .eq(ComponentsMatterEliminateEntity::getQlName, key)); | ||||
if (Objects.isNull(one)){ | |||||
entityList.add(new ComponentsMatterEliminateEntity(key,"1")); | |||||
if (Objects.isNull(one)) { | |||||
entityList.add(new ComponentsMatterEliminateEntity(key, "1")); | |||||
} | } | ||||
// 删除缓存 | // 删除缓存 | ||||
DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); | DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); | ||||
String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); | String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); | ||||
MatterKey matterKey = MatterKey.of(matter.getQlName(),url); | |||||
MatterKey matterKey = MatterKey.of(matter.getQlName(), url); | |||||
try { | try { | ||||
mattersDupCache.invalidate(matterKey); | mattersDupCache.invalidate(matterKey); | ||||
}catch (Exception e){ | |||||
} catch (Exception e) { | |||||
log.error("mattersDupCache is null", e.getMessage()); | log.error("mattersDupCache is null", e.getMessage()); | ||||
} | } | ||||
}); | }); | ||||
@@ -165,8 +152,8 @@ public class SynTask { | |||||
return "剔除成功"; | return "剔除成功"; | ||||
} | } | ||||
public DscSxAdsShareItemQltQlsxCommonIDVKq getSynUrl(String key){ | |||||
public DscSxAdsShareItemQltQlsxCommonIDVKq getSynUrl(String key) { | |||||
DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService | DscSxAdsShareItemQltQlsxCommonIDVKq matter = kqService | ||||
.getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) | .getOne(Wrappers.lambdaQuery(DscSxAdsShareItemQltQlsxCommonIDVKq.class) | ||||
.select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, | .select(DscSxAdsShareItemQltQlsxCommonIDVKq::getRowguid, | ||||
@@ -185,21 +172,18 @@ public class SynTask { | |||||
return matter; | return matter; | ||||
} | } | ||||
public String synSingle(String key){ | |||||
public void synSingle(String key) { | |||||
DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); | DscSxAdsShareItemQltQlsxCommonIDVKq matter = getSynUrl(key); | ||||
String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); | String url = KQ_ZZS_BASE_URL.replace("localInnerCode=", "localInnerCode=" + matter.getQlInnerCode()); | ||||
List<KqZzsfwMenu> menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) | List<KqZzsfwMenu> menus = menuService.list(Wrappers.lambdaQuery(KqZzsfwMenu.class) | ||||
.eq(KqZzsfwMenu::getItemName, key)); | .eq(KqZzsfwMenu::getItemName, key)); | ||||
menus.forEach(menu->{ | |||||
menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | |||||
.eq(KqZzsfwMenu::getId,menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl,url) | |||||
.set(KqZzsfwMenu::getHasUrl,CommonEnum.YES.getCode())); | |||||
}); | |||||
menus.forEach(menu -> menuService.update(Wrappers.lambdaUpdate(KqZzsfwMenu.class) | |||||
.eq(KqZzsfwMenu::getId, menu.getId()) | |||||
.set(KqZzsfwMenu::getWebapplyurl, url) | |||||
.set(KqZzsfwMenu::getHasUrl, CommonEnum.YES.getCode()))); | |||||
// 更新缓存 | // 更新缓存 | ||||
MatterKey matterKey = MatterKey.of(matter.getQlName(),url); | |||||
MatterKey matterKey = MatterKey.of(matter.getQlName(), url); | |||||
mattersDupCache.invalidate(matterKey); | mattersDupCache.invalidate(matterKey); | ||||
mattersDupCache.put(matterKey, KqZzsfwMattersDeduplicate.of(matter.getQlName(),url)); | |||||
return "更新成功,rul:" + url; | |||||
mattersDupCache.put(matterKey, KqZzsfwMattersDeduplicate.of(matter.getQlName(), url)); | |||||
} | } | ||||
} | } |
@@ -15,9 +15,9 @@ import com.ningdatech.log.annotation.WebLog; | |||||
import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.security.access.prepost.PreAuthorize; | |||||
import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
import javax.annotation.security.RolesAllowed; | |||||
import javax.validation.Valid; | import javax.validation.Valid; | ||||
/** | /** | ||||
@@ -39,7 +39,7 @@ public class UserInfoController { | |||||
@PostMapping(value = "/save") | @PostMapping(value = "/save") | ||||
@ApiOperation(value = "保存用户") | @ApiOperation(value = "保存用户") | ||||
@WebLog(value = "保存用户") | @WebLog(value = "保存用户") | ||||
@RolesAllowed("SUPER_ADMIN") | |||||
@PreAuthorize("hasAuthority('SUPER_ADMIN')") | |||||
public void saveUser(@Valid @RequestBody SaveUserReq request) { | public void saveUser(@Valid @RequestBody SaveUserReq request) { | ||||
userInfoManage.saveUser(request); | userInfoManage.saveUser(request); | ||||
} | } | ||||
@@ -47,7 +47,7 @@ public class UserInfoController { | |||||
@PostMapping(value = "/changeAccountStatus") | @PostMapping(value = "/changeAccountStatus") | ||||
@ApiOperation(value = "账号状态变更") | @ApiOperation(value = "账号状态变更") | ||||
@WebLog(value = "账号状态变更") | @WebLog(value = "账号状态变更") | ||||
@RolesAllowed("SUPER_ADMIN") | |||||
@PreAuthorize("hasAuthority('SUPER_ADMIN')") | |||||
public void changeAccountStatus(@Valid @RequestBody ChangeAccountStatusReq req) { | public void changeAccountStatus(@Valid @RequestBody ChangeAccountStatusReq req) { | ||||
userInfoManage.changeAccountStatus(req); | userInfoManage.changeAccountStatus(req); | ||||
} | } | ||||
@@ -62,7 +62,7 @@ public class UserInfoController { | |||||
@DeleteMapping("/del") | @DeleteMapping("/del") | ||||
@ApiOperation("删除用户") | @ApiOperation("删除用户") | ||||
@WebLog(value = "删除用户") | @WebLog(value = "删除用户") | ||||
@RolesAllowed("SUPER_ADMIN") | |||||
@PreAuthorize("hasAuthority('SUPER_ADMIN')") | |||||
public void deleteUser(@RequestBody IdVo<Long> req) { | public void deleteUser(@RequestBody IdVo<Long> req) { | ||||
userInfoManage.deleteUser(req.getId()); | userInfoManage.deleteUser(req.getId()); | ||||
} | } | ||||
@@ -90,7 +90,7 @@ public class UserInfoController { | |||||
@PostMapping("/password/mod") | @PostMapping("/password/mod") | ||||
@ApiOperation("修改密码") | @ApiOperation("修改密码") | ||||
@WebLog(value = "修改密码") | @WebLog(value = "修改密码") | ||||
@RolesAllowed("SUPER_ADMIN") | |||||
@PreAuthorize("hasAuthority('SUPER_ADMIN')") | |||||
public void changePassword(@Valid @RequestBody ModifyPasswordReq po) { | public void changePassword(@Valid @RequestBody ModifyPasswordReq po) { | ||||
userInfoManage.changePassword(po); | userInfoManage.changePassword(po); | ||||
} | } | ||||
@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil; | |||||
import cn.hutool.core.lang.Assert; | import cn.hutool.core.lang.Assert; | ||||
import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | import com.baomidou.mybatisplus.core.conditions.Wrapper; | ||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.ningdatech.basic.exception.BizException; | import com.ningdatech.basic.exception.BizException; | ||||
@@ -20,9 +19,9 @@ import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq; | |||||
import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; | import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq; | ||||
import com.ningdatech.kqapi.user.model.po.SaveUserReq; | import com.ningdatech.kqapi.user.model.po.SaveUserReq; | ||||
import com.ningdatech.kqapi.user.model.po.UserListReq; | import com.ningdatech.kqapi.user.model.po.UserListReq; | ||||
import com.ningdatech.kqapi.user.model.vo.UserListVO; | |||||
import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; | import com.ningdatech.kqapi.user.model.vo.LoginUserDetailVO; | ||||
import com.ningdatech.kqapi.user.model.vo.UserDetailVO; | import com.ningdatech.kqapi.user.model.vo.UserDetailVO; | ||||
import com.ningdatech.kqapi.user.model.vo.UserListVO; | |||||
import com.ningdatech.kqapi.user.service.IUserAuthService; | import com.ningdatech.kqapi.user.service.IUserAuthService; | ||||
import com.ningdatech.kqapi.user.service.IUserInfoService; | import com.ningdatech.kqapi.user.service.IUserInfoService; | ||||
import com.ningdatech.kqapi.user.util.BizUtils; | import com.ningdatech.kqapi.user.util.BizUtils; | ||||
@@ -35,7 +34,10 @@ import org.springframework.stereotype.Component; | |||||
import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.*; | |||||
import java.util.ArrayList; | |||||
import java.util.HashSet; | |||||
import java.util.List; | |||||
import java.util.Set; | |||||
import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
@@ -102,9 +104,14 @@ public class UserInfoManage { | |||||
private void modifyAccount(SaveUserReq req, UserInfo oldUser, Long userId) { | private void modifyAccount(SaveUserReq req, UserInfo oldUser, Long userId) { | ||||
// 用户ID不为空时修改账号 | // 用户ID不为空时修改账号 | ||||
String password = null; | |||||
if (StrUtil.isNotBlank(req.getPassword())) { | |||||
password = passwordEncoder.encode(req.getPassword()); | |||||
} | |||||
if (!oldUser.getMobile().equals(req.getPhoneNo())) { | if (!oldUser.getMobile().equals(req.getPhoneNo())) { | ||||
Wrapper<UserAuth> phoneAuth = Wrappers.lambdaUpdate(UserAuth.class) | Wrapper<UserAuth> phoneAuth = Wrappers.lambdaUpdate(UserAuth.class) | ||||
.set(UserAuth::getIdentifier, req.getPhoneNo()) | .set(UserAuth::getIdentifier, req.getPhoneNo()) | ||||
.set(password != null, UserAuth::getCredential, password) | |||||
.eq(UserAuth::getUserId, userId) | .eq(UserAuth::getUserId, userId) | ||||
.eq(UserAuth::getAuthType, AuthTypeEnum.PHONE_PASSWORD); | .eq(UserAuth::getAuthType, AuthTypeEnum.PHONE_PASSWORD); | ||||
userAuthService.update(phoneAuth); | userAuthService.update(phoneAuth); | ||||
@@ -112,6 +119,7 @@ public class UserInfoManage { | |||||
if (!oldUser.getUsername().equals(req.getUserName())) { | if (!oldUser.getUsername().equals(req.getUserName())) { | ||||
Wrapper<UserAuth> accountAuth = Wrappers.lambdaUpdate(UserAuth.class) | Wrapper<UserAuth> accountAuth = Wrappers.lambdaUpdate(UserAuth.class) | ||||
.set(UserAuth::getIdentifier, req.getUserName()) | .set(UserAuth::getIdentifier, req.getUserName()) | ||||
.set(password != null, UserAuth::getCredential, password) | |||||
.eq(UserAuth::getUserId, userId) | .eq(UserAuth::getUserId, userId) | ||||
.eq(UserAuth::getAuthType, AuthTypeEnum.ACCOUNT_PASSWORD); | .eq(UserAuth::getAuthType, AuthTypeEnum.ACCOUNT_PASSWORD); | ||||
userAuthService.update(accountAuth); | userAuthService.update(accountAuth); | ||||