package net.mingsoft.tf.action; import java.util.List; import java.io.File; import java.util.ArrayList; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import cn.hutool.core.util.ObjectUtil; import java.util.*; import net.mingsoft.base.entity.ResultData; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.util.stream.Collectors; import org.springframework.web.bind.annotation.*; import net.mingsoft.tf.biz.IBoothBiz; import net.mingsoft.tf.entity.BoothEntity; import net.mingsoft.base.entity.BaseEntity; import net.mingsoft.basic.util.BasicUtil; import net.mingsoft.basic.util.StringUtil; import net.mingsoft.basic.bean.EUListBean; import net.mingsoft.basic.annotation.LogAnn; import net.mingsoft.basic.constant.e.BusinessTypeEnum; import org.apache.commons.lang3.StringUtils; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.enums.ParameterIn; /** * 展位管理控制层 * @author 阿白 * 创建日期:2025年10月23日 下午6:41:34
* 历史修订:
*/ @Tag(name = "后台-展位接口") @Controller("tfBoothAction") @RequestMapping("/${ms.manager.path}/tf/booth") public class BoothAction extends net.mingsoft.tf.action.BaseAction{ /** * 注入展位业务层 */ @Autowired private IBoothBiz boothBiz; /** * 返回主界面index */ @Hidden @GetMapping("/index") public String index() { return "/tf/booth/index"; } /** * 返回编辑界面booth的form */ @Hidden @GetMapping("/form") public String form() { return "/tf/booth/form"; } /** * 查询展位列表 * @param booth 展位实体 */ @Operation(summary = "查询展位列表接口") @Parameters({ @Parameter(name = "boothCode", description = "编码", in = ParameterIn.QUERY), @Parameter(name = "boothFloor", description = "楼层", in = ParameterIn.QUERY), @Parameter(name = "boothName", description = "名称", in = ParameterIn.QUERY), @Parameter(name = "boothStyle", description = "风格", in = ParameterIn.QUERY), @Parameter(name = "boothMaterials", description = "材料", in = ParameterIn.QUERY), @Parameter(name = "boothX", description = "坐标X", in = ParameterIn.QUERY), @Parameter(name = "boothY", description = "坐标Y", in = ParameterIn.QUERY), @Parameter(name = "boothWidth", description = "宽度", in = ParameterIn.QUERY), @Parameter(name = "boothHeight", description = "高度", in = ParameterIn.QUERY), }) @RequestMapping(value ="/list",method = {RequestMethod.GET,RequestMethod.POST}) @ResponseBody @RequiresPermissions("tf:booth:view") public ResultData list(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) { BasicUtil.startPage(); List boothList = null; if ( booth.getSqlWhere() != null){ boothList = boothBiz.query(booth); } else { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(booth).orderByDesc(BoothEntity::getCreateDate); boothList = boothBiz.list(wrapper); } return ResultData.build().success(new EUListBean(boothList,(int)BasicUtil.endPage(boothList).getTotal())); } /** * 获取展位 * @param booth 展位实体 */ @Operation(summary = "获取展位列表接口") @Parameter(name = "id", description = "主键ID", required =true,in = ParameterIn.QUERY) @GetMapping("/get") @ResponseBody @RequiresPermissions("tf:booth:view") public ResultData get(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) { if (StringUtils.isBlank(booth.getId())) { return ResultData.build().error(getResString("err.error",this.getResString("id"))); } BoothEntity _booth = (BoothEntity)boothBiz.getById(booth.getId()); return ResultData.build().success(_booth); } /** * 保存展位 * @param booth 展位实体 */ @Operation(summary = "保存展位列表接口") @Parameters({ @Parameter(name = "boothCode", description = "编码", required = true, in = ParameterIn.QUERY), @Parameter(name = "boothFloor", description = "楼层", required = true, in = ParameterIn.QUERY), @Parameter(name = "boothName", description = "名称", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothStyle", description = "风格", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothMaterials", description = "材料", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothX", description = "坐标X", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothY", description = "坐标Y", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothWidth", description = "宽度", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothHeight", description = "高度", required = false, in = ParameterIn.QUERY), }) @PostMapping("/save") @ResponseBody @LogAnn(title = "保存展位", businessType = BusinessTypeEnum.INSERT) @RequiresPermissions("tf:booth:save") public ResultData save(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) { //验证编码的值是否重复 if (super.validated("mdiy_form_booth","BOOTH_CODE",booth.getBoothCode())) { return ResultData.build().error(getResString("err.exist", this.getResString("booth.code"))); } //验证编码的值是否合法 if (StringUtils.isBlank(booth.getBoothCode())) { return ResultData.build().error(getResString("err.empty", this.getResString("booth.code"))); } if (!StringUtil.checkLength(booth.getBoothCode()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.code"), "0", "255")); } //验证楼层的值是否合法 if (StringUtils.isBlank(booth.getBoothFloor())) { return ResultData.build().error(getResString("err.empty", this.getResString("booth.floor"))); } if (!StringUtil.checkLength(booth.getBoothFloor()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.floor"), "0", "255")); } if ( StringUtils.isNotBlank(booth.getBoothName()) && !StringUtil.checkLength(booth.getBoothName()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.name"), "0", "255")); } if ( StringUtils.isNotBlank(booth.getBoothStyle()) && !StringUtil.checkLength(booth.getBoothStyle()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.style"), "0", "255")); } if ( StringUtils.isNotBlank(booth.getBoothMaterials()) && !StringUtil.checkLength(booth.getBoothMaterials()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.materials"), "0", "255")); } if (!StringUtil.checkLength(booth.getBoothX()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.x"), "0", "11")); } if (!StringUtil.checkLength(booth.getBoothY()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.y"), "0", "11")); } if (!StringUtil.checkLength(booth.getBoothWidth()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.width"), "0", "11")); } if (!StringUtil.checkLength(booth.getBoothHeight()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.height"), "0", "11")); } boothBiz.save(booth); return ResultData.build().success(booth); } /** * 删除展位 * * @param booths 展位实体 */ @Operation(summary = "批量删除展位列表接口") @PostMapping("/delete") @ResponseBody @LogAnn(title = "删除展位", businessType = BusinessTypeEnum.DELETE) @RequiresPermissions("tf:booth:del") public ResultData delete(@RequestBody List booths) { List ids = (List)booths.stream().map((p) -> {return p.getId();}).collect(Collectors.toList()); return this.boothBiz.removeByIds(ids) ? ResultData.build().success() : ResultData.build().error(this.getResString("err.error", new String[]{this.getResString("id")})); } /** * 更新展位列表 * * @param booth 展位实体 */ @Operation(summary = "更新展位列表接口") @Parameters({ @Parameter(name = "id", description = "主键ID", required =true,in = ParameterIn.QUERY), @Parameter(name = "boothCode", description = "编码", required = true, in = ParameterIn.QUERY), @Parameter(name = "boothFloor", description = "楼层", required = true, in = ParameterIn.QUERY), @Parameter(name = "boothName", description = "名称", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothStyle", description = "风格", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothMaterials", description = "材料", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothX", description = "坐标X", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothY", description = "坐标Y", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothWidth", description = "宽度", required = false, in = ParameterIn.QUERY), @Parameter(name = "boothHeight", description = "高度", required = false, in = ParameterIn.QUERY), }) @PostMapping("/update") @ResponseBody @LogAnn(title = "更新展位", businessType = BusinessTypeEnum.UPDATE) @RequiresPermissions("tf:booth:update") public ResultData update(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) { //先查询数据是否存在 BoothEntity _booth = (BoothEntity)boothBiz.getById(booth.getId()); if(_booth == null) { return ResultData.build().error(getResString("err.not.exist",booth.getId() )); } //验证编码的值是否重复 if (super.validated("mdiy_form_booth","BOOTH_CODE",booth.getBoothCode(), booth.getId(),"id")) { return ResultData.build().error(getResString("err.exist", this.getResString("booth.code"))); } //验证编码的值是否合法 if (StringUtils.isBlank(booth.getBoothCode())) { return ResultData.build().error(getResString("err.empty", this.getResString("booth.code"))); } if (!StringUtil.checkLength(booth.getBoothCode()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.code"), "0", "255")); } //验证楼层的值是否合法 if (StringUtils.isBlank(booth.getBoothFloor())) { return ResultData.build().error(getResString("err.empty", this.getResString("booth.floor"))); } if (!StringUtil.checkLength(booth.getBoothFloor()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.floor"), "0", "255")); } if ( StringUtils.isNotBlank(booth.getBoothName()) && !StringUtil.checkLength(booth.getBoothName()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.name"), "0", "255")); } if ( StringUtils.isNotBlank(booth.getBoothStyle()) && !StringUtil.checkLength(booth.getBoothStyle()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.style"), "0", "255")); } if ( StringUtils.isNotBlank(booth.getBoothMaterials()) && !StringUtil.checkLength(booth.getBoothMaterials()+"", 0, 255)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.materials"), "0", "255")); } if (!StringUtil.checkLength(booth.getBoothX()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.x"), "0", "11")); } if (!StringUtil.checkLength(booth.getBoothY()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.y"), "0", "11")); } if (!StringUtil.checkLength(booth.getBoothWidth()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.width"), "0", "11")); } if (!StringUtil.checkLength(booth.getBoothHeight()+"", 0, 11)) { return ResultData.build().error(getResString("err.length", this.getResString("booth.height"), "0", "11")); } boothBiz.updateById(booth); return ResultData.build().success(booth); } @GetMapping("verify") @ResponseBody public ResultData verify(String fieldName, String fieldValue, String id,String idName) { boolean verify = false; if (StringUtils.isBlank(id)) { verify = super.validated("mdiy_form_booth",fieldName,fieldValue); } else { verify = super.validated("mdiy_form_booth",fieldName,fieldValue,id,idName); } if (verify) { return ResultData.build().success(false); }else { return ResultData.build().success(true); } } }