package com.ruoyi.web.controller.system;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.system.domain.Industry;
|
import com.ruoyi.system.pojo.dto.AddIndustryDTO;
|
import com.ruoyi.system.pojo.dto.EditIndustryDTO;
|
import com.ruoyi.system.pojo.vo.IndustryPageVO;
|
import com.ruoyi.system.service.IndustryService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.validation.Valid;
|
|
@Slf4j
|
@RestController
|
@RequestMapping("/system/industry")
|
@Api( tags = "后台-系统设置-所属行业管理")
|
public class IndustryController {
|
@Resource
|
private IndustryService industryService;
|
|
/**
|
* 所属行业分页
|
*/
|
@GetMapping("/getIndustryPage")
|
@ApiOperation(value = "所属行业分页")
|
public R<IPage<IndustryPageVO>> getIndustryPage(
|
@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
|
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
|
@RequestParam(value = "name",required = false) String name) {
|
return R.ok(industryService.getIndustryPage(pageNum,pageSize,name));
|
}
|
|
/**
|
* 新增
|
*/
|
@PostMapping("/add")
|
@ApiOperation(value = "所属行业添加")
|
public R<Void> add(@RequestBody @Valid AddIndustryDTO dto) {
|
industryService.add(dto);
|
return R.ok();
|
}
|
/**
|
* 查看详情
|
*/
|
@GetMapping("/getIndustryById/{id}")
|
@ApiOperation(value = "根据id查看详情")
|
public R<Industry> getIndustryById(@PathVariable("id")Integer id) {
|
Industry industry = industryService.getById(id);
|
if (null == industry||industry.getDelFlag()!=0){
|
throw new ServiceException("该行业不存在");
|
}
|
return R.ok(industry);
|
}
|
|
/**
|
* 修改
|
*/
|
@PutMapping("/edit")
|
@ApiOperation(value = "所属行业编辑")
|
public R<Void> edit(@RequestBody @Valid EditIndustryDTO dto) {
|
industryService.edit(dto);
|
return R.ok();
|
}
|
/**
|
* 删除
|
*/
|
@DeleteMapping("/delete/{id}")
|
@ApiOperation(value = "所属行业删除")
|
public R<Void> delete(@PathVariable("id")Integer id) {
|
industryService.delete(id);
|
return R.ok();
|
}
|
|
|
}
|