Skip to content

Commit

Permalink
Merge pull request #69 from Dapp-Learning-DAO/feature/aaron_sharing
Browse files Browse the repository at this point in the history
merge Feature/aaron sharing
  • Loading branch information
liberhe authored Dec 7, 2023
2 parents 7c236cc + 0c6835a commit 4697463
Show file tree
Hide file tree
Showing 28 changed files with 727 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public static <T> BaseResponse successWithData(T data){
return br;
}

public static BaseResponse success(){
BaseResponse br = new BaseResponse<>();
br.setCode(CodeEnums.SUCCESSFUL.getCode());
br.setMsg(CodeEnums.SUCCESSFUL.getMsg());
br.setData(null);
return br;
}

public static <T> BaseResponse failWithReason(String code, String msg){
return new BaseResponse(code, msg, null);
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/dl/officialsite/common/base/PagedList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.dl.officialsite.common.base;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class PagedList<T>{

private List<T> data;

private Pagination pagination;
}
7 changes: 7 additions & 0 deletions src/main/java/com/dl/officialsite/common/base/Pagination.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.dl.officialsite.common.base;

import lombok.Data;

@Data
public class Pagination {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.dl.officialsite.sharing.controller;

import com.dl.officialsite.common.base.BaseResponse;
import com.dl.officialsite.sharing.model.req.CreateSessionRoomReq;
import com.dl.officialsite.sharing.model.req.GenerateSharingDataReq;
import com.dl.officialsite.sharing.model.resp.CreateMeetingRoomResp;
import com.dl.officialsite.sharing.model.resp.GenerateSharingDataResp;
import com.dl.officialsite.sharing.model.resp.QueryMeetingResp;
import com.dl.officialsite.sharing.service.ISharingManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("share/v1/management")
@Slf4j
public class SharingManagementController {

@Autowired
private ISharingManagementService service;

/**
* 分享锁定之后,修改人就不能修改。这功能是避免做好海报之后,分享人又改内容,导致海报同分享不一致场景
*/
@PostMapping("lock")
public BaseResponse lockSharing(long shareId){
this.service.lockSharing(shareId);
return BaseResponse.success();
}

/**
* 解锁。特别情况下,分享人临时改内容。
* @param shareId
*/
@PostMapping("unlock")
public BaseResponse unlockSharing(long shareId){
this.service.unlockSharing(shareId);
return BaseResponse.success();
}


/**
* 创建session room
* @param req
* @return
*/
@PostMapping("meeting/creation")
public BaseResponse<CreateMeetingRoomResp> createSessionRoom(CreateSessionRoomReq req){
CreateMeetingRoomResp resp = this.service.createSessionRoom(req);
return BaseResponse.successWithData(resp);
}

@PostMapping("meeting/query")
public BaseResponse<QueryMeetingResp> createSessionRoom(long shareId){
QueryMeetingResp resp = this.service.queryMeeting(shareId);
return BaseResponse.successWithData(resp);
}


/**
* 生成分享海报、文案
* @param req
* @return
*/
@PostMapping("view")
public BaseResponse<GenerateSharingDataResp> viewSharingData(GenerateSharingDataReq req){
GenerateSharingDataResp resp = this.service.viewSharingData(req);
return BaseResponse.successWithData(resp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.dl.officialsite.sharing.controller;

import com.dl.officialsite.common.base.BaseResponse;
import com.dl.officialsite.sharing.model.resp.ClaimSharingRewardResp;
import com.dl.officialsite.sharing.model.resp.PreCheckSharingRewardResp;
import com.dl.officialsite.sharing.service.IRewardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("share/v1/reward")
@Slf4j
public class SharingRewardController {

@Autowired
private IRewardService rewardService;
/**
* 预先查看分享奖励信息供分享人确认
* @param sharingId
* @return
*/
@GetMapping("precheck")
public BaseResponse<PreCheckSharingRewardResp> preCheckSharingReward(long sharingId){
return BaseResponse.successWithData(this.rewardService.preCheckSharingReward(sharingId));
}

/**
* 领取奖励
* @param sharingId
* @return
*/
@GetMapping("claim")
public BaseResponse<ClaimSharingRewardResp> claimSharingReward(long sharingId){
return BaseResponse.successWithData(this.rewardService.claimSharingReward(sharingId));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.dl.officialsite.sharing.controller;

import com.dl.officialsite.common.base.BaseResponse;
import com.dl.officialsite.sharing.model.pojo.SharingPojo;
import com.dl.officialsite.sharing.model.req.CreateSharingReq;
import com.dl.officialsite.sharing.model.req.UpdateSharingReq;
import com.dl.officialsite.sharing.model.resp.AllSharingResp;
import com.dl.officialsite.sharing.model.resp.ClaimSharingRewardResp;
import com.dl.officialsite.sharing.model.resp.PreCheckSharingRewardResp;
import com.dl.officialsite.sharing.model.resp.SharingByUserResp;
import com.dl.officialsite.sharing.service.IUserSharingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

@Autowired
private IUserSharingService userSharingService;

//————————————————————————————————————分享人相关功能————————————————————————————————————
/**
* 创建分享
* @param req
* @return
*/
@PostMapping("create")
public BaseResponse<Long> createSharing(CreateSharingReq req){
return BaseResponse.successWithData(this.userSharingService.createSharing(req));
}

/**
* 修改分享
*/
@PostMapping("update")
public BaseResponse updateSharing(UpdateSharingReq req){
this.userSharingService.updateSharing(req);
return BaseResponse.success();
}

/**
* 删除分享
*/
@PostMapping("delete")
public BaseResponse deleteSharing(long shareId){
this.userSharingService.deleteSharing(shareId);
return BaseResponse.success();
}

//————————————————————————————————————网站读者相关功能————————————————————————————————————
/**
* 查看全部分享
* @return
*/
public BaseResponse<AllSharingResp> loadSharing(int pageNo, int pageSize){
return BaseResponse.successWithData(this.userSharingService.loadSharing(pageNo, pageSize));
}

/**
* 查看分享内容
* @param shareId
* @return
*/
public BaseResponse<SharingPojo> querySharing(long shareId){
return BaseResponse.successWithData(this.userSharingService.querySharing(shareId));
}

/**
* 查看用户的分享
* @param uid
* @return
*/
public BaseResponse<SharingByUserResp> loadSharingByUser(long uid) {
return BaseResponse.successWithData(this.userSharingService.loadSharingByUser(uid));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.dl.officialsite.sharing.dao;

import com.dl.officialsite.sharing.model.db.SharingEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ISharingRepository extends JpaRepository<SharingEntity, Long> {

@Query(value = "select member_id from team_member where team_id = :team_id", nativeQuery = true)
List<Long> findByTeamId(@Param("team_id")Long teamId);

@Query(value = "select member_id from team_member where team_id = :team_id and status = :status",
nativeQuery =
true)
List<Long> findByTeamIdStatus(@Param("team_id")Long teamId, @Param("status")int status);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.dl.officialsite.sharing.model.db;

import lombok.Data;

import javax.persistence.*;

@Data
@Entity
@Table(name = "tb_share")
public class SharingEntity {

/**
* 分享Id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;

/**
* 分享主题
*/
private String theme;

/**
* 分享日期
*/
private String date;

/**
* 分享时间(UTC+8)
*/
private String time;

/**
* 分享语言
*/
private int language; // 0 Chinese 1 English

/**
* 分享人匿称
*/
private String presenter;

/**
* 分享所属组织
*/
private String Org;

/**
* 分享人twitter
*/
private String twitter;

/**
* 分享人
*/
private String memberId;

/**
* 文档连接
*/
private String sharingDoc;

/**
* 标签类别
*/
//defi zk underlying
private String label;

/**
* 奖励金额
*/
private Integer reward;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.dl.officialsite.sharing;
package com.dl.officialsite.sharing.model.pojo;

import com.dl.officialsite.member.Member;

public class Sharing {
public class SharingPojo {

private Long id;
private String theme;
Expand All @@ -26,12 +24,4 @@ public class Sharing {
private Integer reward;










}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.dl.officialsite.sharing.model.req;

import lombok.Data;

@Data
public class ClaimSharingRewardReq {

private long shareId;



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.dl.officialsite.sharing.model.req;

public class CreateSessionRoomReq {
}
Loading

0 comments on commit 4697463

Please sign in to comment.