/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.equipment.controller; import io.swagger.annotations.*; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import lombok.AllArgsConstructor; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; 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.constant.BladeConstant; import org.springblade.core.tool.utils.Func; import org.springblade.modules.catalog.service.catalogService; import org.springblade.modules.deploy.service.IDeployService; import org.springblade.modules.equipment.vo.EquipmentVOS; import org.springblade.modules.equipment.wrapper.EqWrapper; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.modules.equipment.entity.Equipment; import org.springblade.modules.equipment.vo.EquipmentVO; import org.springblade.modules.equipment.service.IEquipmentService; import org.springblade.core.boot.ctrl.BladeController; import springfox.documentation.annotations.ApiIgnore; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; /** * 控制器 * * @author BladeX * @since 2020-07-01 */ @RestController @AllArgsConstructor @RequestMapping("equipment/equipment") @Api(value = "", tags = "接口") public class EquipmentController extends BladeController { private final IEquipmentService equipmentService; private final IDeployService iDeployService; private final catalogService catalogService; /** * 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入equipment") public R detail(Equipment equipment,HttpServletResponse response) { response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Allow-Credentials","true"); /*Equipment detail = equipmentService.getOne(Condition.getQueryWrapper(equipment));*/ return R.data(equipmentService.selectInfo(equipment)); } /** * 分页 */ @GetMapping("/list") @ApiOperationSupport(order = 2) @ApiOperation(value = "分页", notes = "传入equipment") public R> list(Equipment equipment, Query query) { IPage pages = equipmentService.page(Condition.getPage(query), Condition.getQueryWrapper(equipment)); return R.data(pages); } /** * 自定义分页 */ @GetMapping("/page") @ApiOperationSupport(order = 3) @ApiOperation(value = "分页", notes = "传入equipment") public R> page(EquipmentVO equipment, Query query,String pid, HttpServletResponse response) { response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Allow-Credentials","true"); IPage pages; if (pid==null){ pages = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment); } else { String s = catalogService.selectCatalogEqNUmber(pid); if(s==null){ pages = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment); }else{ String[] split = s.split(","); String strArrays=""; for(int i=0;i> tree() { List tree = equipmentService.tree(); return R.data(tree); } /** * 懒加载列表 */ @GetMapping("/lazy-list") @ApiImplicitParams({ @ApiImplicitParam(name = "deptName", value = "部门名称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "fullName", value = "部门全称", paramType = "query", dataType = "string") }) @ApiOperationSupport(order = 3) @ApiOperation(value = "懒加载列表", notes = "传入dept") public R> lazyList(@ApiIgnore @RequestParam Map dept, Long parentId) { List list = equipmentService.lazyList(parentId, dept); return R.data(EqWrapper.build().listNodeLazyVO(list)); } /** * 设备列表 * @param deviceType 设备类型 * @return */ @GetMapping("/selectList") public R> selectList(String deviceType, HttpServletResponse response) { response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Allow-Credentials","true"); List list = equipmentService.selectList(deviceType); return R.data(list); } }