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