package ${package}.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils;
import ${package}.dao.I${className}Dao;
import ${package}.domain.${className};
import ${package}.service.I${className}Service;

/**
 * ${tableComment} 服务层实现
 * 
 * @author ${author}
 * @date ${datetime}
 */
@Service
public class ${className}ServiceImpl implements I${className}Service 
{
	@Autowired
	private I${className}Dao ${classname}Dao;
	
	/**
     * 查询${tableComment}信息
     * 
     * @param ${primaryKey.attrname} ${tableComment}ID
     * @return ${tableComment}信息
     */
	 @Override
	public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname})
	{
	    return ${classname}Dao.select${className}ById(${primaryKey.attrname});
	}
	
	/**
     * 查询${tableComment}列表
     * 
     * @param ${classname} ${tableComment}信息
     * @return ${tableComment}集合
     */
	 @Override
	public List<${className}> select${className}List(${className} ${classname})
	{
	    return ${classname}Dao.select${className}List(${classname});
	}
	
    /**
     * 新增${tableComment}
     * 
     * @param ${classname} ${tableComment}信息
     * @return 结果
     */
	 @Override
	public int insert${className}(${className} ${classname})
	{
	    return ${classname}Dao.insert${className}(${classname});
	}
	
	/**
     * 修改${tableComment}
     * 
     * @param ${classname} ${tableComment}信息
     * @return 结果
     */
	 @Override
	public int update${className}(${className} ${classname})
	{
	    return ${classname}Dao.update${className}(${classname});
	}
	
	/**
     * 保存${tableComment}
     * 
     * @param ${classname} ${tableComment}信息
     * @return 结果
     */
	 @Override
	public int save${className}(${className} ${classname})
	{
	    ${primaryKey.attrType} ${primaryKey.attrname} = ${classname}.get${primaryKey.attrName}();
		int rows = 0;
		if (StringUtils.isNotNull(${primaryKey.attrname}))
        {
		    rows = ${classname}Dao.update${className}(${classname});
		}
		else
        {
		    rows = ${classname}Dao.insert${className}(${classname});
		}
		return rows;
	}
	
	/**
     * 删除${tableComment}信息
     * 
     * @param ${primaryKey.attrname} ${tableComment}ID
     * @return 结果
     */
	 @Override
	public int delete${className}ById(${primaryKey.attrType} ${primaryKey.attrname})
	{
	    return ${classname}Dao.delete${className}ById(${primaryKey.attrname});
	}
	
	/**
     * 批量删除${tableComment}对象
     * 
     * @param ${primaryKey.attrname}s 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDelete${className}(${primaryKey.attrType}[] ${primaryKey.attrname}s)
	{
		return ${classname}Dao.batchDelete${className}(${primaryKey.attrname}s);
	}
	
}
