feat 增加首次登录强制重置密码的交互

This commit is contained in:
damonyuan
2025-12-26 12:09:58 +08:00
parent b96c67c02d
commit 155b437763
10 changed files with 268 additions and 80 deletions

View File

@@ -45,6 +45,27 @@
</div>
</div>
<layout-footer />
<el-dialog
v-model="showForceChangePwd"
title="首次登录必须修改密码"
width="600px"
center
:show-close="false"
:close-on-click-modal="false"
:close-on-press-escape="false"
append-to-body
>
<div class="flex justify-center items-center">
<div class="w-full">
<user-setting
:is-first-login="true"
:temp-password="formData.password"
@success="handleForcePwdSuccess"
@cancel="handleForcePwdCancel"
/>
</div>
</div>
</el-dialog>
</div>
</template>
@@ -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<InputInstance>()
const formRef = shallowRef<FormInstance>()
@@ -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) {

View File

@@ -9,23 +9,23 @@
:rules="rules"
label-width="100px"
>
<el-form-item label="头像:" prop="avatar">
<el-form-item label="头像:" prop="avatar" v-if="!isFirstLogin">
<material-picker v-model="formData.avatar" :limit="1" />
</el-form-item>
<el-form-item label="账号:" prop="account">
<el-form-item label="账号:" prop="account" v-if="!isFirstLogin">
<div class="w-80">
<el-input v-model="formData.account" disabled />
</div>
</el-form-item>
<el-form-item label="名称:" prop="name">
<el-form-item label="名称:" prop="name" v-if="!isFirstLogin">
<div class="w-80">
<el-input v-model="formData.name" placeholder="请输入名称" />
</div>
</el-form-item>
<el-form-item label="当前密码:" prop="password_old">
<el-form-item label="当前密码:" prop="password_old" v-if="!isFirstLogin">
<div class="w-80">
<el-input
v-model.trim="formData.password_old"
@@ -59,9 +59,13 @@
</el-form-item>
</el-form>
</el-card>
<footer-btns>
<footer-btns v-if="!isFirstLogin">
<el-button type="primary" @click="handleSubmit">保存</el-button>
</footer-btns>
<div v-else class="flex justify-center mt-4">
<el-button @click="emit('cancel')">取消</el-button>
<el-button type="primary" @click="handleSubmit">保存</el-button>
</div>
</div>
</template>
@@ -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<FormInstance>()
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')
}
}
// 提交数据

View File

@@ -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<Object> editSelf(@Validated @RequestBody SystemEditSelfValidate upInfoValidate) {
Integer adminId = LikeAdminThreadLocal.getAdminId();
iAdminService.editSelf(upInfoValidate, adminId);
return AjaxResult.success();
}
}

View File

@@ -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);
}

View File

@@ -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<SystemAuthAdminListedVo>
*/
@Override
public PageResult<SystemAuthAdminListedVo> list(PageValidate pageValidate, SystemAdminSearchValidate searchValidate) {
Integer page = pageValidate.getPage_no();
public PageResult<SystemAuthAdminListedVo> list(PageValidate pageValidate,
SystemAdminSearchValidate searchValidate) {
Integer page = pageValidate.getPage_no();
Integer limit = pageValidate.getPage_size();
MPJQueryWrapper<Admin> 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<Integer> roleIds = new ArrayList<>();
List<String> 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> jobs = jobsMapper.getByAdminId(vo.getId());
List<Integer> jobsId = new ArrayList<>();
List<String> 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<Dept> depts = deptMapper.getByAdminId(vo.getId());
List<Integer> deptIds = new ArrayList<>();
List<String> 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<Admin>()
.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<Admin>()
.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<Admin>()
.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<Admin>().eq("id", updateValidate.getId()).isNull("delete_time"));
Admin admin = systemAuthAdminMapper
.selectOne(new QueryWrapper<Admin>().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<Admin>()
.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<SystemAuthAdminListedVo> 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<SystemAuthAdminListedExportVo> 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<SystemAuthAdminListedExportVo> 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<Admin>()
.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<SystemAuthAdminListedExportVo> getExcellist(boolean isAll, PageValidate pageValidate,
SystemAdminSearchValidate searchValidate) {
Integer page = pageValidate.getPage_no();
Integer limit = pageValidate.getPage_size();
MPJQueryWrapper<Admin> 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<Integer> roleIds = new ArrayList<>();
List<String> 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> jobs = jobsMapper.getByAdminId(vo.getId());
List<Integer> jobsId = new ArrayList<>();
List<String> 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<Dept> depts = deptMapper.getByAdminId(vo.getId());
List<Integer> deptIds = new ArrayList<>();
List<String> 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()));

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -55,4 +55,7 @@ public class SystemAuthAdminDetailVo implements Serializable {
@ApiModelProperty(value = "是否支持多处登录1-是0-否;")
private Integer multipointLogin;
@ApiModelProperty(value = "是否为首次登录")
private Integer firstLogin;
}

View File

@@ -54,4 +54,6 @@ public class Admin implements Serializable {
@ApiModelProperty("删除时间")
private Long deleteTime;
@ApiModelProperty("firstLogin")
private Integer firstLogin;
}

View File

@@ -1216,3 +1216,6 @@ BEGIN;
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
alter table la_admin add first_login int default 1 null comment '是否首次登录';