package com.fs.his.service.impl;

import com.fs.common.core.domain.R;
import com.fs.his.mapper.FsDoctorCommonDrugMapper;
import com.fs.his.param.FsDoctorCommonDrug;
import com.fs.his.service.IFsDoctorCommonDrugService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FsDoctorCommonDrugServiceImpl implements IFsDoctorCommonDrugService {

    @Autowired
    private FsDoctorCommonDrugMapper mapper;

    @Override
    public PageInfo<FsDoctorCommonDrug> getList(FsDoctorCommonDrug param, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<FsDoctorCommonDrug> fsDoctorCommonDrugs = mapper.selectList(param);
        return new PageInfo<>(fsDoctorCommonDrugs);
    }

    @Override
    public R add(FsDoctorCommonDrug drug) {
        mapper.insert(drug);
        return R.ok("新增成功");
    }

    @Override
    public R edit(FsDoctorCommonDrug drug) {
        mapper.updateById(drug);
        return R.ok("修改成功");
    }

    @Override
    public R delete(Long commonDrugId) {
        mapper.deleteById(commonDrugId);
        return R.ok("删除成功");
    }
}