package org.jeecg.modules.eam.controller;
|
|
import java.util.Arrays;
|
import java.util.List;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import org.jeecg.common.api.vo.CommonGenericTree;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.modules.eam.entity.InspectionProject;
|
import org.jeecg.modules.eam.entity.InspectionProjectCategory;
|
import org.jeecg.modules.eam.service.IInspectionProjectService;
|
import org.jeecg.modules.eam.service.IInspectionProjectCategoryService;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.servlet.ModelAndView;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
/**
|
* @Description: mom_eam_inspection_project_category
|
* @Author: jeecg-boot
|
* @Date: 2023-03-10
|
* @Version: V1.0
|
*/
|
@Api(tags="mom_eam_inspection_project_category")
|
@RestController
|
@RequestMapping("/eam/inspectionProjectCategory")
|
@Slf4j
|
public class InspectionProjectCategoryController extends JeecgController<InspectionProjectCategory, IInspectionProjectCategoryService> {
|
@Autowired
|
private IInspectionProjectCategoryService inspectionProjectCategoryService;
|
@Autowired
|
private IInspectionProjectService inspectionProjectService;
|
|
/**
|
* 分页列表查询
|
*
|
* @param inspectionProjectCategory
|
* @param pageNo
|
* @param pageSize
|
* @param req
|
* @return
|
*/
|
//@AutoLog(value = "mom_eam_inspection_project_category-分页列表查询")
|
@ApiOperation(value="mom_eam_inspection_project_category-分页列表查询", notes="mom_eam_inspection_project_category-分页列表查询")
|
@GetMapping(value = "/list")
|
public Result<IPage<InspectionProjectCategory>> queryPageList(InspectionProjectCategory inspectionProjectCategory,
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
HttpServletRequest req) {
|
QueryWrapper<InspectionProjectCategory> queryWrapper = QueryGenerator.initQueryWrapper(inspectionProjectCategory, req.getParameterMap());
|
Page<InspectionProjectCategory> page = new Page<InspectionProjectCategory>(pageNo, pageSize);
|
IPage<InspectionProjectCategory> pageList = inspectionProjectCategoryService.page(page, queryWrapper);
|
return Result.OK(pageList);
|
}
|
|
/**
|
* 添加
|
*
|
* @param inspectionProjectCategory
|
* @return
|
*/
|
@AutoLog(value = "mom_eam_inspection_project_category-添加")
|
@ApiOperation(value="mom_eam_inspection_project_category-添加", notes="mom_eam_inspection_project_category-添加")
|
//@RequiresPermissions("org.jeecg.modules.demo:mom_eam_inspection_project_category:add")
|
@PostMapping(value = "/add")
|
public Result<String> add(@RequestBody InspectionProjectCategory inspectionProjectCategory) {
|
inspectionProjectCategoryService.save(inspectionProjectCategory);
|
return Result.OK("添加成功!");
|
}
|
|
/**
|
* 编辑
|
*
|
* @param inspectionProjectCategory
|
* @return
|
*/
|
@AutoLog(value = "mom_eam_inspection_project_category-编辑")
|
@ApiOperation(value="mom_eam_inspection_project_category-编辑", notes="mom_eam_inspection_project_category-编辑")
|
//@RequiresPermissions("org.jeecg.modules.demo:mom_eam_inspection_project_category:edit")
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
public Result<String> edit(@RequestBody InspectionProjectCategory inspectionProjectCategory) {
|
inspectionProjectCategoryService.updateById(inspectionProjectCategory);
|
return Result.OK("编辑成功!");
|
}
|
|
/**
|
* 通过id删除
|
*
|
* @param id
|
* @return
|
*/
|
@AutoLog(value = "mom_eam_inspection_project_category-通过id删除")
|
@ApiOperation(value="mom_eam_inspection_project_category-通过id删除", notes="mom_eam_inspection_project_category-通过id删除")
|
//@RequiresPermissions("org.jeecg.modules.demo:mom_eam_inspection_project_category:delete")
|
@DeleteMapping(value = "/delete")
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
List<InspectionProject> projectList = inspectionProjectService.lambdaQuery()
|
.eq(InspectionProject::getInspectionProjectCategoryId, id)
|
.eq(InspectionProject::getDelFlag, "0").list();
|
if(projectList.size()>0){
|
return Result.error(projectList.size()+"");
|
}
|
InspectionProjectCategory inspectionProjectCategory = inspectionProjectCategoryService.getById(id);
|
inspectionProjectCategory.setDelFlag(1);
|
inspectionProjectCategoryService.updateById(inspectionProjectCategory);
|
return Result.OK("删除成功!");
|
}
|
|
/**
|
* 批量删除
|
*
|
* @param ids
|
* @return
|
*/
|
@AutoLog(value = "mom_eam_inspection_project_category-批量删除")
|
@ApiOperation(value="mom_eam_inspection_project_category-批量删除", notes="mom_eam_inspection_project_category-批量删除")
|
//@RequiresPermissions("org.jeecg.modules.demo:mom_eam_inspection_project_category:deleteBatch")
|
@DeleteMapping(value = "/deleteBatch")
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
this.inspectionProjectCategoryService.removeByIds(Arrays.asList(ids.split(",")));
|
return Result.OK("批量删除成功!");
|
}
|
|
/**
|
* 通过id查询
|
*
|
* @param id
|
* @return
|
*/
|
//@AutoLog(value = "mom_eam_inspection_project_category-通过id查询")
|
@ApiOperation(value="mom_eam_inspection_project_category-通过id查询", notes="mom_eam_inspection_project_category-通过id查询")
|
@GetMapping(value = "/queryById")
|
public Result<InspectionProjectCategory> queryById(@RequestParam(name="id",required=true) String id) {
|
InspectionProjectCategory inspectionProjectCategory = inspectionProjectCategoryService.getById(id);
|
if(inspectionProjectCategory ==null) {
|
return Result.error("未找到对应数据");
|
}
|
return Result.OK(inspectionProjectCategory);
|
}
|
|
/**
|
* 导出excel
|
*
|
* @param request
|
* @param inspectionProjectCategory
|
*/
|
//@RequiresPermissions("org.jeecg.modules.demo:mom_eam_inspection_project_category:exportXls")
|
@RequestMapping(value = "/exportXls")
|
public ModelAndView exportXls(HttpServletRequest request, InspectionProjectCategory inspectionProjectCategory) {
|
return super.exportXls(request, inspectionProjectCategory, InspectionProjectCategory.class, "mom_eam_inspection_project_category");
|
}
|
|
/**
|
* 通过excel导入数据
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
//@RequiresPermissions("mom_eam_inspection_project_category:importExcel")
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
return super.importExcel(request, response, InspectionProjectCategory.class);
|
}
|
|
/**
|
* @MethodName: loadTree
|
* @Description: 故障原因 树
|
*/
|
@GetMapping("/loadTree")
|
public Result<?> loadTree(HttpServletRequest httpServletRequest) {
|
List<CommonGenericTree> list = inspectionProjectCategoryService.loadTree();
|
return Result.ok(list);
|
}
|
|
}
|