Commit eb546eac authored by chenyan's avatar chenyan

2024/05/09_API文档后台管理开发

parent c7837787
......@@ -2,12 +2,16 @@ package com.upyuns.platform.rs.website.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.upyuns.platform.rs.website.dto.TModelTypeDTO;
import com.upyuns.platform.rs.website.entity.ApiCustomNode;
import com.upyuns.platform.rs.website.entity.TModel;
import com.upyuns.platform.rs.website.entity.TModelType;
import com.upyuns.platform.rs.website.mapper.TModelMapper;
......@@ -15,6 +19,7 @@ import com.upyuns.platform.rs.website.mapper.TModelTypeMapper;
import com.upyuns.platform.rs.website.vo.TModelTypeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List;
......@@ -25,7 +30,9 @@ public class TModelTypeBiz extends BaseBiz<TModelTypeMapper, TModelType> {
public List<TModelTypeVo> getAll() {
List<TModelTypeVo> vos = new ArrayList<>();
List<TModelType> tModelTypes = mapper.selectAll();
Example exampleModel = new Example(TModelType.class);
exampleModel.createCriteria().andEqualTo("isDel", 0);
List<TModelType> tModelTypes = mapper.selectByExample(exampleModel);
for (TModelType tModelType : tModelTypes) {
TModelTypeVo vo = new TModelTypeVo();
BeanUtils.copyProperties(tModelType, vo);
......@@ -70,9 +77,36 @@ public class TModelTypeBiz extends BaseBiz<TModelTypeMapper, TModelType> {
return ObjectRestResponse.succ();
}
public PageDataVO<TModelType> getList(TModelTypeDTO tModelTypeDTO) {
public PageInfo<?> getList(TModelTypeDTO tModelTypeDTO) {
Query query = new Query(tModelTypeDTO);
PageDataVO<TModelType> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.selectList(query.getSuper()));
return pageDataVO;
List<TModelTypeVo> vos = new ArrayList<>();
List<TModelType> tModelTypes = mapper.selectList(query.getSuper());
for (TModelType tModelType : tModelTypes) {
TModelTypeVo vo = new TModelTypeVo();
BeanUtils.copyProperties(tModelType, vo);
vos.add(vo);
}
List<TModelTypeVo> result = new ArrayList<>();
for (TModelTypeVo vo : vos) {
if (vo.getPid().equals(0)) {
result.add(findChildren(vo, vos));
}
}
Page<TModelTypeVo> page = new Page(tModelTypeDTO.getPage(), tModelTypeDTO.getLimit());
int total = result.size();
page.setTotal(total);
int startIndex = (tModelTypeDTO.getPage() - 1) * tModelTypeDTO.getLimit();
int endIndex = Math.min(startIndex + tModelTypeDTO.getLimit(),total);
if(startIndex>endIndex){
page.addAll(new ArrayList());
PageInfo<TModelTypeVo> pageInfo = new PageInfo<>(page);
return pageInfo;
}else{
page.addAll(result.subList(startIndex,endIndex));
PageInfo<TModelTypeVo> pageInfo = new PageInfo<>(page);
return pageInfo;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment