新增分页对象,是doc文档返回对应的文档注释
This commit is contained in:
@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import co.yixiang.domain.PageResult;
|
||||||
/**
|
/**
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${date}
|
* @date ${date}
|
||||||
@ -51,7 +51,7 @@ public class ${className}Controller {
|
|||||||
@Log("查询${apiAlias}")
|
@Log("查询${apiAlias}")
|
||||||
@ApiOperation("查询${apiAlias}")
|
@ApiOperation("查询${apiAlias}")
|
||||||
@PreAuthorize("@el.check('admin','${changeClassName}:list')")
|
@PreAuthorize("@el.check('admin','${changeClassName}:list')")
|
||||||
public ResponseEntity<Object> get${className}s(${className}QueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<PageResult<${className}Dto>> get${className}s(${className}QueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ import java.io.IOException;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import co.yixiang.base.PageResult;
|
||||||
/**
|
/**
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${date}
|
* @date ${date}
|
||||||
@ -67,13 +67,10 @@ public class ${className}ServiceImpl extends BaseServiceImpl<${className}Mapper,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
//@Cacheable
|
//@Cacheable
|
||||||
public Map<String, Object> queryAll(${className}QueryCriteria criteria, Pageable pageable) {
|
public PageResult<${className}Dto> queryAll(${className}QueryCriteria criteria, Pageable pageable) {
|
||||||
getPage(pageable);
|
getPage(pageable);
|
||||||
PageInfo<${className}> page = new PageInfo<>(queryAll(criteria));
|
PageInfo<${className}> page = new PageInfo<>(queryAll(criteria));
|
||||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
return generator.convertPageInfo(page,${className}VO.class);
|
||||||
map.put("content", generator.convert(page.getList(), ${className}Dto.class));
|
|
||||||
map.put("totalElements", page.getTotal());
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Map;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import co.yixiang.base.PageResult;
|
||||||
/**
|
/**
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${date}
|
* @date ${date}
|
||||||
@ -29,7 +29,7 @@ public interface ${className}Service extends BaseService<${className}>{
|
|||||||
* @param pageable 分页参数
|
* @param pageable 分页参数
|
||||||
* @return Map<String,Object>
|
* @return Map<String,Object>
|
||||||
*/
|
*/
|
||||||
Map<String,Object> queryAll(${className}QueryCriteria criteria, Pageable pageable);
|
PageResult<${className}Dto> queryAll(${className}QueryCriteria criteria, Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有数据不分页
|
* 查询所有数据不分页
|
||||||
|
37
yshop-common/src/main/java/co/yixiang/domain/PageResult.java
Normal file
37
yshop-common/src/main/java/co/yixiang/domain/PageResult.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package co.yixiang.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author :LionCity
|
||||||
|
* @date :Created in 2020-08-04 16:55
|
||||||
|
* @description:分页参数返回
|
||||||
|
* @modified By:
|
||||||
|
* @version: V1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Builder
|
||||||
|
public class PageResult<T> implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("总数量")
|
||||||
|
private long totalElements;
|
||||||
|
|
||||||
|
@ApiModelProperty("内容")
|
||||||
|
private List<T> content;
|
||||||
|
|
||||||
|
public PageResult(long totalElements, List<T> content) {
|
||||||
|
this.totalElements = totalElements;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageResult() {
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,8 @@
|
|||||||
package co.yixiang.dozer.service;
|
package co.yixiang.dozer.service;
|
||||||
|
|
||||||
import co.yixiang.common.web.vo.Paging;
|
import co.yixiang.common.web.vo.Paging;
|
||||||
|
import co.yixiang.domain.PageResult;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.dozer.Mapper;
|
import org.dozer.Mapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
@ -65,4 +67,9 @@ public class EJBGenerator implements IGenerator {
|
|||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T, S> PageResult<T> convertPageInfo(PageInfo<S> s, Class<T> clz) {
|
||||||
|
return new PageResult(s.getTotal(), convert(s.getList(), clz));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
package co.yixiang.dozer.service;
|
package co.yixiang.dozer.service;
|
||||||
|
|
||||||
import co.yixiang.common.web.vo.Paging;
|
import co.yixiang.common.web.vo.Paging;
|
||||||
|
import co.yixiang.domain.PageResult;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -80,4 +82,10 @@ public interface IGenerator {
|
|||||||
* @Time 2018年5月9日 下午3:54:57
|
* @Time 2018年5月9日 下午3:54:57
|
||||||
*/
|
*/
|
||||||
<T, S> T[] convert(S[] s, Class<T> clz);
|
<T, S> T[] convert(S[] s, Class<T> clz);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页信息转换
|
||||||
|
* @return {@link PageResult<T>}
|
||||||
|
*/
|
||||||
|
<T, S> PageResult<T> convertPageInfo(PageInfo<S> s, Class<T> clz);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user