| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | } |
| | | |
| | | public List<UserInf> getAll() { |
| | | List<UserInf> users = userMapper.selectList(null); |
| | | List<UserInf> users = userMapper.selectList((Wrapper<UserInf>) ActionUtil.objeNull); |
| | | return users; |
| | | } |
| | | |
| | |
| | | public Response update(UserInf user) { |
| | | //非系统管理员用户,禁止修改访问ip和访问时间 |
| | | if(user.getUId()!=1 && user.getUName().equals("sys_admin")){ |
| | | user.setVisitIp(null); |
| | | user.setVisitTime(null); |
| | | user.setVisitIp((String) ActionUtil.objeNull); |
| | | user.setVisitTime((String) ActionUtil.objeNull); |
| | | } |
| | | UserInf userFound = userBridgeService.findPasswordByUserName(user.getUName()); |
| | | UserInf userOfMobilephone = userBridgeService.findUserByMobilephone(user.getUMobilephone()); |
| | |
| | | ServletContext application = ActionUtil.getApplication(); |
| | | //查看全局中存储的users的Map的key-value集合 |
| | | Map<String, UserClient> map = (Map) application.getAttribute("users"); |
| | | if (map == null) { |
| | | if (map == ActionUtil.objeNull) { |
| | | map = new HashMap<String, UserClient>(); |
| | | } else { |
| | | //如果集合中有值,则获取当前用户对应的用户信息,key为用户名username,Value为用户名,存储的时间 |
| | | UserClient client = map.get(user.getUName()); |
| | | if (client != null) { //已存在 |
| | | if (client != ActionUtil.objeNull) { //已存在 |
| | | map.remove(user.getUName()); |
| | | } |
| | | } |
| | |
| | | //更新新密码 |
| | | UpdateWrapper<UserInf> updateWrapper = Wrappers.update(); |
| | | updateWrapper.set("upassword",RSAUtil.encrypt(passwordNew,RSAUtil.getPublicKey())).eq("uName",userInf.getUName()); |
| | | userMapper.update(null,updateWrapper); |
| | | userMapper.update((UserInf) ActionUtil.objeNull,updateWrapper); |
| | | return new Response().set(1,true,"密码修改成功"); |
| | | } |
| | | |
| | |
| | | public void lock(Long uId) { |
| | | UpdateWrapper<UserInf> wrapper = Wrappers.update(); |
| | | wrapper.set("status", UserConstant.ACCOUNT_STATUS_LOCK_FAIL.getValue()).eq("uId",uId); |
| | | userMapper.update(null,wrapper); |
| | | userMapper.update((UserInf) ActionUtil.objeNull,wrapper); |
| | | } |
| | | |
| | | /**更新登录时间*/ |
| | | public void updateLoginTime(Long uId) { |
| | | UpdateWrapper<UserInf> wrapper = Wrappers.update(); |
| | | wrapper.set("last_login_time", new Date()).eq("uId",uId); |
| | | userMapper.update(null,wrapper); |
| | | userMapper.update((UserInf) ActionUtil.objeNull,wrapper); |
| | | } |
| | | |
| | | |
| | | public void updateExpiredAccount() { |
| | | UpdateWrapper<UserInf> wrapper = Wrappers.update(); |
| | | wrapper.set("status",UserConstant.ACCOUNT_STATUS_CANCEL.getValue()).eq("type",UserConstant.ACCOUNT_TYPE_TEMP.getValue()).gt("expiration_time",new Date()); |
| | | userMapper.update(null,wrapper); |
| | | userMapper.update((UserInf) ActionUtil.objeNull,wrapper); |
| | | } |
| | | |
| | | public void unLock() { |
| | |
| | | wrapper.set("status", UserConstant.ACCOUNT_STATUS_ACTIVE.getValue()).set("lock_time",null) |
| | | .eq("status",UserConstant.ACCOUNT_STATUS_LOCK_FAIL.getValue()) |
| | | .last(" and date_add(lock_time,interval 20 MINUTE)<now() and uId is not null"); |
| | | userMapper.update(null,wrapper); |
| | | userMapper.update((UserInf) ActionUtil.objeNull,wrapper); |
| | | } |
| | | |
| | | public void updateAccountStatus(int status) { |
| | |
| | | wrapper.set("status", status) |
| | | .eq("status",UserConstant.ACCOUNT_STATUS_ACTIVE.getValue()) |
| | | .last(" and date_add(last_login_time,interval 3 MONTH)<now() and uId >100"); |
| | | userMapper.update(null,wrapper); |
| | | userMapper.update((UserInf) ActionUtil.objeNull,wrapper); |
| | | } |
| | | |
| | | public void unLock(int uId, int unLockType) { |
| | | UpdateWrapper<UserInf> wrapper = Wrappers.update(); |
| | | wrapper.set("status",1).eq("uId",uId); |
| | | if(unLockType==1){ |
| | | wrapper.set("lock_time",null); |
| | | wrapper.set("lock_time",ActionUtil.objeNull); |
| | | }else{ |
| | | wrapper.set("last_login_time",new Date()); |
| | | } |
| | | userMapper.update(null,wrapper); |
| | | userMapper.update((UserInf) ActionUtil.objeNull,wrapper); |
| | | } |
| | | |
| | | public List<UserInf> searchCS_All2() { |
| | |
| | | query.select("uId","uName","uSnId","upassword","unote","UKey_ID","uRole","password_update_time","status","visit_time","visit_ip") |
| | | .eq("uId",uId).last(" limit 1"); |
| | | UserInf userInf = userMapper.selectOne(query); |
| | | if(userInf == null){ |
| | | if(userInf == ActionUtil.objeNull){ |
| | | response.setMsg("对应的用户不存在"); |
| | | }else{ |
| | | //判断用户状态 |
| | |
| | | session.setAttribute("ip",ActionUtil.getRequest().getRemoteAddr()); |
| | | |
| | | List<UserPermitGroup> permitGroupList = permitMapper.getPermitGroupListByUId(uId); |
| | | if(permitGroupList!=null && permitGroupList.size()>0){ |
| | | if(permitGroupList!=ActionUtil.objeNull && permitGroupList.size()>0){ |
| | | session.setAttribute("permits", ActionUtil.tojson(permitGroupList)); |
| | | }else{ |
| | | response.setMsg("还未分配权限"); |