Commit 01a7f2ce authored by liuyang's avatar liuyang

修改用户修改保存BUG

parent 2be39ea2
...@@ -61,7 +61,7 @@ public class SysUserController { ...@@ -61,7 +61,7 @@ public class SysUserController {
@RequiresPermissions("sys:user:update") @RequiresPermissions("sys:user:update")
@ResponseStatus(HttpStatus.NO_CONTENT) @ResponseStatus(HttpStatus.NO_CONTENT)
public void update(@RequestBody @Validated(UpdateGroup.class) SysUserModel sysUserModel){ public void update(@RequestBody @Validated(UpdateGroup.class) SysUserModel sysUserModel){
sysUserService.updateUser(sysUserModel);
} }
/** /**
......
...@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls; import tk.mybatis.mapper.util.Sqls;
...@@ -88,4 +89,22 @@ public class SysUserService extends BaseServiceImpl<SysUserPO,Long> { ...@@ -88,4 +89,22 @@ public class SysUserService extends BaseServiceImpl<SysUserPO,Long> {
sysUserMapper.deleteByIds(ids); sysUserMapper.deleteByIds(ids);
sysUserRoleService.deleteByUserIds(ids); sysUserRoleService.deleteByUserIds(ids);
} }
@Transactional
public void updateUser(SysUserModel sysUserModel) {
SysUserPO po = getById(sysUserModel.getId());
if (po == null){
throw new BusinessException("请求错误,用户不存在");
}
po.setUsername(sysUserModel.getUsername());
if (!StringUtils.isEmpty(sysUserModel.getPassword())){
po.setPassword(new Sha256Hash(sysUserModel.getPassword(),po.getSalt()).toHex());
}
po.setEmail(sysUserModel.getEmail());
po.setMobile(sysUserModel.getMobile());
po.setStatus(sysUserModel.getStatus());
updateById(po);
sysUserRoleService.saveOrUpdate(po.getId(),sysUserModel.getRoleIdList());
}
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
where ur.user_id = #{userId} where ur.user_id = #{userId}
</select> </select>
<select id="selectByCondition" resultType="com.qkdata.biz.sys.model.SysUserDTO" parameterType="com.qkdata.biz.sys.model.QueryUserModel"> <select id="selectByCondition" resultType="com.qkdata.biz.sys.model.SysUserDTO" parameterType="com.qkdata.biz.sys.model.QueryUserModel">
select id,username,email,mobile select id,username,email,mobile,status
from sys_user from sys_user
where 1=1 where 1=1
<if test="username != null and username != ''"> <if test="username != null and username != ''">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment