package com.by4cloud.platformx.business.controller;
|
|
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.collection.CollUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.by4cloud.platformx.common.core.util.R;
|
import com.by4cloud.platformx.common.log.annotation.SysLog;
|
import com.by4cloud.platformx.business.entity.AnnualPlanKey;
|
import com.by4cloud.platformx.business.service.AnnualPlanKeyService;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import org.springdoc.core.annotations.ParameterObject;
|
import org.springframework.http.HttpHeaders;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.Operation;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
import java.util.Objects;
|
|
/**
|
* 重点工作计划
|
*
|
* @author syt
|
* @date 2026-10-29 13:35:43
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/annualPlanKey" )
|
@Tag(description = "annualPlanKey" , name = "重点工作计划管理" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class AnnualPlanKeyController {
|
|
private final AnnualPlanKeyService annualPlanKeyService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param annualPlanKey 重点工作计划
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
@PreAuthorize("@pms.hasPermission('bueiness_annualPlanKey_view')" )
|
public R getAnnualPlanKeyPage(@ParameterObject Page page, @ParameterObject AnnualPlanKey annualPlanKey) {
|
LambdaQueryWrapper<AnnualPlanKey> wrapper = Wrappers.lambdaQuery();
|
wrapper.eq(StrUtil.isNotBlank(annualPlanKey.getPlanYear()),AnnualPlanKey::getPlanYear,annualPlanKey.getPlanYear());
|
wrapper.orderByDesc(AnnualPlanKey::getCreateTime);
|
return R.ok(annualPlanKeyService.pageByScope(page, wrapper));
|
}
|
|
|
/**
|
* 通过id查询重点工作计划
|
* @param id id
|
* @return R
|
*/
|
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
@GetMapping("/{id}" )
|
@PreAuthorize("@pms.hasPermission('bueiness_annualPlanKey_view')" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(annualPlanKeyService.getById(id));
|
}
|
|
/**
|
* 新增重点工作计划
|
* @param annualPlanKey 重点工作计划
|
* @return R
|
*/
|
@Operation(summary = "新增重点工作计划" , description = "新增重点工作计划" )
|
@SysLog("新增重点工作计划" )
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('bueiness_annualPlanKey_add')" )
|
public R save(@RequestBody AnnualPlanKey annualPlanKey) {
|
return annualPlanKeyService.add(annualPlanKey);
|
}
|
|
/**
|
* 修改重点工作计划
|
* @param annualPlanKey 重点工作计划
|
* @return R
|
*/
|
@Operation(summary = "修改重点工作计划" , description = "修改重点工作计划" )
|
@SysLog("修改重点工作计划" )
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('bueiness_annualPlanKey_edit')" )
|
public R updateById(@RequestBody AnnualPlanKey annualPlanKey) {
|
return R.ok(annualPlanKeyService.updateById(annualPlanKey));
|
}
|
|
/**
|
* 通过id删除重点工作计划
|
* @param ids id列表
|
* @return R
|
*/
|
@Operation(summary = "通过id删除重点工作计划" , description = "通过id删除重点工作计划" )
|
@SysLog("通过id删除重点工作计划" )
|
@DeleteMapping
|
@PreAuthorize("@pms.hasPermission('bueiness_annualPlanKey_del')" )
|
public R removeById(@RequestBody Long[] ids) {
|
return R.ok(annualPlanKeyService.removeBatchByIds(CollUtil.toList(ids)));
|
}
|
|
|
/**
|
* 导出excel 表格
|
* @param annualPlanKey 查询条件
|
* @param ids 导出指定ID
|
* @return excel 文件流
|
*/
|
@ResponseExcel
|
@GetMapping("/export")
|
@PreAuthorize("@pms.hasPermission('bueiness_annualPlanKey_export')" )
|
public List<AnnualPlanKey> export(AnnualPlanKey annualPlanKey,Long[] ids) {
|
return annualPlanKeyService.list(Wrappers.lambdaQuery(annualPlanKey).in(ArrayUtil.isNotEmpty(ids), AnnualPlanKey::getId, ids));
|
}
|
}
|