1. add APPUserController
This commit is contained in:
2026-02-04 22:06:25 +08:00
parent 89d95daa2e
commit 149857442d
3 changed files with 31 additions and 33 deletions

View File

@@ -4,12 +4,12 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.modules.develop.pojo.entity.Code;
import org.springblade.modules.system.service.IUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@Hidden
@RestController
@@ -27,8 +27,18 @@ public class APPUserController {
@GetMapping("/has-changed")
@ApiOperationSupport(order = 1)
@Operation(summary = "是否修改过密码")
public R<Boolean> hasChangePassword() {
return R.data(userService.hasChangePassword());
public R<Boolean> hasChangedPassword() {
return R.data(userService.hasChangedPassword());
}
/**
* 修改登录密码
*/
@PostMapping("/change-password")
@ApiOperationSupport(order = 2)
@Operation(summary = "修改登录密码", description = "传入String")
public R submit(@RequestBody String password) {
return R.status(userService.changePassword(password));
}
}

View File

@@ -300,6 +300,7 @@ public interface IUserService extends BaseService<User> {
*/
List<UserVO> leaderList(String tenantId, String realName);
Boolean hasChangePassword();
Boolean hasChangedPassword();
boolean changePassword(String password);
}

View File

@@ -1,28 +1,4 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.system.service.impl;
@@ -42,6 +18,7 @@ import org.springblade.core.mp.enums.StatusType;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.oauth2.exception.OAuth2Exception;
import org.springblade.core.oauth2.props.OAuth2Properties;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.BladeTenantProperties;
@@ -58,6 +35,7 @@ import org.springblade.modules.system.service.*;
import org.springblade.modules.system.wrapper.UserWrapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.Collections;
@@ -83,7 +61,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
private final IRoleService roleService;
private final BladeTenantProperties tenantProperties;
private final BladeRedis bladeRedis;
private final IParamService paramService;
private final OAuth2Properties properties;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -614,8 +593,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
}
@Override
public Boolean hasChangePassword() {
public Boolean hasChangedPassword() {
User user = getById(AuthUtil.getUserId());
return user.getCreateTime() == user.getUpdateTime();
}
@Override
public boolean changePassword(String password) {
Assert.isTrue(StringUtil.isNotBlank(password), "无效密码");
User user = getById(AuthUtil.getUserId());
user.setPassword(SM2Util.decrypt(password, properties.getPublicKey(), properties.getPrivateKey()));
return updateById(user);
}
}