Commit 5358d41f669bf17e47c1fed93d386491b1426bd4
1 parent
79c54a3f
音频数据拒绝功能
Showing
3 changed files
with
114 additions
and
1 deletions
src/main/java/com/cnlive/shenhe/controller/AudioController.java
| @@ -189,4 +189,30 @@ public class AudioController extends BaseController { | @@ -189,4 +189,30 @@ public class AudioController extends BaseController { | ||
| 189 | } | 189 | } |
| 190 | return audioService.retReceive(ids, userId); | 190 | return audioService.retReceive(ids, userId); |
| 191 | } | 191 | } |
| 192 | + | ||
| 193 | + /** | ||
| 194 | + * 打回(审核拒绝,应要求不加权限、状态等限制) | ||
| 195 | + * | ||
| 196 | + * @param ids | ||
| 197 | + * @param msg | ||
| 198 | + * @param session | ||
| 199 | + * @return | ||
| 200 | + */ | ||
| 201 | + @PostMapping("/repulse") | ||
| 202 | + @ResponseBody | ||
| 203 | + public ResponseBean repulse(String ids, String msg, HttpSession session) { | ||
| 204 | + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); | ||
| 205 | + String userId = sessionUser.getUserId(); | ||
| 206 | + ResponseBean responseBean = new ResponseBean(); | ||
| 207 | + String[] shyAudiods = ids.split(","); | ||
| 208 | + String showMsg = ""; | ||
| 209 | + for (String shyAudioId : shyAudiods) { | ||
| 210 | + showMsg = audioService.repulse(shyAudioId, msg, userId); | ||
| 211 | + } | ||
| 212 | + if (CommonUtils.isNotEmpty(showMsg)) { | ||
| 213 | + responseBean.setErrorCode(ErrorEnum.ERROR.getErrorCode()); | ||
| 214 | + responseBean.setErrorMessage(showMsg); | ||
| 215 | + } | ||
| 216 | + return responseBean; | ||
| 217 | + } | ||
| 192 | } | 218 | } |
src/main/java/com/cnlive/shenhe/serviceImpl/AudioServiceImpl.java
| 1 | package com.cnlive.shenhe.serviceImpl; | 1 | package com.cnlive.shenhe.serviceImpl; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 3 | import com.cnlive.shenhe.bean.ErrorEnum; | 4 | import com.cnlive.shenhe.bean.ErrorEnum; |
| 4 | import com.cnlive.shenhe.bean.ResponseBean; | 5 | import com.cnlive.shenhe.bean.ResponseBean; |
| 5 | import com.cnlive.shenhe.entity.ShyAudio; | 6 | import com.cnlive.shenhe.entity.ShyAudio; |
| 6 | -import com.cnlive.shenhe.entity.ShyVideos; | ||
| 7 | import com.cnlive.shenhe.mapper.ShyAudioMapper; | 7 | import com.cnlive.shenhe.mapper.ShyAudioMapper; |
| 8 | +import com.cnlive.shenhe.utils.AuditPass; | ||
| 8 | import com.cnlive.shenhe.utils.CommonConst; | 9 | import com.cnlive.shenhe.utils.CommonConst; |
| 9 | import com.cnlive.shenhe.utils.CommonUtils; | 10 | import com.cnlive.shenhe.utils.CommonUtils; |
| 10 | import com.github.pagehelper.PageHelper; | 11 | import com.github.pagehelper.PageHelper; |
| 11 | import com.github.pagehelper.PageInfo; | 12 | import com.github.pagehelper.PageInfo; |
| 12 | import org.apache.ibatis.session.RowBounds; | 13 | import org.apache.ibatis.session.RowBounds; |
| 14 | +import org.slf4j.Logger; | ||
| 15 | +import org.slf4j.LoggerFactory; | ||
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 15 | import tk.mybatis.mapper.entity.Example; | 18 | import tk.mybatis.mapper.entity.Example; |
| @@ -22,9 +25,17 @@ import java.util.List; | @@ -22,9 +25,17 @@ import java.util.List; | ||
| 22 | @Service | 25 | @Service |
| 23 | public class AudioServiceImpl { | 26 | public class AudioServiceImpl { |
| 24 | 27 | ||
| 28 | + private static Logger logger = LoggerFactory.getLogger(AudioServiceImpl.class); | ||
| 29 | + | ||
| 25 | @Autowired | 30 | @Autowired |
| 26 | ShyAudioMapper shyAudioMapper; | 31 | ShyAudioMapper shyAudioMapper; |
| 27 | 32 | ||
| 33 | + @Autowired | ||
| 34 | + AudioServiceImpl audioService; | ||
| 35 | + | ||
| 36 | + @Autowired | ||
| 37 | + AuditPass Pass; | ||
| 38 | + | ||
| 28 | public ShyAudio getAudioMsg(String audioId) { | 39 | public ShyAudio getAudioMsg(String audioId) { |
| 29 | return shyAudioMapper.getAudioMsg(audioId); | 40 | return shyAudioMapper.getAudioMsg(audioId); |
| 30 | } | 41 | } |
| @@ -94,6 +105,57 @@ public class AudioServiceImpl { | @@ -94,6 +105,57 @@ public class AudioServiceImpl { | ||
| 94 | return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "已退领"); | 105 | return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "已退领"); |
| 95 | } | 106 | } |
| 96 | 107 | ||
| 108 | + public String repulse(String shyAudioId,String msg,String userId){ | ||
| 109 | + String showMsg=""; | ||
| 110 | + ShyAudio shyAudio = audioService.selectByPrimaryKey(Integer.parseInt(shyAudioId)); | ||
| 111 | + JSONObject result; | ||
| 112 | + try { | ||
| 113 | + result = Pass.audioPass(shyAudio.getAudioId(), 4, msg, msg, shyAudio.getCallback()); | ||
| 114 | + } catch (Exception e) { | ||
| 115 | + logger.error("视频审核失败,id==" + shyAudioId, e); | ||
| 116 | + showMsg = showMsg + "," + shyAudio.getAudioTitle() + " 拒绝请求失败"; | ||
| 117 | + return showMsg; | ||
| 118 | + } | ||
| 119 | + if (result == null) { | ||
| 120 | + logger.error("视频审核失败且接口错误没有返回信息,id==" + shyAudioId); | ||
| 121 | + showMsg = showMsg + "," + shyAudio.getAudioTitle() + " 拒绝请求失败"; | ||
| 122 | + return showMsg; | ||
| 123 | + } | ||
| 124 | + Integer code = result.getInteger("code"); | ||
| 125 | + if (code != 0) { | ||
| 126 | + logger.error("视频审核失败,id:{},code:{}", shyAudioId, code); | ||
| 127 | + showMsg = showMsg + "," + shyAudio.getAudioTitle() + " " + result.getString("msg"); | ||
| 128 | + return showMsg; | ||
| 129 | + } | ||
| 130 | + //0.未审核,1:已审核,2.拒绝 | ||
| 131 | + int i = audioService.updateAudio(Integer.parseInt(shyAudioId), userId,null,"", 2, msg); | ||
| 132 | + if (i == 0) { | ||
| 133 | + showMsg = showMsg + "," + shyAudio.getAudioTitle() + " 更新失败"; | ||
| 134 | + return showMsg; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + return showMsg; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public int updateAudio(Integer id, String auditor_id,String updater,String attr_tags, Integer state, String msg) { | ||
| 141 | + ShyAudio shyAudio = shyAudioMapper.selectByPrimaryKey(id); | ||
| 142 | + shyAudio.setAuditor_id(auditor_id); | ||
| 143 | + shyAudio.setState(state); | ||
| 144 | + if(CommonUtils.isNotEmpty(attr_tags)){ | ||
| 145 | + shyAudio.setAttr_tags(attr_tags); | ||
| 146 | + } | ||
| 147 | + if(CommonUtils.isNotEmpty(msg)){ | ||
| 148 | + shyAudio.setMsg(msg); | ||
| 149 | + } | ||
| 150 | + shyAudio.setUploader(updater); | ||
| 151 | + if(CommonUtils.isNotEmpty(auditor_id)){ | ||
| 152 | + shyAudio.setReceive(CommonConst.RECEIVE_AFTER); | ||
| 153 | + shyAudio.setReceive_user_id(auditor_id); | ||
| 154 | + shyAudio.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | ||
| 155 | + } | ||
| 156 | + return shyAudioMapper.updateByPrimaryKey(shyAudio); | ||
| 157 | + } | ||
| 158 | + | ||
| 97 | //分页查询音频数据 | 159 | //分页查询音频数据 |
| 98 | public PageInfo<ShyAudio> getListContent(String video_title, String start_date, String end_date, Integer state, Integer receive, Integer page, Integer pageSize, String video_priority, String orderByClause, Integer spid, String userId, String sp_Id) { | 160 | public PageInfo<ShyAudio> getListContent(String video_title, String start_date, String end_date, Integer state, Integer receive, Integer page, Integer pageSize, String video_priority, String orderByClause, Integer spid, String userId, String sp_Id) { |
| 99 | Example example = new Example(ShyAudio.class); | 161 | Example example = new Example(ShyAudio.class); |
src/main/java/com/cnlive/shenhe/utils/AuditPass.java
| @@ -218,4 +218,29 @@ public class AuditPass { | @@ -218,4 +218,29 @@ public class AuditPass { | ||
| 218 | Map<String, String> post = httpUtil.post(URL); | 218 | Map<String, String> post = httpUtil.post(URL); |
| 219 | return JSONObject.parseObject(post.get("result")); | 219 | return JSONObject.parseObject(post.get("result")); |
| 220 | } | 220 | } |
| 221 | + | ||
| 222 | + //音频回调 | ||
| 223 | + public JSONObject audioPass(String video_id, int state, String attr_tags, String msg, String callBack) { | ||
| 224 | + logger.info("点播回调:video_id:{},state:{},attr_tags:{},msg:{}", video_id, state, attr_tags, msg); | ||
| 225 | + JSONObject params = new JSONObject(); | ||
| 226 | + params.put("video_id", video_id); | ||
| 227 | + params.put("state", state + ""); | ||
| 228 | + params.put("attr_tags", attr_tags); | ||
| 229 | + params.put("msg", msg); | ||
| 230 | + HttpUtil httpUtil = HttpUtil.init(); | ||
| 231 | + httpUtil.setParam("param", params.toJSONString()); | ||
| 232 | + String token = ""; | ||
| 233 | + try { | ||
| 234 | + String cb = callBack.replace("//", ""); | ||
| 235 | + cb = cb.substring(cb.indexOf("/")); | ||
| 236 | + token = CommonUtils.md5(cb + platformKey + platformValue); | ||
| 237 | + } catch (NoSuchAlgorithmException e) { | ||
| 238 | + e.printStackTrace(); | ||
| 239 | + } catch (UnsupportedEncodingException e) { | ||
| 240 | + e.printStackTrace(); | ||
| 241 | + } | ||
| 242 | + String URL = callBack + "?platform=" + platformKey + "&token=" + token; | ||
| 243 | + Map<String, String> post = httpUtil.post(URL); | ||
| 244 | + return JSONObject.parseObject(post.get("result")); | ||
| 245 | + } | ||
| 221 | } | 246 | } |