diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/dao/SysUser.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/dao/SysUser.java index 937f366..0536fb8 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/dao/SysUser.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/dao/SysUser.java @@ -1,5 +1,6 @@ package org.nl.system.service.user.dao; +import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -106,6 +107,7 @@ public class SysUser implements Serializable { * 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JSONField(format = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java index a9f181d..8e3caf0 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java @@ -6,13 +6,18 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.SneakyThrows; +import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.beanutils.Converter; +import org.apache.commons.beanutils.converters.DateConverter; import org.apache.commons.lang3.StringUtils; import org.nl.common.domain.query.PageQuery; import org.nl.modules.common.config.FileProperties; import org.nl.modules.common.utils.FileUtil; import org.nl.modules.common.utils.SecurityUtils; +import org.nl.modules.system.domain.Dept; import org.nl.modules.tools.IdUtil; import org.nl.system.service.dept.ISysDeptService; +import org.nl.system.service.dept.dao.SysDept; import org.nl.system.service.dept.dao.mapper.SysDeptMapper; import org.nl.system.service.role.ISysRoleService; import org.nl.system.service.role.dao.SysRole; @@ -30,7 +35,10 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import java.io.File; +import java.text.SimpleDateFormat; import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** *

@@ -104,18 +112,32 @@ public class ISysUserServiceImpl extends ServiceImpl imp if(CollectionUtils.isEmpty(userDetail)|| userDetail.get("userId")==null){ return; } + SysUser sysUser = new SysUser(); + org.springframework.beans.BeanUtils.copyProperties(userDetail,sysUser); + //转换器 + ConvertUtils.register(new Converter() { + @Override + public Object convert(Class aClass, Object o) { + try { + if (o == null){ return null; } + return new SimpleDateFormat("yyyy-MM-dd").parse(o.toString()); + }catch (Exception ex){ + return null; + } + } + }, Date.class); BeanUtils.populate(sysUser,userDetail); sysUser.setUpdateTime(new Date()); sysUser.setUpdateId(SecurityUtils.getCurrentUserId()); this.updateById(sysUser); - if (userDetail.get("depts") !=null){ + if (userDetail.get("deptIds")!=null){ deptService.delUserDeptRelation(sysUser.getUserId()); - deptService.saveUserDeptRelation(sysUser.getUserId(),(List)userDetail.get("depts")); + deptService.saveUserDeptRelation(sysUser.getUserId(), (List) userDetail.get("deptIds")); }; - if (userDetail.get("roles") !=null){ + if (userDetail.get("roleIds") !=null){ roleService.delUserRoleRelation(sysUser.getUserId()); - roleService.saveUserRoleRelation(sysUser.getUserId(),(List)userDetail.get("roles")); + roleService.saveUserRoleRelation(sysUser.getUserId(),(List) userDetail.get("roleIds")); } } } diff --git a/nladmin-ui/src/views/system/user/index.vue b/nladmin-ui/src/views/system/user/index.vue index 19b2359..124a909 100644 --- a/nladmin-ui/src/views/system/user/index.vue +++ b/nladmin-ui/src/views/system/user/index.vue @@ -152,9 +152,9 @@ - + > @@ -799,10 +799,11 @@ export default { userId: this.depCheckedId } if (this.flag) { - user.depts = this.$refs.deptUser.getCheckedKeys() + user.deptIds = this.$refs.deptUser.getCheckedKeys() } else { - user.roles = this.crud.selections.map(item => (item.roleId)) + user.rolesIds = this.crud.selections.map(item => (item.roleId)) } + debugger crudUser.edit(user).then(res => { this.cancelForm() this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)