BoothAction.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. package net.mingsoft.tf.action;
  2. import java.util.List;
  3. import java.io.File;
  4. import java.util.ArrayList;
  5. import java.util.Map;
  6. import java.util.regex.Matcher;
  7. import java.util.regex.Pattern;
  8. import cn.hutool.core.util.ObjectUtil;
  9. import java.util.*;
  10. import net.mingsoft.base.entity.ResultData;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.apache.shiro.authz.annotation.RequiresPermissions;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Controller;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.ResponseBody;
  17. import org.springframework.web.bind.annotation.ModelAttribute;
  18. import org.springframework.web.bind.annotation.GetMapping;
  19. import org.springframework.web.bind.annotation.PostMapping;
  20. import org.springframework.web.bind.annotation.RequestBody;
  21. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  22. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  23. import java.util.stream.Collectors;
  24. import org.springframework.web.bind.annotation.*;
  25. import net.mingsoft.tf.biz.IBoothBiz;
  26. import net.mingsoft.tf.entity.BoothEntity;
  27. import net.mingsoft.base.entity.BaseEntity;
  28. import net.mingsoft.basic.util.BasicUtil;
  29. import net.mingsoft.basic.util.StringUtil;
  30. import net.mingsoft.basic.bean.EUListBean;
  31. import net.mingsoft.basic.annotation.LogAnn;
  32. import net.mingsoft.basic.constant.e.BusinessTypeEnum;
  33. import org.apache.commons.lang3.StringUtils;
  34. import io.swagger.v3.oas.annotations.tags.Tag;
  35. import io.swagger.v3.oas.annotations.Parameter;
  36. import io.swagger.v3.oas.annotations.Parameters;
  37. import io.swagger.v3.oas.annotations.Operation;
  38. import io.swagger.v3.oas.annotations.Hidden;
  39. import io.swagger.v3.oas.annotations.enums.ParameterIn;
  40. /**
  41. * 展位管理控制层
  42. * @author 阿白
  43. * 创建日期:2025年10月23日 下午6:41:34<br/>
  44. * 历史修订:<br/>
  45. */
  46. @Tag(name = "后台-展位接口")
  47. @Controller("tfBoothAction")
  48. @RequestMapping("/${ms.manager.path}/tf/booth")
  49. public class BoothAction extends net.mingsoft.tf.action.BaseAction{
  50. /**
  51. * 注入展位业务层
  52. */
  53. @Autowired
  54. private IBoothBiz boothBiz;
  55. /**
  56. * 返回主界面index
  57. */
  58. @Hidden
  59. @GetMapping("/index")
  60. public String index() {
  61. return "/tf/booth/index";
  62. }
  63. /**
  64. * 返回编辑界面booth的form
  65. */
  66. @Hidden
  67. @GetMapping("/form")
  68. public String form() {
  69. return "/tf/booth/form";
  70. }
  71. /**
  72. * 查询展位列表
  73. * @param booth 展位实体
  74. */
  75. @Operation(summary = "查询展位列表接口")
  76. @Parameters({
  77. @Parameter(name = "boothCode", description = "编码", in = ParameterIn.QUERY),
  78. @Parameter(name = "boothFloor", description = "楼层", in = ParameterIn.QUERY),
  79. @Parameter(name = "boothName", description = "名称", in = ParameterIn.QUERY),
  80. @Parameter(name = "boothStyle", description = "风格", in = ParameterIn.QUERY),
  81. @Parameter(name = "boothMaterials", description = "材料", in = ParameterIn.QUERY),
  82. @Parameter(name = "boothX", description = "坐标X", in = ParameterIn.QUERY),
  83. @Parameter(name = "boothY", description = "坐标Y", in = ParameterIn.QUERY),
  84. @Parameter(name = "boothWidth", description = "宽度", in = ParameterIn.QUERY),
  85. @Parameter(name = "boothHeight", description = "高度", in = ParameterIn.QUERY),
  86. })
  87. @RequestMapping(value ="/list",method = {RequestMethod.GET,RequestMethod.POST})
  88. @ResponseBody
  89. @RequiresPermissions("tf:booth:view")
  90. public ResultData list(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) {
  91. BasicUtil.startPage();
  92. List boothList = null;
  93. if ( booth.getSqlWhere() != null){
  94. boothList = boothBiz.query(booth);
  95. } else {
  96. LambdaQueryWrapper<BoothEntity> wrapper = new LambdaQueryWrapper<>(booth).orderByDesc(BoothEntity::getCreateDate);
  97. boothList = boothBiz.list(wrapper);
  98. }
  99. return ResultData.build().success(new EUListBean(boothList,(int)BasicUtil.endPage(boothList).getTotal()));
  100. }
  101. /**
  102. * 获取展位
  103. * @param booth 展位实体
  104. */
  105. @Operation(summary = "获取展位列表接口")
  106. @Parameter(name = "id", description = "主键ID", required =true,in = ParameterIn.QUERY)
  107. @GetMapping("/get")
  108. @ResponseBody
  109. @RequiresPermissions("tf:booth:view")
  110. public ResultData get(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) {
  111. if (StringUtils.isBlank(booth.getId())) {
  112. return ResultData.build().error(getResString("err.error",this.getResString("id")));
  113. }
  114. BoothEntity _booth = (BoothEntity)boothBiz.getById(booth.getId());
  115. return ResultData.build().success(_booth);
  116. }
  117. /**
  118. * 保存展位
  119. * @param booth 展位实体
  120. */
  121. @Operation(summary = "保存展位列表接口")
  122. @Parameters({
  123. @Parameter(name = "boothCode", description = "编码", required = true, in = ParameterIn.QUERY),
  124. @Parameter(name = "boothFloor", description = "楼层", required = true, in = ParameterIn.QUERY),
  125. @Parameter(name = "boothName", description = "名称", required = false, in = ParameterIn.QUERY),
  126. @Parameter(name = "boothStyle", description = "风格", required = false, in = ParameterIn.QUERY),
  127. @Parameter(name = "boothMaterials", description = "材料", required = false, in = ParameterIn.QUERY),
  128. @Parameter(name = "boothX", description = "坐标X", required = false, in = ParameterIn.QUERY),
  129. @Parameter(name = "boothY", description = "坐标Y", required = false, in = ParameterIn.QUERY),
  130. @Parameter(name = "boothWidth", description = "宽度", required = false, in = ParameterIn.QUERY),
  131. @Parameter(name = "boothHeight", description = "高度", required = false, in = ParameterIn.QUERY),
  132. })
  133. @PostMapping("/save")
  134. @ResponseBody
  135. @LogAnn(title = "保存展位", businessType = BusinessTypeEnum.INSERT)
  136. @RequiresPermissions("tf:booth:save")
  137. public ResultData save(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) {
  138. //验证编码的值是否重复
  139. if (super.validated("mdiy_form_booth","BOOTH_CODE",booth.getBoothCode())) {
  140. return ResultData.build().error(getResString("err.exist", this.getResString("booth.code")));
  141. }
  142. //验证编码的值是否合法
  143. if (StringUtils.isBlank(booth.getBoothCode())) {
  144. return ResultData.build().error(getResString("err.empty", this.getResString("booth.code")));
  145. }
  146. if (!StringUtil.checkLength(booth.getBoothCode()+"", 0, 255)) {
  147. return ResultData.build().error(getResString("err.length", this.getResString("booth.code"), "0", "255"));
  148. }
  149. //验证楼层的值是否合法
  150. if (StringUtils.isBlank(booth.getBoothFloor())) {
  151. return ResultData.build().error(getResString("err.empty", this.getResString("booth.floor")));
  152. }
  153. if (!StringUtil.checkLength(booth.getBoothFloor()+"", 0, 255)) {
  154. return ResultData.build().error(getResString("err.length", this.getResString("booth.floor"), "0", "255"));
  155. }
  156. if ( StringUtils.isNotBlank(booth.getBoothName()) && !StringUtil.checkLength(booth.getBoothName()+"", 0, 255)) {
  157. return ResultData.build().error(getResString("err.length", this.getResString("booth.name"), "0", "255"));
  158. }
  159. if ( StringUtils.isNotBlank(booth.getBoothStyle()) && !StringUtil.checkLength(booth.getBoothStyle()+"", 0, 255)) {
  160. return ResultData.build().error(getResString("err.length", this.getResString("booth.style"), "0", "255"));
  161. }
  162. if ( StringUtils.isNotBlank(booth.getBoothMaterials()) && !StringUtil.checkLength(booth.getBoothMaterials()+"", 0, 255)) {
  163. return ResultData.build().error(getResString("err.length", this.getResString("booth.materials"), "0", "255"));
  164. }
  165. if (!StringUtil.checkLength(booth.getBoothX()+"", 0, 11)) {
  166. return ResultData.build().error(getResString("err.length", this.getResString("booth.x"), "0", "11"));
  167. }
  168. if (!StringUtil.checkLength(booth.getBoothY()+"", 0, 11)) {
  169. return ResultData.build().error(getResString("err.length", this.getResString("booth.y"), "0", "11"));
  170. }
  171. if (!StringUtil.checkLength(booth.getBoothWidth()+"", 0, 11)) {
  172. return ResultData.build().error(getResString("err.length", this.getResString("booth.width"), "0", "11"));
  173. }
  174. if (!StringUtil.checkLength(booth.getBoothHeight()+"", 0, 11)) {
  175. return ResultData.build().error(getResString("err.length", this.getResString("booth.height"), "0", "11"));
  176. }
  177. boothBiz.save(booth);
  178. return ResultData.build().success(booth);
  179. }
  180. /**
  181. * 删除展位
  182. *
  183. * @param booths 展位实体
  184. */
  185. @Operation(summary = "批量删除展位列表接口")
  186. @PostMapping("/delete")
  187. @ResponseBody
  188. @LogAnn(title = "删除展位", businessType = BusinessTypeEnum.DELETE)
  189. @RequiresPermissions("tf:booth:del")
  190. public ResultData delete(@RequestBody List<BoothEntity> booths) {
  191. List<String> ids = (List)booths.stream().map((p) -> {return p.getId();}).collect(Collectors.toList());
  192. return this.boothBiz.removeByIds(ids) ? ResultData.build().success() : ResultData.build().error(this.getResString("err.error", new String[]{this.getResString("id")}));
  193. }
  194. /**
  195. * 更新展位列表
  196. *
  197. * @param booth 展位实体
  198. */
  199. @Operation(summary = "更新展位列表接口")
  200. @Parameters({
  201. @Parameter(name = "id", description = "主键ID", required =true,in = ParameterIn.QUERY),
  202. @Parameter(name = "boothCode", description = "编码", required = true, in = ParameterIn.QUERY),
  203. @Parameter(name = "boothFloor", description = "楼层", required = true, in = ParameterIn.QUERY),
  204. @Parameter(name = "boothName", description = "名称", required = false, in = ParameterIn.QUERY),
  205. @Parameter(name = "boothStyle", description = "风格", required = false, in = ParameterIn.QUERY),
  206. @Parameter(name = "boothMaterials", description = "材料", required = false, in = ParameterIn.QUERY),
  207. @Parameter(name = "boothX", description = "坐标X", required = false, in = ParameterIn.QUERY),
  208. @Parameter(name = "boothY", description = "坐标Y", required = false, in = ParameterIn.QUERY),
  209. @Parameter(name = "boothWidth", description = "宽度", required = false, in = ParameterIn.QUERY),
  210. @Parameter(name = "boothHeight", description = "高度", required = false, in = ParameterIn.QUERY),
  211. })
  212. @PostMapping("/update")
  213. @ResponseBody
  214. @LogAnn(title = "更新展位", businessType = BusinessTypeEnum.UPDATE)
  215. @RequiresPermissions("tf:booth:update")
  216. public ResultData update(@ModelAttribute @Parameter(hidden = true) BoothEntity booth) {
  217. //先查询数据是否存在
  218. BoothEntity _booth = (BoothEntity)boothBiz.getById(booth.getId());
  219. if(_booth == null) {
  220. return ResultData.build().error(getResString("err.not.exist",booth.getId() ));
  221. }
  222. //验证编码的值是否重复
  223. if (super.validated("mdiy_form_booth","BOOTH_CODE",booth.getBoothCode(), booth.getId(),"id")) {
  224. return ResultData.build().error(getResString("err.exist", this.getResString("booth.code")));
  225. }
  226. //验证编码的值是否合法
  227. if (StringUtils.isBlank(booth.getBoothCode())) {
  228. return ResultData.build().error(getResString("err.empty", this.getResString("booth.code")));
  229. }
  230. if (!StringUtil.checkLength(booth.getBoothCode()+"", 0, 255)) {
  231. return ResultData.build().error(getResString("err.length", this.getResString("booth.code"), "0", "255"));
  232. }
  233. //验证楼层的值是否合法
  234. if (StringUtils.isBlank(booth.getBoothFloor())) {
  235. return ResultData.build().error(getResString("err.empty", this.getResString("booth.floor")));
  236. }
  237. if (!StringUtil.checkLength(booth.getBoothFloor()+"", 0, 255)) {
  238. return ResultData.build().error(getResString("err.length", this.getResString("booth.floor"), "0", "255"));
  239. }
  240. if ( StringUtils.isNotBlank(booth.getBoothName()) && !StringUtil.checkLength(booth.getBoothName()+"", 0, 255)) {
  241. return ResultData.build().error(getResString("err.length", this.getResString("booth.name"), "0", "255"));
  242. }
  243. if ( StringUtils.isNotBlank(booth.getBoothStyle()) && !StringUtil.checkLength(booth.getBoothStyle()+"", 0, 255)) {
  244. return ResultData.build().error(getResString("err.length", this.getResString("booth.style"), "0", "255"));
  245. }
  246. if ( StringUtils.isNotBlank(booth.getBoothMaterials()) && !StringUtil.checkLength(booth.getBoothMaterials()+"", 0, 255)) {
  247. return ResultData.build().error(getResString("err.length", this.getResString("booth.materials"), "0", "255"));
  248. }
  249. if (!StringUtil.checkLength(booth.getBoothX()+"", 0, 11)) {
  250. return ResultData.build().error(getResString("err.length", this.getResString("booth.x"), "0", "11"));
  251. }
  252. if (!StringUtil.checkLength(booth.getBoothY()+"", 0, 11)) {
  253. return ResultData.build().error(getResString("err.length", this.getResString("booth.y"), "0", "11"));
  254. }
  255. if (!StringUtil.checkLength(booth.getBoothWidth()+"", 0, 11)) {
  256. return ResultData.build().error(getResString("err.length", this.getResString("booth.width"), "0", "11"));
  257. }
  258. if (!StringUtil.checkLength(booth.getBoothHeight()+"", 0, 11)) {
  259. return ResultData.build().error(getResString("err.length", this.getResString("booth.height"), "0", "11"));
  260. }
  261. boothBiz.updateById(booth);
  262. return ResultData.build().success(booth);
  263. }
  264. @GetMapping("verify")
  265. @ResponseBody
  266. public ResultData verify(String fieldName, String fieldValue, String id,String idName) {
  267. boolean verify = false;
  268. if (StringUtils.isBlank(id)) {
  269. verify = super.validated("mdiy_form_booth",fieldName,fieldValue);
  270. } else {
  271. verify = super.validated("mdiy_form_booth",fieldName,fieldValue,id,idName);
  272. }
  273. if (verify) {
  274. return ResultData.build().success(false);
  275. }else {
  276. return ResultData.build().success(true);
  277. }
  278. }
  279. }