serviceImpl.java.vm 1.54 KB
Newer Older
liqin's avatar
liqin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <pre>
 * $!{table.comment} 服务实现类
 * </pre>
 *
 * @author ${author}
 * @since ${date}
 */
@Slf4j
@Service
#if(${kotlin})
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
#else
liqin's avatar
liqin committed
28
public class ${table.serviceImplName} extends ServiceImpl<${table.mapperName}, ${entity}> implements ${table.serviceName} {
liqin's avatar
liqin committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

    @Autowired
    private ${table.mapperName} ${cfg.mapperObjectName};
#if(${cfg.generatorStrategy} != 'SIMPLE')
#if(${cfg.generatorStrategy} == 'ALL')

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean save${entity}(${entity} ${cfg.entityObjectName}) throws Exception {
        return super.save(${cfg.entityObjectName});
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean update${entity}(${entity} ${cfg.entityObjectName}) throws Exception {
        return super.updateById(${cfg.entityObjectName});
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean delete${entity}(Long id) throws Exception {
        return super.removeById(id);
    }
#end
#end

}
#end