|
|
@ -3,11 +3,9 @@ package a8k.service.usermgr; |
|
|
|
import a8k.appbase.appret.AppRet; |
|
|
|
import a8k.controler.engineer.utils.EngineerPageTab; |
|
|
|
import a8k.controler.engineer.utils.EnginnerPageAction; |
|
|
|
import a8k.controler.engineer.utils.EnginnerPageParam; |
|
|
|
import a8k.controler.engineer.utils.EnginnerPageTabOrder; |
|
|
|
import a8k.db.AppUser; |
|
|
|
import a8k.service.hardware.canbus.protocol.A8kEcode; |
|
|
|
import a8k.utils.AppService; |
|
|
|
import a8k.utils.AppServiceAction; |
|
|
|
import com.iflytop.uf.UfActiveRecord; |
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
|
import org.slf4j.Logger; |
|
|
@ -18,10 +16,23 @@ import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
@EngineerPageTab(name = "用户管理") |
|
|
|
@EngineerPageTab(name = "应用-用户管理", order = EnginnerPageTabOrder.AppUserMgrService) |
|
|
|
public class AppUserMgrService { |
|
|
|
static Logger logger = org.slf4j.LoggerFactory.getLogger(AppUserMgrService.class); |
|
|
|
|
|
|
|
static class ORDER { |
|
|
|
static final int login = 1; |
|
|
|
static final int getLoginUsr = 2; |
|
|
|
static final int getUsrlist = 3; |
|
|
|
static final int addUser = 5; |
|
|
|
static final int delUser = 6; |
|
|
|
static final int modifyUser = 7; |
|
|
|
static final int modifyUsrPwd = 8; |
|
|
|
static final int modifyUsrRole = 9; |
|
|
|
static final int verifyUser = 10; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
AppUser loginUsr; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
@ -51,7 +62,7 @@ public class AppUserMgrService { |
|
|
|
// EXT FUNC |
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "用户登录") |
|
|
|
@EnginnerPageAction(name = "用户登录", order = ORDER.login) |
|
|
|
public AppRet<AppUser> login(String account, String password) { |
|
|
|
var user = dbGetUser(account); |
|
|
|
if (user == null) { |
|
|
@ -64,22 +75,18 @@ public class AppUserMgrService { |
|
|
|
return AppRet.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "获取当前用户") |
|
|
|
@EnginnerPageAction(name = "获取当前用户", order = ORDER.getLoginUsr) |
|
|
|
public AppRet<AppUser> getLoginUsr() { |
|
|
|
return AppRet.success(loginUsr); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "用户列表") |
|
|
|
public AppRet<List<AppUser>> list() { |
|
|
|
@EnginnerPageAction(name = "获取用户列表", order = ORDER.getUsrlist) |
|
|
|
public AppRet<List<AppUser>> getUsrlist() { |
|
|
|
return AppRet.success(dbGetUserList()); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "登录用户列表") |
|
|
|
public AppRet<List<AppUser>> loginList() { |
|
|
|
return AppRet.success(dbGetUserList()); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "用户添加") |
|
|
|
@EnginnerPageAction(name = "用户添加", order = ORDER.addUser) |
|
|
|
public AppRet<AppUser> addUser(String account, String password, Integer isAdmin) { |
|
|
|
if (dbGetUser(account) != null) { |
|
|
|
return AppRet.fail(A8kEcode.UsrExistError); |
|
|
@ -92,7 +99,7 @@ public class AppUserMgrService { |
|
|
|
return AppRet.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "用户删除") |
|
|
|
@EnginnerPageAction(name = "删除用户", order = ORDER.delUser) |
|
|
|
public AppRet<AppUser> delUser(String account) { |
|
|
|
var user = dbGetUser(account); |
|
|
|
if (user == null) { |
|
|
@ -105,7 +112,7 @@ public class AppUserMgrService { |
|
|
|
return AppRet.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "用户变更") |
|
|
|
@EnginnerPageAction(name = "修改用户", order = ORDER.modifyUser) |
|
|
|
public AppRet<AppUser> modifyUser(String account, String password, Integer isAdmin) { |
|
|
|
var user = dbGetUser(account); |
|
|
|
if (user == null) { |
|
|
@ -117,9 +124,37 @@ public class AppUserMgrService { |
|
|
|
return AppRet.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
public AppRet<AppUser> getLoginUsrInfo() { |
|
|
|
return AppRet.success(loginUsr); |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "修改用户密码", order = ORDER.modifyUsrPwd) |
|
|
|
public AppRet<AppUser> modifyUsrPwd(String account, String password) { |
|
|
|
var user = dbGetUser(account); |
|
|
|
if (user == null) { |
|
|
|
return AppRet.fail(A8kEcode.UsrNotExitError); |
|
|
|
} |
|
|
|
user.password = password; |
|
|
|
return AppRet.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "修改用户权限", order = ORDER.modifyUsrRole) |
|
|
|
public AppRet<AppUser> modifyUsrRole(String account, Boolean isAdmin) { |
|
|
|
var user = dbGetUser(account); |
|
|
|
if (user == null) { |
|
|
|
return AppRet.fail(A8kEcode.UsrNotExitError); |
|
|
|
} |
|
|
|
user.isAdmin = isAdmin ? 1 : 0; |
|
|
|
return AppRet.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
@EnginnerPageAction(name = "用户验证", order = ORDER.verifyUser) |
|
|
|
public AppRet<Boolean> verifyUser(String account, String password) { |
|
|
|
var user = dbGetUser(account); |
|
|
|
if (user == null) { |
|
|
|
return AppRet.fail(A8kEcode.UsrNotExitError); |
|
|
|
} |
|
|
|
if (!user.matchPassword(password)) { |
|
|
|
return AppRet.fail(A8kEcode.PasswdError); |
|
|
|
} |
|
|
|
return AppRet.success(true); |
|
|
|
} |
|
|
|
|
|
|
|
} |