提交 a387f194 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 041a636a
package com.zrqx.resource.bg.controller.content;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
......@@ -27,8 +24,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example.Criteria;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -57,6 +52,10 @@ import com.zrqx.resource.bg.service.resourcelibrary.ResourceLibraryService;
import com.zrqx.resource.bg.service.user.UserAccountRelationService;
import com.zrqx.resource.commons.Redis;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import tk.mybatis.mapper.entity.Example.Criteria;
/**
* 内容管理Controller
*/
......@@ -72,8 +71,6 @@ public class ArticleLibraryController {
private ArticleRelationService articleRelationService;
@Autowired
private UserAccountRelationService userAccountRelationService;
@Autowired
private Redis redis;
@ApiOperation(value = "新增", notes = "新增一个")
@PostMapping(value = ResourceRequestPath.SAVE)
......@@ -107,8 +104,8 @@ public class ArticleLibraryController {
res.setObjectId(entity.getId());
articleRelationService.delete(res);
}
//添加图片素材
if(form.getResourceType().equals(2)){
//添加图片/视频素材
if(form.getResourceType().equals(2) || form.getResourceType().equals(3)){
resourceService.saveOrUpdate(form);
}
//添加资源和用户关联信息
......@@ -418,6 +415,9 @@ public class ArticleLibraryController {
}else if(form.getResourceType().equals(2)){
//发布图组内容
tencentAtlas(library, user, form);
}else if(form.getResourceType().equals(2)){
//发布视频内容
tencentVideo(library, user, form);
}
}else if(form.getOriginal_author().get(i).equals("2")){//微信公众号
//上传图文消息内的图片获取URL
......@@ -611,6 +611,58 @@ public class ArticleLibraryController {
articleService.updateByPrimaryKeySelective(library);
return CallBack.success();
}
private CallBack<String> tencentVideo(ArticleLibrary library, UserAccountRelation user,ContetPublishForm form) throws ParseException{
JSONObject jsonobj_token =null;
jsonobj_token = JSON.parseObject(user.getAccess_token());
String token = jsonobj_token.getJSONObject("data").getString("access_token");
//获取用户id
String openid = jsonobj_token.getJSONObject("data").getString("openid");
JSONArray ja = JSON.parseArray(library.getText());
String[] cmds = {"curl", "-H","Content-Type: application/x-www-form-urlencoded; charset=utf-8", "-F", "media=@"+library.getCover()+"", "access_token="+token+"&title="+library.getTitle()+""
+ "&tags="+library.getTags()+"&cat="+library.getCover_type()+"&md5="+12+"&desc="+library.getText()+"","\"http://api.om.qq.com/articlev2/clientpubvid"};
String excute = HttpClientUtil.execCurl(cmds);
JSONObject jsonobj_aid = JSON.parseObject(excute);
//成功结果:{"code":"0","msg": "success","data": {"transaction_id":TRANSACTION_ID,"article_id":article_id //企鹅媒体平台内容唯一id }}
String transaction_id = jsonobj_aid.getJSONObject("data").getString("transaction_id");
//上传视频封面
String param_res="access_token="+token+"&transaction_id="+transaction_id;
String url_res="https://api.om.qq.com/transaction/infoclient?"+param_res;
String status = HttpClientUtil.doGet(url_res, "utf-8");
JSONObject jsonobj_status = JSON.parseObject(status);
//获取审核状态
String article_Status = jsonobj_status.getJSONObject("data").getJSONObject("article_info").getString("article_pub_flag");
//获取发布时间
String pub_time = jsonobj_status.getJSONObject("data").getJSONObject("article_info").getString("article_pub_time");
//获取发布内容id
String article_id = jsonobj_status.getJSONObject("data").getJSONObject("article_info").getString("article_id");
Criteria criteria = articleRelationService.createCriteria();
criteria.andEqualTo("objectId", library.getId());
criteria.andEqualTo("original_author", 1);
ArticleRelation res = articleRelationService.selectOneByCriteria();
if(article_Status!=null && article_Status!=""){
if(article_Status.equals("发布成功")){
res.setExamineStatus(1);
}else if(article_Status.equals("审核中")){
res.setReason("内容审核中");
res.setExamineStatus(0);
}else if(article_Status.contains("审核未通过")){
res.setExamineStatus(2);
res.setReason("内容不符合平台规范提示");
}else if(article_Status.equals("未发布")){
res.setReason("内容不符合平台规范提示");
res.setExamineStatus(6);
}
res.setArticle_id(article_id);
articleRelationService.updateByCriteriaSelective(res);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
library.setExamineTime(sdf.parse(pub_time));
library.setPublishStatus(1);
articleService.updateByPrimaryKeySelective(library);
return CallBack.success();
}
/***
* 获取企鹅号,查看发布文章状态
* @param access_token
......
......@@ -47,6 +47,9 @@ public interface ArticleLibraryMapper extends BaseMapper<ArticleLibrary> {
+ "<if test='form.publishStatus != null'>"
+ " and a.publishStatus = #{form.publishStatus}"
+ "</if>"
+ "<if test='form.resourceType != null'>"
+ " and a.resourceType = #{form.resourceType}"
+ "</if>"
+ "</script>")
List<ArticleLibraryListVO> query(@Param("form")QueryArticleLibraryForm form);
/**
......
......@@ -25,7 +25,7 @@ public interface UserAccountRelationMapper extends BaseMapper<UserAccountRelatio
+ "</script>")
Integer countByfav();
@Select("<script>"
+ "SELECT count(share) from user_account_relation "
+ "SELECT count(shares) from user_account_relation "
+ "</script>")
Integer countByShare();
@Select("<script>"
......
......@@ -36,20 +36,43 @@ public class ResourceLibrarySerivceImpl extends BaseServiceImpl<ResourceLibrary,
public boolean saveOrUpdate(SaveUpdateArticleLibraryForm form) throws ParseException {
List<ResourceLibrary> list = new ArrayList<ResourceLibrary>();
if(form.getText()!=null){
String[] text = form.getText().split(",");
for (String str : text) {
//添加图片
if(form.getResourceType().equals(2)) {
String[] text = form.getText().split(",");
for (String str : text) {
ResourceLibrary res = new ResourceLibrary();
JSONObject jsonObject = JSON.parseObject(str);
String image = jsonObject.getString("image");
String desc = jsonObject.getString("desc");
res.setTitle(form.getTitle());
if(form.getResourceType().equals(2)) {
res.setResourceType(1);
}
res.setPath(image);
res.setIntro(desc);
res.setIsDelete(0);
res.setUploadTime(new Date());
res.setSize(form.getSize());
list.add(res);
}
resourceMapper.insertUuidList(list);
}
if(form.getResourceType().equals(3)) {
ResourceLibrary res = new ResourceLibrary();
JSONObject jsonObject = JSON.parseObject(str);
String image = jsonObject.getString("image");
String desc = jsonObject.getString("desc");
res.setTitle(form.getTitle());
res.setPath(image);
res.setIntro(desc);
if(form.getResourceType().equals(3)) {
res.setResourceType(2);
}
res.setPath(form.getCover());
res.setIntro(form.getText());
res.setUploadTime(new Date());
res.setSize(form.getSize());
res.setTimeLength(form.getTimeLength());
res.setIsDelete(0);
list.add(res);
resourceMapper.insert(res);
}
}
resourceMapper.insertUuidList(list);
return true;
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论