|
|
@@ -1,10 +1,29 @@
|
|
|
package com.template.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.template.api.WelcomeAccountControllerAPI;
|
|
|
+import com.template.common.utils.AesUtils;
|
|
|
+import com.template.model.pojo.WelcomeAccount;
|
|
|
+import com.template.model.pojo.WelcomeBed;
|
|
|
+import com.template.model.pojo.WelcomeOrg;
|
|
|
+import com.template.model.pojo.WelcomeRole;
|
|
|
+import com.template.model.request.loginRequest;
|
|
|
+import com.template.model.result.CommonResult;
|
|
|
+import com.template.model.result.PageUtils;
|
|
|
+import com.template.model.vo.WelcomeAccountVo;
|
|
|
+import com.template.services.WelcomeAccountService;
|
|
|
+import com.template.services.WelcomeOrgService;
|
|
|
+import com.template.services.WelcomeRoleService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 前端控制器
|
|
|
@@ -14,7 +33,83 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
* @since 2025-06-13
|
|
|
*/
|
|
|
@RestController
|
|
|
-public class WelcomeAccountController {
|
|
|
+public class WelcomeAccountController implements WelcomeAccountControllerAPI {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WelcomeAccountService welcomeAccountService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WelcomeOrgService welcomeOrgService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ WelcomeRoleService welcomeRoleService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult saveAccount(WelcomeAccount welcomeAccount) {
|
|
|
+ String account = welcomeAccount.getAccount();
|
|
|
+// 将密码加密
|
|
|
+ String password = welcomeAccount.getPassword();
|
|
|
+ String encPassword = AesUtils.encrypt(password);
|
|
|
+ welcomeAccount.setPassword(encPassword);
|
|
|
+ WelcomeAccount dataByAccount = welcomeAccountService.getDataByAccount(account);
|
|
|
+ if (ObjectUtils.isNotEmpty(dataByAccount)) {
|
|
|
+ return CommonResult.fail("已存在该账号");
|
|
|
+ }
|
|
|
+ welcomeAccountService.insertWelcomeAccount(welcomeAccount);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult deleteAccount(Integer accountId) {
|
|
|
+ welcomeAccountService.removeById(accountId);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult updateAccount(WelcomeAccount welcomeAccount) {
|
|
|
+ String account = welcomeAccount.getAccount();
|
|
|
+ // 将密码加密
|
|
|
+ String password = welcomeAccount.getPassword();
|
|
|
+ String encPassword = AesUtils.encrypt(password);
|
|
|
+ welcomeAccount.setPassword(encPassword);
|
|
|
+
|
|
|
+ WelcomeAccount dataByAccount = welcomeAccountService.getDataByAccount(account);
|
|
|
+ if (ObjectUtils.isNotEmpty(dataByAccount)) {
|
|
|
+ Integer id = dataByAccount.getId();
|
|
|
+ Integer id1 = welcomeAccount.getId();
|
|
|
+ if (!id.equals(id1)) {
|
|
|
+ return CommonResult.fail("已存在该账号");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ welcomeAccountService.updateWelcomeAccount(welcomeAccount);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult listAccount(int currentPage, int pageCount) {
|
|
|
+ PageUtils<WelcomeAccountVo> pageUtils= welcomeAccountService.listAccount(currentPage,pageCount);
|
|
|
+ List<WelcomeAccountVo> list = pageUtils.getList();
|
|
|
+ for (WelcomeAccountVo record : list) {
|
|
|
+ String collegeId = record.getCollegeId();
|
|
|
+ List<WelcomeOrg> checkOrgList= new ArrayList<>();
|
|
|
+ if (ObjectUtils.isNotEmpty(collegeId)) {
|
|
|
+ List<String> checkOrg= Arrays.asList(collegeId.split(","));
|
|
|
+ for(int i=0;i<checkOrg.size();i++){
|
|
|
+ WelcomeOrg welcomeOrg= welcomeOrgService.getById(checkOrg.get(i));
|
|
|
+ if (welcomeOrg!=null){
|
|
|
+ checkOrgList.add(welcomeOrg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setWelcomeOrgList(checkOrgList);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotEmpty(record.getRoleId())) {
|
|
|
+ WelcomeRole byId = welcomeRoleService.getById(record.getRoleId());
|
|
|
+ record.setWelcomeRole(byId);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ return CommonResult.ok(pageUtils);
|
|
|
+ }
|
|
|
}
|
|
|
|