package com.vincent.rsf.server.system.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.vincent.rsf.framework.common.Cools;
|
import com.vincent.rsf.framework.common.R;
|
import com.vincent.rsf.server.common.utils.ExcelUtil;
|
import com.vincent.rsf.server.common.annotation.OperationLog;
|
import com.vincent.rsf.server.common.domain.BaseParam;
|
import com.vincent.rsf.server.common.domain.KeyValVo;
|
import com.vincent.rsf.server.common.domain.PageParam;
|
import com.vincent.rsf.server.system.entity.SubsystemFlowTemplate;
|
import com.vincent.rsf.server.system.service.SubsystemFlowTemplateService;
|
import com.vincent.rsf.server.system.controller.BaseController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.*;
|
|
@RestController
|
public class SubsystemFlowTemplateController extends BaseController {
|
|
@Autowired
|
private SubsystemFlowTemplateService subsystemFlowTemplateService;
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:list')")
|
@PostMapping("/subsystemFlowTemplate/page")
|
public R page(@RequestBody Map<String, Object> map) {
|
BaseParam baseParam = buildParam(map, BaseParam.class);
|
PageParam<SubsystemFlowTemplate, BaseParam> pageParam = new PageParam<>(baseParam, SubsystemFlowTemplate.class);
|
return R.ok().add(subsystemFlowTemplateService.page(pageParam, pageParam.buildWrapper(true)));
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:list')")
|
@PostMapping("/subsystemFlowTemplate/list")
|
public R list(@RequestBody Map<String, Object> map) {
|
return R.ok().add(subsystemFlowTemplateService.list());
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:list')")
|
@PostMapping({"/subsystemFlowTemplate/many/{ids}", "/subsystemFlowTemplates/many/{ids}"})
|
public R many(@PathVariable Long[] ids) {
|
return R.ok().add(subsystemFlowTemplateService.listByIds(Arrays.asList(ids)));
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:list')")
|
@GetMapping("/subsystemFlowTemplate/{id}")
|
public R get(@PathVariable("id") Long id) {
|
return R.ok().add(subsystemFlowTemplateService.getById(id));
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:save')")
|
@OperationLog("Create 子系统模板")
|
@PostMapping("/subsystemFlowTemplate/save")
|
public R save(@RequestBody SubsystemFlowTemplate subsystemFlowTemplate) {
|
subsystemFlowTemplate.setCreateBy(getLoginUserId());
|
subsystemFlowTemplate.setCreateTime(new Date());
|
subsystemFlowTemplate.setUpdateBy(getLoginUserId());
|
subsystemFlowTemplate.setUpdateTime(new Date());
|
if (!subsystemFlowTemplateService.save(subsystemFlowTemplate)) {
|
return R.error("Save Fail");
|
}
|
return R.ok("Save Success").add(subsystemFlowTemplate);
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:update')")
|
@OperationLog("Update 子系统模板")
|
@PostMapping("/subsystemFlowTemplate/update")
|
public R update(@RequestBody SubsystemFlowTemplate subsystemFlowTemplate) {
|
subsystemFlowTemplate.setUpdateBy(getLoginUserId());
|
subsystemFlowTemplate.setUpdateTime(new Date());
|
if (!subsystemFlowTemplateService.updateById(subsystemFlowTemplate)) {
|
return R.error("Update Fail");
|
}
|
return R.ok("Update Success").add(subsystemFlowTemplate);
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:remove')")
|
@OperationLog("Delete 子系统模板")
|
@PostMapping("/subsystemFlowTemplate/remove/{ids}")
|
public R remove(@PathVariable Long[] ids) {
|
if (!subsystemFlowTemplateService.removeByIds(Arrays.asList(ids))) {
|
return R.error("Delete Fail");
|
}
|
return R.ok("Delete Success").add(ids);
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:list')")
|
@PostMapping("/subsystemFlowTemplate/query")
|
public R query(@RequestParam(required = false) String condition) {
|
List<KeyValVo> vos = new ArrayList<>();
|
LambdaQueryWrapper<SubsystemFlowTemplate> wrapper = new LambdaQueryWrapper<>();
|
if (!Cools.isEmpty(condition)) {
|
wrapper.like(SubsystemFlowTemplate::getId, condition);
|
}
|
subsystemFlowTemplateService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
|
item -> vos.add(new KeyValVo(item.getId(), item.getId()))
|
);
|
return R.ok().add(vos);
|
}
|
|
@PreAuthorize("hasAuthority('system:subsystemFlowTemplate:list')")
|
@PostMapping("/subsystemFlowTemplate/export")
|
public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
|
ExcelUtil.build(ExcelUtil.create(subsystemFlowTemplateService.list(), SubsystemFlowTemplate.class), response);
|
}
|
|
}
|