Skip to content

Commit

Permalink
Merge pull request #72 from Dapp-Learning-DAO/feature/arc_share
Browse files Browse the repository at this point in the history
feat(share)
  • Loading branch information
yanyanho committed Dec 9, 2023
2 parents c7d8f4a + 71240d1 commit 08184ee
Show file tree
Hide file tree
Showing 41 changed files with 549 additions and 221 deletions.
29 changes: 29 additions & 0 deletions src/main/java/com/dl/officialsite/common/base/Pagination.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
package com.dl.officialsite.common.base;

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

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Pagination {

/**
* 总数据条目
*/
private int totalCount;

/**
* 总共页数
*/
private int totalPages;

/**
* 当前页码
*/
private int currentPage;

/**
* 当前页面包含条目数
*/
private int currentPageSize;

/**
* 是否还有下一页
*/
private boolean hasNext;
}
10 changes: 9 additions & 1 deletion src/main/java/com/dl/officialsite/common/enums/CodeEnums.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ public enum CodeEnums {
TEAM_ADMIN_NOT_EXIST("1006", "team admin not exist"),
MEMBER_ALREADY_REQUEST_TEAM("1007", "member already request team"),

NOT_FOUND_JD("1008", "not found jd");
NOT_FOUND_JD("1008", "not found jd"),
//Sharing
SHARING_NOT_FOUND("5001", "Sharing not found"),
SHARING_NOT_OWNER("5002", "You are no sharing user"),

SHARING_LOCKED("5003", "Sharing locked, please contact admin to unlock");




private String code;

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

import com.dl.officialsite.common.enums.CodeEnums;
import lombok.Data;
import lombok.EqualsAndHashCode;

Expand All @@ -17,6 +18,12 @@ public class BizException extends RuntimeException{

private String msg;

public BizException(CodeEnums codeEnums){
super(codeEnums.getMsg());
this.code = codeEnums.getCode();
this.msg = codeEnums.getMsg();
}

public BizException(String code, String msg) {
super(msg);
this.code = code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static SessionUserInfo getMember(HttpSession session){
return (SessionUserInfo)sessionObj;
}


public static void requireLogin(HttpSession session) {
SessionUserInfo sessionUserInfo = getMember(session);
if (!isUserLogin(session)) {
Expand All @@ -56,4 +57,6 @@ public static void clearLogin(HttpSession session) {

session.removeAttribute(MEMBER_ATTRIBUTE_KEY);
}


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

import lombok.Getter;

@Getter
public enum SharingLanguageEnum {

CHINESE(0),

ENGLISH(1),

FRENCH(2),

JAPANESE(3);

private int code;

SharingLanguageEnum(int code){
this.code = code;
}

public static SharingLanguageEnum codeOf(int languageCode) {
for(SharingLanguageEnum language: SharingLanguageEnum.values()){
if(language.code == languageCode){
return language;
}
}
throw new IllegalArgumentException("languageCode "+languageCode);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.dl.officialsite.sharing.constant;

import lombok.Getter;

@Getter
public enum SharingLockStatus {

UNLOCKED(0),

LOCKED(1);

private int code;

SharingLockStatus(int code){
this.code = code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.dl.officialsite.sharing.constant;

import lombok.Getter;

@Getter
public enum SharingMeetingType {

TENCENT(0),

GOOGLE(1),

ZOOM(2),

TELEGRAM(3),

DC(4);

private int code;

SharingMeetingType(int code){
this.code = code;
}

public static SharingMeetingType codeOf(int meetingType) {
for(SharingMeetingType m: SharingMeetingType.values()){
if(m.code == meetingType){
return m;
}
}
throw new IllegalArgumentException("meetingType "+meetingType);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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.vo.SharingVo;
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.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;

@RestController
Expand Down Expand Up @@ -55,7 +54,8 @@ public BaseResponse deleteSharing(long shareId){
* 查看全部分享
* @return
*/
public BaseResponse<AllSharingResp> loadSharing(int pageNo, int pageSize){
@GetMapping("all")
public BaseResponse<AllSharingResp> loadSharing(@Param("pageNo") int pageNo, @Param("pageSize") int pageSize){
return BaseResponse.successWithData(this.userSharingService.loadSharing(pageNo, pageSize));
}

Expand All @@ -64,16 +64,16 @@ public BaseResponse<AllSharingResp> loadSharing(int pageNo, int pageSize){
* @param shareId
* @return
*/
public BaseResponse<SharingPojo> querySharing(long shareId){
@GetMapping("{shareId}")
public BaseResponse<SharingVo> querySharing(@PathVariable("shareId") 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));
@GetMapping("{memberId}")
public BaseResponse<SharingByUserResp> loadSharingByUser(@PathVariable("memberId") long memberId, @Param("pageNo") int pageNo, @Param("pageSize") int pageSize) {
return BaseResponse.successWithData(this.userSharingService.loadSharingByUser(memberId, pageNo, pageSize));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.dl.officialsite.sharing.dao;

import com.dl.officialsite.sharing.model.db.TbShare;
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<TbShare, Long> {

@Query(value = "select * from tb_share limit :offset, :limit", nativeQuery = true)
List<TbShare> findAllSharesPaged(@Param("offset") int offset, @Param("limit") int limit);

@Query(value = "select count(*) from tb_share", nativeQuery = true)
int loadAllCount();

@Query(value = "select * from tb_share where member_id = :memberId limit :offset, :limit", nativeQuery = true)
List<TbShare> findAllSharesByUidPaged(@Param("memberId") long memberId, @Param("offset") int offset, @Param("limit") int limit);

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


}
84 changes: 84 additions & 0 deletions src/main/java/com/dl/officialsite/sharing/model/db/TbShare.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.dl.officialsite.sharing.model.db;

import lombok.Data;

import javax.persistence.*;

@Data
@Entity
@Table(name = "tb_share",
uniqueConstraints={@UniqueConstraint(columnNames={"theme"})},
indexes= {
@Index(columnList="member_id")
})
public class TbShare {

/**
* 分享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;

/**
* 分享人
*/
@Column(name = "member_id")
private long memberId;

/**
* 文档连接
*/
@Column(name = "sharing_doc")
private String sharingDoc;

/**
* 标签类别
*/
private String label;

/**
* 锁定状态
*/
@Column(name = "lock_status")
private int lockStatus;

private int meetingType;

private String meetingLink;
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
package com.dl.officialsite.sharing.model.db;
package com.dl.officialsite.sharing.model.req;

import lombok.Data;

import javax.persistence.*;

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

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

/**
* 分享主题
*/
Expand Down Expand Up @@ -51,24 +44,14 @@ public class SharingEntity {
*/
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
@@ -0,0 +1,8 @@
package com.dl.officialsite.sharing.model.resp;

import com.dl.officialsite.common.base.PagedList;
import com.dl.officialsite.sharing.model.vo.SharingVo;

public class AllSharingResp extends PagedList<SharingVo> {

}
Loading

0 comments on commit 08184ee

Please sign in to comment.