package cn.gistack.sm.point.controller;
|
|
|
import cn.gistack.sm.point.entity.Point;
|
import cn.gistack.sm.point.service.PointService;
|
import cn.gistack.sm.point.vo.PointVO;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Arrays;
|
import java.util.Date;
|
|
/**
|
* 点位控制层
|
* @author zhongrj
|
* @date 2023-09-23
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/point/point")
|
public class PointController {
|
|
private final PointService pointService;
|
|
/**
|
* 分页列表查询
|
*
|
* @param point
|
* @return
|
*/
|
@ApiOperation(value="点位-分页列表查询", notes="点位-分页列表查询")
|
@GetMapping(value = "/list")
|
public R queryPageList(Point point, Query query) {
|
IPage<Point> pageList = pointService.page(Condition.getPage(query), Condition.getQueryWrapper(point));
|
return R.data(pageList);
|
}
|
|
/**
|
* 自定义分页列表查询
|
* @param query
|
* @param point
|
* @return
|
*/
|
@ApiOperation(value="点位-自定义分页列表查询", notes="点位-自定义分页列表查询")
|
@GetMapping(value = "/page")
|
public R page(PointVO point, Query query) {
|
return R.data( pointService.selectPointPage(Condition.getPage(query),point));
|
}
|
|
/**
|
* 添加
|
*
|
* @param point
|
* @return
|
*/
|
@ApiOperation(value="点位-添加", notes="点位-添加")
|
@PostMapping(value = "/add")
|
public R add(@RequestBody Point point) {
|
point.setCreateTime(new Date());
|
return R.data(pointService.save(point));
|
}
|
|
/**
|
* 编辑
|
*
|
* @param point
|
* @return
|
*/
|
@ApiOperation(value="点位-编辑", notes="点位-编辑")
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
public R edit(@RequestBody Point point) {
|
return R.data(pointService.updateById(point));
|
}
|
|
/**
|
* 通过id删除
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value="点位-通过id删除", notes="点位-通过id删除")
|
@PostMapping(value = "/delete")
|
public R delete(@RequestParam(name="id",required=true) String id) {
|
return R.data(pointService.removeById(id));
|
}
|
|
/**
|
* 批量删除
|
*
|
* @param ids
|
* @return
|
*/
|
@ApiOperation(value="点位-批量删除", notes="点位-批量删除")
|
@PostMapping(value = "/deleteBatch")
|
public R deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
return R.data(this.pointService.removeByIds(Arrays.asList(ids.split(","))));
|
}
|
|
/**
|
* 通过id查询
|
*
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value="点位-通过id查询", notes="点位-通过id查询")
|
@GetMapping(value = "/queryById")
|
public R queryById(@RequestParam(name="id",required=true) String id) {
|
Point point = pointService.getById(id);
|
return R.data(point);
|
}
|
|
|
/**
|
* 通过图片id删除
|
* @param id
|
* @return
|
*/
|
@ApiOperation(value="点位-通过图片id删除", notes="点位-通过图片id删除")
|
@PostMapping(value = "/deleteByPicId")
|
public R deleteByPicId(@RequestParam(name="id",required=true) String id) {
|
return R.data(pointService.deleteByPicId(id));
|
}
|
|
}
|