CardChecklistBaseController.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. package com.tzy.base.controller;
  2. import com.tzy.base.domain.CardChecklistBaseInfo;
  3. import com.tzy.base.domain.ChecklistInfo;
  4. import com.tzy.base.domain.PaniniBaseInfo;
  5. import com.tzy.base.dto.PaniniVersionConfigDto;
  6. import com.tzy.base.dto.TeamImgDto;
  7. import com.tzy.base.dto.entry.*;
  8. import com.tzy.base.enums.ChecklistTypeEnums;
  9. import com.tzy.base.service.*;
  10. import com.tzy.common.annotation.Log;
  11. import com.tzy.common.core.controller.BaseController;
  12. import com.tzy.common.core.domain.AjaxResult;
  13. import com.tzy.common.core.page.TableDataInfo;
  14. import com.tzy.common.enums.BusinessType;
  15. import com.tzy.common.utils.ShiroUtils;
  16. import com.tzy.common.utils.StringUtils;
  17. import com.tzy.framework.util.RedisUtils;
  18. import io.swagger.annotations.*;
  19. import lombok.extern.slf4j.Slf4j;
  20. import org.apache.shiro.authz.annotation.RequiresPermissions;
  21. import org.simpleframework.xml.core.Validate;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.stereotype.Controller;
  24. import org.springframework.ui.ModelMap;
  25. import org.springframework.web.bind.annotation.*;
  26. import javax.servlet.http.HttpServletResponse;
  27. import java.util.List;
  28. import java.util.Objects;
  29. import java.util.Optional;
  30. /**
  31. * 商家拼团checklist 基础信息
  32. */
  33. @Slf4j
  34. @Api(value = "商家拼团checklist",tags = "商家拼团checklist")
  35. @Controller
  36. @RequestMapping("/v2/checklist/base")
  37. public class CardChecklistBaseController extends BaseController {
  38. String prefix = "baseV/checklist";
  39. @Autowired
  40. private SysFileBaseService sysFileBaseService;
  41. @Autowired
  42. private SysBaseService sysBaseService;
  43. @Autowired
  44. private CardChecklistBaseInfoService cardChecklistBaseInfoService;
  45. @Autowired
  46. private PaniniBaseInfoService paniniBaseInfoService;
  47. @Autowired
  48. private ChecklistService checklistService;
  49. @Autowired
  50. private RedisUtils redisUtils;
  51. /**
  52. * 主页面
  53. */
  54. @ApiOperation(value = "",hidden = true)
  55. @GetMapping()
  56. public String base(ModelMap mmap)
  57. {
  58. mmap.put("host",sysFileBaseService.getHost());
  59. return prefix + "/baseInfo";
  60. }
  61. /**
  62. * 查询checklist基础信息列表
  63. */
  64. @ApiOperation(value = "",hidden = true)
  65. @RequiresPermissions("checklist:base:list")
  66. @PostMapping("/list")
  67. @ResponseBody
  68. public TableDataInfo list(CardChecklistBaseInfo checklistBaseInfo)
  69. {
  70. //获取登录用户的信息
  71. startPageOrderBy(" id desc ");
  72. if(null == checklistBaseInfo.getDelFlg()){
  73. checklistBaseInfo.setDelFlg(0);
  74. }
  75. List<CardChecklistBaseInfo> list = cardChecklistBaseInfoService.selectChecklistBaseInfoList(checklistBaseInfo);
  76. return getDataTable(list);
  77. }
  78. @GetMapping("/setParent/{id}")
  79. public String setParent(@PathVariable("id") Long id, ModelMap mmap)
  80. {
  81. CardChecklistBaseInfo checklistBaseInfo = cardChecklistBaseInfoService.selectChecklistBaseInfoById(id);
  82. mmap.put("checklist", checklistBaseInfo);
  83. return prefix + "/modal/setParent";
  84. }
  85. /**
  86. * 修改checklist基础信息
  87. */
  88. @ApiOperation(value = "",hidden = true)
  89. @GetMapping("/review/{id}")
  90. public String reviewView(@PathVariable("id") Long id, ModelMap mmap)
  91. {
  92. CardChecklistBaseInfo checklistBaseInfo = cardChecklistBaseInfoService.selectChecklistBaseInfoById(id);
  93. //设置玩法信息
  94. mmap.put("type", ChecklistTypeEnums.checkMyType(checklistBaseInfo.getType()).getName()+(StringUtils.isBlank(checklistBaseInfo.getSubType())?"":("|"+checklistBaseInfo.getSubType())));
  95. if(Objects.equals(checklistBaseInfo.getLot() , 1)){
  96. mmap.put("paniniBaseInfo", checklistService.searchLotBaseInfoConfig(id));
  97. }else{
  98. //查询基础库信息
  99. mmap.put("paniniBaseInfo", Optional.ofNullable(paniniBaseInfoService.selectPaniniBaseInfoById(checklistBaseInfo.getParentId())).orElse(new PaniniBaseInfo()));
  100. }
  101. mmap.put("baseInfo", checklistBaseInfo);
  102. return prefix + "/modal/review";
  103. }
  104. /**
  105. * 审核
  106. */
  107. @Log(title = "审核")
  108. @ApiOperation("审核")
  109. @ApiResponses({
  110. @ApiResponse(code = 200, message = "审核", response = AjaxResult.class)
  111. })
  112. @RequiresPermissions("checklist:base:review")
  113. @PostMapping("/review")
  114. @ResponseBody
  115. public AjaxResult review(@RequestBody ReviewEntry reviewEntry)
  116. {
  117. AjaxResult review = cardChecklistBaseInfoService.review(reviewEntry);
  118. try{
  119. redisUtils.del("group_checklist_review_"+reviewEntry.getId());
  120. } catch (Exception e) {
  121. }
  122. return review;
  123. }
  124. /**
  125. * 详情checklist
  126. */
  127. @ApiOperation(value = "",hidden = true)
  128. @RequiresPermissions("checklist:base:detail")
  129. @GetMapping("/detail/{id}")
  130. public String detail(@PathVariable("id") Long id, ModelMap mmap)
  131. {
  132. CardChecklistBaseInfo checklistBaseInfo = cardChecklistBaseInfoService.selectChecklistBaseInfoById(id);
  133. mmap.put("baseInfo", Optional.ofNullable(checklistBaseInfo).orElse(new CardChecklistBaseInfo()));
  134. if(Objects.equals(checklistBaseInfo.getLot() , 1)){
  135. mmap.put("baseConfig", checklistService.searchLotBaseInfoConfig(id));
  136. }else {
  137. //查询配置 如果没有baseConfig id 则根据版本字段值查询配置
  138. PaniniVersionConfigDto paniniVersionConfigDto = paniniBaseInfoService.searchBaseInfoAndSetVersionByConfigId(Objects.requireNonNull(checklistBaseInfo).getPaniniConfigId());
  139. if(Objects.isNull(paniniVersionConfigDto)){
  140. Long parentId = Objects.requireNonNull(checklistBaseInfo).getParentId();
  141. String setsVersion = Objects.requireNonNull(checklistBaseInfo).getSetsVersion();
  142. paniniVersionConfigDto = paniniBaseInfoService.searchBaseInfoAndSetVersionByConfigVersion(parentId,setsVersion);
  143. }
  144. mmap.put("baseConfig", Optional.ofNullable(paniniVersionConfigDto).orElse(new PaniniVersionConfigDto()));
  145. }
  146. mmap.put("host", sysFileBaseService.getHost());
  147. //查询该checklist 的使用次数【除未审核通过】
  148. mmap.put("useTimes", sysBaseService.selectGroupCount(Math.toIntExact(id)));
  149. return prefix + "/allcards";
  150. }
  151. /**
  152. * 详情checklist
  153. */
  154. @ApiOperation("单checklist内容列表")
  155. @Log(title = "单checklist内容列表", businessType = BusinessType.SEARCH)
  156. @RequiresPermissions("checklist:base:detail")
  157. @PostMapping("/details/{id}")
  158. @ResponseBody
  159. public TableDataInfo details(@PathVariable("id") Long id, CardCheckListEntry cardCheckList)
  160. {
  161. log.info(" cardCheckList > {}",cardCheckList);
  162. cardCheckList.setChecklistBaseId(id);
  163. startPage();
  164. List<ChecklistInfo> checklistInfos = checklistService.selectCardCheckListByBaseId(cardCheckList);
  165. return getDataTable(checklistInfos);
  166. }
  167. /**
  168. * 编辑卡种
  169. */
  170. @ApiOperation(value = "",hidden = true)
  171. @RequiresPermissions("checklist:cardset:edit")
  172. @Log(title = "编辑卡种", businessType = BusinessType.UPDATE)
  173. @GetMapping( "/holdCardSets/{id}/{cardsetsId}")
  174. public String holdCardSets(@PathVariable("id") String id ,@PathVariable("cardsetsId") String cardsetsId , ModelMap mmap)
  175. {
  176. //如果是编辑则查询数据 否则
  177. if("undefined".equals(cardsetsId)){
  178. cardsetsId = null;
  179. }
  180. mmap.put("baseId",id);
  181. mmap.put("checklist",checklistService.getDetailById(Long.valueOf(cardsetsId)));
  182. return prefix + "/modal/editCardSets";
  183. }
  184. /**
  185. * 删除checklist基础信息
  186. */
  187. @ApiOperation(value = "",hidden = true)
  188. @RequiresPermissions("checklist:cardset:edit")
  189. @Log(title = "编辑卡种", businessType = BusinessType.UPDATE)
  190. @PostMapping( "/holdCardSets")
  191. @ResponseBody
  192. public AjaxResult holdCardSetsInfo(CardCheckListEntry cardCheckList)
  193. {
  194. return cardChecklistBaseInfoService.holdCardSetsInfo(cardCheckList);
  195. }
  196. /**
  197. * 导出指定的list
  198. */
  199. @ApiOperation(value = "",hidden = true)
  200. @RequiresPermissions("checklist:base:export")
  201. @Log(title = "导出指定的list", businessType = BusinessType.EXPORT)
  202. @GetMapping("/downloadById/{id}")
  203. @ResponseBody
  204. public void downloadById(@PathVariable("id") Long id, HttpServletResponse response)
  205. {
  206. cardChecklistBaseInfoService.downloadChecklistByBaseId(id);
  207. }
  208. /**
  209. * 导出指定的list-指定的数据
  210. */
  211. @ApiOperation(value = "",hidden = true)
  212. @Log(title = "导出指定的list", businessType = BusinessType.EXPORT)
  213. @GetMapping("/downloadListByType/{id}/{type}")
  214. @ResponseBody
  215. public void downloadListByType(@PathVariable("id") Long id, @PathVariable("type") String type, HttpServletResponse response)
  216. {
  217. cardChecklistBaseInfoService.downloadChecklistByBaseIdAndType(id,type);
  218. }
  219. /**
  220. * 商家获取拼团checklist列表
  221. */
  222. @ApiOperation("商家获取拼团checklist列表")
  223. @ApiImplicitParams({
  224. @ApiImplicitParam( name = "type", value="获取数据的类型>值:lot,year,sport,manufacturer,sets,setsVersion,type,subType,title,randomTeamInfo", dataType = "String", paramType = "path" ,example = "lot,year,sport,manufacturer,sets,setsVersion,type,subType,title,randomTeamInfo")
  225. })
  226. @Log(title = "获取CheckList", businessType = BusinessType.SEARCH)
  227. @PostMapping("/searchBaseInfoBySelect/{type}")
  228. @ResponseBody
  229. public AjaxResult searchBaseInfoBySelect(@PathVariable("type") String type, @RequestBody @Validate SelectBaseInfoEntry entry) {
  230. if (!Objects.isNull(ShiroUtils.getMerchantInfo())) {
  231. entry.setMerchantId(ShiroUtils.getMerchantInfo().getId());
  232. }
  233. return cardChecklistBaseInfoService.searchBaseInfoBySelect(type,entry);
  234. }
  235. /**
  236. * 商家获取拼团checklist列表
  237. */
  238. @ApiOperation("商家获取拼团checklist列表")
  239. @ApiImplicitParams({
  240. @ApiImplicitParam( name = "version", value="请求类型>值:shop,group", dataType = "String", paramType = "path" ,example = "shop,group"),
  241. @ApiImplicitParam( name = "type", value="获取数据的类型>值:lot,year,sport,manufacturer,sets,setsVersion,type,subType,title,randomTeamInfo", dataType = "String", paramType = "path" ,example = "lot,year,sport,manufacturer,sets,setsVersion,type,subType,title,randomTeamInfo")
  242. })
  243. @Log(title = "获取CheckList", businessType = BusinessType.SEARCH)
  244. @PostMapping("/{version}/searchBaseInfoBySelect/{type}")
  245. @ResponseBody
  246. public AjaxResult searchBaseInfoBySelectV2(@PathVariable("version") String version, @PathVariable("type") String type, @RequestBody @Validate SelectBaseInfoEntry entry) {
  247. if (!Objects.isNull(ShiroUtils.getMerchantInfo())) {
  248. entry.setMerchantId(ShiroUtils.getMerchantInfo().getId());
  249. }
  250. entry.setFromVersion(version);
  251. return cardChecklistBaseInfoService.searchBaseInfoBySelectV2(type,entry);
  252. }
  253. /**
  254. * 商家获取拼团checklist列表
  255. */
  256. @ApiOperation("获取轮播图")
  257. @ApiImplicitParams({
  258. @ApiImplicitParam( name = "id", value="拼团checklistid", dataType = "Long", paramType = "path" )
  259. })
  260. @Log(title = "获取轮播图", businessType = BusinessType.SEARCH)
  261. @PostMapping("/searchCarouseMapByListId/{id}")
  262. @ResponseBody
  263. public AjaxResult searchCarouseMapByListId(@PathVariable("id") Long id) {
  264. return cardChecklistBaseInfoService.searchCarouseMapByListId(id);
  265. }
  266. /**
  267. * 更新版本信息
  268. */
  269. @Log(title = "处理旧数据", businessType = BusinessType.UPDATE)
  270. @PostMapping("/applyCardChecklistInfo/{id}")
  271. @ResponseBody
  272. public AjaxResult applyCardChecklistInfo(@PathVariable("id") Long id ) {
  273. return cardChecklistBaseInfoService.applyCardChecklistInfo(id,null);
  274. }
  275. /**
  276. * 更新版本信息
  277. */
  278. @Log(title = "处理旧数据[批量]", businessType = BusinessType.UPDATE)
  279. @PostMapping("/applyCardChecklistInfos")
  280. @ResponseBody
  281. public AjaxResult applyCardChecklistInfos(@RequestParam("ids") String ids ) {
  282. return cardChecklistBaseInfoService.applyCardChecklistInfos(ids);
  283. }
  284. /**
  285. * 更新版本信息
  286. */
  287. @Log(title = "处理旧数据-选队随机", businessType = BusinessType.UPDATE)
  288. @PostMapping("/applyRandomTeamCardChecklistInfo/{id}/{type}")
  289. @ResponseBody
  290. public AjaxResult applyRandomTeamCardChecklistInfo(@PathVariable("id") Long id ,@PathVariable("type")String type) {
  291. AjaxResult ajaxResult = cardChecklistBaseInfoService.applyCardChecklistInfo(id, type);
  292. if(Objects.equals(0 , ajaxResult.get("code"))){
  293. String msg = StringUtils.isNotBlank(String.valueOf(ajaxResult.get("msg")))?String.valueOf(ajaxResult.get("msg")):"";
  294. return AjaxResult.success(msg );
  295. }
  296. return ajaxResult;
  297. }
  298. /**
  299. * 绑定基础库
  300. */
  301. @Log(title = "绑定基础库 ", businessType = BusinessType.UPDATE)
  302. @PostMapping("/bindParent")
  303. @ResponseBody
  304. public AjaxResult bindParent(@RequestBody CardChecklistBaseInfo checklistBaseInfo)
  305. {
  306. return cardChecklistBaseInfoService.bindParent(checklistBaseInfo);
  307. }
  308. /**
  309. * 查询拼团列表code
  310. * @param req
  311. * @return
  312. */
  313. @Log(title = "查询拼团列表code", businessType = BusinessType.UPDATE)
  314. @PostMapping("/searchGroupListCode")
  315. @ResponseBody
  316. public AjaxResult searchGroupListCode(@RequestBody SearchGroupListCodeReq req)
  317. {
  318. return cardChecklistBaseInfoService.searchGroupListCode(req);
  319. }
  320. /**
  321. * 同步球队图片
  322. * @param id
  323. * @param mmap
  324. * @return
  325. */
  326. @RequestMapping(value = "/syncTeamBgModal/{id}",method = RequestMethod.GET)
  327. public String syncTeamBgModal(@PathVariable("id") Long id, ModelMap mmap)
  328. {
  329. String host = (String) sysFileBaseService.initQiniuConfig().get("img_static_qiniu_host");
  330. mmap.put("host",host);
  331. mmap.put("id",id);
  332. //查询当前list version 的球队图片有无数量
  333. mmap.put("teamLogoCount", cardChecklistBaseInfoService.checkTeamLogoCount(id)) ;
  334. return "baseV/checklist/modal/syncTeamBg";
  335. }
  336. /**
  337. * 同步球队图片
  338. * @return
  339. */
  340. @Log(title = "同步球队图片列表", businessType = BusinessType.UPDATE)
  341. @PostMapping(value = "/syncTeamBg" )
  342. @ResponseBody
  343. public TableDataInfo syncTeamBg(@RequestBody PaniniSyncImageReq req)
  344. {
  345. List<TeamImgDto> teamImgDtos = cardChecklistBaseInfoService.selectTeamImgByBaseInfoId(req.getId());
  346. return new TableDataInfo(0, teamImgDtos , teamImgDtos.size());
  347. }
  348. /**
  349. * 同步球队图片
  350. * @return
  351. */
  352. @Log(title = "同步球队图片列表", businessType = BusinessType.UPDATE)
  353. @PostMapping(value = "/doSyncTeamBg" )
  354. @ResponseBody
  355. public AjaxResult doSyncTeamBg(@RequestBody PaniniSyncImageReq req){
  356. return cardChecklistBaseInfoService.doSyncTeamBg(req);
  357. }
  358. }