|
@@ -1,14 +1,18 @@
|
|
package com.welampiot.controller;
|
|
package com.welampiot.controller;
|
|
|
|
|
|
import com.welampiot.common.BaseResult;
|
|
import com.welampiot.common.BaseResult;
|
|
-import com.welampiot.dto.BroadcastDTO;
|
|
|
|
-import com.welampiot.dto.BroadcastItemDTO;
|
|
|
|
-import com.welampiot.dto.BroadcastProListDTO;
|
|
|
|
|
|
+import com.welampiot.common.InterfaceResultEnum;
|
|
|
|
+import com.welampiot.dto.*;
|
|
|
|
+import com.welampiot.service.BroadcastItemService;
|
|
|
|
+import com.welampiot.service.BroadcastPolicyInfoService;
|
|
import com.welampiot.service.BroadcastService;
|
|
import com.welampiot.service.BroadcastService;
|
|
|
|
+import com.welampiot.service.UserService;
|
|
import com.welampiot.utils.ToolUtils;
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
|
+import com.welampiot.vo.BroadcastDetailsVO;
|
|
import com.welampiot.vo.BroadcastItemVO;
|
|
import com.welampiot.vo.BroadcastItemVO;
|
|
import com.welampiot.vo.BroadcastProListVO;
|
|
import com.welampiot.vo.BroadcastProListVO;
|
|
import com.welampiot.vo.BroadcastVO;
|
|
import com.welampiot.vo.BroadcastVO;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -16,6 +20,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* ClassName: BroadcastController
|
|
* ClassName: BroadcastController
|
|
@@ -36,6 +44,15 @@ public class BroadcastController {
|
|
@Autowired
|
|
@Autowired
|
|
private ToolUtils toolUtils;
|
|
private ToolUtils toolUtils;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserService userService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private BroadcastItemService broadcastItemService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private BroadcastPolicyInfoService broadcastPolicyInfoService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取音柱列表
|
|
* 获取音柱列表
|
|
* @param request
|
|
* @param request
|
|
@@ -76,4 +93,181 @@ public class BroadcastController {
|
|
BroadcastItemVO vo = broadcastService.getItemListByDTO(username, devId);
|
|
BroadcastItemVO vo = broadcastService.getItemListByDTO(username, devId);
|
|
return BaseResult.success(vo);
|
|
return BaseResult.success(vo);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加编辑节目
|
|
|
|
+ * @param vo 节目表属性
|
|
|
|
+ * @return 添加编辑节目
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/itemSave", method = RequestMethod.POST)
|
|
|
|
+ public BaseResult<?> itemSave(BroadcastDetailsVO vo) {
|
|
|
|
+ BroadcastDetailsVO detailsVO = BroadcastDetailsVO.getBroadcastDetailsVO(vo);
|
|
|
|
+ Integer version = detailsVO.getVersion();
|
|
|
|
+ String username = detailsVO.getUsername();
|
|
|
|
+ Integer proType = detailsVO.getProType();
|
|
|
|
+ String name = detailsVO.getName();
|
|
|
|
+ Integer playType = detailsVO.getPlayType();
|
|
|
|
+ String broadcastId = detailsVO.getBroadcastId();
|
|
|
|
+ if (username.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
|
+ UserDTO userDTO = userService.queryUserIdByUsername(username);
|
|
|
|
+ if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
|
+ detailsVO.setUserId(userDTO.getId());
|
|
|
|
+ if (proType == null || name.length() == 0 || broadcastId.length() == 0 || playType == null)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
|
|
|
|
+ BroadcastItemDTO broadcastItemDTO = new BroadcastItemDTO();
|
|
|
|
+ BeanUtils.copyProperties(detailsVO,broadcastItemDTO);
|
|
|
|
+ Integer id = detailsVO.getId();
|
|
|
|
+ if (proType == 0) { // 普通节目
|
|
|
|
+ if (id == 0) {
|
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
|
+ broadcastItemDTO.setCreateTime(format);
|
|
|
|
+ broadcastItemService.addCommonProgramData(broadcastItemDTO);
|
|
|
|
+ } else {
|
|
|
|
+ broadcastItemService.updateCommonProgramData(broadcastItemDTO);
|
|
|
|
+ }
|
|
|
|
+ } else { // 策略节目
|
|
|
|
+ Integer policyType = broadcastItemDTO.getPolicyType();
|
|
|
|
+ List<BroadcastContentDTO> proList = detailsVO.getProList();
|
|
|
|
+ if (policyType == null || proList.size() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
|
|
|
|
+ List<BroadcastPolicyInfoDTO> contentList = new ArrayList<>();
|
|
|
|
+ for (BroadcastContentDTO b : proList) {
|
|
|
|
+ BroadcastPolicyInfoDTO policyInfoDTO = new BroadcastPolicyInfoDTO();
|
|
|
|
+ String startDate = b.getBeginDate();
|
|
|
|
+ policyInfoDTO.setBeginDate(startDate);
|
|
|
|
+ List<BroadcastPolicyInfoDTO> proTimeList = b.getProTimeList();
|
|
|
|
+ if (proTimeList == null || proTimeList.size() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
|
|
|
|
+ for (BroadcastPolicyInfoDTO dto : proTimeList) {
|
|
|
|
+ String beginTime = dto.getBeginTime();
|
|
|
|
+ Integer time = dto.getTime();
|
|
|
|
+ Integer vol = dto.getVol();
|
|
|
|
+ Integer type = dto.getPlayType();
|
|
|
|
+ if (beginTime == null || beginTime.length() == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_START_TIME_ERROR,version);
|
|
|
|
+ if (time == null || time == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PROGRAM_TIME_ERROR,version);
|
|
|
|
+ if (vol == null || vol == 0)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_VOL_ERROR,version);
|
|
|
|
+ if (type == null)
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.LACK_PLAY_TYPE_ERROR,version);
|
|
|
|
+ BeanUtils.copyProperties(dto,policyInfoDTO);
|
|
|
|
+ contentList.add(policyInfoDTO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (id == 0) {
|
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String format = simpleDateFormat.format(l);
|
|
|
|
+ broadcastItemDTO.setCreateTime(format);
|
|
|
|
+ broadcastItemService.addCommonProgramData(broadcastItemDTO);
|
|
|
|
+ Integer broadcastItemId = broadcastItemDTO.getId();
|
|
|
|
+ contentList.forEach(dto -> dto.setBroadcastPolicyId(broadcastItemId));
|
|
|
|
+ for (BroadcastPolicyInfoDTO b : contentList) {
|
|
|
|
+ broadcastPolicyInfoService.addBroadcastPolicyInfoData(b);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ broadcastItemService.updateCommonProgramData(broadcastItemDTO);
|
|
|
|
+ contentList.forEach(dto -> dto.setBroadcastPolicyId(id));
|
|
|
|
+ broadcastPolicyInfoService.deleteBroadcastPolicyInfoData(id);
|
|
|
|
+ for (BroadcastPolicyInfoDTO b : contentList) {
|
|
|
|
+ broadcastPolicyInfoService.addBroadcastPolicyInfoData(b);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除节目
|
|
|
|
+ * @param vo id
|
|
|
|
+ * @return 删除节目
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/itemDel", method = RequestMethod.POST)
|
|
|
|
+ public BaseResult<?> itemDel(BroadcastDetailsVO vo) {
|
|
|
|
+ BroadcastDetailsVO detailsVO = BroadcastDetailsVO.getBroadcastDetailsVO(vo);
|
|
|
|
+ Integer version = detailsVO.getVersion();
|
|
|
|
+ Integer id = detailsVO.getId();
|
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
|
+ broadcastItemService.deleteBroadcastItemDataById(id);
|
|
|
|
+ BroadcastItemDTO dto = broadcastItemService.getBroadcastItemDTOById(id);
|
|
|
|
+ if (dto.getProType() == 1) {
|
|
|
|
+ broadcastPolicyInfoService.deleteBroadcastPolicyInfoData(id);
|
|
|
|
+ }
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取节目详情
|
|
|
|
+ * @param vo id
|
|
|
|
+ * @return 获取节目详情
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/itemInfo", method = RequestMethod.POST)
|
|
|
|
+ public BaseResult<?> itemInfo(BroadcastDetailsVO vo) {
|
|
|
|
+ BroadcastDetailsVO detailsVO = BroadcastDetailsVO.getBroadcastDetailsVO(vo);
|
|
|
|
+ Integer version = detailsVO.getVersion();
|
|
|
|
+ Integer id = detailsVO.getId();
|
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
|
+ BroadcastItemDTO dto = broadcastItemService.getBroadcastItemDTOById(id);
|
|
|
|
+ Integer proType = dto.getProType();
|
|
|
|
+ BroadcastDetailsVO broadcastDetailsVO = new BroadcastDetailsVO();
|
|
|
|
+ if (proType == 0) { // 普通节目
|
|
|
|
+ BeanUtils.copyProperties(dto,broadcastDetailsVO);
|
|
|
|
+ } else { // 策略节目
|
|
|
|
+ List<BroadcastPolicyInfoDTO> list = broadcastPolicyInfoService.getBroadcastPolicyInfoListByBroadcastId(id);
|
|
|
|
+ broadcastDetailsVO.setName(dto.getName());
|
|
|
|
+ broadcastDetailsVO.setProType(dto.getProType());
|
|
|
|
+ broadcastDetailsVO.setBroadcastId(dto.getBroadcastId());
|
|
|
|
+ broadcastDetailsVO.setPolicyType(dto.getPolicyType());
|
|
|
|
+ List<BroadcastContentDTO> proList = new ArrayList<>();
|
|
|
|
+ List<String> strings = new ArrayList<>();
|
|
|
|
+ list.forEach(dto1 -> strings.add(dto1.getBeginDate()));
|
|
|
|
+ List<String> stringList = strings.stream().distinct().collect(Collectors.toList());
|
|
|
|
+ for (String s : stringList) {
|
|
|
|
+ List<BroadcastPolicyInfoDTO> proTimeList = new ArrayList<>();
|
|
|
|
+ for (BroadcastPolicyInfoDTO b : list) {
|
|
|
|
+ if (s.equals(b.getBeginDate())) {
|
|
|
|
+ proTimeList.add(b);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BroadcastContentDTO contentDTO = new BroadcastContentDTO();
|
|
|
|
+ contentDTO.setBeginDate(s);
|
|
|
|
+ contentDTO.setProTimeList(proTimeList);
|
|
|
|
+ proList.add(contentDTO);
|
|
|
|
+ }
|
|
|
|
+ broadcastDetailsVO.setProList(proList);
|
|
|
|
+ }
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,broadcastDetailsVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 策略信息列表
|
|
|
|
+ * @param vo id
|
|
|
|
+ * @return 策略信息列表
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/policyList", method = RequestMethod.POST)
|
|
|
|
+ public BaseResult<?> policyList(BroadcastItemVO vo) {
|
|
|
|
+ BroadcastItemVO itemVO = BroadcastItemVO.getBroadcastItemVO(vo);
|
|
|
|
+ Integer version = itemVO.getVersion();
|
|
|
|
+ String username = itemVO.getUsername();
|
|
|
|
+ if (username.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
|
+ UserDTO userDTO = userService.queryUserIdByUsername(username);
|
|
|
|
+ if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
|
|
|
|
+ Integer page = itemVO.getPage();
|
|
|
|
+ Integer count = itemVO.getCount();
|
|
|
|
+ String keyword = itemVO.getKeyword();
|
|
|
|
+ BroadcastItemVO broadcastItemVO = new BroadcastItemVO();
|
|
|
|
+ broadcastItemVO.setPage(count * (page - 1));
|
|
|
|
+ broadcastItemVO.setCount(count);
|
|
|
|
+ broadcastItemVO.setKeyword(keyword);
|
|
|
|
+ broadcastItemVO.setUserId(userDTO.getId());
|
|
|
|
+ List<BroadcastItemDTO> list = broadcastItemService.getBroadcastItemListByItemVO(broadcastItemVO);
|
|
|
|
+ Integer total = broadcastItemService.getBroadcastItemTotalByItemVO(broadcastItemVO);
|
|
|
|
+ BroadcastItemVO broadcastItemVO1 = new BroadcastItemVO();
|
|
|
|
+ broadcastItemVO1.setList(list);
|
|
|
|
+ broadcastItemVO1.setTotal(total);
|
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,broadcastItemVO1);
|
|
|
|
+ }
|
|
}
|
|
}
|