-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from yanyanho/main
quer member with team info and add sponsor
- Loading branch information
Showing
26 changed files
with
251 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
@Getter | ||
public enum UserRoleEnum { | ||
|
||
ADMIN(Integer.MAX_VALUE), | ||
ADMIN(1), | ||
|
||
NORMAL(0); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/main/java/com/dl/officialsite/login/model/UserPrincipleData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 43 additions & 3 deletions
46
src/main/java/com/dl/officialsite/member/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,56 @@ | ||
package com.dl.officialsite.member; | ||
|
||
import com.dl.officialsite.team.Team; | ||
import com.dl.officialsite.team.TeamRepository; | ||
import com.dl.officialsite.team.teammember.TeamMember; | ||
import com.dl.officialsite.team.teammember.TeamMemberRepository; | ||
import com.dl.officialsite.team.vo.TeamVO; | ||
import org.springframework.beans.BeanUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Service | ||
public class MemberService { | ||
|
||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
@Autowired | ||
private TeamMemberRepository teamMemberRepository; | ||
@Autowired | ||
private TeamRepository teamRepository; | ||
|
||
public Member getMemberByAddress(String address) { | ||
Optional<Member> member = memberRepository.findByAddress(address); | ||
if(member.isPresent()) { | ||
return member.get(); | ||
} | ||
return null; | ||
} | ||
|
||
|
||
public MemberWithTeam getMemberWithTeamInfoByAddress(String address) { | ||
Optional<Member> member = memberRepository.findByAddress(address); | ||
|
||
if(member.isPresent()) { | ||
MemberWithTeam memberWithTeam = new MemberWithTeam(); | ||
BeanUtils.copyProperties(member, memberWithTeam); | ||
ArrayList teams = memberWithTeam.getTeams(); | ||
List<TeamMember> teamMembers = teamMemberRepository.findByMemberId(member.get().getId()); | ||
|
||
// public Member getMemberByAddress(String address) { | ||
// return memberRepository.findByAddress(address); | ||
// } | ||
teamMembers.stream().forEach(teamMember -> { | ||
Team team = teamRepository.findById(teamMember.getTeamId()).get(); | ||
if(team.getTeamName().equals("Dapp-Learning DAO co-founders")){ | ||
memberWithTeam.setAdmin(true); | ||
} | ||
teams.add(team); | ||
}); | ||
return memberWithTeam; | ||
} | ||
return null; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/dl/officialsite/member/MemberWithTeam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.dl.officialsite.member; | ||
|
||
|
||
import com.dl.officialsite.team.vo.TeamVO; | ||
import lombok.*; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.NotNull; | ||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
|
||
@Data | ||
public class MemberWithTeam extends Member | ||
{ | ||
|
||
private ArrayList<TeamVO> teams; | ||
|
||
private boolean isAdmin; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.dl.officialsite.sponsor; | ||
|
||
import lombok.Data; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import javax.persistence.*; | ||
|
||
/** | ||
* @ClassName SponsorVo | ||
* @Author jackchen | ||
* @Date 2023/12/11 21:16 | ||
* @Description 广告 | ||
**/ | ||
@Data | ||
@EntityListeners(AuditingEntityListener.class) | ||
@Entity | ||
@Table(name = "sponsor") | ||
public class Sponsor { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String company; | ||
|
||
private String link; | ||
|
||
private String icon; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/dl/officialsite/sponsor/SponsorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.dl.officialsite.sponsor; | ||
|
||
import com.dl.officialsite.common.base.BaseResponse; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @ClassName HireController | ||
* @Author jackchen | ||
* @Date 2023/11/7 10:45 | ||
* @Description HireController | ||
**/ | ||
@RestController | ||
@RequestMapping("/sponsors") | ||
public class SponsorController { | ||
|
||
@Autowired | ||
private SponsorService sponsorService; | ||
@Autowired | ||
private SponsorRepository sponsorRepository; | ||
|
||
@PostMapping | ||
public BaseResponse create(@RequestParam String address, @RequestBody Sponsor sponsor) { | ||
return BaseResponse.successWithData( sponsorService.add(address , sponsor)); | ||
|
||
} | ||
@GetMapping("/all") | ||
public BaseResponse all(@RequestParam String address) { | ||
List<Sponsor> sponsors = sponsorRepository.findAll(); | ||
return BaseResponse.successWithData(sponsors); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/dl/officialsite/sponsor/SponsorRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.dl.officialsite.sponsor; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
|
||
public interface SponsorRepository extends JpaRepository<Sponsor, Long>, JpaSpecificationExecutor <Sponsor>{ | ||
//Optional<Sponser> findByAddress(@Param("address") String address); | ||
} |
Oops, something went wrong.