19 changed files with 271 additions and 209 deletions
-
81src/main/java/a8k/appbase/appret/AppRet.java
-
8src/main/java/a8k/appbase/appret/AppRetType.java
-
23src/main/java/a8k/appbase/ecode/AppRetEcodeInfo.java
-
2src/main/java/a8k/controler/A8kExceptionProcesser.java
-
2src/main/java/a8k/controler/engineer/EngineerPageControler.java
-
29src/main/java/a8k/db/AppUser.java
-
51src/main/java/a8k/db/MdbUser.java
-
2src/main/java/a8k/service/ctrl_service/DeviceInitializationCtrlService.java
-
2src/main/java/a8k/service/hardware/CommonHardwareOpeartion.java
-
2src/main/java/a8k/service/hardware/HbotControlService.java
-
2src/main/java/a8k/service/hardware/MotorTubeRackMoveCtrlService.java
-
2src/main/java/a8k/service/hardware/ReactionPlatesTransmitCtrlService.java
-
2src/main/java/a8k/service/hardware/SamplesPreProcessModuleCtrlService.java
-
2src/main/java/a8k/service/hardware/TestScript.java
-
5src/main/java/a8k/service/hardware/canbus/protocol/A8kEcode.java
-
8src/main/java/a8k/service/state_service/A8kStateMgrService.java
-
59src/main/java/a8k/service/usermgr/UserMgrService.java
-
BINzhaohe_app.db
@ -0,0 +1,8 @@ |
|||
package a8k.appbase.appret; |
|||
|
|||
public enum AppRetType { |
|||
NORMAL, |
|||
FAILURE, |
|||
RECONFIRM, |
|||
MESSAGE, |
|||
} |
@ -0,0 +1,29 @@ |
|||
package a8k.db; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import com.iflytop.uf.UfActiveRecord; |
|||
import com.iflytop.uf.UfActiveRecordField; |
|||
|
|||
public class AppUser extends UfActiveRecord { |
|||
@UfActiveRecordField |
|||
public String account; |
|||
|
|||
@JsonIgnore |
|||
@UfActiveRecordField |
|||
public String password; |
|||
|
|||
@UfActiveRecordField |
|||
public Integer isAdmin; |
|||
|
|||
|
|||
// get table name |
|||
public static String getTableName() { |
|||
return "AppUser" + "Table"; |
|||
} |
|||
|
|||
// check if password matches |
|||
public Boolean matchPassword(String password) { |
|||
return this.password.equals(password); |
|||
} |
|||
|
|||
} |
@ -1,51 +0,0 @@ |
|||
package a8k.db; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import com.iflytop.uf.UfActiveRecord; |
|||
import com.iflytop.uf.UfActiveRecordField; |
|||
import org.springframework.util.DigestUtils; |
|||
public class MdbUser extends UfActiveRecord { |
|||
@UfActiveRecordField |
|||
public String account; |
|||
|
|||
@JsonIgnore |
|||
@UfActiveRecordField |
|||
public String password; |
|||
|
|||
@JsonIgnore |
|||
@UfActiveRecordField |
|||
public String salt; |
|||
|
|||
@UfActiveRecordField |
|||
public Integer isAdmin; |
|||
|
|||
@UfActiveRecordField |
|||
public Integer createdAt; |
|||
|
|||
@UfActiveRecordField |
|||
public String createdBy; |
|||
|
|||
@JsonIgnore |
|||
@UfActiveRecordField |
|||
public String accessToken; |
|||
|
|||
@JsonIgnore |
|||
@UfActiveRecordField |
|||
public Integer accessTokenExpiredAt; |
|||
|
|||
// get table name |
|||
public static String getTableName() { |
|||
return "app_users"; |
|||
} |
|||
|
|||
// check if password matches |
|||
public Boolean matchPassword(String password) { |
|||
String hash = this.hashPassword(password); |
|||
return this.password.equals(hash); |
|||
} |
|||
|
|||
// hash password |
|||
public String hashPassword(String password) { |
|||
String salt = this.salt; |
|||
return DigestUtils.md5DigestAsHex((salt + password + salt).getBytes()); |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
package a8k.service.usermgr; |
|||
|
|||
import a8k.appbase.appret.AppRet; |
|||
import a8k.db.AppUser; |
|||
import a8k.service.hardware.canbus.protocol.A8kEcode; |
|||
import com.iflytop.uf.UfActiveRecord; |
|||
import jakarta.annotation.PostConstruct; |
|||
import org.slf4j.Logger; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Component |
|||
public class UserMgrService { |
|||
static Logger logger = org.slf4j.LoggerFactory.getLogger(UserMgrService.class); |
|||
|
|||
AppUser loginUsr; |
|||
|
|||
@PostConstruct |
|||
public void init() { |
|||
logger.info("UserMgrService init"); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
List<AppUser> getUserList() { |
|||
return UfActiveRecord.find(AppUser.class); |
|||
} |
|||
|
|||
AppUser getUser(String account) { |
|||
return UfActiveRecord.findOne(AppUser.class, Map.of("account", account)); |
|||
} |
|||
|
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
// EXTFUNC |
|||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|||
|
|||
public AppRet<AppUser> login(String account, String password) { |
|||
var user = getUser(account); |
|||
if (user == null) { |
|||
return AppRet.fail(A8kEcode.UsrNotExitError); |
|||
} |
|||
if (!user.matchPassword(password)) { |
|||
return AppRet.fail(A8kEcode.PasswdError); |
|||
} |
|||
loginUsr = user; |
|||
return AppRet.success(user); |
|||
} |
|||
|
|||
public AppRet<AppUser> getLoginUsr() { |
|||
return AppRet.success(loginUsr); |
|||
} |
|||
|
|||
public AppRet<List<AppUser>> loginList() { |
|||
return AppRet.success(getUserList()); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue