package com.farriver.bwf.service.security; import com.farriver.bwf.common.model.ApiData; import com.farriver.bwf.common.model.ApiPageData; import com.farriver.bwf.common.statics.LangConstants; import com.farriver.bwf.data.transferobject.queryobject.security.AccountMasterQueryObject; import com.farriver.bwf.data.transferobject.viewmodel.common.AuthBean; import com.farriver.bwf.data.transferobject.viewmodel.pa.PAEmployeeViewModel; import com.farriver.bwf.data.transferobject.viewmodel.security.AccountMasterViewModel; import com.farriver.bwf.data.transferobject.viewmodel.security.PasswordViewModel; import com.farriver.bwf.service.ServiceBase; import com.farriver.bwf.service.extend.rbac.RBACService; import jakarta.annotation.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; @Service public class SecurityService extends ServiceBase { private static final Logger logger = LoggerFactory.getLogger(SecurityService.class); private String message; @Resource RBACService rbacService; @Value("${applicationcode}") private String applicationcode; public ApiData UpdateProfile(@RequestBody PAEmployeeViewModel model) { try { return rbacService.UpdatePAEmployeeProfile(model); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetEmployeePositionsByEmployeeId(@RequestParam("employeeid") String employeeid) { try { return rbacService.GetEmployeePositionsByEmployeeId(employeeid); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetEmployeePositionWithOrganizationsByEmployeeId(@RequestParam("employeeid") String employeeid) { try { return rbacService.GetEmployeePositionWithOrganizationsByEmployeeId(employeeid); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData UpdateAccountPassword(PasswordViewModel model) { try { return rbacService.UpdateAccountPassword(model); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiPageData GetAllApplication(Integer permissionLevel) { try { return rbacService.GetAllApplication(permissionLevel); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiPageData GetAccountApplications(String accountid) { try { return rbacService.GetAccountApplications(accountid); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public boolean CheckPermission(String applicationcode, AccountMasterViewModel account, String uri) { try { ApiData rp = rbacService.CheckPermission(applicationcode, account, uri); if (rp == null) { return false; } return (boolean) rp.getData(); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return false; } public ApiData RegisterAccount(AccountMasterViewModel model) { try { return rbacService.RegisterAccount(model); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData ResetPasswordSMSCode(PasswordViewModel model) { try { return rbacService.ResetPasswordSMSCode(model); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData ResetPasswordByEmail(PasswordViewModel model) { try { return rbacService.ResetPasswordByEmail(model); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData RetrievePasswordByEmail(String email, String ticket) { try { return rbacService.RetrievePasswordByEmail(email, ticket); } catch (Exception exception) { logger.error(exception.getMessage(), exception); message = LangConstants.MSG_ERROR_SYSTEM; } return ApiData.error(message); } public ApiData LoginByAccountPassword(AuthBean authBean) { try { return rbacService.LoginByAccountPassword(authBean); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData LoginBySMSCode(AuthBean authBean) { try { return rbacService.LoginBySMSCode(authBean); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData Logout(String accountid) { try { return rbacService.GetLogout(accountid); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public void SetVerifyCode(String account, String code) { try { rbacService.SetVerifyCode(account, code); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } } public ApiData GetSMSCode(String cellphone) { try { return rbacService.GetSMSCode(cellphone); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetAccountRolesByAccountId(String id) { try { return rbacService.GetAccountRolesByAccountId(id); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiPageData getAllRoles(Integer permissionLevel) { try { return rbacService.getAllRoles(permissionLevel); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetRolesByAccountId(String accountid) { try { return rbacService.GetRolesByAccountId(accountid); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetRolesByPositionId(String positionid) { try { return rbacService.GetRolesByPositionId(positionid); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetRolePermissions(String applicationcode) { try { return rbacService.GetRolePermissions(applicationcode); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData LoadAccountByAccount(String code) { try { return rbacService.LoadAccountByAccount(code); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetAccountDetail(AccountMasterQueryObject queryObject) { try { return rbacService.GetAccountDetail(queryObject); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } public ApiData GetAccountWithRolesAndPermissions(String id) { try { return rbacService.GetAccountWithRolesAndPermissions(id); } catch (Exception exception) { logger.error(exception.getMessage(), exception); } return null; } }