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