| New file |
| | |
| | | package cn.gistack.sm.sg.controller; |
| | | |
| | | import cn.gistack.sm.sg.DO.SgDeviceDO; |
| | | import cn.gistack.sm.sg.DO.SgGxStepDO; |
| | | import cn.gistack.sm.sg.DTO.SgDeviceSearchDTO; |
| | | import cn.gistack.sm.sg.service.SgDeviceService; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 施工项目子设备表前端控制器 |
| | | * </p> |
| | | * |
| | | * @author shenyijian |
| | | * @since 2024-06-13 11:51:20 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/sg_device") |
| | | public class SgDeviceController extends BladeController { |
| | | @Autowired |
| | | private SgDeviceService sgDeviceService; |
| | | /** |
| | | * 分页列表查询 |
| | | */ |
| | | @GetMapping(value = "/list") |
| | | public R queryPageList(SgDeviceSearchDTO searchDTO, Query query) { |
| | | IPage<SgDeviceDO> page = sgDeviceService.queryPageList(Condition.getPage(query), searchDTO); |
| | | return R.data(page); |
| | | } |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param sgDeviceDO |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="子设备-添加", notes="子设备-添加") |
| | | @PostMapping(value = "/add") |
| | | public R add(@RequestBody SgDeviceDO sgDeviceDO) { |
| | | Date now = DateUtil.now(); |
| | | if (sgDeviceDO.getId() == null) { |
| | | sgDeviceDO.setCreateTime(now); |
| | | } |
| | | sgDeviceDO.setUpdateTime(now); |
| | | return R.data(sgDeviceService.saveById(sgDeviceDO)); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param sgDeviceDO |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="子设备-编辑", notes="子设备-编辑") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public R edit(@RequestBody SgDeviceDO sgDeviceDO) { |
| | | Date now = DateUtil.now(); |
| | | if (sgDeviceDO.getId() == null) { |
| | | sgDeviceDO.setCreateTime(now); |
| | | } |
| | | sgDeviceDO.setUpdateTime(now); |
| | | return R.data(sgDeviceService.updateById(sgDeviceDO)); |
| | | } |
| | | |
| | | /** |
| | | * 通过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(sgDeviceService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="子设备-批量删除", notes="子设备-批量删除") |
| | | @PostMapping(value = "/deleteBatch") |
| | | public R deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | return R.data(sgDeviceService.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) { |
| | | SgDeviceDO sgDeviceDO = sgDeviceService.getSgDeviceById(id); |
| | | return R.data(sgDeviceDO); |
| | | } |
| | | |
| | | @GetMapping(value = "/getDeviceList") |
| | | public R getDeviceList(@RequestParam(name="programId",required=true) String programId) { |
| | | List<SgDeviceDO> page = sgDeviceService.getDeviceList(programId); |
| | | return R.data(page); |
| | | } |
| | | |
| | | @GetMapping(value = "/getStepList") |
| | | public R queryStepList(@RequestParam(name="deviceId",required=true) String deviceId) { |
| | | List<SgGxStepDO> page = sgDeviceService.queryStepList(deviceId); |
| | | return R.data(page); |
| | | } |
| | | } |