templates.v4.servicersv4.ftl Maven / Gradle / Ivy
package ${packageName}.service.rs;
import ${groupId}.api.service.RsRepositoryServiceV4;
import ${packageName}.model.${className};
import jakarta.inject.Singleton;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.List;
<#if rsPathIsAppConstant>
import static ${packageName}.management.AppConstants.${rsPath};
#if>
@Path(${rsPath})
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Singleton
public class ${className}ServiceRs extends RsRepositoryServiceV4<${className}, ${idFieldType}> {
public ${className}ServiceRs() {
super(${className}.class);
}
@Override
protected ${idFieldType} getId(${className} object) {
// field with @id
return object.${idFieldName};
}
@Override
protected String getDefaultOrderBy() {
<#if defaultSort??>
return "${defaultSort}";
<#else>
return "not_set";
#if>
}
@Override
public Predicate[] query(CriteriaBuilder criteriaBuilder, Root<${className}> root) throws Exception {
var predicates = new ArrayList();
return predicates.toArray(new Predicate[]{});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy