| | |
| | | import com.whyc.mapper.KeyInfMapper; |
| | | import com.whyc.pojo.db_area.KeyInf; |
| | | import com.whyc.pojo.db_area.LockInf; |
| | | import com.whyc.pojo.db_user.UserInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private AreaInfService areaInfService; |
| | | |
| | | @Autowired(required = false) |
| | | private AreaUserService areaUserService; |
| | | |
| | | //查询所有钥匙信息 |
| | | public Response getAllKeyInf(String keyName, String uname, int pageNum, int pageSize) { |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | UserInf uinf= ActionUtil.getUser(); |
| | | List areaList=areaInfService.getAllAreaUser(uinf.getUid(),uinf.getUrole()); |
| | | List<String> unameList=new ArrayList<>(); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | if(uinf.getUrole()==0){ |
| | | unameList.add(uinf.getUname()); |
| | | wrapper.in("uname",unameList); |
| | | } |
| | | if(uinf.getUrole()==1){ |
| | | //获取区域对应的用户名 |
| | | unameList=areaUserService.getUserNameByAreaIds(areaList); |
| | | wrapper.in("uname",unameList); |
| | | } |
| | | if(keyName!=null){ |
| | | wrapper.like("key_name",keyName); |
| | | } |
| | | if(uname!=null){ |
| | | wrapper.like("uname",uname); |
| | | } |
| | | wrapper.ne("key_id",0); |
| | | /*List areaList=new ArrayList(); |
| | | areaList.add(areaId); |
| | | areaInfService.getAllAreaId(areaId,areaList); |
| | | if(areaList!=null){ |
| | | wrapper.in("area_id",areaList); |
| | | }*/ |
| | | wrapper.ne("key_id",0);//排除蓝牙钥匙 |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<KeyInf> list=mapper.selectList(wrapper); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"查询所有钥匙信息"); |
| | |
| | | }else { |
| | | UpdateWrapper wrapper = new UpdateWrapper(); |
| | | wrapper.eq("key_id", kinf.getKeyId()); |
| | | if (kinf.getAreaId() != null) { |
| | | wrapper.set("area_id", kinf.getAreaId()); |
| | | } |
| | | if (kinf.getKeyName() != null) { |
| | | wrapper.set("key_name", kinf.getKeyName()); |
| | | } |
| | |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | return new Response().setII(1,list!=null,lnameList,"查询所有钥匙名信息(用于下拉)"); |
| | | } |
| | | |
| | | } |