package com.fs.app.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.domain.R;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.domain.FsDoctorProduct;
import com.fs.his.domain.FsDoctorWords;
import com.fs.his.param.FsDoctorArticleListUParam;
import com.fs.his.param.FsDoctorWordsListUParam;
import com.fs.his.service.IFsDoctorProductService;
import com.fs.his.service.IFsDoctorWordsService;
import com.fs.his.vo.FsDoctorArticleListUVO;
import com.fs.his.vo.FsDoctorWordsListUVO;
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.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("医生常用词接口")
@RestController
@RequestMapping("/app/doctorWords")
public class DoctorWordsController extends AppBaseController
{
    @Autowired
    private IFsDoctorWordsService doctorWordsService;

    @GetMapping("/getDoctorWordsList")
    public R getDoctorWordsList(FsDoctorWordsListUParam param)
    {
        param.setDoctorId(Long.parseLong(getDoctorId()));
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<FsDoctorWordsListUVO> list=doctorWordsService.selectFsDoctorWordsListUVO(param);
        PageInfo<FsDoctorWordsListUVO> listPageInfo=new PageInfo<>(list);
        return R.ok().put("data",listPageInfo);
    }


    @PostMapping("/addDoctorWords")
    public R addDoctorWords(@RequestBody FsDoctorWords param)
    {
        param.setDoctorId(Long.parseLong(getDoctorId()));
        if(doctorWordsService.insertFsDoctorWords(param)>0){
            return R.ok();
        }
        else{
            return R.error();
        }

    }
    @PostMapping("/delDoctorWords")
    public R delDoctorWords(@RequestBody FsDoctorWords param)
    {
        if(doctorWordsService.deleteFsDoctorWordsById(param.getId())>0){
            return R.ok();
        }
        else{
            return R.error();
        }
    }


}
