package com.iailab.module.pms.controller.admin.demo;
|
|
import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
|
import com.iailab.framework.common.pojo.CommonResult;
|
import com.iailab.framework.common.pojo.PageParam;
|
import com.iailab.framework.common.pojo.PageResult;
|
import com.iailab.framework.common.util.object.BeanUtils;
|
import com.iailab.framework.excel.core.util.ExcelUtils;
|
import com.iailab.module.pms.controller.admin.demo.vo.DemoPageReqVO;
|
import com.iailab.module.pms.controller.admin.demo.vo.DemoRespVO;
|
import com.iailab.module.pms.controller.admin.demo.vo.DemoSaveReqVO;
|
import com.iailab.module.pms.dal.dataobject.demo.DemoDO;
|
import com.iailab.module.pms.service.demo.DemoService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.validation.Valid;
|
import java.io.IOException;
|
import java.util.List;
|
|
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static com.iailab.framework.common.pojo.CommonResult.success;
|
|
@Tag(name = "管理后台 - 演示管理")
|
@RestController
|
@RequestMapping("/pms/demo")
|
public class DemoController {
|
|
@Resource
|
private DemoService demoService;
|
|
@PostMapping("/create")
|
@Operation(summary = "创建演示")
|
@PreAuthorize("@ss.hasPermission('pms:demo:create')")
|
public CommonResult<Long> createDemo(@Valid @RequestBody DemoSaveReqVO createReqVO) {
|
return success(demoService.create(createReqVO));
|
}
|
|
@PutMapping("/update")
|
@Operation(summary = "更新演示")
|
@PreAuthorize("@ss.hasPermission('pms:demo:update')")
|
public CommonResult<Boolean> updateDemo(@Valid @RequestBody DemoSaveReqVO updateReqVO) {
|
demoService.update(updateReqVO);
|
return success(true);
|
}
|
|
@DeleteMapping("/delete")
|
@Operation(summary = "删除演示")
|
@Parameter(name = "id", description = "ID", required = true, example = "1024")
|
@PreAuthorize("@ss.hasPermission('pms:demo:delete')")
|
public CommonResult<Boolean> deleteDemo(@RequestParam("id") Long id) {
|
demoService.delete(id);
|
return success(true);
|
}
|
|
@GetMapping("/get")
|
@Operation(summary = "获得演示")
|
@Parameter(name = "id", description = "ID", required = true, example = "1024")
|
@PreAuthorize("@ss.hasPermission('pms:demo:query')")
|
public CommonResult<DemoRespVO> getDemo(@RequestParam("id") Long id) {
|
DemoDO data = demoService.getInfo(id);
|
return success(BeanUtils.toBean(data, DemoRespVO.class));
|
}
|
|
@GetMapping("/page")
|
@Operation(summary = "获得分页")
|
@PreAuthorize("@ss.hasPermission('pms:demo:query')")
|
public CommonResult<PageResult<DemoRespVO>> getDemoPage(@Valid DemoPageReqVO pageVO) {
|
PageResult<DemoDO> pageResult = demoService.getPage(pageVO);
|
return success(BeanUtils.toBean(pageResult, DemoRespVO.class));
|
}
|
|
@GetMapping("/export-excel")
|
@Operation(summary = "导出 Excel")
|
@PreAuthorize("@ss.hasPermission('system:demo:export')")
|
@ApiAccessLog(operateType = EXPORT)
|
public void exportDemoExcel(@Valid DemoPageReqVO exportReqVO,
|
HttpServletResponse response) throws IOException {
|
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
List<DemoDO> list = demoService.getPage(exportReqVO).getList();
|
// 导出 Excel
|
ExcelUtils.write(response, "租户.xls", "数据", DemoRespVO.class,
|
BeanUtils.toBean(list, DemoRespVO.class));
|
}
|
}
|