diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/HomeMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/HomeMapper.java new file mode 100644 index 0000000000..027f620c69 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/ext/HomeMapper.java @@ -0,0 +1,15 @@ +package io.dataease.base.mapper.ext; + +import io.dataease.mobile.dto.HomeItemDTO; +import java.util.List; +import java.util.Map; + +public interface HomeMapper { + + + List queryStore(Long userId); + + List queryHistory(); + + List queryShare(Map param); +} diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/HomeMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/HomeMapper.xml new file mode 100644 index 0000000000..fff3b708d4 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/ext/HomeMapper.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + diff --git a/backend/src/main/java/io/dataease/mobile/api/HomeApi.java b/backend/src/main/java/io/dataease/mobile/api/HomeApi.java new file mode 100644 index 0000000000..f92acb8dc5 --- /dev/null +++ b/backend/src/main/java/io/dataease/mobile/api/HomeApi.java @@ -0,0 +1,26 @@ +package io.dataease.mobile.api; + +import io.dataease.mobile.dto.HomeItemDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +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 query(@PathVariable Integer type); + + @ApiOperation("详情") + @ApiImplicitParam(value = "ID", name = "id", paramType = "path") + @PostMapping("/detail/{id}") + Object detail(@PathVariable String id); + +} diff --git a/backend/src/main/java/io/dataease/mobile/dto/HomeItemDTO.java b/backend/src/main/java/io/dataease/mobile/dto/HomeItemDTO.java new file mode 100644 index 0000000000..18e9085683 --- /dev/null +++ b/backend/src/main/java/io/dataease/mobile/dto/HomeItemDTO.java @@ -0,0 +1,18 @@ +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; +} diff --git a/backend/src/main/java/io/dataease/mobile/server/HomeServer.java b/backend/src/main/java/io/dataease/mobile/server/HomeServer.java new file mode 100644 index 0000000000..3c923935cd --- /dev/null +++ b/backend/src/main/java/io/dataease/mobile/server/HomeServer.java @@ -0,0 +1,25 @@ +package io.dataease.mobile.server; + +import io.dataease.mobile.api.HomeApi; +import io.dataease.mobile.dto.HomeItemDTO; +import io.dataease.mobile.service.HomeService; +import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import java.util.List; + +@RestController +public class HomeServer implements HomeApi { + + @Resource + private HomeService homeService; + + @Override + public List query(Integer type) { + return homeService.query(type); + } + + @Override + public Object detail(String id) { + return null; + } +} diff --git a/backend/src/main/java/io/dataease/mobile/service/HomeService.java b/backend/src/main/java/io/dataease/mobile/service/HomeService.java new file mode 100644 index 0000000000..dbc7782ddb --- /dev/null +++ b/backend/src/main/java/io/dataease/mobile/service/HomeService.java @@ -0,0 +1,44 @@ +package io.dataease.mobile.service; + +import io.dataease.auth.api.dto.CurrentRoleDto; +import io.dataease.auth.api.dto.CurrentUserDto; +import io.dataease.commons.utils.AuthUtils; +import io.dataease.mobile.dto.HomeItemDTO; +import io.dataease.base.mapper.ext.HomeMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +public class HomeService { + + @Resource + private HomeMapper homeMapper; + + public List query(Integer type) { + List result = new ArrayList<>(); + CurrentUserDto user = AuthUtils.getUser(); + switch (type){ + case 0: + result = homeMapper.queryStore(user.getUserId()); + break; + case 1: + result = homeMapper.queryHistory(); + break; + case 2: + Map param = new HashMap<>(); + Long deptId = user.getDeptId(); + List roleIds = user.getRoles().stream().map(CurrentRoleDto::getId).collect(Collectors.toList()); + param.put("userId", user.getUserId()); + param.put("deptId", deptId); + param.put("roleIds", roleIds); + result = homeMapper.queryShare(param); + break; + } + return result; + } +}