package org.jeecg.modules.arj.controller; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.jeecg.modules.arj.config.AjaxResult; import org.jeecg.modules.arj.entity.Head; import org.jeecg.modules.arj.entity.ShengchanTj; import org.jeecg.modules.arj.mapper.HeadMapper; import org.jeecg.modules.arj.service.HeadService; import org.jeecg.modules.arj.service.ShengchanTjService; import org.jeecg.modules.arj.vo.ShengchanTJVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /*其中com.terra.arj.service就等于 com.example.demo.service,ShengchanTjService就等于SpiderdataSpiderxrmmwService*/ /*其中com.terra.arj.entity就等于com.example.demo.entity,ShengchanTj就等于SpiderdataSpiderxrmmw,一种Java的模板引擎语法*/ /** *
* 生产停机记录表 前端控制器 *
* * @author hyy * @since 2022-12-21 */ @Api(tags = "A9生产停机记录接口") @RestController @RequestMapping("/shengchan-tj") public class ShengchanTjVoController { @Autowired private HeadService headService; @Autowired private HeadMapper headMapper; @Resource private ShengchanTjService shengchanTjService; /** * 新增数据 * * @param shengchanTJVo 实例对象 * @return 实例对象 */ @ApiOperation("新增数据") @PostMapping("/add") public AjaxResult save(@RequestBody ShengchanTJVo shengchanTJVo) { //新增或者更新 Head h = headService.insert(shengchanTJVo.getHead()); if (shengchanTJVo.getShengchanTjList() != null) { shengchanTJVo.getShengchanTjList().stream().forEach(item -> item.setHeadId(h.getId())); shengchanTjService.saveBatch(shengchanTJVo.getShengchanTjList()); } return AjaxResult.success(h.getId()); } /** * 更新数据 * * @param shengchanTJVo 实例对象 * @return 实例对象 */ @ApiOperation("更新数据") @PostMapping("/edit") public AjaxResult edit(@RequestBody ShengchanTJVo shengchanTJVo) { Head h2 = shengchanTJVo.getHead(); h2.setId(""); Head h = headService.insert(h2); if (shengchanTJVo.getShengchanTjList() != null) { shengchanTJVo.getShengchanTjList().stream().forEach(item -> item.setHeadId(h.getId())); shengchanTjService.saveOrUpdateBatch(shengchanTJVo.getShengchanTjList()); } return AjaxResult.success(h.getId()); } /** * 通过主键删除数据 * * @param id 主键 * @return 是否成功 */ @ApiOperation("通过主键删除数据") @DeleteMapping public AjaxResult deleteById(String id) { return AjaxResult.success(headService.deleteById(id)); } //查询所有内容接口 @GetMapping("/findAll") public List