LAPTOP-KB9HII50\70708 3 rokov pred
rodič
commit
c7940f91d0

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

@ -0,0 +1,56 @@
package com.yihu.jw.entity.care.video;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by yeshijie on 2022/3/21.
 */
@Entity
@Table(name = "base_video")
public class BaseVideoDO extends UuidIdentityEntityWithCreateTime {
    private String type;//类型 1疾病防治 2健康生活 3慢病防治
    private String title;//标题
    private String url;//url
    private String img;//封面图片
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "title")
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    @Column(name = "url")
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @Column(name = "img")
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
}

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/video/BaseVideoDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.care.dao.video;
import com.yihu.jw.entity.care.video.BaseVideoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2022/3/21.
 */
public interface BaseVideoDao extends PagingAndSortingRepository<BaseVideoDO, String>, JpaSpecificationExecutor<BaseVideoDO> {
    @Query("select a from BaseVideoDO a where a.type = ?1")
    List<BaseVideoDO> findByType(String type) throws Exception;
}

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

@ -0,0 +1,64 @@
package com.yihu.jw.care.endpoint.video;
import com.yihu.jw.care.dao.video.BaseVideoDao;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
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.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2022/3/21.
 */
@RestController
@RequestMapping(value = "pateintVideo")
@Api(value = "居民视频", description = "居民视频", tags = {"居民视频"})
public class PatientVideoEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseVideoDao baseVideoDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @RequestMapping(value = "findVideoNum", method = RequestMethod.GET)
    @ApiOperation(value = "按类型获取视频列表")
    public ObjEnvelop findVideoNum() {
        try {
            String sql = "SELECT type,COUNT(*) num from base_video GROUP BY type";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            Map<String, Integer> map = new HashMap<>();
            //类型 1疾病防治 2健康生活 3慢病防治
            map.put("1",0);
            map.put("2",0);
            map.put("3",0);
            for (Map<String, Object> one:list){
                map.put(String.valueOf(one.get("type")), Integer.valueOf(String.valueOf(one.get("num"))));
            }
            return ObjEnvelop.getSuccess("获取成功",map);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @RequestMapping(value = "findVideo", method = RequestMethod.GET)
    @ApiOperation(value = "按类型获取视频列表")
    public ListEnvelop findVideo(@ApiParam(name = "type", value = "类型 1疾病防治 2健康生活 3慢病防治")
                                 @RequestParam(value = "type", required = true) String type) {
        try {
            return ListEnvelop.getSuccess("获取成功",baseVideoDao.findByType(type));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
    }
}