|
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.configuration.BroadcastConfig;
|
|
|
-import com.welampiot.dao.BroadcastProListDao;
|
|
|
import com.welampiot.dto.*;
|
|
|
import com.welampiot.service.*;
|
|
|
import com.welampiot.utils.BroadcastUtil;
|
|
@@ -23,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.File;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -277,6 +277,57 @@ public class BroadcastController {
|
|
|
broadcastItemVO1.setTotal(total);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,broadcastItemVO1);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加音乐
|
|
|
+ * @param vo 音乐地址名称
|
|
|
+ * @return 添加音乐
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/proSave", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> proSave(BroadcastProListVO vo) {
|
|
|
+ if (vo.getVersion() == null) vo.setVersion(0);
|
|
|
+ Integer version = vo.getVersion();
|
|
|
+ String username = vo.getUsername();
|
|
|
+ String name = vo.getName();
|
|
|
+ String url = vo.getUrl();
|
|
|
+ if (url.isEmpty()) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ if (name.trim().isEmpty()) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ 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);
|
|
|
+ BroadcastProListDTO broadcastProListDTO = new BroadcastProListDTO();
|
|
|
+ broadcastProListDTO.setName(name);
|
|
|
+ broadcastProListDTO.setUserId(userDTO.getId());
|
|
|
+ broadcastProListDTO.setUrl(url);
|
|
|
+ broadcastProListService.addBroadcastMusic(broadcastProListDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除音乐
|
|
|
+ * @param vo 音乐id
|
|
|
+ * @return 删除音乐
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/proDel", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> proDel(BroadcastProListVO vo) {
|
|
|
+ if (vo.getVersion() == null) vo.setVersion(0);
|
|
|
+ Integer version = vo.getVersion();
|
|
|
+ Integer id = vo.getId();
|
|
|
+ if (id == null) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+ BroadcastProListDTO oneById = broadcastProListService.getOneById(id);
|
|
|
+ String url = oneById.getUrl();
|
|
|
+ File file = new File(url);
|
|
|
+ if (file.exists()) {
|
|
|
+ if (!file.delete()) { // 文件删除失败
|
|
|
+ return toolUtils.response(InterfaceResultEnum.FILE_DELETE_FAIL,version);
|
|
|
+ }
|
|
|
+ } else { // 文件不存在
|
|
|
+ return toolUtils.response(InterfaceResultEnum.FILE_NO_EXIST_ERROR,version);
|
|
|
+ }
|
|
|
+ broadcastProListService.deleteBroadcastProListDate(id);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 调节设备音量
|
|
|
* @param request
|