|
|
|
package org.jeecg.modules.airag.app.controller;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
import org.jeecg.modules.airag.app.entity.AiragButton;
|
|
|
|
import org.jeecg.modules.airag.app.service.IAiragButtonService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Description: 按钮表单
|
|
|
|
* @Author: jeecg-boot
|
|
|
|
* @Date: 2025-06-05
|
|
|
|
* @Version: V1.0
|
|
|
|
*/
|
|
|
|
@Tag(name="按钮表单")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/airagbutton/airagButton")
|
|
|
|
@Slf4j
|
|
|
|
public class AiragButtonController extends JeecgController<AiragButton, IAiragButtonService> {
|
|
|
|
@Autowired
|
|
|
|
private IAiragButtonService airagButtonService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param airagButton
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "按钮表单-分页列表查询")
|
|
|
|
@Operation(summary="按钮表单-分页列表查询")
|
|
|
|
@GetMapping(value = "/list")
|
|
|
|
public Result<IPage<AiragButton>> queryPageList(AiragButton airagButton,
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
QueryWrapper<AiragButton> queryWrapper = QueryGenerator.initQueryWrapper(airagButton, req.getParameterMap());
|
|
|
|
Page<AiragButton> page = new Page<AiragButton>(pageNo, pageSize);
|
|
|
|
IPage<AiragButton> pageList = airagButtonService.page(page, queryWrapper);
|
|
|
|
// pageList.setRecords(airagButtonService. findAll(airagButton));
|
|
|
|
return Result.OK(pageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 添加
|
|
|
|
*
|
|
|
|
* @param airagButton
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "按钮表单-添加")
|
|
|
|
@Operation(summary="按钮表单-添加")
|
|
|
|
@RequiresPermissions("airagbutton:airag_button:add")
|
|
|
|
@PostMapping(value = "/add")
|
|
|
|
public Result<String> add(@RequestBody AiragButton airagButton) {
|
|
|
|
// 检查按钮开关是否为开启状态
|
|
|
|
if ("Y".equals(airagButton.getButtonSwitch())) {
|
|
|
|
// 查询当前已开启的按钮数量
|
|
|
|
QueryWrapper<AiragButton> queryWrapper = new QueryWrapper<>();
|
|
|
|
queryWrapper.eq("button_switch", "Y");
|
|
|
|
long openedButtonCount = airagButtonService.count(queryWrapper);
|
|
|
|
|
|
|
|
// 如果已开启的按钮数量超过或等于5个,则返回错误提示
|
|
|
|
if (openedButtonCount >= 5) {
|
|
|
|
return Result.error("按钮超过五个,请先关闭一个按钮");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
airagButtonService.save(airagButton);
|
|
|
|
return Result.OK("添加成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 编辑
|
|
|
|
*
|
|
|
|
* @param airagButton
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "按钮表单-编辑")
|
|
|
|
@Operation(summary="按钮表单-编辑")
|
|
|
|
@RequiresPermissions("airagbutton:airag_button:edit")
|
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
|
public Result<String> edit(@RequestBody AiragButton airagButton) {
|
|
|
|
// 检查按钮开关是否为开启状态
|
|
|
|
if ("Y".equals(airagButton.getButtonSwitch())) {
|
|
|
|
// 查询当前已开启的按钮数量(排除自身)
|
|
|
|
QueryWrapper<AiragButton> queryWrapper = new QueryWrapper<>();
|
|
|
|
queryWrapper.eq("button_switch", "Y")
|
|
|
|
.ne("id", airagButton.getId()); // 排除当前正在编辑的按钮
|
|
|
|
long openedButtonCount = airagButtonService.count(queryWrapper);
|
|
|
|
|
|
|
|
// 如果已开启的按钮数量超过或等于5个,则返回错误提示
|
|
|
|
if (openedButtonCount >= 5) {
|
|
|
|
return Result.error("按钮超过五个,请先关闭一个按钮");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
airagButtonService.updateById(airagButton);
|
|
|
|
return Result.OK("编辑成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过id删除
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "按钮表单-通过id删除")
|
|
|
|
@Operation(summary="按钮表单-通过id删除")
|
|
|
|
@RequiresPermissions("airagbutton:airag_button:delete")
|
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
|
airagButtonService.removeById(id);
|
|
|
|
return Result.OK("删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 批量删除
|
|
|
|
*
|
|
|
|
* @param ids
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "按钮表单-批量删除")
|
|
|
|
@Operation(summary="按钮表单-批量删除")
|
|
|
|
@RequiresPermissions("airagbutton:airag_button:deleteBatch")
|
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
|
this.airagButtonService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
|
return Result.OK("批量删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过id查询
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "按钮表单-通过id查询")
|
|
|
|
@Operation(summary="按钮表单-通过id查询")
|
|
|
|
@GetMapping(value = "/queryById")
|
|
|
|
public Result<AiragButton> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
|
AiragButton airagButton = airagButtonService.getById(id);
|
|
|
|
if(airagButton==null) {
|
|
|
|
return Result.error("未找到对应数据");
|
|
|
|
}
|
|
|
|
return Result.OK(airagButton);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出excel
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param airagButton
|
|
|
|
*/
|
|
|
|
@RequiresPermissions("airagbutton:airag_button:exportXls")
|
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
|
public ModelAndView exportXls(HttpServletRequest request, AiragButton airagButton) {
|
|
|
|
return super.exportXls(request, airagButton, AiragButton.class, "按钮表单");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过excel导入数据
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param response
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@RequiresPermissions("airagbutton:airag_button:importExcel")
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
return super.importExcel(request, response, AiragButton.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|