|
@@ -17,6 +17,7 @@ import com.metro.mapper.AccountsMapper;
|
|
|
import com.metro.mapper.CompanysMapper;
|
|
|
import com.metro.mapper.PoliceMapper;
|
|
|
import com.metro.service.PoliceService;
|
|
|
+import com.metro.service.base.BaseService;
|
|
|
import com.metro.utils.MD5UtilNew;
|
|
|
import com.metro.utils.MapperManager;
|
|
|
import com.metro.utils.StringUtil;
|
|
@@ -44,66 +45,72 @@ import static com.metro.service.impl.AccountServiceImpl.getUpdateAccountResp;
|
|
|
* ...
|
|
|
*/
|
|
|
@Service
|
|
|
-public class PoliceServiceImpl implements PoliceService{
|
|
|
+public class PoliceServiceImpl extends BaseService implements PoliceService {
|
|
|
@Autowired
|
|
|
private PoliceMapper mapper;
|
|
|
@Autowired
|
|
|
private CompanysMapper companysMapper;
|
|
|
@Autowired
|
|
|
private AccountsMapper accountsMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<SelectPolicePageResp> page(SelectPolicePageReq req) {
|
|
|
IPage<SelectPolicePageResp> respPage = new Page<>(req.getPageNum(), req.getPageSize());
|
|
|
IPage<Police> selectPage = mapper.selectPage(new Page<>(req.getPageNum(), req.getPageSize()), pageWrapper(req));
|
|
|
if (org.springframework.util.CollectionUtils.isEmpty(selectPage.getRecords())) return respPage;
|
|
|
Set<String> deptSet = selectPage.getRecords().stream().map(Police::getCompanyId).collect(Collectors.toSet());
|
|
|
- Map<String, String> companysMap = companysMapper.selectList(new LambdaQueryWrapper<Company>().in(Company::getCompanyId,deptSet)).stream().collect(Collectors.toMap(Company::getCompanyId, Company::getCompanyName, (t1, t2) -> t1));
|
|
|
+ Map<String, String> companysMap = companysMapper.selectList(new LambdaQueryWrapper<Company>().in(Company::getCompanyId, deptSet)).stream().collect(Collectors.toMap(Company::getCompanyId, Company::getCompanyName, (t1, t2) -> t1));
|
|
|
return selectPage.convert(p -> MapperManager.mapper(p, SelectPolicePageResp.class, t -> t.setCompanyName(companysMap.get(p.getCompanyId()))));
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * 新增
|
|
|
- * */
|
|
|
+ * 查询条件
|
|
|
+ * */
|
|
|
+ private LambdaQueryWrapper<Police> pageWrapper(SelectPolicePageReq req) {
|
|
|
+ LambdaQueryWrapper<Police> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.like(StringUtils.isNotEmpty(req.getUserName()), Police::getUserName, req.getUserName());
|
|
|
+ wrapper.eq(StringUtils.isNotEmpty(req.getPhone()), Police::getPhone, req.getPhone());
|
|
|
+ wrapper.eq(Police::getIsDelete, UserConstant.NOT_DELETE);
|
|
|
+ wrapper.like(StringUtils.isNotEmpty(req.getAddress()), Police::getAddress, req.getAddress());
|
|
|
+ wrapper.eq(StringUtils.isNotEmpty(req.getCompanyId()), Police::getCompanyId, req.getCompanyId());
|
|
|
+ wrapper.gt(Police::getType,getAccountInfo().getType());
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 新增
|
|
|
+ * */
|
|
|
@Override
|
|
|
public InsertPoliceResp add(InsertPoliceReq req) {
|
|
|
Police account = mapper.selectOne(new LambdaQueryWrapper<Police>().eq(Police::getAccount, req.getAccount()).eq(Police::getIsDelete, UserConstant.NOT_DELETE));
|
|
|
if (ObjectUtil.isNotEmpty(account)) throw new BusinessException(account.getAccount() + "已经存在!不能注册");
|
|
|
- return new InsertPoliceResp().setCount(mapper.insert(MapperManager.mapper(req, Police.class, p -> p.setPassword(MD5UtilNew.string2MD5(req.getPassword())).setType(4))));
|
|
|
+ return new InsertPoliceResp().setCount(mapper.insert(MapperManager.mapper(req, Police.class, p -> p.setPassword(MD5UtilNew.string2MD5(req.getPassword())).setType(getAccountInfo().getType() + 1))));
|
|
|
}
|
|
|
+
|
|
|
/*
|
|
|
- * 查看详情
|
|
|
- * */
|
|
|
+ * 查看详情
|
|
|
+ * */
|
|
|
@Override
|
|
|
public DetailPoliceResp detail(DetailPoliceReq req) {
|
|
|
Police Police = mapper.selectById(req.getId());
|
|
|
- return MapperManager.mapper(Police,DetailPoliceResp.class);
|
|
|
+ return MapperManager.mapper(Police, DetailPoliceResp.class);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * 修改账号
|
|
|
- * */
|
|
|
+ * 修改账号
|
|
|
+ * */
|
|
|
@Override
|
|
|
public UpdateAccountResp update(UpdateAccountReq req) {
|
|
|
- return getUpdateAccountResp(req, accountsMapper); }
|
|
|
+ return getUpdateAccountResp(req, accountsMapper);
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
- * 删除账号
|
|
|
- * */
|
|
|
+ * 删除账号
|
|
|
+ * */
|
|
|
@Override
|
|
|
public DeleteAccountResp delete(DeleteAccountReq req) {
|
|
|
return new DeleteAccountResp().setCount(accountsMapper.updateById(new Account().setId(req.getId())
|
|
|
.setIsDelete(UserConstant.DELETE).setUpdateTime(LocalDateTime.now())));
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * 查询条件
|
|
|
- * */
|
|
|
- private LambdaQueryWrapper<Police> pageWrapper(SelectPolicePageReq req) {
|
|
|
- LambdaQueryWrapper<Police> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.like(StringUtils.isNotEmpty(req.getUserName()), Police::getUserName, req.getUserName());
|
|
|
- wrapper.eq(StringUtils.isNotEmpty(req.getPhone()), Police::getPhone, req.getPhone());
|
|
|
- wrapper.eq(Police::getIsDelete, UserConstant.NOT_DELETE);
|
|
|
- wrapper.like(StringUtils.isNotEmpty(req.getAddress()), Police::getAddress,req.getAddress());
|
|
|
- wrapper.eq(StringUtils.isNotEmpty(req.getCompanyId()),Police::getCompanyId,req.getCompanyId());
|
|
|
- return wrapper;
|
|
|
- }
|
|
|
}
|