package ${classPath};

import ${beanPath};
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* Description:
* Author: ${author}
* Version: ${version}
* Create Date: ${date}
*/
@Service
public class ${className} {
    @Autowired
    SqlSessionTemplate sqlSessionTemplate;

    /**
    * Description: 新增和修改
    * @param ${lowerBeanName}
    * @return
    * Note: Nothing much.
    */
    public void save(${upperBeanName} ${lowerBeanName}){
        if (StringUtils.isEmpty(${lowerBeanName})) {
            sqlSessionTemplate.insert("${sqlPath}.insertSelective",${lowerBeanName});
        }else{
            sqlSessionTemplate.update("${sqlPath}.updateByPrimaryKeySelective",${lowerBeanName});
        }
    }

    /**
    * Description: 新增
    * @param ${lowerBeanName}
    * @return
    * Note: Nothing much.
    */
    public void insert(${upperBeanName} ${lowerBeanName}){
       sqlSessionTemplate.insert("${sqlPath}.insertSelective",${lowerBeanName});
    }

    /**
    * Description: 修改
    * @param ${lowerBeanName}
    * @return
    * Note: Nothing much.
    */
    public void update(${upperBeanName} ${lowerBeanName}){
       sqlSessionTemplate.update("${sqlPath}.updateByPrimaryKeySelective",${lowerBeanName});
    }

    /**
    * Description: 删除
    * @param id
    * @return
    * Note: Nothing much.
    */
    public void delete(String id){
       sqlSessionTemplate.delete("${sqlPath}.deleteByPrimaryKey",id);
    }

}