package com.ruoyi.web.controller.oa;
|
|
import java.util.List;
|
import java.util.Arrays;
|
import java.util.concurrent.TimeUnit;
|
|
import com.ruoyi.common.annotation.DataDictClass;
|
import lombok.RequiredArgsConstructor;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.validation.constraints.*;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.validation.annotation.Validated;
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.validate.AddGroup;
|
import com.ruoyi.common.core.validate.EditGroup;
|
import com.ruoyi.common.core.validate.QueryGroup;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.oa.domain.vo.SgExchangeVo;
|
import com.ruoyi.oa.domain.bo.SgExchangeBo;
|
import com.ruoyi.oa.service.ISgExchangeService;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiOperation;
|
|
/**
|
* 交换设备Controller
|
*
|
* @author ruoyi
|
* @date 2022-05-13
|
*/
|
@Validated
|
@Api(value = "交换设备控制器", tags = {"交换设备管理"})
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
@RestController
|
@RequestMapping("/oa/exchange")
|
public class SgExchangeController extends BaseController {
|
|
private final ISgExchangeService iSgExchangeService;
|
|
/**
|
* 查询交换设备列表
|
*/
|
@DataDictClass
|
@ApiOperation("查询交换设备列表")
|
@PreAuthorize("@ss.hasPermi('oa:exchange:list')")
|
@GetMapping("/list")
|
public TableDataInfo<SgExchangeVo> list(@Validated(QueryGroup.class) SgExchangeBo bo) {
|
return iSgExchangeService.queryPageList(bo);
|
}
|
|
/**
|
* 导出交换设备列表
|
*/
|
@ApiOperation("导出交换设备列表")
|
@PreAuthorize("@ss.hasPermi('oa:exchange:export')")
|
@Log(title = "交换设备", businessType = BusinessType.EXPORT)
|
@GetMapping("/export")
|
public void export(@Validated SgExchangeBo bo, HttpServletResponse response) {
|
List<SgExchangeVo> list = iSgExchangeService.queryList(bo);
|
ExcelUtil.exportExcel(list, "交换设备", SgExchangeVo.class, response);
|
}
|
|
/**
|
* 获取交换设备详细信息
|
*/
|
@ApiOperation("获取交换设备详细信息")
|
@PreAuthorize("@ss.hasPermi('oa:exchange:query')")
|
@GetMapping("/{id}")
|
public AjaxResult<SgExchangeVo> getInfo(@ApiParam("主键")
|
@NotNull(message = "主键不能为空")
|
@PathVariable("id") Long id) {
|
return AjaxResult.success(iSgExchangeService.queryById(id));
|
}
|
|
/**
|
* 新增交换设备
|
*/
|
@ApiOperation("新增交换设备")
|
@PreAuthorize("@ss.hasPermi('oa:exchange:add')")
|
@Log(title = "交换设备", businessType = BusinessType.INSERT)
|
@RepeatSubmit()
|
@PostMapping()
|
public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody SgExchangeBo bo) {
|
return toAjax(iSgExchangeService.insertByBo(bo) ? 1 : 0);
|
}
|
|
/**
|
* 修改交换设备
|
*/
|
@ApiOperation("修改交换设备")
|
@PreAuthorize("@ss.hasPermi('oa:exchange:edit')")
|
@Log(title = "交换设备", businessType = BusinessType.UPDATE)
|
@RepeatSubmit()
|
@PutMapping()
|
public AjaxResult<Void> edit(@Validated(EditGroup.class) @RequestBody SgExchangeBo bo) {
|
return toAjax(iSgExchangeService.updateByBo(bo) ? 1 : 0);
|
}
|
|
/**
|
* 删除交换设备
|
*/
|
@ApiOperation("删除交换设备")
|
@PreAuthorize("@ss.hasPermi('oa:exchange:remove')")
|
@Log(title = "交换设备" , businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public AjaxResult<Void> remove(@ApiParam("主键串")
|
@NotEmpty(message = "主键不能为空")
|
@PathVariable Long[] ids) {
|
return toAjax(iSgExchangeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
}
|
}
|