You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
182 lines
6.3 KiB
182 lines
6.3 KiB
|
2 weeks ago
|
package ${package.ServiceImpl};
|
||
|
|
|
||
|
|
import apelet.common.core.annotation.MyDataSource;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import apelet.common.core.base.service.BaseService;
|
||
|
|
import apelet.common.core.object.TokenData;
|
||
|
|
import cn.hutool.core.util.*
|
||
|
|
import ${package.Entity}.${entity};
|
||
|
|
import ${package.Mapper}.${table.mapperName};
|
||
|
|
<#if table.serviceInterface>
|
||
|
|
import ${package.Service}.${table.serviceName};
|
||
|
|
</#if>
|
||
|
|
import ${superServiceImplClassPackage};
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* <p>
|
||
|
|
* ${table.comment!} 服务实现类
|
||
|
|
* </p>
|
||
|
|
*
|
||
|
|
* @author ${author}
|
||
|
|
* @since ${date}
|
||
|
|
*/
|
||
|
|
@Service
|
||
|
|
@Slf4j
|
||
|
|
<#--<#if kotlin>-->
|
||
|
|
<#--open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>()<#if table.serviceInterface>, ${table.serviceName}-->
|
||
|
|
<#--</#if> {}-->
|
||
|
|
<#--<#else>-->
|
||
|
|
<#--public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}><#if table.serviceInterface> implements ${table.serviceName}-->
|
||
|
|
<#--</#if> {}-->
|
||
|
|
<#--</#if>-->
|
||
|
|
public class ${table.serviceImplName} extends BaseService<${entity}, Long> implements ${table.serviceName} {
|
||
|
|
@Autowired
|
||
|
|
private ${table.mapperName} ${table.mapperName};
|
||
|
|
|
||
|
|
@Override
|
||
|
|
protected BaseDaoMapper<${entity}> mapper() { return baseMapper; }
|
||
|
|
|
||
|
|
|
||
|
|
String path="C:\\导出路径后期模版修改";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 查询列表
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public List<${entity}> get${entity}ListWithRelation(${entity} filter, String buildOrderBy) {
|
||
|
|
LambdaQueryWrapper<${entity}> queryWrapper = new LambdaQueryWrapper<>(filter);
|
||
|
|
if (StrUtil.isNotBlank(buildOrderBy)) {
|
||
|
|
queryWrapper.last(" ORDER BY " + buildOrderBy);
|
||
|
|
}
|
||
|
|
List<${entity}> resultList = baseMapper.selectList(queryWrapper);
|
||
|
|
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||
|
|
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||
|
|
return resultList;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 新增
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean addAll(${entity} base) {
|
||
|
|
//设置主数据基本信息
|
||
|
|
addOrUpdateBaseData(base,null);
|
||
|
|
boolean save =this.save(base);
|
||
|
|
//如果有分录
|
||
|
|
<#-- Long id = base.getId();-->
|
||
|
|
<#-- if (null==id)return false;-->
|
||
|
|
<#-- //设置分录数据基本信息,添加-->
|
||
|
|
<#-- return addChild(base,id);-->
|
||
|
|
return save;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 修改
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean editAll(${entity} base) {
|
||
|
|
Long id = base.getId();
|
||
|
|
if (null==id)return false;
|
||
|
|
//设置主数据基本信息
|
||
|
|
boolean update =addOrUpdateBaseData(apeBase,null);
|
||
|
|
this.updateById(apeBase);
|
||
|
|
<#-- //删除分录数据-->
|
||
|
|
<#-- removeChild(id);-->
|
||
|
|
<#-- //设置分录数据基本信息,重新添加-->
|
||
|
|
<#-- return addChild(apeBase,id);-->
|
||
|
|
return update;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 删除
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public Boolean removeAllById(Long id) {
|
||
|
|
boolean remove = this.removeById(id);
|
||
|
|
//有分录情况删除
|
||
|
|
<#-- if (remove){-->
|
||
|
|
<#-- removeChild(id);-->
|
||
|
|
<#-- }-->
|
||
|
|
return remove;
|
||
|
|
}
|
||
|
|
@Override
|
||
|
|
public void exportExcel(JSONObject data, HttpServletResponse response){
|
||
|
|
JSONArray ids = data.getJSONArray("ids");
|
||
|
|
List<${entity}> dataList=new ArrayList<>();
|
||
|
|
if (ObjectUtil.isNotEmpty(ids)){
|
||
|
|
dataList.addAll(this.listByIds(ids.toJavaList(Long.class)));
|
||
|
|
}else {
|
||
|
|
dataList.addAll(this.list());
|
||
|
|
}
|
||
|
|
<#-- //如果有分录-->
|
||
|
|
<#-- for (${entity} base : dataList) {-->
|
||
|
|
<#-- base.setChild1(child1Mapper.selectList(new LambdaQueryWrapper<${entity}>().eq(ApeBaseChild1::getMaterId,apeBase.getId())));-->
|
||
|
|
<#-- base.setChild2(child2Mapper.selectList(new LambdaQueryWrapper<${entity}>().eq(ApeBaseChild2::getMaterId,apeBase.getId())));-->
|
||
|
|
<#-- base.setChild3(child3Mapper.selectList(new LambdaQueryWrapper<${entity}>().eq(ApeBaseChild3::getMaterId,apeBase.getId())));-->
|
||
|
|
<#-- }-->
|
||
|
|
ApeEasyPoiUtil.exportExcel(response,dataList,${entity}.class,path,"excel导出的名称","excel导出的sheet名称");
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 导入
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public void importExcel(HttpServletRequest request){
|
||
|
|
List<${entity}> list = ApeEasyPoiUtil.importExcel(request, ApeBase.class);
|
||
|
|
for (ApeBase apeBase : list) {
|
||
|
|
addAll(apeBase);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<#-- /**-->
|
||
|
|
<#-- * 如果有分录情况下且需要参数映射就需要这样命名方法-->
|
||
|
|
<#-- */-->
|
||
|
|
<#-- @Override-->
|
||
|
|
<#-- public List<child> getChild1WithRelation(Long id) {-->
|
||
|
|
<#-- return child1Service.getChild1WithRelation(id);-->
|
||
|
|
<#-- }-->
|
||
|
|
|
||
|
|
|
||
|
|
<#-- /**-->
|
||
|
|
<#-- * 如果有分录且需要条件-->
|
||
|
|
<#-- */-->
|
||
|
|
<#-- private Boolean addChild(ApeBase apeBase,Long id){-->
|
||
|
|
<#-- List<child> child = apeBase.getChild1();-->
|
||
|
|
<#-- if (ObjectUtil.isNotEmpty(child)){-->
|
||
|
|
<#-- for (child one : child) {-->
|
||
|
|
<#-- addOrUpdateBaseData(one,id);-->
|
||
|
|
<#-- childMapper.insert(one);-->
|
||
|
|
<#-- }-->
|
||
|
|
<#-- }-->
|
||
|
|
<#-- return true;-->
|
||
|
|
<#-- }-->
|
||
|
|
|
||
|
|
|
||
|
|
<#-- /**-->
|
||
|
|
<#-- * 有分录的情况下删除分录的方法-->
|
||
|
|
<#-- */-->
|
||
|
|
<#-- private void removeChild(Long id){-->
|
||
|
|
<#-- child1Service1.remove(new LambdaQueryWrapper<child>().eq(child::getMaterId,id));-->
|
||
|
|
<#-- }-->
|
||
|
|
/**
|
||
|
|
* 设置基本参数方法
|
||
|
|
*/
|
||
|
|
private <T> void addOrUpdateBaseData(T t,Long id){
|
||
|
|
if (t instanceof ${entity}){
|
||
|
|
${entity} data = (${entity}) t;
|
||
|
|
data.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||
|
|
data.setUpdateUserId(TokenData.takeFromRequest().getUserId());
|
||
|
|
data.setUpdateTime(new Date());
|
||
|
|
if (ObjectUtil.isEmpty(data.getCreateTime())){
|
||
|
|
data.setCreateUserId(TokenData.takeFromRequest().getUserId());
|
||
|
|
data.setCreateTime(new Date());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|