package com.bonus.boot.manager.health.service.Impl;

import com.bonus.boot.manager.basic.entity.PersonnelLibraryBean;
import com.bonus.boot.manager.health.dao.SpecialPositionsDao;
import com.bonus.boot.manager.health.entity.SpecialPositionsBean;
import com.bonus.boot.manager.health.service.SpecialPositionsService;
import com.bonus.boot.manager.manager.dao.UtilDao;
import com.bonus.boot.manager.manager.entity.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
/**
 * @author xliu
 * @Data 2023/6/2 9:30
 */
@Service("specialPositionsService")
public class SpecialPositionsServiceImpl implements SpecialPositionsService {

    @Resource
    private SpecialPositionsDao specialPositionsDao;

    @Resource
    private UtilDao utilDao;


    @Override
    public List<SpecialPositionsBean> getList(SpecialPositionsBean o) {
        return specialPositionsDao.getList(o);
    }

    @Override
    public R addSpecialPost(SpecialPositionsBean o) {
        int num = utilDao.determineIfExists("pm_base_special_job","job_name",o.getJobName(),"");
        if(num ==1){
            return  R.okTable("该岗位已存在！", 1);
        }else{
            int nums = specialPositionsDao.addSpecialPost(o);
            if(nums>0){
                return R.okTable("岗位添加成功！", 2);
            }else{
                return R.okTable("岗位添加失败！", 3);
            }
        }

    }

    @Override
    public R modifySpecialPost(SpecialPositionsBean o) {

        int num = utilDao.determineIfExists("pm_base_special_job","job_name",o.getJobName(),o.getId()+"");
        if(num ==1){
            return  R.okTable("该岗位已存在！", 1);
        }else{
            int nums = specialPositionsDao.modifySpecialPost(o);
            if(nums>0){
                return R.okTable("岗位添加成功！", 2);
            }else{
                return R.okTable("岗位添加失败！", 3);
            }
        }
    }

    @Override
    public int del(SpecialPositionsBean o) {
        return specialPositionsDao.del(o);
    }
}
