package com.fs.app.controller;


import com.fs.app.annotation.Login;
import com.fs.common.core.domain.R;
import com.fs.common.utils.ServletUtils;
import com.fs.his.domain.*;
import com.fs.his.param.*;
import com.fs.his.service.*;
import com.fs.his.vo.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Synchronized;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


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


    @Autowired
    private IFsDoctorArticleService articleService;
    @Autowired
    private IFsDoctorArticleCateService articleCateService;

    @ApiOperation("获取文章分类列表")
    @Cacheable(value = "getDoctorArticleCateList" )
    @GetMapping("/getDoctorArticleCateList")
    public R getArticleCateList(){
        FsDoctorArticleCate map=new FsDoctorArticleCate();
        map.setIsDel(0);
        List<FsDoctorArticleCate> list=articleCateService.selectFsDoctorArticleCateList(map);
        return R.ok().put("data",list);
    }
    @GetMapping("/getDoctorArticleList")
    @Cacheable(value = "getDoctorArticleList", key = "#param")
    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")
    @Cacheable(value = "getDoctorArticleById", key = "#articleId")
    public R getDoctorArticleById(@RequestParam("articleId")Long articleId)
    {
        //更新阅读数
        FsDoctorArticleUVO article=articleService.selectFsDoctorArticleUVOByArticleId(articleId);
        articleService.updateViews(article.getArticleId());
        return R.ok().put("data",article);
    }

}
