diff --git a/admin/src/views/account/login.vue b/admin/src/views/account/login.vue index 20d066d5..2ff85c41 100644 --- a/admin/src/views/account/login.vue +++ b/admin/src/views/account/login.vue @@ -45,6 +45,27 @@ + +
+
+ +
+
+
@@ -59,6 +80,7 @@ import LayoutFooter from '@/layout/components/footer.vue' import useAppStore from '@/stores/modules/app' import useUserStore from '@/stores/modules/user' import cache from '@/utils/cache' +import UserSetting from '@/views/user/setting.vue' const passwordRef = shallowRef() const formRef = shallowRef() @@ -67,6 +89,7 @@ const userStore = useUserStore() const route = useRoute() const router = useRouter() const remAccount = ref(false) +const showForceChangePwd = ref(false) const config = computed(() => appStore.config) const formData = reactive({ account: '', @@ -104,14 +127,27 @@ const handleLogin = async () => { account: remAccount.value ? formData.account : '' }) await userStore.login(formData) - const { - query: { redirect } - } = route - const path = typeof redirect === 'string' ? redirect : PageEnum.INDEX - router.push(path) + const userInfo = await userStore.getUserInfo() + console.log('userInfo', userInfo) + // 检查是否首次登录 + if (userInfo?.first_login === 1 || userInfo?.user?.first_login === 1) { + showForceChangePwd.value = true + return + } + window.location.href = '/workbench' } const { isLock, lockFn: lockLogin } = useLockFn(handleLogin) +const handleForcePwdSuccess = async () => { + showForceChangePwd.value = false + window.location.href = '/workbench' +} + +const handleForcePwdCancel = async () => { + await userStore.logout() + showForceChangePwd.value = false +} + onMounted(() => { const value = cache.get(ACCOUNT_KEY) if (value?.remember) { diff --git a/admin/src/views/user/setting.vue b/admin/src/views/user/setting.vue index be75d14c..2312c61e 100644 --- a/admin/src/views/user/setting.vue +++ b/admin/src/views/user/setting.vue @@ -9,23 +9,23 @@ :rules="rules" label-width="100px" > - + - +
- +
- +
- + 保存 +
+ 取消 + 保存 +
@@ -72,6 +76,16 @@ import { setUserInfo } from '@/api/user' import useUserStore from '@/stores/modules/user' import feedback from '@/utils/feedback' +const props = defineProps<{ + isFirstLogin?: boolean + tempPassword?: string +}>() + +const emit = defineEmits<{ + (event: 'success'): void + (event: 'cancel'): void +}>() + const formRef = ref() const userStore = useUserStore() // 表单数据 @@ -109,6 +123,10 @@ const getUser = async () => { //@ts-ignore formData[key] = userInfo[key] } + // 如果是首次登录强制修改密码,自动填充旧密码 + if (props.isFirstLogin && props.tempPassword) { + formData.password_old = props.tempPassword + } } // 设置个人设置 @@ -143,7 +161,11 @@ const setUser = async () => { } } await setUserInfo(formData) - userStore.getUserInfo() + await userStore.getUserInfo() + if (props.isFirstLogin) { + feedback.msgSuccess('修改成功') + emit('success') + } } // 提交数据 diff --git a/server/like-admin/src/main/java/com/mdd/admin/controller/adminapi/auth/AdminController.java b/server/like-admin/src/main/java/com/mdd/admin/controller/adminapi/auth/AdminController.java index 3e446f31..31f22233 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/controller/adminapi/auth/AdminController.java +++ b/server/like-admin/src/main/java/com/mdd/admin/controller/adminapi/auth/AdminController.java @@ -4,6 +4,8 @@ import com.mdd.admin.LikeAdminThreadLocal; import com.mdd.admin.service.IIndexService; import com.mdd.admin.service.admin.IAdminRoleService; import com.mdd.admin.service.admin.IAdminService; +import com.mdd.admin.validate.system.SystemAdminUpInfoValidate; +import com.mdd.admin.validate.system.SystemEditSelfValidate; import com.mdd.admin.vo.auth.AdminMySelfVo; import com.mdd.common.aop.NotLogin; import com.mdd.common.aop.NotPower; @@ -11,9 +13,9 @@ import com.mdd.common.core.AjaxResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.checkerframework.checker.units.qual.A; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -31,6 +33,9 @@ public class AdminController { @Resource IAdminRoleService iAdminRoleService; + @Resource + IAdminService iSystemAuthAdminService; + @NotPower @GetMapping("/mySelf") @ApiOperation(value="获取当前管理员信息") @@ -43,4 +48,11 @@ public class AdminController { return AjaxResult.success(mySelf); } + @PostMapping("/editSelf") + @ApiOperation(value = "编辑当前管理员信息") + public AjaxResult editSelf(@Validated @RequestBody SystemEditSelfValidate upInfoValidate) { + Integer adminId = LikeAdminThreadLocal.getAdminId(); + iAdminService.editSelf(upInfoValidate, adminId); + return AjaxResult.success(); + } } diff --git a/server/like-admin/src/main/java/com/mdd/admin/service/admin/IAdminService.java b/server/like-admin/src/main/java/com/mdd/admin/service/admin/IAdminService.java index bccb9658..6997c15c 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/service/admin/IAdminService.java +++ b/server/like-admin/src/main/java/com/mdd/admin/service/admin/IAdminService.java @@ -2,10 +2,7 @@ package com.mdd.admin.service.admin; import com.alibaba.fastjson2.JSONObject; import com.mdd.admin.validate.commons.PageValidate; -import com.mdd.admin.validate.system.SystemAdminCreateValidate; -import com.mdd.admin.validate.system.SystemAdminSearchValidate; -import com.mdd.admin.validate.system.SystemAdminUpInfoValidate; -import com.mdd.admin.validate.system.SystemAdminUpdateValidate; +import com.mdd.admin.validate.system.*; import com.mdd.admin.vo.auth.AdminMySelfVo; import com.mdd.admin.vo.system.SystemAuthAdminDetailVo; import com.mdd.admin.vo.system.SystemAuthAdminListedVo; @@ -106,4 +103,9 @@ public interface IAdminService { * 导出 */ String export(SystemAdminSearchValidate searchValidate); + + /** + * 编辑自己信息 + */ + void editSelf(SystemEditSelfValidate upInfoValidate, Integer adminId); } diff --git a/server/like-admin/src/main/java/com/mdd/admin/service/impl/admin/AdminServiceImpl.java b/server/like-admin/src/main/java/com/mdd/admin/service/impl/admin/AdminServiceImpl.java index 873ca3eb..f1f2eaeb 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/service/impl/admin/AdminServiceImpl.java +++ b/server/like-admin/src/main/java/com/mdd/admin/service/impl/admin/AdminServiceImpl.java @@ -13,10 +13,7 @@ import com.mdd.admin.service.admin.*; import com.mdd.admin.service.system.ISystemMenuService; import com.mdd.admin.service.system.ISystemRoleMenuService; import com.mdd.admin.validate.commons.PageValidate; -import com.mdd.admin.validate.system.SystemAdminCreateValidate; -import com.mdd.admin.validate.system.SystemAdminSearchValidate; -import com.mdd.admin.validate.system.SystemAdminUpInfoValidate; -import com.mdd.admin.validate.system.SystemAdminUpdateValidate; +import com.mdd.admin.validate.system.*; import com.mdd.admin.validate.user.UserSearchValidate; import com.mdd.admin.vo.auth.AdminMySelfVo; import com.mdd.admin.vo.auth.AuthMySelfVo; @@ -38,6 +35,7 @@ import com.mdd.common.mapper.system.SystemRoleMapper; import com.mdd.common.util.*; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.File; @@ -83,13 +81,14 @@ public class AdminServiceImpl implements IAdminService { * 管理员列表 * * @author fzr - * @param pageValidate 分页参数 + * @param pageValidate 分页参数 * @param searchValidate 搜索参数 * @return PageResult */ @Override - public PageResult list(PageValidate pageValidate, SystemAdminSearchValidate searchValidate) { - Integer page = pageValidate.getPage_no(); + public PageResult list(PageValidate pageValidate, + SystemAdminSearchValidate searchValidate) { + Integer page = pageValidate.getPage_no(); Integer limit = pageValidate.getPage_size(); MPJQueryWrapper mpjQueryWrapper = new MPJQueryWrapper<>(); @@ -97,11 +96,10 @@ public class AdminServiceImpl implements IAdminService { "t.multipoint_login," + "t.disable,t.login_ip,t.login_time,t.create_time,t.update_time") .leftJoin("la_admin_role lar ON lar.admin_id = t.id") - .isNull("t.delete_time") - .orderByDesc(Arrays.asList("t.id")); + .isNull("t.delete_time") + .orderByDesc(Arrays.asList("t.id")); - - systemAuthAdminMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{ + systemAuthAdminMapper.setSearch(mpjQueryWrapper, searchValidate, new String[] { "like:account:str", "like:name:str" }); @@ -125,7 +123,7 @@ public class AdminServiceImpl implements IAdminService { List roleIds = new ArrayList<>(); List roleNames = new ArrayList<>(); if (!roles.isEmpty()) { - roles.forEach(item-> { + roles.forEach(item -> { roleIds.add(item.getId()); roleNames.add(item.getName()); @@ -134,12 +132,11 @@ public class AdminServiceImpl implements IAdminService { vo.setRoleName(StringUtils.join(roleNames, ",")); } - List jobs = jobsMapper.getByAdminId(vo.getId()); List jobsId = new ArrayList<>(); List jobsNames = new ArrayList<>(); if (!jobs.isEmpty()) { - jobs.forEach(item-> { + jobs.forEach(item -> { jobsId.add(item.getId()); jobsNames.add(item.getName()); }); @@ -147,12 +144,11 @@ public class AdminServiceImpl implements IAdminService { vo.setJobsName(StringUtils.join(jobsNames, ",")); } - List depts = deptMapper.getByAdminId(vo.getId()); List deptIds = new ArrayList<>(); List deptNames = new ArrayList<>(); if (!depts.isEmpty()) { - depts.forEach(item-> { + depts.forEach(item -> { deptIds.add(item.getId()); deptNames.add(item.getName()); }); @@ -162,7 +158,6 @@ public class AdminServiceImpl implements IAdminService { } } - vo.setDisableDesc(vo.getDisable() != null && vo.getDisable().equals(0) ? "启用" : "禁用"); vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(vo.getAvatar())); vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime())); @@ -184,9 +179,8 @@ public class AdminServiceImpl implements IAdminService { public SystemAuthAdminSelvesVo self(Integer adminId) { // 管理员信息 Admin sysAdmin = systemAuthAdminMapper.selectOne(new QueryWrapper() - .select(Admin.class, info-> - !info.getColumn().equals("password") && - !info.getColumn().equals("delete_time")) + .select(Admin.class, info -> !info.getColumn().equals("password") && + !info.getColumn().equals("delete_time")) .isNull("delete_time") .eq("id", adminId) .last("limit 1")); @@ -258,6 +252,7 @@ public class AdminServiceImpl implements IAdminService { vo.setRoleId(iAdminRoleService.getRoleIdAttr(sysAdmin.getId())); vo.setJobsId(iAdminJobsService.getJobIdAttr(sysAdmin.getId())); vo.setDeptId(iAdminDeptService.getDeptIdAttr(sysAdmin.getId())); + vo.setFirstLogin(sysAdmin.getFirstLogin()); return vo; } @@ -269,7 +264,7 @@ public class AdminServiceImpl implements IAdminService { */ @Override public void add(SystemAdminCreateValidate createValidate) { - String[] field = {"id", "account", "name"}; + String[] field = { "id", "account", "name" }; Assert.isNull(systemAuthAdminMapper.selectOne(new QueryWrapper() .select(field) .isNull("delete_time") @@ -282,11 +277,12 @@ public class AdminServiceImpl implements IAdminService { .eq("name", createValidate.getName()) .last("limit 1")), "昵称已存在换一个吧!"); - String pwd = ToolUtils.makePassword(createValidate.getPassword().trim()); + String pwd = ToolUtils.makePassword(createValidate.getPassword().trim()); - String createAvatar = createValidate.getAvatar(); + String createAvatar = createValidate.getAvatar(); String defaultAvatar = "/api/static/backend_avatar.png"; - String avatar = StringUtils.isNotEmpty(createValidate.getAvatar()) ? UrlUtils.toRelativeUrl(createAvatar) : defaultAvatar; + String avatar = StringUtils.isNotEmpty(createValidate.getAvatar()) ? UrlUtils.toRelativeUrl(createAvatar) + : defaultAvatar; Admin model = new Admin(); model.setAccount(createValidate.getAccount()); @@ -316,7 +312,7 @@ public class AdminServiceImpl implements IAdminService { * * @author fzr * @param updateValidate 参数 - * @param adminId 管理员ID + * @param adminId 管理员ID */ @Override public void edit(SystemAdminUpdateValidate updateValidate, Integer adminId) { @@ -329,8 +325,7 @@ public class AdminServiceImpl implements IAdminService { isEditInfo = true; } - - String[] field = {"id", "account", "name"}; + String[] field = { "id", "account", "name" }; Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper() .select(field) .eq("id", updateValidate.getId()) @@ -351,7 +346,8 @@ public class AdminServiceImpl implements IAdminService { .ne("id", updateValidate.getId()) .last("limit 1")), "昵称已存在换一个吧!"); - Admin admin = systemAuthAdminMapper.selectOne(new QueryWrapper().eq("id", updateValidate.getId()).isNull("delete_time")); + Admin admin = systemAuthAdminMapper + .selectOne(new QueryWrapper().eq("id", updateValidate.getId()).isNull("delete_time")); if (admin.getRoot().equals(1) && updateValidate.getDisable().equals(1)) { throw new OperateException("超级管理员不能设为停用"); @@ -372,7 +368,8 @@ public class AdminServiceImpl implements IAdminService { model.setAccount(updateValidate.getAccount()); } - if (StringUtils.isNotNull(updateValidate.getPassword()) && StringUtils.isNotEmpty(updateValidate.getPassword())) { + if (StringUtils.isNotNull(updateValidate.getPassword()) + && StringUtils.isNotEmpty(updateValidate.getPassword())) { String pwd = ToolUtils.makePassword(updateValidate.getPassword().trim()); model.setPassword(pwd); } @@ -384,7 +381,8 @@ public class AdminServiceImpl implements IAdminService { if (isEditInfo) { - if (StringUtils.isNotNull(updateValidate.getPassword()) && StringUtils.isNotEmpty(updateValidate.getPassword())) { + if (StringUtils.isNotNull(updateValidate.getPassword()) + && StringUtils.isNotEmpty(updateValidate.getPassword())) { StpUtil.kickout(updateValidate.getId()); } @@ -399,8 +397,6 @@ public class AdminServiceImpl implements IAdminService { this.iAdminRoleService.batchInsert(updateValidate.getId(), roleIds); } - - } /** @@ -419,26 +415,29 @@ public class AdminServiceImpl implements IAdminService { Assert.notNull(model, "账号不存在了!"); - String createAvatar = upInfoValidate.getAvatar(); + String createAvatar = upInfoValidate.getAvatar(); String defaultAvatar = "/api/static/backend_avatar.png"; - String avatar = StringUtils.isNotEmpty(upInfoValidate.getAvatar()) ? UrlUtils.toRelativeUrl(createAvatar) : defaultAvatar; + String avatar = StringUtils.isNotEmpty(upInfoValidate.getAvatar()) ? UrlUtils.toRelativeUrl(createAvatar) + : defaultAvatar; model.setAvatar(avatar); model.setName(upInfoValidate.getNickname()); model.setUpdateTime(System.currentTimeMillis() / 1000); - if (StringUtils.isNotNull(upInfoValidate.getPassword()) && StringUtils.isNotEmpty(upInfoValidate.getPassword())) { + if (StringUtils.isNotNull(upInfoValidate.getPassword()) + && StringUtils.isNotEmpty(upInfoValidate.getPassword())) { String currPassword = ToolUtils.makePassword(upInfoValidate.getCurrPassword()); Assert.isFalse(!currPassword.equals(model.getPassword()), "当前密码不正确!"); if (upInfoValidate.getPassword().length() > 64) { throw new OperateException("密码不能超出64个字符"); } - String pwd = ToolUtils.makePassword( upInfoValidate.getPassword().trim()); + String pwd = ToolUtils.makePassword(upInfoValidate.getPassword().trim()); model.setPassword(pwd); } systemAuthAdminMapper.updateById(model); - if (StringUtils.isNotNull(upInfoValidate.getPassword()) && StringUtils.isNotEmpty(upInfoValidate.getPassword())) { + if (StringUtils.isNotNull(upInfoValidate.getPassword()) + && StringUtils.isNotEmpty(upInfoValidate.getPassword())) { StpUtil.kickout(adminId); } } @@ -447,12 +446,12 @@ public class AdminServiceImpl implements IAdminService { * 管理员删除 * * @author fzr - * @param id 主键 + * @param id 主键 * @param adminId 管理员ID */ @Override public void del(Integer id, Integer adminId) { - String[] field = {"id", "account", "name"}; + String[] field = { "id", "account", "name" }; Assert.notNull(systemAuthAdminMapper.selectOne(new QueryWrapper() .select(field) .eq("id", id) @@ -460,7 +459,7 @@ public class AdminServiceImpl implements IAdminService { .last("limit 1")), "账号已不存在!"); Assert.isFalse(id.equals(1), "系统管理员不允许删除!"); - Assert.isFalse(id.equals(adminId) , "不能删除自己!"); + Assert.isFalse(id.equals(adminId), "不能删除自己!"); Admin model = new Admin(); model.setId(id); @@ -477,7 +476,7 @@ public class AdminServiceImpl implements IAdminService { * 管理员状态切换 * * @author fzr - * @param id 主键参数 + * @param id 主键参数 * @param adminId 管理员ID */ @Override @@ -489,7 +488,7 @@ public class AdminServiceImpl implements IAdminService { .last("limit 1")); Assert.notNull(systemAuthAdmin, "账号已不存在!"); - Assert.isFalse(id.equals(adminId) , "不能禁用自己!"); + Assert.isFalse(id.equals(adminId), "不能禁用自己!"); Integer disable = systemAuthAdmin.getDisable() == 1 ? 0 : 1; systemAuthAdmin.setDisable(disable); @@ -515,15 +514,18 @@ public class AdminServiceImpl implements IAdminService { user.setJobsId(admin.getJobsId()); user.setRoleId(admin.getRoleId()); ret.setUser(user); + + ret.setFirstLogin(admin.getFirstLogin()); return ret; } @Override public JSONObject getExportData(PageValidate pageValidate, SystemAdminSearchValidate searchValidate) { - Integer page = pageValidate.getPage_no(); + Integer page = pageValidate.getPage_no(); Integer limit = pageValidate.getPage_size(); PageResult userVoPageResult = this.list(pageValidate, searchValidate); - JSONObject ret = ToolUtils.getExportData(userVoPageResult.getCount(), limit, searchValidate.getPage_start(), searchValidate.getPage_end(),"管理员记录列表"); + JSONObject ret = ToolUtils.getExportData(userVoPageResult.getCount(), limit, searchValidate.getPage_start(), + searchValidate.getPage_end(), "管理员记录列表"); return ret; } @@ -536,17 +538,21 @@ public class AdminServiceImpl implements IAdminService { pageValidate.setPage_no(1); } - if (StringUtils.isNotNull(searchValidate.getPage_end()) && StringUtils.isNotNull(searchValidate.getPage_size())) { + if (StringUtils.isNotNull(searchValidate.getPage_end()) + && StringUtils.isNotNull(searchValidate.getPage_size())) { pageValidate.setPage_size(searchValidate.getPage_end() * searchValidate.getPage_size()); } else { pageValidate.setPage_size(20); } - Boolean isAll = StringUtils.isNull(searchValidate.getPage_type()) || searchValidate.getPage_type().equals(0) ? true : false; + Boolean isAll = StringUtils.isNull(searchValidate.getPage_type()) || searchValidate.getPage_type().equals(0) + ? true + : false; List excellist = this.getExcellist(isAll, pageValidate, searchValidate); - String fileName = StringUtils.isNull(searchValidate.getFile_name()) ? ToolUtils.makeUUID() : searchValidate.getFile_name(); - String folderPath = "/excel/export/"+ TimeUtils.timestampToDay(System.currentTimeMillis() / 1000) +"/" ; - String path = folderPath + fileName +".xlsx"; - String filePath = YmlUtils.get("like.upload-directory") + path; + String fileName = StringUtils.isNull(searchValidate.getFile_name()) ? ToolUtils.makeUUID() + : searchValidate.getFile_name(); + String folderPath = "/excel/export/" + TimeUtils.timestampToDay(System.currentTimeMillis() / 1000) + "/"; + String path = folderPath + fileName + ".xlsx"; + String filePath = YmlUtils.get("like.upload-directory") + path; File folder = new File(YmlUtils.get("like.upload-directory") + folderPath); if (!folder.exists()) { if (!folder.mkdirs()) { @@ -561,20 +567,80 @@ public class AdminServiceImpl implements IAdminService { return UrlUtils.toAdminAbsoluteUrl(path); } - private List getExcellist(boolean isAll, PageValidate pageValidate, SystemAdminSearchValidate searchValidate) { - Integer page = pageValidate.getPage_no(); + @Override + @Transactional + public void editSelf(SystemEditSelfValidate updateValidate, Integer adminId) { + Admin model = systemAuthAdminMapper.selectOne(new QueryWrapper() + .eq("id", adminId) + .isNull("delete_time") + .last("limit 1")); + model.setName(updateValidate.getName()); + model.setAvatar(UrlUtils.toRelativeUrl(updateValidate.getAvatar())); + model.setUpdateTime(System.currentTimeMillis() / 1000); + + if (StringUtils.isNotNull(updateValidate.getPassword()) + && StringUtils.isNotEmpty(updateValidate.getPassword())) { + String newPassword = updateValidate.getPassword().trim(); + if (StringUtils.isNotEmpty(newPassword)) { + this.validatePassword(newPassword); + String pwd = ToolUtils.makePassword(newPassword); + model.setPassword(pwd); + } + } + + model.setFirstLogin(0); + systemAuthAdminMapper.updateById(model); + } + + /** + * 校验密码强度 + * + * @author damonyuan + * @date 2025-12-26 + * @param password 密码 + */ + private void validatePassword(String password) { + if (password.length() < 8) { + throw new OperateException("密码长度不能少于8位"); + } + + int count = 0; + // 大写字母 + if (password.matches(".*[A-Z].*")) { + count++; + } + // 小写字母 + if (password.matches(".*[a-z].*")) { + count++; + } + // 数字 + if (password.matches(".*[0-9].*")) { + count++; + } + // 特殊符号 + if (password.matches(".*[^a-zA-Z0-9].*")) { + count++; + } + + if (count < 3) { + throw new OperateException("密码必须包含大小写字母、数字、特殊符号中的至少3种"); + } + } + + private List getExcellist(boolean isAll, PageValidate pageValidate, + SystemAdminSearchValidate searchValidate) { + Integer page = pageValidate.getPage_no(); Integer limit = pageValidate.getPage_size(); MPJQueryWrapper mpjQueryWrapper = new MPJQueryWrapper<>(); mpjQueryWrapper.select("distinct t.id,t.account,t.name,t.avatar," + - "t.multipoint_login," + - "t.disable,t.login_ip,t.login_time,t.create_time,t.update_time") + "t.multipoint_login," + + "t.disable,t.login_ip,t.login_time,t.create_time,t.update_time") .leftJoin("la_admin_role lar ON lar.admin_id = t.id") .isNull("t.delete_time") .orderByDesc(Arrays.asList("t.id")); - - systemAuthAdminMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{ + systemAuthAdminMapper.setSearch(mpjQueryWrapper, searchValidate, new String[] { "like:account:str", "like:name:str" }); @@ -604,7 +670,7 @@ public class AdminServiceImpl implements IAdminService { List roleIds = new ArrayList<>(); List roleNames = new ArrayList<>(); if (!roles.isEmpty()) { - roles.forEach(item-> { + roles.forEach(item -> { roleIds.add(item.getId()); roleNames.add(item.getName()); @@ -613,12 +679,11 @@ public class AdminServiceImpl implements IAdminService { vo.setRoleName(StringUtils.join(roleNames, ",")); } - List jobs = jobsMapper.getByAdminId(vo.getId()); List jobsId = new ArrayList<>(); List jobsNames = new ArrayList<>(); if (!jobs.isEmpty()) { - jobs.forEach(item-> { + jobs.forEach(item -> { jobsId.add(item.getId()); jobsNames.add(item.getName()); }); @@ -626,12 +691,11 @@ public class AdminServiceImpl implements IAdminService { vo.setJobsName(StringUtils.join(jobsNames, ",")); } - List depts = deptMapper.getByAdminId(vo.getId()); List deptIds = new ArrayList<>(); List deptNames = new ArrayList<>(); if (!depts.isEmpty()) { - depts.forEach(item-> { + depts.forEach(item -> { deptIds.add(item.getId()); deptNames.add(item.getName()); }); @@ -641,7 +705,6 @@ public class AdminServiceImpl implements IAdminService { } } - vo.setDisableDesc(vo.getDisable() != null && vo.getDisable().equals(0) ? "启用" : "禁用"); vo.setAvatar(UrlUtils.toAdminAbsoluteUrl(vo.getAvatar())); vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime())); diff --git a/server/like-admin/src/main/java/com/mdd/admin/validate/system/SystemEditSelfValidate.java b/server/like-admin/src/main/java/com/mdd/admin/validate/system/SystemEditSelfValidate.java new file mode 100644 index 00000000..d313a79d --- /dev/null +++ b/server/like-admin/src/main/java/com/mdd/admin/validate/system/SystemEditSelfValidate.java @@ -0,0 +1,40 @@ +package com.mdd.admin.validate.system; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotEmpty; +import java.io.Serializable; + +@Data +@ApiModel("系统管理员自更新参数") +public class SystemEditSelfValidate implements Serializable { + + private static final long serialVersionUID = 1L; + + @NotEmpty(message = "昵称不能为空") + @Length(min = 2, max = 30, message = "昵称必须在2~30个字符内") + @ApiModelProperty(value = "用户昵称") + private String account; + + @NotEmpty(message = "昵称不能为空") + @Length(min = 2, max = 30, message = "昵称必须在2~30个字符内") + @ApiModelProperty(value = "用户昵称") + private String name; + + @Length(max = 200, message = "头像不能超出200个字符") + private String avatar = ""; + + @Length(max = 64, message = "密码必须在6~32个字符内") + private String password=""; + + @Length(max = 64, message = "当前密码错误") + private String password_confirm=""; + + @Length(max = 64, message = "旧密码错误") + private String password_old; + + +} diff --git a/server/like-admin/src/main/java/com/mdd/admin/vo/auth/AdminMySelfVo.java b/server/like-admin/src/main/java/com/mdd/admin/vo/auth/AdminMySelfVo.java index 9e08c01f..f3a8ba43 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/vo/auth/AdminMySelfVo.java +++ b/server/like-admin/src/main/java/com/mdd/admin/vo/auth/AdminMySelfVo.java @@ -2,6 +2,7 @@ package com.mdd.admin.vo.auth; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -23,4 +24,8 @@ public class AdminMySelfVo implements Serializable { @ApiModelProperty(value = "user") private AuthMySelfVo user; + + @ApiModelProperty(value = "是否初次登录") + @JsonProperty("first_login") + private Integer firstLogin; } diff --git a/server/like-admin/src/main/java/com/mdd/admin/vo/system/SystemAuthAdminDetailVo.java b/server/like-admin/src/main/java/com/mdd/admin/vo/system/SystemAuthAdminDetailVo.java index 18abeadb..9beb733d 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/vo/system/SystemAuthAdminDetailVo.java +++ b/server/like-admin/src/main/java/com/mdd/admin/vo/system/SystemAuthAdminDetailVo.java @@ -55,4 +55,7 @@ public class SystemAuthAdminDetailVo implements Serializable { @ApiModelProperty(value = "是否支持多处登录:1-是;0-否;") private Integer multipointLogin; + @ApiModelProperty(value = "是否为首次登录") + private Integer firstLogin; + } diff --git a/server/like-common/src/main/java/com/mdd/common/entity/admin/Admin.java b/server/like-common/src/main/java/com/mdd/common/entity/admin/Admin.java index 16c30bda..5c767286 100644 --- a/server/like-common/src/main/java/com/mdd/common/entity/admin/Admin.java +++ b/server/like-common/src/main/java/com/mdd/common/entity/admin/Admin.java @@ -54,4 +54,6 @@ public class Admin implements Serializable { @ApiModelProperty("删除时间") private Long deleteTime; + @ApiModelProperty("firstLogin") + private Integer firstLogin; } diff --git a/sql/install.sql b/sql/install.sql index f5ef2b72..4a0e1143 100644 --- a/sql/install.sql +++ b/sql/install.sql @@ -1216,3 +1216,6 @@ BEGIN; COMMIT; SET FOREIGN_KEY_CHECKS = 1; + +alter table la_admin add first_login int default 1 null comment '是否首次登录'; +