package thyyxxk.webserver.service.zhuyuanyisheng;

import org.springframework.stereotype.Service;
import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuPublicDao;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.service.PublicServer;
import thyyxxk.webserver.utils.ResultVoUtil;
import thyyxxk.webserver.utils.TokenUtil;

import java.util.List;

@Service
public class YiZhuPublicService {
    // 模板编辑
    public static final int MU_BAN_BIAN_JI_QUAN_XIAN = 43;
    // 科室主任编码
    public static final int KE_ZHU_REN_BIAN_MA = 11;

    private final YiZhuPublicDao dao;
    private final PublicServer publicServer;

    public YiZhuPublicService(YiZhuPublicDao dao, PublicServer publicServer) {
        this.dao = dao;
        this.publicServer = publicServer;
    }

    public ResultVo<List<CodeName>> getAllWards() {
        if (publicServer.needRule(2, 8, 52)) {
            return ResultVoUtil.success(dao.getAllWards());
        } else {
            return ResultVoUtil.success(dao.getDoctorWards(TokenUtil.getInstance().getTokenUserId()));
        }
    }
}
