Skip to content

Commit

Permalink
Merge pull request #96 from yanyanho/main
Browse files Browse the repository at this point in the history
refactor the share interface
  • Loading branch information
yanyanho authored Dec 15, 2023
2 parents 9a0bf96 + 8310e8a commit 5a75e67
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/main/java/com/dl/officialsite/sharing/SharingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("share/usershare")
@RequestMapping("/share")
@Slf4j
public class SharingController {

Expand Down Expand Up @@ -66,18 +66,18 @@ public BaseResponse loadSharing(@RequestParam(value = "pageNo",defaultValue = "1
* @param shareId
* @return
*/
@GetMapping("queryByShareId")
@GetMapping("query")
public BaseResponse<Share> querySharing(@RequestParam("shareId") long shareId){
return BaseResponse.successWithData(this.sharingService.querySharing(shareId));
}

/**
* 查看用户的分享
*/
@GetMapping("byUser")
public BaseResponse loadSharingByUser(@RequestParam("memberId") long memberId,
@GetMapping("user")
public BaseResponse loadSharingByUser(@RequestParam("memberAddress") String memberAddress,
@RequestParam(value = "pageNo",defaultValue = "1") int pageNo,
@RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
return BaseResponse.successWithData(this.sharingService.loadSharingByUser(memberId, pageNo, pageSize));
return BaseResponse.successWithData(this.sharingService.loadSharingByUser(memberAddress, pageNo, pageSize));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public interface SharingRepository extends JpaRepository<Share, Long>, JpaSpecif
@Query(value = "select count(*) from share", nativeQuery = true)
int loadAllCount();

@Query(value = "select * from share where member_id = :memberId limit :offset, :limit", nativeQuery = true)
List<Share> findAllSharesByUidPaged(@Param("memberId") long memberId, @Param("offset") int offset, @Param("limit") int limit);
@Query(value = "select * from share where member_address = :memberAddress limit :offset, :limit", nativeQuery = true)
List<Share> findAllSharesByUidPaged(@Param("memberAddress") String memberAddress, @Param("offset") int offset, @Param("limit") int limit);

@Query(value = "select count(*) from share where member_id = :memberId", nativeQuery = true)
int loadCountByUid(@Param("memberId") long memberId);
@Query(value = "select count(*) from share where member_address = :memberAddress", nativeQuery = true)
int loadCountByUid(@Param("memberAddress") String memberAddress);


}
6 changes: 3 additions & 3 deletions src/main/java/com/dl/officialsite/sharing/SharingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public Share querySharing(long shareId) {
}


public PagedList loadSharingByUser(long memberId, int pageNo, int pageSize) {
public PagedList loadSharingByUser(String memberAddress, int pageNo, int pageSize) {
int offset = (pageNo - 1)*pageSize;
int totalCount = this.sharingRepository.loadCountByUid(memberId);
int totalCount = this.sharingRepository.loadCountByUid(memberAddress);
int totalPages =(totalCount + pageSize - 1) / pageSize;
List<Share> items = this.sharingRepository.findAllSharesByUidPaged(memberId, offset, pageSize);
List<Share> items = this.sharingRepository.findAllSharesByUidPaged(memberAddress, offset, pageSize);

// SharingByUserResp resp = new SharingByUserResp();
PagedList resp = new PagedList(items ,new Pagination(totalCount, totalPages, pageNo, items.size(), pageNo < totalPages));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.dl.officialsite.sharing.reward;

import com.dl.officialsite.sharing.model.req.InitSharingRewardsReq;
import com.dl.officialsite.sharing.model.resp.ClaimSharingRewardResp;
import com.dl.officialsite.sharing.model.resp.PreCheckSharingRewardResp;
import com.dl.officialsite.sharing.model.resp.PrepareSharingRewardsResp;
import com.dl.officialsite.sharing.reward.IRewardService;
import org.springframework.stereotype.Service;

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.dl.officialsite.sharing.reward;

import com.dl.officialsite.sharing.model.req.InitSharingRewardsReq;
import com.dl.officialsite.sharing.model.resp.ClaimSharingRewardResp;
import com.dl.officialsite.sharing.model.resp.PreCheckSharingRewardResp;
import com.dl.officialsite.sharing.model.resp.PrepareSharingRewardsResp;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.dl.officialsite.sharing.reward;

public class InitSharingRewardsReq {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dl.officialsite.sharing.model.req;
package com.dl.officialsite.sharing.reward;

import lombok.Data;

Expand Down

0 comments on commit 5a75e67

Please sign in to comment.