| | |
| | | package com.yuanchu.mom.service.imp; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.UserPageDto; |
| | | import com.yuanchu.mom.exception.ErrorException; |
| | | import com.yuanchu.mom.mapper.UserMapper; |
| | | import com.yuanchu.mom.pojo.User; |
| | | import com.yuanchu.mom.service.UserService; |
| | |
| | | |
| | | Jwt jwt; |
| | | |
| | | private GetLook getLook; |
| | | |
| | | @Override |
| | | public User selectUserByPwd(String account, String password) { |
| | | QueryWrapper<User> wrapper = new QueryWrapper<>(); |
| | |
| | | public Map<String, Object> selectUserList(IPage<UserPageDto> page, UserPageDto user) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(UserPageDto.class)); |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectUserList"); |
| | | if(map1.get("look")==1) user.setCreateUser(map1.get("userId")); |
| | | map.put("body", userMapper.selectUserDtoPageList(page, QueryWrappers.queryWrappers(user))); |
| | | return map; |
| | | } |
| | |
| | | public int addUser(User user) { |
| | | return userMapper.insert(user); |
| | | } |
| | | |
| | | @Override |
| | | public List<User> getUserMenu() { |
| | | return userMapper.selectList(Wrappers.<User>lambdaQuery().eq(User::getState, 1).select(User::getName, User::getId)); |
| | | } |
| | | |
| | | @Override |
| | | public int upUserPassword(String oldPassword, String newPassWord) { |
| | | Map<String, Integer> map = getLook.selectPowerByMethodAndUserId(null); |
| | | User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getId, map.get("userId")).eq(User::getPassword, DigestUtils.md5DigestAsHex(oldPassword.getBytes())).select(User::getId)); |
| | | if(BeanUtil.isEmpty(user)){ |
| | | throw new ErrorException("密码不正确"); |
| | | } |
| | | user.setPassword(DigestUtils.md5DigestAsHex(newPassWord.getBytes())); |
| | | return userMapper.updateById(user); |
| | | } |
| | | } |