package com.wb.permission.domain;

import com.wb.permission.pojo.WbDept;
import com.wb.util.SysUtil;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
* Description:部门权限
* Author: wangll
* Version: 1.0
* Create Date: 2020-03-05 23:43:10
*/
@Service
public class WbDeptBO {
    @Autowired
    SqlSessionTemplate sqlSessionTemplate;

    /**
     * Description: 查询部门信息
     * @param wbDept
     * @return
     * Note: Nothing much.
     */
//    public List<WbDept> listWbDept(WbDept wbDept){
//        return sqlSessionTemplate.selectList("resources/permission.WbDeptMapper.selectWbDept",wbDept);
//    }

    /**
    * Description: 新增和修改
    * @param wbDept
    * @return
    * Note: Nothing much.
    */
    public void save(WbDept wbDept){
        if (StringUtils.isEmpty(wbDept.getDeptId())) {
            wbDept.setDeptId(SysUtil.getId());
            sqlSessionTemplate.insert("resources/permission.WbDeptMapper.insertSelective",wbDept);
        }else{
            sqlSessionTemplate.update("resources/permission.WbDeptMapper.updateByPrimaryKeySelective",wbDept);
        }
    }

    /**
    * Description: 新增
    * @param wbDept
    * @return
    * Note: Nothing much.
    */
    public void insert(WbDept wbDept){
       sqlSessionTemplate.insert("resources/permission.WbDeptMapper.insertSelective",wbDept);
    }

    /**
    * Description: 修改
    * @param wbDept
    * @return
    * Note: Nothing much.
    */
    public void update(WbDept wbDept){
       sqlSessionTemplate.update("resources/permission.WbDeptMapper.updateByPrimaryKeySelective",wbDept);
    }

    /**
    * Description: 删除
    * @param deptId
    * @return
    * Note: Nothing much.
    */
    public void delete(String deptId){
       sqlSessionTemplate.delete("resources/permission.WbDeptMapper.deleteByPrimaryKey",deptId);
    }

    /**
     * Description: 删除
     * @param deptIds
     * @return
     * Note: Nothing much.
     */
    public void delWbDeptByDeptIds(String deptIds){
        sqlSessionTemplate.delete("resources/permission.WbDeptMapper.delWbDeptByDeptIds",deptIds);
    }

}