<%
    var tableAlias = util.getTableAlias(table.name);
%>
package ${daoPath};

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ${package.Mapper}.${table.mapperName};
import ${entityPath}.dto.${table.entityName}SelectDto;
import ${package.Entity}.${entity};
import ${entityPath}.table.${entity}Table;
import ${entityPath}.vo.${table.entityName}Vo;
import com.jy.framework.model.base.BaseDao;
import com.jy.system.service.AuthService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

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

<% } %>
@Service
public class ${table.entityName}Dao extends BaseDao<${table.entityName}Mapper, ${table.entityName}> {

    @Resource
    private AuthService authService;

<% if(isNotEmpty(controllerMethods.list)){  %>
    /**
     * ${table.comment!}列表
     */
    public List<${table.entityName}Vo> getList(${table.entityName}SelectDto dto) {
        ${entity}Table ${tableAlias} = ${entity}Table.${tableAlias};

        return sql(${table.entityName}Vo.class)
                .select(
                        ${tableAlias}.all
                )
                .from(${tableAlias})
                .where(
                        ${tableAlias}.createUser.in(authService.getUserPermissionSet())
                )
                .orderBy(
                    ${tableAlias}.id.desc()
                )
                .list();
    }

<% } %>
<% if(isNotEmpty(controllerMethods.page)){  %>
    /**
     * ${table.comment!}分页
     */
    public Page<${table.entityName}Vo> getPage(${table.entityName}SelectDto dto) {
        ${entity}Table ${tableAlias} = ${entity}Table.${tableAlias};

        return sql(${table.entityName}Vo.class)
                .select(
                        ${tableAlias}.all
                )
                .from(${tableAlias})
                .where(
                        ${tableAlias}.createUser.in(authService.getUserPermissionSet())
                )
                .orderBy(
                        ${tableAlias}.id.desc()
                )
                .page(dto.getPage());
    }

<% } %>
<% if(isNotEmpty(controllerMethods.detail)){ %>
    /**
     * ${table.comment!}明细
     */
    public ${table.entityName}Vo getDetail(Long id) {
        ${entity}Table ${tableAlias} = ${entity}Table.${tableAlias};

        return sql(${table.entityName}Vo.class)
                .select(
                        ${tableAlias}.all
                )
                .from(${tableAlias})
                .where(
                        ${tableAlias}.id.eq(id)
                )
                .one();
    }

<% } %>
}
