| | |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import javax.servlet.ServletContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | private AreaInfMapper ainfMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private AreaInfService areaInfService; |
| | | |
| | | @Autowired(required = false) |
| | | private AuthiruzeInfMapper authMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private LockInfMapper linfMapper; |
| | | |
| | | |
| | | //查询所有用户信息 |
| | | public Response getAllUser(String uname,String realName,Integer role, int pageCurr, int pageSize) { |
| | | public Response getAllUser(String uname, String realName, int areaId, int pageCurr, int pageSize) { |
| | | UserInf uinf= ActionUtil.getUser(); |
| | | List areaList=new ArrayList(); |
| | | areaList.add(areaId); |
| | | areaInfService.getAllAreaId(areaId,areaList); |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | | List<UserInf> list=mapper.getAllUser(uname,realName,role); |
| | | for (UserInf uinf:list) { |
| | | List<UserInf> list=mapper.getAllUser(uname,realName,uinf.getUrole(),areaList); |
| | | for (UserInf u:list) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("area_uname",uinf.getUname()); |
| | | wrapper.eq("id",u.getAreaId()); |
| | | wrapper.last("limit 1"); |
| | | AreaInf ainf=ainfMapper.selectOne(wrapper); |
| | | uinf.setAinf(ainf); |
| | | u.setAinf(ainf); |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"数据返回"); |
| | | } |
| | | //编辑权限 |
| | | public Response updateUser(int uid,String uname, int udownloadRole) { |
| | | /* //编辑权限 |
| | | public Response updateUser(int uid,String uname) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.set("udownload_role",udownloadRole); |
| | | if(uname!=null){ |
| | | wrapper.set("uname",uname); |
| | | } |
| | |
| | | int bl=mapper.update(null,wrapper); |
| | | return new Response().set(1,bl>0); |
| | | } |
| | | |
| | | */ |
| | | //新添加用户信息 |
| | | public Response addUser(UserInf uinf) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | //判断是否存在普通用户(uid>100),若无,初始为1001 |
| | | //判断是否存在普通用户(uid>100),若无,初始为101 |
| | | int judgecount=mapper.judgeUname(); |
| | | if(judgecount==0){ |
| | | uinf.setUid(101); |
| | |
| | | //插入默认数据 |
| | | String sql=" INSERT INTO temp_numbers(unumber) " + |
| | | " VALUES "; |
| | | for(int i=101;i<=1000;i++){ |
| | | for(int i=101;i<=10000;i++){ |
| | | sql+="("+i+")"; |
| | | if(i!=1000){ |
| | | if(i!=10000){ |
| | | sql+=","; |
| | | } |
| | | } |
| | | mapper.setUnumber(sql); |
| | | } |
| | | String minUid=mapper.getIn1000(); |
| | | String minUid=mapper.getIn10000(); |
| | | if(minUid==null){ |
| | | return new Response().set(1,false,"管理员个数超过上限"); |
| | | } |
| | |
| | | //查询最大的uid |
| | | String maxUid=mapper.getMaxUid(); |
| | | if(maxUid==null){ |
| | | maxUid="1001"; |
| | | maxUid="10001"; |
| | | } |
| | | //根据用户id查询用户信息 |
| | | QueryWrapper qWrapper=new QueryWrapper(); |
| | |
| | | } |
| | | return model; |
| | | } |
| | | //查询所有用户信息(不分页用于包机组) |
| | | //查询所有用户信息(不分页用于下拉) |
| | | public Response getUinf() { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.select("uid","uname","udownload_role"); |
| | | wrapper.select("uid","uname","urole"); |
| | | wrapper.gt("uid",100); |
| | | wrapper.eq("urole",0);//普通用户 |
| | | wrapper.orderByAsc("uid"); |
| | | List<UserInf> list=mapper.selectList(wrapper); |
| | | return new Response().setII(1,list!=null,list,"查询所有用户信息(不分页用于包机组)"); |
| | | return new Response().setII(1,list!=null,list,"查询所有用户信息(不分页用于下拉)"); |
| | | } |
| | | //根据uId获取设备信息 |
| | | public UserInf getUinfByUId(int uId){ |
| | |
| | | } |
| | | //查询未被指定区域的用户 |
| | | public Response getUnloadUinf() { |
| | | List<AreaInf> ainfList=ainfMapper.selectList(null); |
| | | /* List<AreaInf> ainfList=ainfMapper.selectList(null); |
| | | List<String> unameList = ainfList.stream() |
| | | .map(AreaInf::getAreaUname) // 提取名字 |
| | | .collect(Collectors.toList()); // 转换为列表 |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.select("uname","uid","real_name","udownload_role","create_time"); |
| | | wrapper.notIn("uname",unameList); |
| | | wrapper.select("uname","uid","real_name","urole","create_time"); |
| | | wrapper.eq("area_id",0); |
| | | wrapper.gt("uid",100); |
| | | List<UserInf> list=mapper.selectList(wrapper); |
| | | return new Response().setII(1,list!=null,list,"查询未被指定区域的用户"); |
| | |
| | | List<KeyInf> list=linfMapper.selectList(lockwrapper); |
| | | return new Response().setII(1,list!=null,list,"查询当前用户授予权限的锁"); |
| | | } |
| | | //编辑用户信息 |
| | | public Response updateUinf(UserInf uinf) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | /*if(uinf.getUname()!=null){ |
| | | wrapper.set("uname",uinf.getUname()); |
| | | }*/ |
| | | if(uinf.getRealName()!=null){ |
| | | wrapper.set("real_name",uinf.getRealName()); |
| | | } |
| | | if(uinf.getPhoneNumber()!=null){ |
| | | wrapper.set("phone_number",uinf.getPhoneNumber()); |
| | | } |
| | | if(uinf.getAreaId()!=null){ |
| | | wrapper.set("area_id",uinf.getAreaId()); |
| | | } |
| | | if(uinf.getUrole()!=null){ |
| | | wrapper.set("urole",uinf.getUrole()); |
| | | } |
| | | if(uinf.getAddress()!=null){ |
| | | wrapper.set("address",uinf.getAddress()); |
| | | } |
| | | wrapper.eq("uid",uinf.getUid()); |
| | | mapper.update(null,wrapper); |
| | | return new Response().set(1,true,"编辑用户信息成功"); |
| | | } |
| | | } |