package org.dromara.demo.controller;
|
|
import java.util.Date;
|
import java.util.List;
|
|
import lombok.RequiredArgsConstructor;
|
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.validation.constraints.*;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import org.dromara.common.core.domain.model.LoginUser;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.validation.annotation.Validated;
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
import org.dromara.common.log.annotation.Log;
|
import org.dromara.common.web.core.BaseController;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.validate.AddGroup;
|
import org.dromara.common.core.validate.EditGroup;
|
import org.dromara.common.log.enums.BusinessType;
|
import org.dromara.common.excel.utils.ExcelUtil;
|
import org.dromara.demo.domain.vo.TargetManageVo;
|
import org.dromara.demo.domain.bo.TargetManageBo;
|
import org.dromara.demo.service.ITargetManageService;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
/**
|
* 【指标管理】
|
*
|
* @author Lion Li
|
* @date 2024-02-20
|
*/
|
@Validated
|
@RequiredArgsConstructor
|
@RestController
|
@RequestMapping("/tg/manage")
|
public class TargetManageController extends BaseController {
|
|
private final ITargetManageService targetManageService;
|
|
/**
|
* 查询【指标管理】列表
|
*/
|
@SaCheckPermission("tg:manage:list")
|
@GetMapping("/list")
|
public TableDataInfo<TargetManageVo> list(TargetManageBo bo, PageQuery pageQuery) {
|
|
return targetManageService.queryPageList(bo, pageQuery);
|
}
|
|
/**
|
* 导出【指标管理】列表
|
*
|
*/
|
@SaCheckPermission("tg:manage:export")
|
@Log(title = "导出【指标管理】列表", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(TargetManageBo bo, HttpServletResponse response) {
|
List<TargetManageVo> list = targetManageService.queryList(bo);
|
ExcelUtil.exportExcel(list, "【指标管理】", TargetManageVo.class, response);
|
}
|
|
/**
|
* 获取【指标管理】详细信息
|
*
|
* @param tgId 主键
|
*/
|
@SaCheckPermission("tg:manage:query")
|
@GetMapping("/{tgId}")
|
public R<TargetManageVo> getInfo(@NotNull(message = "主键不能为空")
|
@PathVariable Long tgId) {
|
return R.ok(targetManageService.queryById(tgId));
|
}
|
|
/**
|
* 新增【指标管理】
|
*/
|
@SaCheckPermission("tg:manage:add")
|
@Log(title = "新增【指标管理】", businessType = BusinessType.INSERT)
|
@RepeatSubmit()
|
@PostMapping()
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody TargetManageBo bo) {
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
loginUser.getNickname();
|
System.out.println("登录人员"+loginUser);
|
bo.setUserId(loginUser.getUserId());
|
bo.setTgCreateTime(new Date());
|
return toAjax(targetManageService.insertByBo(bo));
|
}
|
|
/**
|
* 修改【指标管理】
|
*/
|
@SaCheckPermission("tg:manage:edit")
|
@Log(title = "修改【指标管理】", businessType = BusinessType.UPDATE)
|
@RepeatSubmit()
|
@PutMapping()
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TargetManageBo bo) {
|
return toAjax(targetManageService.updateByBo(bo));
|
}
|
@Log(title = "修改【启用状态】", businessType = BusinessType.UPDATE)
|
@RepeatSubmit()
|
@PutMapping("/update/{id}")
|
public R<Void> updateStatus(@PathVariable Long id) {
|
targetManageService.updateStatus(id);
|
return R.ok("状态调整成功");
|
}
|
|
/**
|
* 删除【指标管理】
|
*
|
* @param tgIds 主键串
|
*/
|
@SaCheckPermission("tg:manage:remove")
|
@Log(title = "删除【指标管理】", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{tgIds}")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
@PathVariable Long[] tgIds) {
|
return toAjax(targetManageService.deleteWithValidByIds(List.of(tgIds), true));
|
}
|
}
|