xiaoyunquan 2 سال پیش
والد
کامیت
573b7c600f

+ 11 - 1
common/common-entity/sql记录

@ -1876,4 +1876,14 @@ CREATE TABLE `base`.`base_video_group`  (
  `status` tinyint(1) NULL COMMENT '1启用,0禁用',
  `create_time` timestamp NULL COMMENT '创建时间',
  PRIMARY KEY (`id`)
) COMMENT = '视频栏目表';
) COMMENT = '视频栏目表';
INSERT INTO `base`.`base_video_group` (`name`, `sort_num`, `status`, `create_time`) VALUES ('疾病防治', 1, 1, '2022-07-04 17:06:58');
INSERT INTO `base`.`base_video_group` (`name`, `sort_num`, `status`, `create_time`) VALUES ('健康生活', 1, 1, '2022-07-04 16:31:06');
INSERT INTO `base`.`base_video_group` (`name`, `sort_num`, `status`, `create_time`) VALUES ('慢病健康', 1, 1, '2022-07-04 16:31:16');
-- 2022-07-04 xyq 视频表新增字段
ALTER TABLE `base`.`base_video`
ADD COLUMN `introduction` varchar(500) NULL COMMENT '简介' AFTER `create_time`,
ADD COLUMN `sort_num` int(10) NULL DEFAULT 0 COMMENT '排序' AFTER `introduction`,
ADD COLUMN `status` tinyint(1) NULL DEFAULT 1 COMMENT '1可用,0禁用' AFTER `sort_num`;

+ 31 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/video/BaseVideoDO.java

@ -18,6 +18,10 @@ public class BaseVideoDO extends UuidIdentityEntityWithCreateTime {
    private String url;//url
    private String img;//封面图片
    private String introduction;//简介
    private Integer sortNum;//排序
    private Integer status;//1可用,0禁用
    @Column(name = "type")
    public String getType() {
        return type;
@ -53,4 +57,31 @@ public class BaseVideoDO extends UuidIdentityEntityWithCreateTime {
    public void setImg(String img) {
        this.img = img;
    }
    @Column(name = "introduction")
    public String getIntroduction() {
        return introduction;
    }
    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }
    @Column(name = "sort_num")
    public Integer getSortNum() {
        return sortNum;
    }
    public void setSortNum(Integer sortNum) {
        this.sortNum = sortNum;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 49 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/video/BaseVideoEndpoint.java

@ -71,4 +71,53 @@ public class BaseVideoEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("分页获取视频列表")
    @GetMapping("/getVideoPage")
    public PageEnvelop getVideoPage(@ApiParam(name = "title",value = "视频标题")@RequestParam(required = false) String title,
                                    @ApiParam(name = "type",value = "栏目id")@RequestParam(required = false)Integer type,
                                    @ApiParam(name = "page",value = "页码") @RequestParam(required = false,defaultValue = "1")Integer page,
                                    @ApiParam(name = "pageSize",value = "每页大小") @RequestParam(required = false,defaultValue = "20")Integer pageSize){
        try {
            return videoGroupService.getVideoPage(title, type, page, pageSize);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @ApiOperation("修改视频")
    @PostMapping("/updateVideo")
    public Envelop updateVideo(@ApiParam @RequestParam String id,
                               @ApiParam(name = "type",value = "栏目id")@RequestParam Integer type,
                               @ApiParam(name = "title",value = "视频标题")@RequestParam String title,
                               @ApiParam(name = "url",value = "视频播放地址")@RequestParam String url,
                               @ApiParam(name = "img",value = "封面图片")@RequestParam(required = false) String img,
                               @ApiParam(name = "introduction",value = "简介")@RequestParam(required = false)String introduction,
                               @ApiParam(name = "sortNum",value = "排序")@RequestParam(required = false,defaultValue = "1")Integer sortNum,
                               @ApiParam(name = "status",value = "1可用,0禁用")@RequestParam(required = false,defaultValue = "1")Integer status){
        try {
            return videoGroupService.updateVideo(id, type, title, url, img, introduction, sortNum, status);
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @ApiOperation("新增视频")
    @PostMapping("/addVideo")
    public Envelop addVideo(@ApiParam(name = "type",value = "栏目id")@RequestParam Integer type,
                               @ApiParam(name = "title",value = "视频标题")@RequestParam String title,
                               @ApiParam(name = "url",value = "视频播放地址")@RequestParam String url,
                               @ApiParam(name = "img",value = "封面图片")@RequestParam(required = false) String img,
                               @ApiParam(name = "introduction",value = "简介")@RequestParam(required = false)String introduction,
                               @ApiParam(name = "sortNum",value = "排序")@RequestParam(required = false,defaultValue = "1")Integer sortNum,
                               @ApiParam(name = "status",value = "1可用,0禁用")@RequestParam(required = false,defaultValue = "1")Integer status){
        try {
            return videoGroupService.updateVideo(null, type, title, url, img, introduction, sortNum, status);
        }catch (Exception e){
            return failedException2(e);
        }
    }
}

+ 59 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/video/BaseVideoGroupService.java

@ -2,6 +2,7 @@ package com.yihu.jw.base.service.video;
import com.yihu.jw.base.dao.video.BaseVideoDao;
import com.yihu.jw.base.dao.video.BaseVideoGroupDao;
import com.yihu.jw.entity.care.video.BaseVideoDO;
import com.yihu.jw.entity.care.video.BaseVideoGroupDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -90,4 +91,62 @@ public class BaseVideoGroupService extends BaseJpaService<BaseVideoGroupDO, Base
    }
    /**
     * 分页获取视频列表
     * @param title
     * @param type
     * @param page
     * @param pageSize
     * @return
     */
    public PageEnvelop getVideoPage(String title,Integer type,Integer page,Integer pageSize){
        page = page>0?page-1:0;
        String colSql = "SELECT v.id,v.type,v.title,v.url,v.img,CAST(DATE_FORMAT(v.create_time,'%Y-%m-%d %H:%i:%S') as char) createTime, " +
                " v.introduction,v.sort_num sortNum,CAST(v.status as UNSIGNED) status,g.name ";
        String countSql = "SELECT count(*) ";
        String fromSql = " from base_video v left join base_video_group g on v.type = g.id where v.status = 1 ";
        if(StringUtils.isNotBlank(title)){
            fromSql += " and v.title like '%"+title+"%' ";
        }
        if(type != null){
            fromSql += " and v.type = "+type;
        }
        Long count = jdbcTemplate.queryForObject(countSql + fromSql, Long.class);
        fromSql += " order by v.sort_num limit "+page*pageSize+","+pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(colSql + fromSql);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
    /**
     * 修改视频信息
     * @param id
     * @param type
     * @param title
     * @param url
     * @param img
     * @param introduction
     * @param sortNum
     * @param status
     * @return
     */
    public Envelop updateVideo(String id,Integer type,String title,String url,String img,String introduction,Integer sortNum,Integer status){
        if(StringUtils.isBlank(title) || type == null || StringUtils.isBlank(url)){
            return Envelop.getError("必填参数不能为空");
        }
        BaseVideoDO videoDO = new BaseVideoDO();
        if(StringUtils.isNotBlank(id)){
            videoDO.setId(id);
        }
        videoDO.setTitle(title);
        videoDO.setType(type.toString());
        videoDO.setUrl(url);
        videoDO.setImg(img);
        videoDO.setIntroduction(introduction);
        videoDO.setSortNum(sortNum);
        videoDO.setStatus(status);
        videoDO.setCreateTime(new Date());
        videoDao.save(videoDO);
        return Envelop.getSuccess("保存成功");
    }
}