package com.fs.app.controller.store;


import com.fs.app.controller.AppBaseController;
import com.fs.common.core.domain.R;
import com.fs.hisStore.param.*;
import com.fs.hisStore.service.IFsDoctorArticleScrmService;
import com.fs.hisStore.vo.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api("医生文章接口")
@RestController
@RequestMapping(value="/store/app/doctorArticle")
public class DoctorArticleScrmController extends AppBaseController {


    @Autowired
    private IFsDoctorArticleScrmService articleService;



    @GetMapping("/getDoctorArticleList")
    public R getDoctorArticleList(FsDoctorArticleListUParam param)
    {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<FsDoctorArticleListUVO> list=articleService.selectFsDoctorArticleListUVO(param);
        PageInfo<FsDoctorArticleListUVO> listPageInfo=new PageInfo<>(list);
        return R.ok().put("data",listPageInfo);
    }


    @GetMapping("/getDoctorArticleById")
    public R getDoctorArticleById(@RequestParam("articleId")Long articleId)
    {
        //更新阅读数
        FsDoctorArticleUVO article=articleService.selectFsDoctorArticleUVOByArticleId(articleId);
        articleService.updateViews(article.getArticleId());
        return R.ok().put("data",article);
    }

}
