| | |
| | | import com.whyc.pojo.User; |
| | | import com.whyc.util.DigestsUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Resource |
| | | private UserBridgeService userBridgeService; |
| | | |
| | | |
| | | @Autowired |
| | | private ApplicationContext applicationContext; |
| | | |
| | |
| | | return new Response<>().set(0); |
| | | } |
| | | } |
| | | |
| | | public boolean addBatch(List<User> roles) { |
| | | return userMapper.insertBatchSomeColumn(roles)==roles.size(); |
| | | } |
| | | |
| | | |
| | | |
| | | public User getById(int id) { |
| | |
| | | return new Response<IPage<User>>().set(1,page); |
| | | } |
| | | |
| | | |
| | | public boolean validatePassword(String userName, String password) { |
| | | User user = userBridgeService.findPasswordAndSlatByUserName(userName); |
| | | boolean result = user.getPassword().equals(DigestsUtil.sha1(password, user.getSalt())); |
| | | return result; |
| | | } |
| | | |
| | | public Response update(User user) { |
| | | |
| | | Map<String, String> encryptMap = DigestsUtil.encryptPassword(user.getPassword()); |
| | | user.setPassword(encryptMap.get("password")); |
| | | user.setSalt(encryptMap.get("salt")); |
| | | |
| | | if(userMapper.updateById(user)>0){ |
| | | return new Response().setMsg(1,"更新成功"); |
| | | }else { |
| | | return new Response().setMsg(0,"更新失败"); |
| | | } |
| | | } |
| | | |
| | | public Response updateUserFreeze(int id,int state){ |
| | | User user =userMapper.selectById(id); |
| | | user.setState(state); |