| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | 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.service.UserService; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.DigestUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserServiceImp implements UserService { |
| | | |
| | | @Resource |
| | | UserMapper userMapper; |
| | | |
| | | @Resource |
| | | Jwt jwt; |
| | | |
| | | @Resource |
| | | private GetLook getLook; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public User selectUserByPwd(String account, String password) { |
| | | QueryWrapper<User> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("account", account).eq("password", DigestUtils.md5DigestAsHex(password.getBytes())).eq("state", 1); |
| | | List<User> list = userMapper.selectList(wrapper); |
| | | return list.size()>0?list.get(0):null; |
| | | return list.size() > 0 ? list.get(0) : null; |
| | | } |
| | | |
| | | //根据用户id查询用户名 |
| | |
| | | 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")); |
| | | if (map1.get("look") == 1) user.setCreateUser(map1.get("userId")); |
| | | map.put("body", userMapper.selectUserDtoPageList(page, QueryWrappers.queryWrappers(user))); |
| | | return map; |
| | | } |
| | |
| | | @Override |
| | | public User getUserNow() { |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null); |
| | | return userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getId, map1.get("userId")).eq(User::getIsCustom, 1).select(User::getId,User::getCompany,User::getName,User::getCode)); |
| | | return userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getId, map1.get("userId")).eq(User::getIsCustom, 1).select(User::getId, User::getCompany, User::getName, User::getCode)); |
| | | } |
| | | |
| | | @Override |
| | | public User getUserInfo() { |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId(null); |
| | | return userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getId, map1.get("userId")).select(User::getId,User::getCompany,User::getName,User::getCode)); |
| | | return userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getId, map1.get("userId")).select(User::getId, User::getCompany, User::getName, User::getCode)); |
| | | } |
| | | |
| | | @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)){ |
| | | if (BeanUtil.isEmpty(user)) { |
| | | throw new ErrorException("密码不正确"); |
| | | } |
| | | user.setPassword(DigestUtils.md5DigestAsHex(newPassWord.getBytes())); |
| | | return userMapper.updateById(user); |
| | | } |
| | | |
| | | } |