|
@@ -0,0 +1,127 @@
|
|
|
|
|
+package com.jpsoft.enterprise.modules.mobile.controller;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.ActivityInfoDTO;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.ActivityInfoListDTO;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.NewsInfoListDTO;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.ActivityInfo;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.NewsInfo;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.NewsType;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.service.ActivityInfoService;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.MessageResult;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.Sort;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author 墨鱼_mo
|
|
|
|
|
+ * @date 2021-1-12 17:02
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/mobile/activityInfoApi")
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class ActivityInfoApiController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ActivityInfoService activityInfoService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("activityList")
|
|
|
|
|
+ @ApiOperation(value = "活动列表(公开接口)")
|
|
|
|
|
+ public MessageResult<Map> activityList(@RequestParam(value="pageIndex",defaultValue="1") int pageIndex, @RequestParam(value="pageSize",defaultValue="10") int pageSize) {
|
|
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<ActivityInfo> activityInfoList = new ArrayList<>();
|
|
|
|
|
+ List<ActivityInfoListDTO> list = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
|
+ searchParams.put("status",1);
|
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
|
|
+
|
|
|
|
|
+ Page<ActivityInfo> page = activityInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
|
|
+ List<ActivityInfo> activityInfos = page.getResult();
|
|
|
|
|
+ if (activityInfos.size()>0){
|
|
|
|
|
+ for (ActivityInfo activityInfo : activityInfos){
|
|
|
|
|
+ ActivityInfoListDTO activityInfoListDTO = new ActivityInfoListDTO();
|
|
|
|
|
+ BeanUtils.copyProperties(activityInfo,activityInfoListDTO);
|
|
|
|
|
+ activityInfoListDTO.setCreateTime(DateUtil.format(activityInfo.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ list.add(activityInfoListDTO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String,Object> pageMap = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ pageMap.put("recordsTotal",page.getTotal());
|
|
|
|
|
+ pageMap.put("recordsFiltered",page.getTotal());
|
|
|
|
|
+ pageMap.put("totalPage",page.getPages());
|
|
|
|
|
+ pageMap.put("pageNumber",page.getPageNum());
|
|
|
|
|
+ pageMap.put("pageSize",page.getPageSize());
|
|
|
|
|
+ pageMap.put("data", list);
|
|
|
|
|
+
|
|
|
|
|
+ messageResult.setData(pageMap);
|
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
+ messageResult.setCode(400);
|
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return messageResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("activityDetail")
|
|
|
|
|
+ @ApiOperation(value = "活动详情(公开接口)")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form")
|
|
|
|
|
+ })
|
|
|
|
|
+ public MessageResult<ActivityInfoDTO> activityDetail(String id) {
|
|
|
|
|
+ MessageResult<ActivityInfoDTO> messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ ActivityInfo activityInfo = activityInfoService.get(id);
|
|
|
|
|
+ if (activityInfo !=null){
|
|
|
|
|
+ ActivityInfoDTO activityInfoDTO = new ActivityInfoDTO();
|
|
|
|
|
+ BeanUtils.copyProperties(activityInfo,activityInfoDTO);
|
|
|
|
|
+ activityInfoDTO.setStartTime(DateUtil.format(activityInfo.getStartTime(),"yyyy-MM-dd"));
|
|
|
|
|
+ activityInfoDTO.setEndTime(DateUtil.format(activityInfo.getEndTime(),"yyyy-MM-dd"));
|
|
|
|
|
+ messageResult.setData(activityInfoDTO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
+ messageResult.setCode(400);
|
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return messageResult;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|