|
@@ -4,17 +4,29 @@ import cn.hutool.core.bean.BeanUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.metro.baseRe.Ret;
|
|
|
|
+import com.metro.constant.UserConstant;
|
|
import com.metro.entity.po.Account;
|
|
import com.metro.entity.po.Account;
|
|
-import com.metro.entity.ro.SelectAccountPageReq;
|
|
|
|
-import com.metro.entity.ro.SelectAccountPageResp;
|
|
|
|
-import com.metro.entity.ro.SelectPassreCordsPageListResp;
|
|
|
|
|
|
+import com.metro.entity.po.Area;
|
|
|
|
+import com.metro.entity.ro.account.SelectAccountPageReq;
|
|
|
|
+import com.metro.entity.ro.account.SelectAccountPageResp;
|
|
import com.metro.mapper.AccountsMapper;
|
|
import com.metro.mapper.AccountsMapper;
|
|
|
|
+import com.metro.mapper.AreaMapper;
|
|
import com.metro.service.AccountService;
|
|
import com.metro.service.AccountService;
|
|
|
|
+import com.metro.utils.MapperManager;
|
|
|
|
+import com.metro.utils.StringUtil;
|
|
|
|
+import io.github.classgraph.utils.Join;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @ClassName: AccountServiceImpl
|
|
* @ClassName: AccountServiceImpl
|
|
* @Description: TODO
|
|
* @Description: TODO
|
|
@@ -24,35 +36,46 @@ import org.springframework.util.CollectionUtils;
|
|
* ...
|
|
* ...
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
-public class AccountServiceImpl implements AccountService{
|
|
|
|
|
|
+public class AccountServiceImpl implements AccountService {
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
- private AccountsMapper AccountsMapper;
|
|
|
|
- @Override
|
|
|
|
|
|
+ private AccountsMapper AccountsMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private AreaMapper areaMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 账号查询
|
|
* 账号查询
|
|
|
|
+ *
|
|
* @param req 查询条件
|
|
* @param req 查询条件
|
|
* @return 返回结果
|
|
* @return 返回结果
|
|
*/
|
|
*/
|
|
- public IPage page(SelectAccountPageReq req) {
|
|
|
|
-
|
|
|
|
- IPage<SelectAccountPageReq> respPage = new Page<>(req.getPageNo(), req.getPageSize());
|
|
|
|
-
|
|
|
|
- Page<Account> selectPage = AccountsMapper.selectPage(new Page<>(req.getPageNo(), req.getPageSize()), pageWrapper(req));
|
|
|
|
-
|
|
|
|
- if(CollectionUtils.isEmpty(selectPage.getRecords())) return respPage;
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<SelectAccountPageResp> page(SelectAccountPageReq req) {
|
|
|
|
+ IPage<SelectAccountPageResp> respPage = new Page<>(req.getPageNo(), req.getPageSize());
|
|
|
|
+ IPage<Account> selectPage = AccountsMapper.selectPage(new Page<>(req.getPageNo(), req.getPageSize()), pageWrapper(req));
|
|
|
|
+ if (CollectionUtils.isEmpty(selectPage.getRecords())) return respPage;
|
|
|
|
+ // 从查询结果中过滤出areaId集合
|
|
|
|
+ Set<Integer> areaIdSet = selectPage.getRecords().stream().map(Account::getAreaId).collect(Collectors.toSet());
|
|
|
|
|
|
- return selectPage.convert(p -> BeanUtil.toBean(p,SelectAccountPageResp.class));
|
|
|
|
|
|
+ Map<Integer, String> areaMap = areaMapper.selectList(new LambdaQueryWrapper<Area>().in(Area::getId, areaIdSet)).stream().collect(Collectors.toMap(Area::getId, p ->
|
|
|
|
+ Join.join("-", areaMapper.selectList(new LambdaQueryWrapper<Area>().eq(Area::getId, StringUtils.split(p.getDistrictSqe(),"."))).stream().map(Area::getName).collect(Collectors.toList()))
|
|
|
|
+ ));
|
|
|
|
+ return selectPage.convert(p -> MapperManager.mapper(p, SelectAccountPageResp.class, q -> q.setAreaDesc(areaMap.get(p.getAreaId()))));
|
|
}
|
|
}
|
|
|
|
|
|
- private LambdaQueryWrapper<Account>pageWrapper(SelectAccountPageReq req) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Ret add(Integer id) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // page wrapper 查询条件
|
|
|
|
+ private LambdaQueryWrapper<Account> pageWrapper(SelectAccountPageReq req) {
|
|
LambdaQueryWrapper<Account> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Account> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.like(StringUtils.isNotEmpty(req.getUserName()), Account::getUserName, req.getUserName());
|
|
|
|
+ wrapper.eq(StringUtils.isNotEmpty(req.getPhone()), Account::getPhone, req.getPhone());
|
|
|
|
+ return wrapper;
|
|
|
|
+ }
|
|
|
|
|
|
- wrapper.like(StringUtils.isNotEmpty(req.getAdministratorName()),Account::getAdministratorName,req.getAdministratorName());
|
|
|
|
|
|
|
|
- wrapper.eq(StringUtils.isNotEmpty(req.getAdministratorPhone()),Account::getAdministratorPhone,req.getAdministratorPhone());
|
|
|
|
|
|
|
|
- return wrapper;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|