新增城市管理
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.ruoyi.oa.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.oa.domain.bo.OaCityBo;
|
||||
import com.ruoyi.oa.domain.vo.OaCityVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface IOaCityService {
|
||||
|
||||
OaCityVo queryById(Long cityId);
|
||||
|
||||
TableDataInfo<OaCityVo> queryPageList(OaCityBo bo, PageQuery pageQuery);
|
||||
|
||||
List<OaCityVo> queryList(OaCityBo bo);
|
||||
|
||||
Boolean insertByBo(OaCityBo bo);
|
||||
|
||||
Boolean updateByBo(OaCityBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.ruoyi.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.oa.domain.OaCity;
|
||||
import com.ruoyi.oa.domain.bo.OaCityBo;
|
||||
import com.ruoyi.oa.domain.vo.OaCityVo;
|
||||
import com.ruoyi.oa.mapper.OaCityMapper;
|
||||
import com.ruoyi.oa.service.IOaCityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class OaCityServiceImpl implements IOaCityService {
|
||||
|
||||
private final OaCityMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public OaCityVo queryById(Long cityId) {
|
||||
return baseMapper.selectVoById(cityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<OaCityVo> queryPageList(OaCityBo bo, PageQuery pageQuery) {
|
||||
IPage<OaCityVo> page = baseMapper.selectVoPage(pageQuery.build(), buildQueryWrapper(bo));
|
||||
TableDataInfo<OaCityVo> tableDataInfo = new TableDataInfo<>(page.getRecords(), page.getTotal());
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OaCityVo> queryList(OaCityBo bo) {
|
||||
return baseMapper.selectVoList(buildQueryWrapper(bo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(OaCityBo bo) {
|
||||
OaCity add = BeanUtil.toBean(bo, OaCity.class);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setCityId(add.getCityId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(OaCityBo bo) {
|
||||
OaCity update = BeanUtil.toBean(bo, OaCity.class);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<OaCity> buildQueryWrapper(OaCityBo bo) {
|
||||
LambdaQueryWrapper<OaCity> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getCountryName()), OaCity::getCountryName, bo.getCountryName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getCityName()), OaCity::getCityName, bo.getCityName());
|
||||
lqw.eq(bo.getStatus() != null, OaCity::getStatus, bo.getStatus());
|
||||
lqw.orderByDesc(OaCity::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user