<%
    var tableAlias = util.getTableAlias(table.name);
%>
<%
    var entityInstanceName = util.lowerFirst(table.entityName);
%>
package ${package.ServiceImpl};

<% if(isNotEmpty(controllerMethods.page)){  %>
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
<% } %>
<% if(isNotEmpty(controllerMethods.detail)){ %>
import utils.com.jy.framework.AssertUtil;
<% } %>
import ${daoPath}.${table.entityName}Dao;
<% if(isNotEmpty(controllerMethods.create) || isNotEmpty(controllerMethods.update)){ %>
import ${entityPath}.dto.${table.entityName}Dto;
<% } %>
<% if(isNotEmpty(controllerMethods.page) || isNotEmpty(controllerMethods.list)){  %>
import ${entityPath}.dto.${table.entityName}SelectDto;
<% } %>
<% if(isNotEmpty(controllerMethods.page) || isNotEmpty(controllerMethods.list)){  %>
import ${entityPath}.vo.${table.entityName}Vo;
<% } %>
<% if(table.serviceInterface){ %>
import ${package.Service}.${table.serviceName};
<% } %>
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
<% if(isNotEmpty(controllerMethods.delete)){  %>
import org.springframework.transaction.annotation.Transactional;
<% } %>

<% if(isNotEmpty(controllerMethods.list) || isNotEmpty(controllerMethods.delete)){  %>
import java.util.List;

<% } %>
/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
public class ${table.serviceImplName} implements ${table.serviceName} {

    @Resource
    private ${table.entityName}Dao ${entityInstanceName}Dao;

    <% if(isNotEmpty(controllerMethods.list)){  %>
    @Override
    public List<${table.entityName}Vo> getList(${table.entityName}SelectDto dto) {
        return ${entityInstanceName}Dao.getList(dto);
    }

    <% } %>
    <% if(isNotEmpty(controllerMethods.page)){  %>
    @Override
    public Page<${table.entityName}Vo> getPage(${table.entityName}SelectDto dto) {
        return ${entityInstanceName}Dao.getPage(dto);
    }

    <% } %>
    <% if(isNotEmpty(controllerMethods.detail)){ %>
    @Override
    public ${table.entityName}Vo getDetail(Long id) {
        ${table.entityName}Vo vo = ${entityInstanceName}Dao.getDetail(id);
        AssertUtil.notNull(vo, "未知数据");
        return vo;
    }

    <% } %>
    <% if(isNotEmpty(controllerMethods.create)){ %>
    @Override
    public void add(${table.entityName}Dto dto) {
        ${entityInstanceName}Dao.save(dto);
    }

    <% } %>
    <% if(isNotEmpty(controllerMethods.update)){ %>
    @Override
    public void edit(${table.entityName}Dto dto) {
        ${entityInstanceName}Dao.updateById(dto);
    }

    <% } %>
    <% if(isNotEmpty(controllerMethods.delete)){ %>
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(List<Long> idList) {
        ${entityInstanceName}Dao.removeBatchByIds(idList);
    }

    <% } %>
}
