All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.jdbc.service-impl.hbs Maven / Gradle / Ivy

The newest version!
package {{config.packageName}}{{viewModifier}}.service.autogenerate.impl;

{{> [header-comment.java]}}
import com.bixuebihui.query.Paging;

import {{config.packageName}}{{viewModifier}}.business.{{pojoClassName}}Manager;
import {{config.packageName}}{{viewModifier}}.cmd.{{pojoClassName}}SearchCmd;
{{#unless tableInfo.isView}}
import {{config.packageName}}{{viewModifier}}.cmd.{{pojoClassName}}DelCmd;
{{/unless}}
import {{config.packageName}}{{viewModifier}}.converter.{{pojoClassName}}Converter;
import {{config.packageName}}{{viewModifier}}.dto.{{pojoClassName}}Dto;
import {{config.packageName}}{{viewModifier}}.pojo.{{pojoClassName}};
import {{config.packageName}}{{viewModifier}}.service.autogenerate.{{pojoClassName}}Service;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;

import javax.annotation.processing.Generated;
import java.util.List;

import static java.util.stream.Collectors.toList;

@Generated("com.github.yujiaao:tablegen")
@Service
public class {{className}} implements  {{pojoClassName}}Service{
    @Autowired
    {{pojoClassName}}Manager {{firstLow pojoClassName}}Manager;

    @Override
    public Pair> queryList(Paging<{{pojoClassName}}SearchCmd> searchCmd) {
        Pair>  infos = {{firstLow pojoClassName}}Manager.ar()
                    .query(searchCmd).findAllWithCount();

        List<{{pojoClassName}}Dto> collect = {{pojoClassName}}Converter.MAPPER.toDtoList(infos.getRight());

        return Pair.of(infos.getLeft().intValue(), collect);
    }
{{#unless tableInfo.isView}}
    @Override
    public Boolean del({{pojoClassName}}DelCmd delCmd) {
{{#eq keys.size 1}}
    {{#if hasLogicDelCol}}
        return {{firstLow pojoClassName}}Manager.logicDeleteByIds(delCmd.get{{firstUp firstKeyName}}s());
    {{~ else }}
        return {{firstLow pojoClassName}}Manager.deleteByKeys(delCmd.get{{firstUp firstKeyName}}s()
                .toArray(new {{{firstKeyType}}}[0]));
    {{/if}}
{{~ else }}
    return false;
{{/eq}}
    }

    @Override
    public {{pojoClassName}}Dto save({{pojoClassName}}Dto dto)
    {
        {{pojoClassName}} info = {{pojoClassName}}Converter.MAPPER.toDao(dto);
        {{firstLow pojoClassName}}Manager.save(info);
        return dto;
    }
{{/unless}}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy