2022-07-20 15:29:54 +08:00
|
|
|
|
package com.cnbm.basic.controller;
|
|
|
|
|
|
|
|
|
|
import com.cnbm.admin.annotation.LogOperation;
|
|
|
|
|
import com.cnbm.common.constant.Constant;
|
|
|
|
|
import com.cnbm.common.page.PageData;
|
|
|
|
|
import com.cnbm.common.utils.ExcelUtils;
|
|
|
|
|
import com.cnbm.common.utils.Result;
|
|
|
|
|
import com.cnbm.common.validator.AssertUtils;
|
|
|
|
|
import com.cnbm.common.validator.ValidatorUtils;
|
|
|
|
|
import com.cnbm.common.validator.group.AddGroup;
|
|
|
|
|
import com.cnbm.common.validator.group.DefaultGroup;
|
|
|
|
|
import com.cnbm.common.validator.group.UpdateGroup;
|
|
|
|
|
import com.cnbm.basic.dto.MachineDTO;
|
|
|
|
|
import com.cnbm.basic.excel.MachineExcel;
|
|
|
|
|
import com.cnbm.basic.service.IMachineService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 机台表 前端控制器
|
|
|
|
|
*
|
|
|
|
|
* @author why
|
|
|
|
|
* @since 2022-07-15
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/code/machine")
|
|
|
|
|
@Api(tags="机台表")
|
|
|
|
|
public class MachineController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMachineService machineService;
|
|
|
|
|
|
|
|
|
|
@GetMapping("page")
|
|
|
|
|
@ApiOperation("分页")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
|
|
|
|
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
|
|
|
|
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
|
|
|
|
|
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
|
|
|
|
|
})
|
|
|
|
|
@PreAuthorize("@ex.hasAuthority('code:machine:page')")
|
|
|
|
|
public Result<PageData<MachineDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
|
|
|
|
PageData<MachineDTO> page = machineService.page(params);
|
|
|
|
|
|
|
|
|
|
return new Result<PageData<MachineDTO>>().ok(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("{id}")
|
|
|
|
|
@ApiOperation("信息")
|
|
|
|
|
@PreAuthorize("@ex.hasAuthority('code:machine:info')")
|
|
|
|
|
public Result<MachineDTO> get(@PathVariable("id") Long id){
|
|
|
|
|
MachineDTO data = machineService.get(id);
|
|
|
|
|
|
|
|
|
|
return new Result<MachineDTO>().ok(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping
|
|
|
|
|
@ApiOperation("保存")
|
|
|
|
|
@LogOperation("保存")
|
|
|
|
|
@PreAuthorize("@ex.hasAuthority('code:machine:save')")
|
|
|
|
|
public Result save(@RequestBody MachineDTO dto){
|
|
|
|
|
//效验数据
|
|
|
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
|
|
|
|
|
|
|
|
|
machineService.save(dto);
|
|
|
|
|
|
|
|
|
|
return new Result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping
|
|
|
|
|
@ApiOperation("修改")
|
|
|
|
|
@LogOperation("修改")
|
|
|
|
|
@PreAuthorize("@ex.hasAuthority('code:machine:update')")
|
|
|
|
|
public Result update(@RequestBody MachineDTO dto){
|
|
|
|
|
//效验数据
|
|
|
|
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
|
|
|
|
|
|
|
|
machineService.update(dto);
|
|
|
|
|
|
|
|
|
|
return new Result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping
|
|
|
|
|
@ApiOperation("删除")
|
|
|
|
|
@LogOperation("删除")
|
|
|
|
|
@PreAuthorize("@ex.hasAuthority('code:machine:delete')")
|
|
|
|
|
public Result delete(@RequestBody Long[] ids){
|
|
|
|
|
//效验数据
|
|
|
|
|
AssertUtils.isArrayEmpty(ids, "id");
|
|
|
|
|
|
|
|
|
|
machineService.delete(ids);
|
|
|
|
|
|
|
|
|
|
return new Result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("export")
|
|
|
|
|
@ApiOperation("导出")
|
|
|
|
|
@LogOperation("导出")
|
|
|
|
|
@PreAuthorize("@ex.hasAuthority('code:machine:export')")
|
|
|
|
|
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
|
|
|
|
List<MachineDTO> list = machineService.list(params);
|
|
|
|
|
|
|
|
|
|
ExcelUtils.exportExcelToTarget(response, null, list, MachineExcel.class);
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 09:47:38 +08:00
|
|
|
|
@GetMapping("{statusId}")
|
|
|
|
|
@ApiOperation("改变状态")
|
|
|
|
|
@LogOperation("改变状态")
|
|
|
|
|
public Result changeStatus(@PathVariable("id") Long id){
|
|
|
|
|
machineService.changeStatus(id);
|
|
|
|
|
|
|
|
|
|
return new Result();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-20 15:29:54 +08:00
|
|
|
|
}
|