xiaoyunquan пре 2 година
родитељ
комит
65386b8c85

+ 11 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/video/BaseVideoEndpoint.java

@ -8,7 +8,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
@ -17,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
 * @slogan 他化自在,我自逍遥
 */
@RestController
@RequestMapping(value = "/video/manager",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/video/manager")
@Api(value = "视频栏目管理接口", description = "视频栏目管理接口", tags = {"wlyy基础服务 - 视频栏目管理接口"})
public class BaseVideoEndpoint extends EnvelopRestEndpoint {
@ -117,7 +116,17 @@ public class BaseVideoEndpoint extends EnvelopRestEndpoint {
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @ApiOperation("删除视频")
    @RequestMapping(value = "/deleteVideo",method = RequestMethod.POST)
    public Envelop deleteVideo(@ApiParam(name = "id",value = "视频id")@RequestParam String id){
        try {
            return videoGroupService.deleteVideo(id);
        }catch (Exception e){
            return failedException2(e);
        }
    }
}

+ 13 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/video/BaseVideoGroupService.java

@ -108,7 +108,7 @@ public class BaseVideoGroupService extends BaseJpaService<BaseVideoGroupDO, Base
        if(StringUtils.isNotBlank(title)){
            fromSql += " and v.title like '%"+title+"%' ";
        }
        if(type != null){
        if(type != null && type > 0){
            fromSql += " and v.type = "+type;
        }
        Long count = jdbcTemplate.queryForObject(countSql + fromSql, Long.class);
@ -149,4 +149,16 @@ public class BaseVideoGroupService extends BaseJpaService<BaseVideoGroupDO, Base
        return Envelop.getSuccess("保存成功");
    }
    /**
     * 删除视频
     * @param id
     * @return
     */
    public Envelop deleteVideo(String id){
        BaseVideoDO video = videoDao.findOne(id);
        if(video != null){
            videoDao.delete(video);
        }
        return Envelop.getSuccess("删除成功");
    }
}

+ 27 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/video/PatientVideoEndpoint.java

@ -1,8 +1,10 @@
package com.yihu.jw.care.endpoint.video;
import com.yihu.jw.care.dao.video.BaseVideoDao;
import com.yihu.jw.care.service.video.BaseVideoService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,6 +29,8 @@ public class PatientVideoEndpoint extends EnvelopRestEndpoint {
    private BaseVideoDao baseVideoDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseVideoService baseVideoService;
    @RequestMapping(value = "findVideoNum", method = RequestMethod.GET)
    @ApiOperation(value = "按类型获取视频列表")
@ -61,4 +65,27 @@ public class PatientVideoEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping("/getVideoGroup")
    @ApiOperation(value = "获取视频栏目")
    public ListEnvelop getVideoGroup(){
        try {
            return baseVideoService.getVideoGroup();
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping("/getVideoPageByGroup")
    @ApiOperation(value = "获取视频列表")
    public PageEnvelop getVideoPageByGroup(@ApiParam(name = "groupId",value = "栏目id")@RequestParam(required = false,defaultValue = "0") Integer groupId,
                                           @ApiParam @RequestParam(required = false,defaultValue = "1")Integer page,
                                           @ApiParam @RequestParam(required = false,defaultValue = "20")Integer pageSize){
        try {
            return baseVideoService.getVideoPageByGroup(groupId, page, pageSize);
        }catch (Exception e){
            return failedPageEnvelopException(e);
        }
    }
}

+ 60 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/video/BaseVideoService.java

@ -0,0 +1,60 @@
package com.yihu.jw.care.service.video;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * @author xyq
 * @create 2022-07-05 9:57
 * @slogan 他化自在,我自逍遥
 */
@Service
public class BaseVideoService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取视频栏目列表
     * @return
     */
    public ListEnvelop getVideoGroup(){
        String sql = "SELECT id,name,sort_num sortNum,CAST(status as UNSIGNED) status," +
                " CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) createTime " +
                " from base_video_group " +
                " where status = 1 order by sort_num ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return ListEnvelop.getSuccess("查询成功",list);
    }
    /**
     * 分页获取视频列表
     * @param groupId
     * @param page
     * @param pageSize
     * @return
     */
    public PageEnvelop getVideoPageByGroup(Integer groupId,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(v.id) ";
        String sql = " from base_video v " +
                " left join base_video_group g on v.type = g.id " +
                " where v.status = 1 ";
        if(groupId > 0){
            sql += " and v.type = "+groupId+" ";
        }
        Long count = jdbcTemplate.queryForObject(countSql + sql, Long.class);
        sql += " order by v.sort_num limit "+page*pageSize+","+pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(colSql + sql);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
}