commit
3c68a6e606
@ -1,95 +1,103 @@
|
|||||||
package com.chanko.yunxi.mes.module.heli.controller.admin.material;
|
package com.chanko.yunxi.mes.module.heli.controller.admin.material;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import javax.servlet.http.*;
|
import javax.servlet.http.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
||||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||||
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
||||||
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
import com.chanko.yunxi.mes.module.heli.controller.admin.material.vo.*;
|
import com.chanko.yunxi.mes.module.heli.controller.admin.material.vo.*;
|
||||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.material.MaterialDO;
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.material.MaterialDO;
|
||||||
import com.chanko.yunxi.mes.module.heli.service.material.MaterialService;
|
import com.chanko.yunxi.mes.module.heli.service.material.MaterialService;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 物料")
|
@Tag(name = "管理后台 - 物料")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/heli/material")
|
@RequestMapping("/heli/material")
|
||||||
@Validated
|
@Validated
|
||||||
public class MaterialController {
|
public class MaterialController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialService materialService;
|
private MaterialService materialService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建物料")
|
@Operation(summary = "创建物料")
|
||||||
@PreAuthorize("@ss.hasPermission('heli:material:create')")
|
@PreAuthorize("@ss.hasPermission('heli:material:create')")
|
||||||
public CommonResult<Long> createMaterial(@Valid @RequestBody MaterialSaveReqVO createReqVO) {
|
public CommonResult<Long> createMaterial(@Valid @RequestBody MaterialSaveReqVO createReqVO) {
|
||||||
return success(materialService.createMaterial(createReqVO));
|
return success(materialService.createMaterial(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新物料")
|
@Operation(summary = "更新物料")
|
||||||
@PreAuthorize("@ss.hasPermission('heli:material:update')")
|
@PreAuthorize("@ss.hasPermission('heli:material:update')")
|
||||||
public CommonResult<Boolean> updateMaterial(@Valid @RequestBody MaterialSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateMaterial(@Valid @RequestBody MaterialSaveReqVO updateReqVO) {
|
||||||
materialService.updateMaterial(updateReqVO);
|
materialService.updateMaterial(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除物料")
|
@Operation(summary = "删除物料")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('heli:material:delete')")
|
@PreAuthorize("@ss.hasPermission('heli:material:delete')")
|
||||||
public CommonResult<Boolean> deleteMaterial(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> deleteMaterial(@RequestParam("id") Long id) {
|
||||||
materialService.deleteMaterial(id);
|
materialService.deleteMaterial(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得物料")
|
@Operation(summary = "获得物料")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('heli:material:query')")
|
@PreAuthorize("@ss.hasPermission('heli:material:query')")
|
||||||
public CommonResult<MaterialRespVO> getMaterial(@RequestParam("id") Long id) {
|
public CommonResult<MaterialRespVO> getMaterial(@RequestParam("id") Long id) {
|
||||||
MaterialDO material = materialService.getMaterial(id);
|
MaterialDO material = materialService.getMaterial(id);
|
||||||
return success(BeanUtils.toBean(material, MaterialRespVO.class));
|
return success(BeanUtils.toBean(material, MaterialRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得物料分页")
|
@Operation(summary = "获得物料分页")
|
||||||
@PreAuthorize("@ss.hasPermission('heli:material:query')")
|
@PreAuthorize("@ss.hasPermission('heli:material:query')")
|
||||||
public CommonResult<PageResult<MaterialRespVO>> getMaterialPage(@Valid MaterialPageReqVO pageReqVO) {
|
public CommonResult<PageResult<MaterialRespVO>> getMaterialPage(@Valid MaterialPageReqVO pageReqVO) {
|
||||||
PageResult<MaterialDO> pageResult = materialService.getMaterialPage(pageReqVO);
|
PageResult<MaterialDO> pageResult = materialService.getMaterialPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, MaterialRespVO.class));
|
return success(BeanUtils.toBean(pageResult, MaterialRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出物料 Excel")
|
@Operation(summary = "导出物料 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('heli:material:export')")
|
@PreAuthorize("@ss.hasPermission('heli:material:export')")
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void exportMaterialExcel(@Valid MaterialPageReqVO pageReqVO,
|
public void exportMaterialExcel(@Valid MaterialPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<MaterialDO> list = materialService.getMaterialPage(pageReqVO).getList();
|
List<MaterialDO> list = materialService.getMaterialPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "物料.xls", "数据", MaterialRespVO.class,
|
ExcelUtils.write(response, "物料.xls", "数据", MaterialRespVO.class,
|
||||||
BeanUtils.toBean(list, MaterialRespVO.class));
|
BeanUtils.toBean(list, MaterialRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@GetMapping({"/all-simples"})
|
||||||
|
@Operation(summary = "TODO:获取物料精简信息列表", description = "只包含被开启的物料,主要用于前端的下拉选项")
|
||||||
|
public CommonResult<List<Map<String, Object>> > getSimpleList() {
|
||||||
|
List<Map<String, Object>> list = materialService.getSimpleList();
|
||||||
|
// 拼接数据
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,55 +1,57 @@
|
|||||||
package com.chanko.yunxi.mes.module.heli.service.material;
|
package com.chanko.yunxi.mes.module.heli.service.material;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import com.chanko.yunxi.mes.module.heli.controller.admin.material.vo.*;
|
import com.chanko.yunxi.mes.module.heli.controller.admin.material.vo.*;
|
||||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.material.MaterialDO;
|
import com.chanko.yunxi.mes.module.heli.dal.dataobject.material.MaterialDO;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料 Service 接口
|
* 物料 Service 接口
|
||||||
*
|
*
|
||||||
* @author 开发者
|
* @author 开发者
|
||||||
*/
|
*/
|
||||||
public interface MaterialService {
|
public interface MaterialService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建物料
|
* 创建物料
|
||||||
*
|
*
|
||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
Long createMaterial(@Valid MaterialSaveReqVO createReqVO);
|
Long createMaterial(@Valid MaterialSaveReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新物料
|
* 更新物料
|
||||||
*
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateMaterial(@Valid MaterialSaveReqVO updateReqVO);
|
void updateMaterial(@Valid MaterialSaveReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除物料
|
* 删除物料
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
*/
|
*/
|
||||||
void deleteMaterial(Long id);
|
void deleteMaterial(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得物料
|
* 获得物料
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 物料
|
* @return 物料
|
||||||
*/
|
*/
|
||||||
MaterialDO getMaterial(Long id);
|
MaterialDO getMaterial(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得物料分页
|
* 获得物料分页
|
||||||
*
|
*
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 物料分页
|
* @return 物料分页
|
||||||
*/
|
*/
|
||||||
PageResult<MaterialDO> getMaterialPage(MaterialPageReqVO pageReqVO);
|
PageResult<MaterialDO> getMaterialPage(MaterialPageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
List<Map<String, Object>> getSimpleList();
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in new issue