| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- package com.tzy.base.controller;
- import com.tzy.base.domain.CardChecklistBaseInfo;
- import com.tzy.base.domain.ChecklistInfo;
- import com.tzy.base.domain.PaniniBaseInfo;
- import com.tzy.base.dto.PaniniVersionConfigDto;
- import com.tzy.base.dto.TeamImgDto;
- import com.tzy.base.dto.entry.*;
- import com.tzy.base.enums.ChecklistTypeEnums;
- import com.tzy.base.service.*;
- import com.tzy.common.annotation.Log;
- import com.tzy.common.core.controller.BaseController;
- import com.tzy.common.core.domain.AjaxResult;
- import com.tzy.common.core.page.TableDataInfo;
- import com.tzy.common.enums.BusinessType;
- import com.tzy.common.utils.ShiroUtils;
- import com.tzy.common.utils.StringUtils;
- import com.tzy.framework.util.RedisUtils;
- import io.swagger.annotations.*;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.shiro.authz.annotation.RequiresPermissions;
- import org.simpleframework.xml.core.Validate;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletResponse;
- import java.util.List;
- import java.util.Objects;
- import java.util.Optional;
- /**
- * 商家拼团checklist 基础信息
- */
- @Slf4j
- @Api(value = "商家拼团checklist",tags = "商家拼团checklist")
- @Controller
- @RequestMapping("/v2/checklist/base")
- public class CardChecklistBaseController extends BaseController {
- String prefix = "baseV/checklist";
- @Autowired
- private SysFileBaseService sysFileBaseService;
- @Autowired
- private SysBaseService sysBaseService;
- @Autowired
- private CardChecklistBaseInfoService cardChecklistBaseInfoService;
- @Autowired
- private PaniniBaseInfoService paniniBaseInfoService;
- @Autowired
- private ChecklistService checklistService;
- @Autowired
- private RedisUtils redisUtils;
- /**
- * 主页面
- */
- @ApiOperation(value = "",hidden = true)
- @GetMapping()
- public String base(ModelMap mmap)
- {
- mmap.put("host",sysFileBaseService.getHost());
- return prefix + "/baseInfo";
- }
- /**
- * 查询checklist基础信息列表
- */
- @ApiOperation(value = "",hidden = true)
- @RequiresPermissions("checklist:base:list")
- @PostMapping("/list")
- @ResponseBody
- public TableDataInfo list(CardChecklistBaseInfo checklistBaseInfo)
- {
- //获取登录用户的信息
- startPageOrderBy(" id desc ");
- if(null == checklistBaseInfo.getDelFlg()){
- checklistBaseInfo.setDelFlg(0);
- }
- List<CardChecklistBaseInfo> list = cardChecklistBaseInfoService.selectChecklistBaseInfoList(checklistBaseInfo);
- return getDataTable(list);
- }
- @GetMapping("/setParent/{id}")
- public String setParent(@PathVariable("id") Long id, ModelMap mmap)
- {
- CardChecklistBaseInfo checklistBaseInfo = cardChecklistBaseInfoService.selectChecklistBaseInfoById(id);
- mmap.put("checklist", checklistBaseInfo);
- return prefix + "/modal/setParent";
- }
- /**
- * 修改checklist基础信息
- */
- @ApiOperation(value = "",hidden = true)
- @GetMapping("/review/{id}")
- public String reviewView(@PathVariable("id") Long id, ModelMap mmap)
- {
- CardChecklistBaseInfo checklistBaseInfo = cardChecklistBaseInfoService.selectChecklistBaseInfoById(id);
- //设置玩法信息
- mmap.put("type", ChecklistTypeEnums.checkMyType(checklistBaseInfo.getType()).getName()+(StringUtils.isBlank(checklistBaseInfo.getSubType())?"":("|"+checklistBaseInfo.getSubType())));
- if(Objects.equals(checklistBaseInfo.getLot() , 1)){
- mmap.put("paniniBaseInfo", checklistService.searchLotBaseInfoConfig(id));
- }else{
- //查询基础库信息
- mmap.put("paniniBaseInfo", Optional.ofNullable(paniniBaseInfoService.selectPaniniBaseInfoById(checklistBaseInfo.getParentId())).orElse(new PaniniBaseInfo()));
- }
- mmap.put("baseInfo", checklistBaseInfo);
- return prefix + "/modal/review";
- }
- /**
- * 审核
- */
- @Log(title = "审核")
- @ApiOperation("审核")
- @ApiResponses({
- @ApiResponse(code = 200, message = "审核", response = AjaxResult.class)
- })
- @RequiresPermissions("checklist:base:review")
- @PostMapping("/review")
- @ResponseBody
- public AjaxResult review(@RequestBody ReviewEntry reviewEntry)
- {
- AjaxResult review = cardChecklistBaseInfoService.review(reviewEntry);
- try{
- redisUtils.del("group_checklist_review_"+reviewEntry.getId());
- } catch (Exception e) {
- }
- return review;
- }
- /**
- * 详情checklist
- */
- @ApiOperation(value = "",hidden = true)
- @RequiresPermissions("checklist:base:detail")
- @GetMapping("/detail/{id}")
- public String detail(@PathVariable("id") Long id, ModelMap mmap)
- {
- CardChecklistBaseInfo checklistBaseInfo = cardChecklistBaseInfoService.selectChecklistBaseInfoById(id);
- mmap.put("baseInfo", Optional.ofNullable(checklistBaseInfo).orElse(new CardChecklistBaseInfo()));
- if(Objects.equals(checklistBaseInfo.getLot() , 1)){
- mmap.put("baseConfig", checklistService.searchLotBaseInfoConfig(id));
- }else {
- //查询配置 如果没有baseConfig id 则根据版本字段值查询配置
- PaniniVersionConfigDto paniniVersionConfigDto = paniniBaseInfoService.searchBaseInfoAndSetVersionByConfigId(Objects.requireNonNull(checklistBaseInfo).getPaniniConfigId());
- if(Objects.isNull(paniniVersionConfigDto)){
- Long parentId = Objects.requireNonNull(checklistBaseInfo).getParentId();
- String setsVersion = Objects.requireNonNull(checklistBaseInfo).getSetsVersion();
- paniniVersionConfigDto = paniniBaseInfoService.searchBaseInfoAndSetVersionByConfigVersion(parentId,setsVersion);
- }
- mmap.put("baseConfig", Optional.ofNullable(paniniVersionConfigDto).orElse(new PaniniVersionConfigDto()));
- }
- mmap.put("host", sysFileBaseService.getHost());
- //查询该checklist 的使用次数【除未审核通过】
- mmap.put("useTimes", sysBaseService.selectGroupCount(Math.toIntExact(id)));
- return prefix + "/allcards";
- }
- /**
- * 详情checklist
- */
- @ApiOperation("单checklist内容列表")
- @Log(title = "单checklist内容列表", businessType = BusinessType.SEARCH)
- @RequiresPermissions("checklist:base:detail")
- @PostMapping("/details/{id}")
- @ResponseBody
- public TableDataInfo details(@PathVariable("id") Long id, CardCheckListEntry cardCheckList)
- {
- log.info(" cardCheckList > {}",cardCheckList);
- cardCheckList.setChecklistBaseId(id);
- startPage();
- List<ChecklistInfo> checklistInfos = checklistService.selectCardCheckListByBaseId(cardCheckList);
- return getDataTable(checklistInfos);
- }
- /**
- * 编辑卡种
- */
- @ApiOperation(value = "",hidden = true)
- @RequiresPermissions("checklist:cardset:edit")
- @Log(title = "编辑卡种", businessType = BusinessType.UPDATE)
- @GetMapping( "/holdCardSets/{id}/{cardsetsId}")
- public String holdCardSets(@PathVariable("id") String id ,@PathVariable("cardsetsId") String cardsetsId , ModelMap mmap)
- {
- //如果是编辑则查询数据 否则
- if("undefined".equals(cardsetsId)){
- cardsetsId = null;
- }
- mmap.put("baseId",id);
- mmap.put("checklist",checklistService.getDetailById(Long.valueOf(cardsetsId)));
- return prefix + "/modal/editCardSets";
- }
- /**
- * 删除checklist基础信息
- */
- @ApiOperation(value = "",hidden = true)
- @RequiresPermissions("checklist:cardset:edit")
- @Log(title = "编辑卡种", businessType = BusinessType.UPDATE)
- @PostMapping( "/holdCardSets")
- @ResponseBody
- public AjaxResult holdCardSetsInfo(CardCheckListEntry cardCheckList)
- {
- return cardChecklistBaseInfoService.holdCardSetsInfo(cardCheckList);
- }
- /**
- * 导出指定的list
- */
- @ApiOperation(value = "",hidden = true)
- @RequiresPermissions("checklist:base:export")
- @Log(title = "导出指定的list", businessType = BusinessType.EXPORT)
- @GetMapping("/downloadById/{id}")
- @ResponseBody
- public void downloadById(@PathVariable("id") Long id, HttpServletResponse response)
- {
- cardChecklistBaseInfoService.downloadChecklistByBaseId(id);
- }
- /**
- * 导出指定的list-指定的数据
- */
- @ApiOperation(value = "",hidden = true)
- @Log(title = "导出指定的list", businessType = BusinessType.EXPORT)
- @GetMapping("/downloadListByType/{id}/{type}")
- @ResponseBody
- public void downloadListByType(@PathVariable("id") Long id, @PathVariable("type") String type, HttpServletResponse response)
- {
- cardChecklistBaseInfoService.downloadChecklistByBaseIdAndType(id,type);
- }
- /**
- * 商家获取拼团checklist列表
- */
- @ApiOperation("商家获取拼团checklist列表")
- @ApiImplicitParams({
- @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")
- })
- @Log(title = "获取CheckList", businessType = BusinessType.SEARCH)
- @PostMapping("/searchBaseInfoBySelect/{type}")
- @ResponseBody
- public AjaxResult searchBaseInfoBySelect(@PathVariable("type") String type, @RequestBody @Validate SelectBaseInfoEntry entry) {
- if (!Objects.isNull(ShiroUtils.getMerchantInfo())) {
- entry.setMerchantId(ShiroUtils.getMerchantInfo().getId());
- }
- return cardChecklistBaseInfoService.searchBaseInfoBySelect(type,entry);
- }
- /**
- * 商家获取拼团checklist列表
- */
- @ApiOperation("商家获取拼团checklist列表")
- @ApiImplicitParams({
- @ApiImplicitParam( name = "version", value="请求类型>值:shop,group", dataType = "String", paramType = "path" ,example = "shop,group"),
- @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")
- })
- @Log(title = "获取CheckList", businessType = BusinessType.SEARCH)
- @PostMapping("/{version}/searchBaseInfoBySelect/{type}")
- @ResponseBody
- public AjaxResult searchBaseInfoBySelectV2(@PathVariable("version") String version, @PathVariable("type") String type, @RequestBody @Validate SelectBaseInfoEntry entry) {
- if (!Objects.isNull(ShiroUtils.getMerchantInfo())) {
- entry.setMerchantId(ShiroUtils.getMerchantInfo().getId());
- }
- entry.setFromVersion(version);
- return cardChecklistBaseInfoService.searchBaseInfoBySelectV2(type,entry);
- }
- /**
- * 商家获取拼团checklist列表
- */
- @ApiOperation("获取轮播图")
- @ApiImplicitParams({
- @ApiImplicitParam( name = "id", value="拼团checklistid", dataType = "Long", paramType = "path" )
- })
- @Log(title = "获取轮播图", businessType = BusinessType.SEARCH)
- @PostMapping("/searchCarouseMapByListId/{id}")
- @ResponseBody
- public AjaxResult searchCarouseMapByListId(@PathVariable("id") Long id) {
- return cardChecklistBaseInfoService.searchCarouseMapByListId(id);
- }
- /**
- * 更新版本信息
- */
- @Log(title = "处理旧数据", businessType = BusinessType.UPDATE)
- @PostMapping("/applyCardChecklistInfo/{id}")
- @ResponseBody
- public AjaxResult applyCardChecklistInfo(@PathVariable("id") Long id ) {
- return cardChecklistBaseInfoService.applyCardChecklistInfo(id,null);
- }
- /**
- * 更新版本信息
- */
- @Log(title = "处理旧数据[批量]", businessType = BusinessType.UPDATE)
- @PostMapping("/applyCardChecklistInfos")
- @ResponseBody
- public AjaxResult applyCardChecklistInfos(@RequestParam("ids") String ids ) {
- return cardChecklistBaseInfoService.applyCardChecklistInfos(ids);
- }
- /**
- * 更新版本信息
- */
- @Log(title = "处理旧数据-选队随机", businessType = BusinessType.UPDATE)
- @PostMapping("/applyRandomTeamCardChecklistInfo/{id}/{type}")
- @ResponseBody
- public AjaxResult applyRandomTeamCardChecklistInfo(@PathVariable("id") Long id ,@PathVariable("type")String type) {
- AjaxResult ajaxResult = cardChecklistBaseInfoService.applyCardChecklistInfo(id, type);
- if(Objects.equals(0 , ajaxResult.get("code"))){
- String msg = StringUtils.isNotBlank(String.valueOf(ajaxResult.get("msg")))?String.valueOf(ajaxResult.get("msg")):"";
- return AjaxResult.success(msg );
- }
- return ajaxResult;
- }
- /**
- * 绑定基础库
- */
- @Log(title = "绑定基础库 ", businessType = BusinessType.UPDATE)
- @PostMapping("/bindParent")
- @ResponseBody
- public AjaxResult bindParent(@RequestBody CardChecklistBaseInfo checklistBaseInfo)
- {
- return cardChecklistBaseInfoService.bindParent(checklistBaseInfo);
- }
- /**
- * 查询拼团列表code
- * @param req
- * @return
- */
- @Log(title = "查询拼团列表code", businessType = BusinessType.UPDATE)
- @PostMapping("/searchGroupListCode")
- @ResponseBody
- public AjaxResult searchGroupListCode(@RequestBody SearchGroupListCodeReq req)
- {
- return cardChecklistBaseInfoService.searchGroupListCode(req);
- }
- /**
- * 同步球队图片
- * @param id
- * @param mmap
- * @return
- */
- @RequestMapping(value = "/syncTeamBgModal/{id}",method = RequestMethod.GET)
- public String syncTeamBgModal(@PathVariable("id") Long id, ModelMap mmap)
- {
- String host = (String) sysFileBaseService.initQiniuConfig().get("img_static_qiniu_host");
- mmap.put("host",host);
- mmap.put("id",id);
- //查询当前list version 的球队图片有无数量
- mmap.put("teamLogoCount", cardChecklistBaseInfoService.checkTeamLogoCount(id)) ;
- return "baseV/checklist/modal/syncTeamBg";
- }
- /**
- * 同步球队图片
- * @return
- */
- @Log(title = "同步球队图片列表", businessType = BusinessType.UPDATE)
- @PostMapping(value = "/syncTeamBg" )
- @ResponseBody
- public TableDataInfo syncTeamBg(@RequestBody PaniniSyncImageReq req)
- {
- List<TeamImgDto> teamImgDtos = cardChecklistBaseInfoService.selectTeamImgByBaseInfoId(req.getId());
- return new TableDataInfo(0, teamImgDtos , teamImgDtos.size());
- }
- /**
- * 同步球队图片
- * @return
- */
- @Log(title = "同步球队图片列表", businessType = BusinessType.UPDATE)
- @PostMapping(value = "/doSyncTeamBg" )
- @ResponseBody
- public AjaxResult doSyncTeamBg(@RequestBody PaniniSyncImageReq req){
- return cardChecklistBaseInfoService.doSyncTeamBg(req);
- }
- }
|