forked from github/dataease
fix: 移动端分页api
This commit is contained in:
parent
8ca71983e1
commit
a50c94fbd5
@ -7,7 +7,7 @@ import java.util.Map;
|
||||
public interface HomeMapper {
|
||||
|
||||
|
||||
List<HomeItemDTO> queryStore(Long userId);
|
||||
List<HomeItemDTO> queryStore(Map<String, Object> param);
|
||||
|
||||
List<HomeItemDTO> queryHistory();
|
||||
|
||||
|
@ -12,6 +12,9 @@
|
||||
on s.panel_group_id = g.id
|
||||
where s.user_id = #{userId}
|
||||
and FIND_IN_SET( g.id, cids )
|
||||
<if test="lastTime != null">
|
||||
and #{lastTime} > s.create_time
|
||||
</if>
|
||||
order by s.create_time desc
|
||||
</select>
|
||||
|
||||
@ -33,6 +36,9 @@
|
||||
</foreach>
|
||||
and s.type = 1 )
|
||||
)
|
||||
<if test="lastTime != null">
|
||||
and #{lastTime} > s.create_time
|
||||
</if>
|
||||
order by s.create_time desc
|
||||
</select>
|
||||
|
||||
|
@ -78,7 +78,7 @@ public abstract class TaskHandler implements InitializingBean {
|
||||
}
|
||||
|
||||
private String getDayOfWeek(Calendar instance) {
|
||||
int index = instance.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
int index = instance.get(Calendar.DAY_OF_WEEK);
|
||||
return week[index];
|
||||
}
|
||||
|
||||
|
@ -3,20 +3,16 @@ package io.dataease.mobile.api;
|
||||
|
||||
import io.dataease.mobile.dto.DirItemDTO;
|
||||
import io.dataease.mobile.dto.DirRequest;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "移动端:目录")
|
||||
@RequestMapping("/mobile/dir")
|
||||
public interface DirApi {
|
||||
|
||||
|
||||
@ApiOperation("查询")
|
||||
@PostMapping("/query")
|
||||
List<DirItemDTO> query(@RequestBody DirRequest request);
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package io.dataease.mobile.api;
|
||||
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.mobile.dto.HomeItemDTO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.dataease.mobile.dto.HomeRequest;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "移动端:首页")
|
||||
@RequestMapping("/mobile/home")
|
||||
public interface HomeApi {
|
||||
|
||||
@ApiOperation("查询")
|
||||
@ApiImplicitParam(value = "类型", name = "type", paramType = "path", allowableValues = "{@code 0(收藏), 1(历史), 2(分享)}")
|
||||
@PostMapping("/query/{type}")
|
||||
List<HomeItemDTO> query(@PathVariable Integer type);
|
||||
@PostMapping("/query")
|
||||
Pager<List<HomeItemDTO>> query(@RequestBody HomeRequest request);
|
||||
|
||||
|
||||
@ApiOperation("详情")
|
||||
@ApiImplicitParam(value = "ID", name = "id", paramType = "path")
|
||||
@PostMapping("/detail/{id}")
|
||||
Object detail(@PathVariable String id);
|
||||
|
||||
|
@ -1,18 +1,14 @@
|
||||
package io.dataease.mobile.api;
|
||||
|
||||
import io.dataease.mobile.dto.MeItemDTO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
|
||||
|
||||
@Api(tags = "移动端:我的")
|
||||
@RequestMapping("/mobile/me")
|
||||
public interface MeApi {
|
||||
|
||||
@ApiOperation("查询个人信息")
|
||||
@PostMapping("/query")
|
||||
MeItemDTO query();
|
||||
}
|
||||
|
@ -1,21 +1,14 @@
|
||||
package io.dataease.mobile.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("目录数据实体")
|
||||
public class DirItemDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
private String id;
|
||||
@ApiModelProperty("名称")
|
||||
private String text;
|
||||
@ApiModelProperty(value = "类型", allowableValues = "{@code folder, panel}")
|
||||
private String type;
|
||||
@ApiModelProperty("子集数")
|
||||
private Integer subs;
|
||||
}
|
||||
|
@ -7,13 +7,10 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("目录查询条件")
|
||||
public class DirRequest implements Serializable {
|
||||
|
||||
@ApiModelProperty("父ID")
|
||||
private String pid;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,13 @@
|
||||
package io.dataease.mobile.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("首页数据实体")
|
||||
public class HomeItemDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
private String id;
|
||||
@ApiModelProperty("标题")
|
||||
private String title;
|
||||
@ApiModelProperty("时间")
|
||||
private Long time;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package io.dataease.mobile.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class HomeRequest implements Serializable {
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Long lastTime;
|
||||
}
|
@ -1,16 +1,12 @@
|
||||
package io.dataease.mobile.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ApiModel("个人信息")
|
||||
public class MeItemDTO implements Serializable {
|
||||
@ApiModelProperty("组织名称")
|
||||
private String deptName;
|
||||
@ApiModelProperty("创建时间")
|
||||
private Long createTime;
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.dataease.mobile.server;
|
||||
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.mobile.api.HomeApi;
|
||||
import io.dataease.mobile.dto.HomeItemDTO;
|
||||
import io.dataease.mobile.dto.HomeRequest;
|
||||
import io.dataease.mobile.service.HomeService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
@ -13,13 +15,17 @@ public class HomeServer implements HomeApi {
|
||||
@Resource
|
||||
private HomeService homeService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<HomeItemDTO> query(Integer type) {
|
||||
return homeService.query(type);
|
||||
public Pager<List<HomeItemDTO>> query(HomeRequest request) {
|
||||
return homeService.query(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object detail(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
package io.dataease.mobile.service;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.dataease.auth.api.dto.CurrentRoleDto;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.mobile.dto.HomeItemDTO;
|
||||
import io.dataease.base.mapper.ext.HomeMapper;
|
||||
import io.dataease.mobile.dto.HomeRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
@ -18,23 +23,33 @@ public class HomeService {
|
||||
@Resource
|
||||
private HomeMapper homeMapper;
|
||||
|
||||
public List<HomeItemDTO> query(Integer type) {
|
||||
public Pager<List<HomeItemDTO>> query(HomeRequest request) {
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
switch (type){
|
||||
Page<Object> page = PageHelper.startPage(1, 13, true);
|
||||
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("userId", user.getUserId());
|
||||
switch (request.getType()){
|
||||
|
||||
|
||||
case 1:
|
||||
return homeMapper.queryHistory();
|
||||
case 2:
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
|
||||
Long deptId = user.getDeptId();
|
||||
List<Long> roleIds = user.getRoles().stream().map(CurrentRoleDto::getId).collect(Collectors.toList());
|
||||
param.put("userId", user.getUserId());
|
||||
|
||||
param.put("deptId", deptId);
|
||||
param.put("roleIds", roleIds);
|
||||
List<HomeItemDTO> result = homeMapper.queryShare(param);
|
||||
return result;
|
||||
if (null != request.getLastTime()) {
|
||||
param.put("lastTime", request.getLastTime());
|
||||
}
|
||||
|
||||
return PageUtils.setPageInfo(page, homeMapper.queryShare(param));
|
||||
default:
|
||||
return homeMapper.queryStore(user.getUserId());
|
||||
param.put("userId", user.getUserId());
|
||||
if (null != request.getLastTime()) {
|
||||
param.put("lastTime", request.getLastTime());
|
||||
}
|
||||
return PageUtils.setPageInfo(page, homeMapper.queryStore(param));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user