From 8cac07d66bef9c682f071fcc1df36a6f8c2a0c30 Mon Sep 17 00:00:00 2001 From: dengqingliu <2733574813@qq.com> Date: 星期二, 22 十一月 2022 10:14:25 +0800 Subject: [PATCH] 门户资讯接口 --- src/main/java/com/qxueyou/scc/portal/information/vo/UpdateArticleVO.java | 164 +++++++ src/main/java/com/qxueyou/scc/portal/information/vo/SaveArticleVO.java | 152 ++++++ src/main/java/com/qxueyou/scc/portal/information/dto/ArticleInfoDTO.java | 161 +++++++ src/main/java/com/qxueyou/scc/portal/information/vo/ListArticleVO.java | 64 ++ src/main/java/com/qxueyou/scc/portal/information/controller/InformationController.java | 103 ++++ src/main/java/com/qxueyou/scc/portal/information/dto/ArticleDTO.java | 143 ++++++ src/main/java/com/qxueyou/scc/portal/information/model/Information.java | 280 ++++++++++++ src/main/java/com/qxueyou/scc/portal/information/service/impl/InformationService.java | 202 ++++++++ src/main/java/com/qxueyou/scc/portal/information/service/IInformationService.java | 70 +++ 9 files changed, 1,339 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/portal/information/controller/InformationController.java b/src/main/java/com/qxueyou/scc/portal/information/controller/InformationController.java new file mode 100644 index 0000000..7504e43 --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/controller/InformationController.java @@ -0,0 +1,103 @@ +package com.qxueyou.scc.portal.information.controller; + +//import com.qxueyou.appraisal.console.article.vo.ListArticleVO; +//import com.qxueyou.appraisal.console.article.vo.SaveArticleVO; +//import com.qxueyou.appraisal.console.article.vo.UpdateArticleVO; +//import com.qxueyou.model.Result; +//import com.qxueyou.scc.base.model.Result; +import com.qxueyou.scc.base.model.Result; +import com.qxueyou.scc.portal.information.service.IInformationService; +import com.qxueyou.scc.portal.information.vo.ListArticleVO; +import com.qxueyou.scc.portal.information.vo.SaveArticleVO; +import com.qxueyou.scc.portal.information.vo.UpdateArticleVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.List; + +/** + * 鏂囩珷鎺у埗鍣� + * + * @author angy + * @created by 2021/3/1 + */ +@RestController +@RequestMapping("/information") +@Api(tags = "璧勮鎺у埗鍣�") +public class InformationController { + + @Autowired + private IInformationService informationService; + + @GetMapping("/list") + @ApiOperation("鑾峰彇鏂囩珷鍒楄〃") + public Result listArticle(@RequestBody ListArticleVO vo) { + return informationService.listArticle(vo); + } +// + @PostMapping("/add") + @ApiOperation("鏂板") + public + Result save(@RequestBody SaveArticleVO vo) { + return informationService.save(vo); + } + + @DeleteMapping("/delete") + @ApiOperation("鍒犻櫎") + @ApiImplicitParam(name = "id", value = "鏂囩珷id", dataType = "string", required = true) + public Result delete( String id) { + + if (StringUtils.isBlank(id)) { + return new Result(false, "id is not blank!"); + } + return informationService.delete(id); + } +// + @PutMapping("/update") + @ApiOperation("鏇存柊") + public Result update(@RequestBody UpdateArticleVO vo) { + return informationService.update(vo); + } +// + @GetMapping("/getArticleById") + @ApiOperation("鑾峰彇鏂囩珷璇︽儏") + @ApiImplicitParam(name = "id", value = "鏂囩珷id", dataType = "string", required = true) + public Result getArticleById( String id) { + if (StringUtils.isBlank(id)) { + return new Result(false, "id is not blank!"); + } + return informationService.getArticleById(id); + } +// + @PostMapping("/up") + @ApiOperation("鍙戝竷") + + public Result up( String id) { + String[] arrStr = id.split(","); + List<String> idLst = Arrays.asList(arrStr); + for (String articleId : idLst) { + Result result = informationService.upById(articleId); + if (!result.isSuccess()) { + return result; + } + } + + return Result.SUCCESS; + } +//@PathVariable/{id} + @PostMapping("/down") + @ApiOperation("鎾ゅ洖") + public Result downById( String id) { + if (StringUtils.isBlank(id)) { + return new Result(false, "id is not blank!"); + } + return informationService.downById(id); + } + +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/dto/ArticleDTO.java b/src/main/java/com/qxueyou/scc/portal/information/dto/ArticleDTO.java new file mode 100644 index 0000000..ae901b3 --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/dto/ArticleDTO.java @@ -0,0 +1,143 @@ +package com.qxueyou.scc.portal.information.dto; + +import java.util.List; +import java.util.Map; + +/** + * @author angy + * @created by 2021/3/1 + */ +public class ArticleDTO { + + //鏂囩珷id + private String id; + + //鏂囩珷鏍囬 + private String title; + + //鏂囩珷绫诲瀷 + private String type; + + //缂╃暐鍥� + private String thumbnailUrl; + + //瀛愭爮鐩� + private String subColumn; + + //鐘舵�� + private String status; + + //娴忚鏁� + private Integer browseCount; + + //鍒涘缓鏃堕棿 + private String dateTime; + + //闄勪欢url + private String attachmentUrl; + + //闄勪欢鍚嶇О + private String attachmentName; + + //闄勪欢鏁伴噺 + private Integer attachmentCount; + + //闄勪欢 + private List<Map<String,String>> attachment; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAttachmentUrl() { + return attachmentUrl; + } + + public void setAttachmentUrl(String attachmentUrl) { + this.attachmentUrl = attachmentUrl; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName; + } + + public Integer getBrowseCount() { + return browseCount; + } + + public void setBrowseCount(Integer browseCount) { + this.browseCount = browseCount; + } + + public String getSubColumn() { + return subColumn; + } + + public void setSubColumn(String subColumn) { + this.subColumn = subColumn; + } + + public Integer getAttachmentCount() { + return attachmentCount; + } + + public void setAttachmentCount(Integer attachmentCount) { + this.attachmentCount = attachmentCount; + } + + public List<Map<String, String>> getAttachment() { + return attachment; + } + + public void setAttachment(List<Map<String, String>> attachment) { + this.attachment = attachment; + } +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/dto/ArticleInfoDTO.java b/src/main/java/com/qxueyou/scc/portal/information/dto/ArticleInfoDTO.java new file mode 100644 index 0000000..07f4c88 --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/dto/ArticleInfoDTO.java @@ -0,0 +1,161 @@ +package com.qxueyou.scc.portal.information.dto; + +import java.util.List; +import java.util.Map; + +/** + * @author angy + * @created by 2021/3/1 + */ +public class ArticleInfoDTO { + + //鏂囩珷id + private String id; + + //鏂囩珷鏍囬 + private String title; + + //鏂囩珷绫诲瀷 + private String type; + + //鍒涘缓鏃堕棿 + private String dateTime; + + //缂╃暐鍥� + private String thumbnailUrl; + + //鏂囩珷鍐呭 + private String content; + + + //闄勪欢 + private List<Map<String,String>> attachment; + + //娴忚鏁� + private Integer browseCount; + + private String subColumn; + + private String numbers; + + private String competition; + + private String preliminaries; + + private String finals; + + private String videoUrl; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getBrowseCount() { + return browseCount; + } + + public void setBrowseCount(Integer browseCount) { + this.browseCount = browseCount; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public List<Map<String, String>> getAttachment() { + return attachment; + } + + public void setAttachment(List<Map<String, String>> attachment) { + this.attachment = attachment; + } + + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + + public String getSubColumn() { + return subColumn; + } + + public void setSubColumn(String subColumn) { + this.subColumn = subColumn; + } + + public String getNumbers() { + return numbers; + } + + public void setNumbers(String numbers) { + this.numbers = numbers; + } + + public String getCompetition() { + return competition; + } + + public void setCompetition(String competition) { + this.competition = competition; + } + + public String getPreliminaries() { + return preliminaries; + } + + public void setPreliminaries(String preliminaries) { + this.preliminaries = preliminaries; + } + + public String getFinals() { + return finals; + } + + public void setFinals(String finals) { + this.finals = finals; + } + + public String getVideoUrl() { + return videoUrl; + } + + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/model/Information.java b/src/main/java/com/qxueyou/scc/portal/information/model/Information.java new file mode 100644 index 0000000..295a366 --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/model/Information.java @@ -0,0 +1,280 @@ +package com.qxueyou.scc.portal.information.model; + + +//sa_information + + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.qxueyou.scc.base.model.ITrace; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Proxy; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Map; + +//@Proxy(lazy = false) +@Entity +@Table( name = "sa_information") +public class Information implements Serializable { + + private static final long serialVersionUID = 1L; + + //草稿 draft + public static final String DRAFT_STATUS = "draft"; + //上架 + public static final String UP_STATUS = "up"; + //下架 + public static final String DOWN_STATUS = "down"; + + + public Information() { + + } + + public Information(String id, String title, String type, String thumbnailUrl, Date createTime, Date updateTime, String status, Integer browseCount, String attachment, String content, Date dateTime, String subColumn, String videoUrl, String numbers, String competition, Integer deleteFlag) { + this.id = id; + this.title = title; + this.type = type; + this.thumbnailUrl = thumbnailUrl; + this.createTime = createTime; + this.updateTime = updateTime; + this.status = status; + this.browseCount = browseCount; + this.attachment = attachment; + this.content = content; + this.dateTime = dateTime; + this.subColumn = subColumn; + this.videoUrl = videoUrl; + this.numbers = numbers; + this.competition = competition; + this.deleteFlag = deleteFlag; + } + + + private String id; + public void setId(String id) { + this.id = id; + } + + @Id + @GeneratedValue(generator = "hibernate-uuid") + @GenericGenerator(name = "hibernate-uuid", strategy = "uuid") + @Column(name = "Id", unique = true, nullable = false, length = 32) + public String getId() { + return id; + } + //文章标题 + private String title; + + //文章类型 + //examBriefing 走进大赛 + // qualifiedSet 通知公告 + // policiesRegulations 新闻中心 + // examinationGuide 资料下载 + // popularInformation 联系方式 + // occupationalStandard + private String type; + + //缩略图 + private String thumbnailUrl; + + + private Date createTime; + + private Date updateTime; + //状态 + private String status; + + //浏览数 + //BROWSE_COUNT browseCount + private Integer browseCount; + + //附件 + private String attachment; + +// //工种编号 +// private String occupationCode; + + //文章内容 + private String content; + + //发布时间 + private Date dateTime; + + //子栏目 + private String subColumn; + + //视频路径 + private String videoUrl; + + //届数 + private String numbers; + + //竞赛文件路径 + private String competition; + + //是否删除:0未删除 1删除 + private Integer deleteFlag; + +// //初赛成绩路径 +// private String preliminaries; + + //决赛成绩路径 +// private String finals; + + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + @Column(name = "THUMBNAIL_URL", nullable = false, length = 100) + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + @Column(name = "CREATE_TIME", length = 19) + @Temporal(TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonIgnore + public Date getCreateTime() { + return createTime; + } + + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Column(name = "UPDATE_TIME", length = 19) + @Temporal(TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonIgnore + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + @Column(name = "STATUS", length = 10) + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Column(name = "BROWSE_COUNT" ,length = 20) + public Integer getBrowseCount() { + return browseCount; + } + + public void setBrowseCount(Integer browseCount) { + this.browseCount = browseCount; + } + + @Column(name = "ATTACHMENT" ,length = 100) + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + @Column(name = "CONTENT" ) + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + @Column(name = "DATE_TIME", length = 19) + @Temporal(TemporalType.TIMESTAMP) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") +// @JsonIgnore + public Date getDateTime() { + return dateTime; + } + + public void setDateTime(Date dateTime) { + this.dateTime = dateTime; + } + + @Column(name = "SUB_COLUMN" ) + public String getSubColumn() { + return subColumn; + } + + public void setSubColumn(String subColumn) { + this.subColumn = subColumn; + } + @Column(name = "VIDEO_URL" ) + public String getVideoUrl() { + return videoUrl; + } + + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } + @Column(name = "NUMBERS" ) + public String getNumbers() { + return numbers; + } + public void setNumbers(String numbers) { + this.numbers = numbers; + } + @Column(name = "COMPETITION" ) + public String getCompetition() { + return competition; + } + + public void setCompetition(String competition) { + this.competition = competition; + } + + @Column(name = "DELTE_FLAG" ) + public Integer getDeleteFlag() { + return deleteFlag; + } + + public void setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + } + + + // public String getPreliminaries() { +// return preliminaries; +// } +// +// public void setPreliminaries(String preliminaries) { +// this.preliminaries = preliminaries; +// } +// +// public String getFinals() { +// return finals; +// } +// +// public void setFinals(String finals) { +// this.finals = finals; +// } +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/service/IInformationService.java b/src/main/java/com/qxueyou/scc/portal/information/service/IInformationService.java new file mode 100644 index 0000000..60a1858 --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/service/IInformationService.java @@ -0,0 +1,70 @@ +package com.qxueyou.scc.portal.information.service; + + +import com.qxueyou.scc.base.model.Result; +import com.qxueyou.scc.portal.information.vo.ListArticleVO; +import com.qxueyou.scc.portal.information.vo.SaveArticleVO; +import com.qxueyou.scc.portal.information.vo.UpdateArticleVO; + +public interface IInformationService { + /** + * 鑾峰彇鏂囩珷鍒楄〃 + * + * @param vo + * @return + */ + Result listArticle(ListArticleVO vo); + + /** + * + * @param keyword + * @return + */ + int findInformationCount(String type,String title,String status) ; + + /** + * 淇濆瓨鏂囩珷 + * + * @param vo + * @return + */ + Result save(SaveArticleVO vo); +// + /** + * 鍒犻櫎鏂囩珷 + * + * @param id 鏂囩珷id + * @return + */ + Result delete(String id); +// + /** + * 鏇存柊鏂囩珷 + * + * @param vo + * @return + */ + Result update(UpdateArticleVO vo); +// + /** + * 鑾峰彇鏂囩珷璇︾粏淇℃伅 + * + * @param id 鏂囩珷id + * @return + */ + Result getArticleById(String id); +// + /** + * 鍙戝竷 + * @param id 鏂囩珷id + * @return + */ + Result upById(String id); + + /** + * 鎾ゅ洖 + * @param id 鏂囩珷id + * @return + */ + Result downById(String id); +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/service/impl/InformationService.java b/src/main/java/com/qxueyou/scc/portal/information/service/impl/InformationService.java new file mode 100644 index 0000000..b82007e --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/service/impl/InformationService.java @@ -0,0 +1,202 @@ +package com.qxueyou.scc.portal.information.service.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +//import com.qxueyou.appraisal.console.article.dto.ArticleDTO; +//import com.qxueyou.appraisal.console.article.dto.ArticleInfoDTO; +//import com.qxueyou.appraisal.console.article.service.IArticleService; +//import com.qxueyou.appraisal.console.article.vo.ListArticleVO; +//import com.qxueyou.appraisal.console.article.vo.SaveArticleVO; +//import com.qxueyou.appraisal.console.article.vo.UpdateArticleVO; +//import com.qxueyou.entity.article.ArticleDO; +//import com.qxueyou.model.Result; +import com.qxueyou.scc.base.model.Pager; +import com.qxueyou.scc.base.model.Result; +import com.qxueyou.scc.base.service.impl.CommonAppService; +//import com.qxueyou.service.CommonMongoService; +//import com.qxueyou.util.TraceMongoUtils; +import com.qxueyou.scc.base.util.ClientUtils; +import com.qxueyou.scc.base.util.CollectionUtils; +import com.qxueyou.scc.portal.information.dto.ArticleInfoDTO; +import com.qxueyou.scc.portal.information.model.Information; +import com.qxueyou.scc.portal.information.service.IInformationService; +import com.qxueyou.scc.portal.information.vo.ListArticleVO; +import com.qxueyou.scc.portal.information.vo.SaveArticleVO; +import com.qxueyou.scc.portal.information.vo.UpdateArticleVO; +import com.qxueyou.scc.user.model.UserTeacher; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Sort; +//import org.springframework.data.mongodb.core.query.Criteria; +//import org.springframework.data.mongodb.core.query.Query; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author angy + * @created by 2021/3/1 + */ +@Service +public class InformationService extends CommonAppService implements IInformationService { + + private ObjectMapper objectMapper = new ObjectMapper(); + + /** + * 鑾峰彇璧勮鎬绘潯鏁� + */ + @Override + public int findInformationCount(String type,String title,String status) { + + String hql = "from Information where type like :type and title like :title and status like :status and deleteFlag=0"; + return findCountByComplexHql(hql, CollectionUtils.newObjectMap("type", type + "%","title", title + "%","status",status+"%")); + } + + @Override + public Result listArticle(ListArticleVO vo) { + String type = StringUtils.isEmpty(vo.getType()) ? "" : vo.getType(); + + String title = StringUtils.isEmpty(vo.getKeyword()) ? "" : vo.getKeyword(); + + String hql = "from Information where deleteFlag=0 and type like ? and title like ? order by createTime desc"; + List<Information> list = findList(hql, new Pager(vo.getSize(), vo.getPage()), CollectionUtils.newList(type.concat("%"), title.concat("%")), Information.class); + int count =findInformationCount(type,title,"");//璧勮鎬绘潯鏁� + return new Result(true,"success", CollectionUtils.newObjectMap("list", list, "count", count)); + } + + @Override + public Result save(SaveArticleVO vo) { + Information articleDO = new Information(); + BeanUtils.copyProperties(vo, articleDO); + articleDO.setBrowseCount(0); + articleDO.setDeleteFlag(0); + articleDO.setCreateTime(new Date()); + articleDO.setUpdateTime(new Date()); + articleDO.setStatus(Information.DRAFT_STATUS); + if (StringUtils.isNotBlank(vo.getAttachment())) { +// try { + //List<Map<String, String>> attachment = objectMapper.readValue(vo.getAttachment(), List.class); + articleDO.setAttachment(vo.getAttachment()); +// } catch (IOException e) { +// log.error("鏂囩珷闄勪欢json杞崲鍑洪敊锛宩son content : {}", vo.getAttachment()); +// } + } + if (vo.getVideoUrl()!=null) { +// String videoUrl=""; +// try { +// List<Map<String, String>> attachment = objectMapper.readValue(vo.getVideoUrl(), List.class); +// for (Map<String, String> map : attachment) { +// videoUrl=map.get("videoUrl"); +// } + articleDO.setVideoUrl(vo.getVideoUrl()); +// } catch (IOException e) { +// log.error("鏂囩珷闄勪欢json杞崲鍑洪敊锛宩son content : {}", vo.getVideoUrl()); +// } + } +// TraceMongoUtils.setCreateTrace(articleDO); + save(articleDO); + return Result.SUCCESS; + } + + @Override + public Result delete(String id) { + Result result = new Result(true); + String[] arrStr = id.split(","); + if (arrStr != null && arrStr.length > 0) { + String hql = "update Information set deleteFlag = 1 where Id=?"; + result = bulkUpdateInLoop(hql, arrStr); + } +// andIn(condition, "id", idLst); +// +// Update update = Update.update("deleteFlag", true); +// update.set("updateTime", LocalDateTime.now()); +// template.updateMulti(Query.query(condition), update, ArticleDO.class); +// + return result; +// + } + + @Override + public Result update(UpdateArticleVO vo) { +// + Information articleDO = read(Information.class, vo.getId()); +// + if (StringUtils.equals(articleDO.getStatus(), Information.UP_STATUS)) { + return new Result(true, "涓嶈兘瀵瑰彂甯冪姸鎬佺殑鏂囩珷杩涜淇敼锛�"); + } +// + BeanUtils.copyProperties(vo, articleDO); +// + if (StringUtils.isNotBlank(vo.getAttachment())) { +// try { +// List<Map<String, String>> attachment = objectMapper.readValue(vo.getAttachment(), List.class); + articleDO.setAttachment(vo.getAttachment()); +// } catch (IOException e) { +// log.error("鏂囩珷闄勪欢json杞崲鍑洪敊锛宩son content : {}", vo.getAttachment()); +// } + } + + if (StringUtils.isNotBlank(vo.getVideoUrl())) { + String videoUrl=""; +// try { +// List<Map<String, String>> attachment = objectMapper.readValue(vo.getVideoUrl(), List.class); +// for (Map<String, String> map : attachment) { +// videoUrl=map.get("videoUrl"); +// } + articleDO.setVideoUrl(vo.getVideoUrl()); +// } catch (IOException e) { +// log.error("鏂囩珷闄勪欢json杞崲鍑洪敊锛宩son content : {}", vo.getVideoUrl()); +// } + } +// +// TraceMongoUtils.setUpdateTrace(articleDO); + save(articleDO); + return Result.SUCCESS; + } +// + @Override + public Result getArticleById(String id) { + + Information articleDO = read(Information.class, id); + ArticleInfoDTO articleInfoDTO = new ArticleInfoDTO(); + BeanUtils.copyProperties(articleDO, articleInfoDTO); + return new Result(true, "articleInfoDTO",articleInfoDTO); +// + } + + @Override + public Result upById(String id) { + Information articleDO = read(Information.class, id); + + if (StringUtils.isNotBlank(articleDO.getTitle())) { + int count = findInformationCount("", articleDO.getTitle(),Information.UP_STATUS); + if (count > 0) { + return new Result(true, "璇ユ爣棰樻枃绔犲凡鍙戝竷锛岃鍕垮彂甯冪浉鍚岀殑鏍囬鏂囩珷锛�"); + } + } + articleDO.setStatus(Information.UP_STATUS); +// TraceMongoUtils.setUpdateTrace(articleDO); + save(articleDO); + return Result.SUCCESS; + } +// + @Override + public Result downById(String id) { + Result result = new Result(true); +// Criteria condition = condition(); + String[] arrStr = id.split(","); +// List<String> idLst = Arrays.asList(arrStr); +// andIn(condition, "id", idLst); +// Update update = Update.update("status", Information.DOWN_STATUS); +// update.set("updateTime", LocalDateTime.now()); +// template.updateMulti(Query.query(condition), update, ArticleDO.class); + String hql = "update Information set updateTime=now() ,status = 'down' where Id=?"; + result = bulkUpdateInLoop(hql, arrStr); + return result; + } +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/vo/ListArticleVO.java b/src/main/java/com/qxueyou/scc/portal/information/vo/ListArticleVO.java new file mode 100644 index 0000000..a1b2109 --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/vo/ListArticleVO.java @@ -0,0 +1,64 @@ +package com.qxueyou.scc.portal.information.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.constraints.NotNull; + +/** + * @author angy + * @created by 2021/3/1 + */ +@ApiModel("listArticleVO") +public class ListArticleVO { + + //椤电爜 + @NotNull(message = "椤电爜涓嶈兘涓虹┖锛�") + @ApiModelProperty(value = "椤电爜", name = "page", dataType = "integer", required = true) + private Integer page; + + //椤垫暟 + @NotNull(message = "椤垫暟涓嶈兘涓虹┖锛�") + @ApiModelProperty(value = "椤垫暟", name = "size", dataType = "integer", required = true) + private Integer size; + + //鍏抽敭瀛� + @ApiModelProperty(value = "鎼滅储鍏抽敭瀛�", name = "keyword", dataType = "string") + private String keyword; + + //绫诲瀷 + @ApiModelProperty(value = "宸ョ绫诲瀷", name = "type", dataType = "string") + private String type; + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/vo/SaveArticleVO.java b/src/main/java/com/qxueyou/scc/portal/information/vo/SaveArticleVO.java new file mode 100644 index 0000000..203e70d --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/vo/SaveArticleVO.java @@ -0,0 +1,152 @@ +package com.qxueyou.scc.portal.information.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.validator.constraints.NotBlank; + +//import javax.validation.constraints.NotBlank; + +/** + * @author angy + * @created by 2021/3/1 + */ +@ApiModel("淇濆瓨鏂囩珷VO") +public class SaveArticleVO { + + //鏂囩珷鏍囬 + @NotBlank(message = "鏂囩珷鏍囬涓嶈兘涓虹┖锛�") + @ApiModelProperty(name = "title", value = "鏂囩珷鏍囬", dataType = "string", required = true) + private String title; + + //鏂囩珷绫诲瀷 + @NotBlank(message = "鏂囩珷绫诲瀷") + @ApiModelProperty(name = "type", value = "鏂囩珷绫诲瀷", dataType = "string", required = true) + private String type; + + @ApiModelProperty(name = "dateTime", value = "鏃堕棿", dataType = "string") + private String dateTime; + + //缂╃暐鍥� + @ApiModelProperty(name = "thumbnailUrl", value = "缂╃暐鍥緐rl", dataType = "string") + private String thumbnailUrl; + + //鏂囩珷鍐呭 + @ApiModelProperty(name = "content", value = "鏂囩珷鍐呭", dataType = "string") + private String content; + + @ApiModelProperty(name = "attachment", value = "鏂囩珷闄勪欢", dataType = "string") + private String attachment; + + @ApiModelProperty(name = "subColumn", value ="瀛愭爮鐩�",dataType = "string") + private String subColumn; + + @ApiModelProperty(name = "numbers", value ="灞婃暟",dataType = "string") + private String numbers; + + @ApiModelProperty(name = "competition", value ="绔炶禌鏂囦欢",dataType = "string") + private String competition; + + @ApiModelProperty(name = "preliminaries", value ="鍒濊禌鎴愮哗",dataType = "string") + private String preliminaries; + + @ApiModelProperty(name = "finals", value ="鍐宠禌鎴愮哗",dataType = "string") + private String finals; + + private String videoUrl; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } + + public String getSubColumn() { + return subColumn; + } + + public void setSubColumn(String subColumn) { + this.subColumn = subColumn; + } + + public String getNumbers() { + return numbers; + } + + public void setNumbers(String numbers) { + this.numbers = numbers; + } + + public String getCompetition() { + return competition; + } + + public void setCompetition(String competition) { + this.competition = competition; + } + + public String getPreliminaries() { + return preliminaries; + } + + public void setPreliminaries(String preliminaries) { + this.preliminaries = preliminaries; + } + + public String getFinals() { + return finals; + } + + public void setFinals(String finals) { + this.finals = finals; + } + + public String getVideoUrl() { + return videoUrl; + } + + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } +} diff --git a/src/main/java/com/qxueyou/scc/portal/information/vo/UpdateArticleVO.java b/src/main/java/com/qxueyou/scc/portal/information/vo/UpdateArticleVO.java new file mode 100644 index 0000000..3687ebd --- /dev/null +++ b/src/main/java/com/qxueyou/scc/portal/information/vo/UpdateArticleVO.java @@ -0,0 +1,164 @@ +package com.qxueyou.scc.portal.information.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.hibernate.validator.constraints.NotBlank; + + +/** + * @author angy + * @created by 2021/3/1 + */ +@ApiModel("鏇存柊鏂囩珷VO") +public class UpdateArticleVO { + + @NotBlank(message = "鏂囩珷ID涓嶈兘涓虹┖锛�") + @ApiModelProperty(name = "id", value = "鏂囩珷Id", dataType = "string", required = true) + private String id; + + //鏂囩珷鏍囬 + @NotBlank(message = "鏂囩珷鏍囬涓嶈兘涓虹┖锛�") + @ApiModelProperty(name = "title", value = "鏂囩珷鏍囬", dataType = "string", required = true) + private String title; + + //鏂囩珷绫诲瀷 + @NotBlank(message = "鏂囩珷绫诲瀷") + @ApiModelProperty(name = "type", value = "鏂囩珷绫诲瀷", dataType = "string", required = true) + private String type; + + @ApiModelProperty(name = "dateTime", value = "鏃堕棿", dataType = "string") + private String dateTime; + + //缂╃暐鍥� + @ApiModelProperty(name = "thumbnailUrl", value = "缂╃暐鍥緐rl", dataType = "string") + private String thumbnailUrl; + + //鏂囩珷鍐呭 + @ApiModelProperty(name = "content", value = "鏂囩珷鍐呭", dataType = "string") + private String content; + + //鏂囩珷闄勪欢 + @ApiModelProperty(name = "attachment", value = "鏂囩珷闄勪欢", dataType = "string") + private String attachment; + + @ApiModelProperty(name = "subColumn", value ="瀛愭爮鐩�",dataType = "string") + private String subColumn; + + @ApiModelProperty(name = "numbers", value ="灞婃暟",dataType = "string") + private String numbers; + + @ApiModelProperty(name = "competition", value ="绔炶禌鏂囦欢",dataType = "string") + private String competition; + + @ApiModelProperty(name = "preliminaries", value ="鍒濊禌鎴愮哗",dataType = "string") + private String preliminaries; + + @ApiModelProperty(name = "finals", value ="鍐宠禌鎴愮哗",dataType = "string") + private String finals; + + private String videoUrl; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } + + public String getThumbnailUrl() { + return thumbnailUrl; + } + + public void setThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAttachment() { + return attachment; + } + + public void setAttachment(String attachment) { + this.attachment = attachment; + } + + public String getSubColumn() { + return subColumn; + } + + public void setSubColumn(String subColumn) { + this.subColumn = subColumn; + } + + public String getNumbers() { + return numbers; + } + + public void setNumbers(String numbers) { + this.numbers = numbers; + } + + public String getCompetition() { + return competition; + } + + public void setCompetition(String competition) { + this.competition = competition; + } + + public String getPreliminaries() { + return preliminaries; + } + + public void setPreliminaries(String preliminaries) { + this.preliminaries = preliminaries; + } + + public String getFinals() { + return finals; + } + + public void setFinals(String finals) { + this.finals = finals; + } + + public String getVideoUrl() { + return videoUrl; + } + + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } +} -- Gitblit v1.8.0