From ca4b0fb1c4df771226d894a4e0f68fe28cc21d0d Mon Sep 17 00:00:00 2001 From: ggb <1223416496@qq.com> Date: Tue, 6 Jun 2023 23:32:32 +0800 Subject: [PATCH] Add employee name suffixes to work item information. Add password modification function. --- .../controller/permission/UserController.java | 17 ++--- Pinnacle/src/main/resources/application.yml | 9 ++- .../src/main/resources/mapper/WorkMapper.xml | 33 +++++++--- .../components/personalProfile/editPasswd.vue | 17 +++++ ui/src/components/work/DetailComponents.vue | 4 +- ui/src/components/work/EditWork.vue | 37 +++++------ ui/src/pages/profile/PersonalProfile.vue | 63 ++++++++++++++++--- ui/src/pages/work/Manage.vue | 46 +++++++++++--- 8 files changed, 171 insertions(+), 55 deletions(-) diff --git a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/permission/UserController.java b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/permission/UserController.java index 6884771..f6e855a 100644 --- a/Pinnacle/src/main/java/com/cfive/pinnacle/controller/permission/UserController.java +++ b/Pinnacle/src/main/java/com/cfive/pinnacle/controller/permission/UserController.java @@ -16,6 +16,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Map; /** *

@@ -44,15 +45,17 @@ public class UserController { @PutMapping("/passwd") @Operation(summary = "修改密码") - public ResponseResult modifyPasswd(String oldPasswd, String newPassword) { - if (oldPasswd == null || newPassword == null) { + public ResponseResult modifyPasswd(@RequestBody Map passwd) { + String oldPasswd = passwd.get("oldPasswd"); + String newPasswd = passwd.get("newPasswd"); + if (oldPasswd == null || newPasswd == null) { throw new DataValidationFailedException(); } - newPassword = newPassword.trim(); - if (oldPasswd.isBlank() || oldPasswd.length() < 8 || oldPasswd.length() > 64 || newPassword.isBlank() || newPassword.length() < 8 || newPassword.length() > 64) { + newPasswd = newPasswd.trim(); + if (oldPasswd.isBlank() || newPasswd.isBlank() || newPasswd.length() < 8 || newPasswd.length() > 64) { throw new DataValidationFailedException(); } - if (userService.modifyPasswd(oldPasswd, newPassword)) { + if (userService.modifyPasswd(oldPasswd, newPasswd)) { return ResponseResult.databaseUpdateSuccess(null); } else { return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "error", null); @@ -70,14 +73,14 @@ public class UserController { @PreAuthorize("hasAnyAuthority('work:manage:add', 'work:admin:add', 'attendance:manage:modify')") @Operation(summary = "获取同部门下所有用户") public ResponseResult> getDepartmentUser() { - return ResponseResult.databaseSaveSuccess(userService.getDepartmentUser()); + return ResponseResult.databaseSelectSuccess(userService.getDepartmentUser()); } @GetMapping("/notice") @PreAuthorize("hasAuthority('notice:manage:get')") @Operation(summary = "获取拥有发布公告权限的用户") public ResponseResult> getNoticeUser() { - return ResponseResult.databaseSaveSuccess(userService.getNoticeUser()); + return ResponseResult.databaseSelectSuccess(userService.getNoticeUser()); } @GetMapping diff --git a/Pinnacle/src/main/resources/application.yml b/Pinnacle/src/main/resources/application.yml index 45d886a..52b1492 100644 --- a/Pinnacle/src/main/resources/application.yml +++ b/Pinnacle/src/main/resources/application.yml @@ -1,6 +1,5 @@ server: port: 8621 - spring: datasource: type: com.alibaba.druid.pool.DruidDataSource @@ -16,4 +15,10 @@ mybatis-plus: logic-not-delete-value: 0 logic-delete-value: id id-type: assign_id - type-aliases-package: com.cfive.pinnacle.entity \ No newline at end of file + type-aliases-package: com.cfive.pinnacle.entity + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +logging: + level: + root: debug \ No newline at end of file diff --git a/Pinnacle/src/main/resources/mapper/WorkMapper.xml b/Pinnacle/src/main/resources/mapper/WorkMapper.xml index e21f21a..9d212b6 100644 --- a/Pinnacle/src/main/resources/mapper/WorkMapper.xml +++ b/Pinnacle/src/main/resources/mapper/WorkMapper.xml @@ -12,10 +12,15 @@ - - - - + + + + + + + + + diff --git a/ui/src/components/personalProfile/editPasswd.vue b/ui/src/components/personalProfile/editPasswd.vue index 331e1b4..62f641d 100644 --- a/ui/src/components/personalProfile/editPasswd.vue +++ b/ui/src/components/personalProfile/editPasswd.vue @@ -23,6 +23,7 @@ diff --git a/ui/src/pages/profile/PersonalProfile.vue b/ui/src/pages/profile/PersonalProfile.vue index c82baa8..832b079 100644 --- a/ui/src/pages/profile/PersonalProfile.vue +++ b/ui/src/pages/profile/PersonalProfile.vue @@ -7,12 +7,12 @@ - + - + @@ -57,13 +57,13 @@ - + - + - + 重置 @@ -89,7 +89,11 @@ import _ from 'lodash' import request from '@/services' import { ElMessage } from 'element-plus' import { requestUser } from '@/utils/auth' -import { DATABASE_SELECT_OK, DATABASE_UPDATE_OK } from '@/constants/Common.constants' +import { + DATABASE_SELECT_OK, + DATABASE_UPDATE_OK, + OLD_PASSWORD_NOT_MATCH +} from '@/constants/Common.constants' export default { data() { @@ -148,7 +152,9 @@ export default { required: true, message: '请选择性别' } - ] + ], + email: [{ validator: this.checkEmail }], + tel: [{ validator: this.checkTel }] }, visible: false } @@ -203,10 +209,51 @@ export default { this.form = _.cloneDeep(this.staff) }, updatePasswd(passwdForm) { - this.visible = false + request + .put('/user/passwd', { + oldPasswd: passwdForm.oldPasswd, + newPasswd: passwdForm.newPasswd + }) + .then(async (res) => { + const response = res.data + if (response.code === DATABASE_UPDATE_OK) { + ElMessage({ + message: '修改成功', + type: 'success' + }) + this.visible = false + } else if (response.code === OLD_PASSWORD_NOT_MATCH) { + ElMessage({ + message: '旧密码错误,修改失败,请重试', + type: 'error' + }) + } else { + ElMessage({ + message: '系统错误,修改失败', + type: 'error' + }) + } + }) }, cancelPasswd() { this.visible = false + }, + checkEmail(rule, value, callback) { + const mailReg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/ + if (mailReg.test(value)) { + callback() + } else { + return callback(new Error('邮箱格式错误!')) + } + }, + checkTel(rule, value, callback) { + const telReg = + /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ + if (telReg.test(value)) { + callback() + } else { + return callback(new Error('手机号格式错误!')) + } } }, created() { diff --git a/ui/src/pages/work/Manage.vue b/ui/src/pages/work/Manage.vue index ac04d57..d0cfd2d 100644 --- a/ui/src/pages/work/Manage.vue +++ b/ui/src/pages/work/Manage.vue @@ -37,7 +37,13 @@ round style="margin-right: 10px" > - {{ item.username }} + {{ + item.staff.lastName + + item.staff.firstName + + '(' + + item.username + + ')' + }} @@ -77,12 +83,27 @@ - - + + - + @@ -110,7 +131,8 @@ export default { addVisible: false, editVisible: false, loading: true, - searchContent: '' + searchContent: '', + workers: [] } }, methods: { @@ -198,7 +220,7 @@ export default { return new Date(time).toLocaleString() }, searchByContent() { - request.get('/work', { content: this.searchContent }).then((res) => { + request.get('/work', { content: this.searchContent.trim() }).then((res) => { const response = res.data if (response.code === DATABASE_SELECT_OK) { this.tableData = response.data @@ -212,10 +234,20 @@ export default { }) } }) + }, + getWorkers() { + request.get('/user/department').then((res) => { + const response = res.data + if (response.code === DATABASE_SELECT_OK) { + this.workers = response.data + console.log(this.workers) + } + }) } }, - created() { + mounted() { this.getTableData() + this.getWorkers() }, components: { EditWork