package cn.exrick.xboot.your.controller;
|
|
import cn.exrick.xboot.core.common.utils.PageUtil;
|
import cn.exrick.xboot.core.common.utils.ResultUtil;
|
import cn.exrick.xboot.core.common.vo.PageVo;
|
import cn.exrick.xboot.core.common.vo.Result;
|
import cn.exrick.xboot.your.entity.AreaMap;
|
import cn.exrick.xboot.your.service.IAreaMapService;
|
import cn.hutool.core.util.StrUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
|
/**
|
* @author whj
|
*/
|
@Slf4j
|
@RestController
|
@Api(tags = "区域坐标管理接口")
|
@RequestMapping("/xboot/areaMap")
|
@Transactional
|
public class AreaMapController {
|
|
@Autowired
|
private IAreaMapService iAreaMapService;
|
|
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
|
@ApiOperation(value = "通过id获取")
|
public Result<AreaMap> get(@PathVariable String id) {
|
|
AreaMap areaMap = iAreaMapService.getById(id);
|
return new ResultUtil<AreaMap>().setData(areaMap);
|
}
|
|
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
|
@ApiOperation(value = "获取全部数据")
|
public Result<List<AreaMap>> getAll() {
|
|
List<AreaMap> list = iAreaMapService.list();
|
return new ResultUtil<List<AreaMap>>().setData(list);
|
}
|
|
@RequestMapping(value = "/getAllById", method = RequestMethod.GET)
|
@ApiOperation(value = "获取全部数据")
|
public Result<List<AreaMap>> getAllById(String id) {
|
QueryWrapper<AreaMap> wrapper = new QueryWrapper<>();
|
wrapper.eq("area_id",id);
|
wrapper.orderByAsc("seq");
|
List<AreaMap> list = iAreaMapService.list(wrapper);
|
return new ResultUtil<List<AreaMap>>().setData(list);
|
}
|
|
@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
|
@ApiOperation(value = "分页获取")
|
public Result<IPage<AreaMap>> getByPage(PageVo page) {
|
|
IPage<AreaMap> data = iAreaMapService.page(PageUtil.initMpPage(page));
|
return new ResultUtil<IPage<AreaMap>>().setData(data);
|
}
|
|
@RequestMapping(value = "/insertOrUpdate", method = RequestMethod.POST)
|
@ApiOperation(value = "编辑或更新数据")
|
public Result<AreaMap> saveOrUpdate(AreaMap areaMap) {
|
if (iAreaMapService.saveOrUpdate(areaMap)) {
|
return new ResultUtil<AreaMap>().setData(areaMap);
|
}
|
return new ResultUtil<AreaMap>().setErrorMsg("操作失败");
|
}
|
|
|
@RequestMapping(value = "/delById2", method = RequestMethod.POST)
|
@ApiOperation(value = "通过areaid删除")
|
public Result<Object> delById2(String id) {
|
QueryWrapper<AreaMap> wrapper = new QueryWrapper<>();
|
wrapper.eq("area_id",id);
|
iAreaMapService.remove(wrapper);
|
return ResultUtil.success("通过id删除数据成功");
|
}
|
|
|
@RequestMapping(value = "/delByIds", method = RequestMethod.POST)
|
@ApiOperation(value = "批量通过id删除")
|
public Result<Object> delAllByIds(@RequestParam String[] ids) {
|
|
for (String id : ids) {
|
iAreaMapService.removeById(id);
|
}
|
return ResultUtil.success("批量通过id删除数据成功");
|
}
|
}
|