Skip to content

Commit

Permalink
Merge pull request #212 from cheng521521/main
Browse files Browse the repository at this point in the history
feat: not filter defi api
  • Loading branch information
yanyanho authored Mar 20, 2024
2 parents e9d7e1f + 9b7712e commit b3ba6dc
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Constant {
public static final TokenConfig SCROLL_USDT =TokenConfig.builder().name("USDT").address("0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df").build();
public static final TokenConfig SCROLL_WETH =TokenConfig.builder().name("WETH").address("0x5300000000000000000000000000000000000004").build();
// public static final TokenConfig SCROLL_WBTC =TokenConfig.builder().name("WBTC").address("123").build();
public static final List<TokenConfig> SCROLL_TOKEN_LIST =Arrays.asList(SCROLL_USDC,SCROLL_USDT,SCROLL_WETH);
public static final List<TokenConfig> SCROLL_TOKEN_LIST =Arrays.asList(SCROLL_USDC,SCROLL_WETH);


public static final TokenConfig ARB_DAI =TokenConfig.builder().name("DAI").address("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1").build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.web3j.crypto.Credentials;
Expand Down Expand Up @@ -131,6 +132,7 @@ public List<ChainInfo> queryChainList() {
}

@Scheduled(cron = "${jobs.defi.corn: 0 30 * * * * ?}")
@ConditionalOnProperty(name = "scheduler.enabled", havingValue = "true", matchIfMissing = true)
public void updateTokenAPYInfo() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
log.info("update token info task begin --------------------- ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
Expand All @@ -35,24 +49,17 @@
import org.apache.http.util.EntityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.*;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.transaction.Transactional;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Slf4j(topic = "Distribute")
@Configuration
Expand Down Expand Up @@ -93,6 +100,7 @@ public class DistributeService {
private ConstantConfig constantConfig;

@Scheduled(cron = "${jobs.distribute.corn:0/10 * * * * ?}")
@ConditionalOnProperty(name = "scheduler.enabled", havingValue = "true", matchIfMissing = true)
public void updateDistributeStatus() {
log.info("schedule task begin --------------------- ");
for (String chainId : chainConfig.getIds()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.dl.officialsite.hiring.application;

import com.dl.officialsite.common.base.BaseResponse;
import com.dl.officialsite.common.enums.CodeEnums;
import com.dl.officialsite.common.exception.BizException;
import com.dl.officialsite.hiring.HireService;
import com.dl.officialsite.hiring.vo.ApplySearchVo;
import com.dl.officialsite.hiring.vo.ApplyVo;
import com.dl.officialsite.hiring.vo.HiringVO;
import com.dl.officialsite.team.TeamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -30,6 +35,16 @@ public class ApplicationController {

@Autowired
private ApplicationService applicationService;

private final TeamService teamService;

private final HireService hireService;

public ApplicationController(TeamService teamService, HireService hireService) {
this.teamService = teamService;
this.hireService = hireService;
}

/**
* 创建申请
*/
Expand Down Expand Up @@ -70,10 +85,40 @@ public BaseResponse status(@RequestBody ApplySearchVo applySearchVo, @RequestPar
if (pageNumber > 0) {
pageNumber = pageNumber - 1;
}
if (!teamService.checkMemberIsAdmin(address)) {
throw new BizException(CodeEnums.NOT_THE_ADMIN);
}
Pageable pageable = PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createTime"));
Page<Application> page = applicationService.applySearch(applySearchVo, pageable);
return BaseResponse.successWithData(page);
}

/**
* admin get apply detail
*/
@GetMapping("/apply/hiring/detail")
public BaseResponse applyHiringDetail(@RequestParam Long hireId,@RequestParam String address) {
if (!teamService.checkMemberIsAdmin(address)) {
throw new BizException(CodeEnums.NOT_THE_ADMIN);
}
ApplicationHiringDetailVo applicationHiringDetailVo = applicationService.getInfo(hireId);
return BaseResponse.successWithData(applicationHiringDetailVo);
}

/**
* creator get apply detail
*/
@GetMapping("/apply/hiring/detail/creator")
public BaseResponse applyHiringDetailCreator(@RequestParam Long hireId,@RequestParam String address) {
hireService.findById(hireId).ifPresent(hiringVO -> {
if (!hiringVO.getAddress().equals(address) || ObjectUtils.isEmpty(hiringVO)) {
throw new BizException(CodeEnums.FAIL);
}
});
ApplicationHiringDetailVo applicationHiringDetailVo = applicationService.getInfo(hireId);
return BaseResponse.successWithData(applicationHiringDetailVo);
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.dl.officialsite.hiring.application;

import com.dl.officialsite.member.Member;
import java.util.List;
import lombok.Data;

/**
* @ClassName ApplicationHiringDetailVo
* @Author jackchen
* @Date 2024/3/19 22:57
* @Description ApplicationHiringDetailVo
**/
@Data
public class ApplicationHiringDetailVo {

private long applyPersonNum;

private List<Member> applyPersonAddress;

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ public void apply(ApplyVo applyVo, String address) {

Member createJDMember =
memberRepository.findByAddress(hiring.getAddress()).orElseThrow(() -> new BizException(
NOT_FOUND_MEMBER.getCode(), NOT_FOUND_MEMBER.getMsg()));
NOT_FOUND_MEMBER.getCode(), NOT_FOUND_MEMBER.getMsg()));
applicationRepository.findByMemberIdAndHiringId(member.getId(), hiring.getId())
.ifPresent(application -> {
throw new BizException(APPLY_REPEAT.getCode(), APPLY_REPEAT.getMsg());
});
try {
emailService.sendMail(member.getEmail(), "有新人投递简历", "有新人投递简历:\n简历地址:\n "+ "https://dlh-1257682033.cos.ap-hongkong.myqcloud.com/"+ applyVo.getFile() );
emailService.sendMail(member.getEmail(), "有新人投递简历", "有新人投递简历:\n简历地址:\n "
+ "https://dlh-1257682033.cos.ap-hongkong.myqcloud.com/" + applyVo.getFile());
//添加应聘记录
Application application = new Application();
application.setHiringId(hiring.getId());
Expand All @@ -80,8 +81,8 @@ public void apply(ApplyVo applyVo, String address) {

/**
* 查看应聘者应聘了那些岗位
* @param memberId memberId
* @return
*
* @param memberId memberId
*/
public Page<HiringVO> applyList(Long memberId, Pageable pageable) {
List<Application> applicationList = applicationRepository.findAll(
Expand All @@ -107,20 +108,48 @@ public Page<Application> applySearch(ApplySearchVo applySearchVo, Pageable pagea
return applicationRepository.findAll(specification, pageable);
}

public static Specification<Application> hasDescriptionAndNickName(ApplySearchVo applySearchVo) {
public static Specification<Application> hasDescriptionAndNickName(
ApplySearchVo applySearchVo) {
return (root, query, builder) -> {
List<Predicate> predicates = new LinkedList<>();
// Adding conditions for the query
if (!ObjectUtils.isEmpty(applySearchVo.getApplyName())) {
predicates.add(
builder.like(root.get("applyName"), "%" + applySearchVo.getApplyName() + "%"));
}
if (!ObjectUtils.isEmpty(applySearchVo.getCreatorName())) {
predicates.add(builder.like(root.get("creatorName"), "%" + applySearchVo.getCreatorName() + "%"));
predicates.add(builder.like(root.get("creatorName"),
"%" + applySearchVo.getCreatorName() + "%"));
}
if (!ObjectUtils.isEmpty(applySearchVo.getMemberName())) {
predicates.add(builder.like(root.get("memberName"), "%" + applySearchVo.getMemberName() + "%"));
predicates.add(builder.like(root.get("memberName"),
"%" + applySearchVo.getMemberName() + "%"));
}
if (!ObjectUtils.isEmpty(applySearchVo.getApplyTime())) {
predicates.add(builder.greaterThan(root.get("createTime"), "%" + applySearchVo.getApplyTime() + "%"));
predicates.add(builder.greaterThan(root.get("createTime"),
"%" + applySearchVo.getApplyTime() + "%"));
}
return query.where(predicates.toArray(new Predicate[0])).getRestriction();
};
}

public ApplicationHiringDetailVo getInfo(Long hireId) {
ApplicationHiringDetailVo info = new ApplicationHiringDetailVo();
long count = applicationRepository.count(
(root, query, builder) -> {
List<Predicate> predicates = new LinkedList<>();
predicates.add(builder.equal(root.get("hiringId"), hireId));
return query.where(predicates.toArray(new Predicate[0])).getRestriction();
});
info.setApplyPersonNum(count);
List<Long> memberIds = applicationRepository.findAll(
(root, query, builder) -> {
List<Predicate> predicates = new LinkedList<>();
predicates.add(builder.equal(root.get("hiringId"), hireId));
return query.where(predicates.toArray(new Predicate[0])).getRestriction();
}).stream().map(Application::getMemberId).collect(Collectors.toList());
List<Member> member = memberRepository.findByIdIn(memberIds);
info.setApplyPersonAddress(member);
return info;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class LoginFilter extends OncePerRequestFilter {
add("/share/all");
add("/share/rank");
add("/hello");
add("/defi/chainList");
add("/defi/tokenApy");
add("/defi/healthInfo");
}} ;

private Set<String> noAddrCheckApis = new HashSet(){{
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/dl/officialsite/member/MemberService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dl.officialsite.member;

import static com.dl.officialsite.common.enums.CodeEnums.INVALID_MEMBER;

import com.dl.officialsite.common.enums.CodeEnums;
import com.dl.officialsite.common.exception.BizException;
import com.dl.officialsite.common.utils.UserSecurityUtils;
Expand All @@ -9,20 +11,17 @@
import com.dl.officialsite.team.TeamService;
import com.dl.officialsite.team.teammember.TeamMember;
import com.dl.officialsite.team.teammember.TeamMemberRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import javax.transaction.Transactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import static com.dl.officialsite.common.enums.CodeEnums.INVALID_MEMBER;

@Service
public class MemberService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
Expand All @@ -15,13 +18,11 @@
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.*;

/**
* @ClassName TeamService
* @Author jackchen
Expand All @@ -42,6 +43,7 @@ public class RedPacketService {
public CloseableHttpClient httpClient = HttpClients.createDefault();

@Scheduled(cron = "${jobs.redpacket.corn:0/10 * * * * ?}")
@ConditionalOnProperty(name = "scheduler.enabled", havingValue = "true", matchIfMissing = true)
public void updateRedpacketStatus() {
log.info("schedule task begin --------------------- ");
for (String chainId : chainConfig.getIds()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ bot:
threadOrTopicId: 2
- name: builder
threadOrTopicId: 116
scheduler:
enabled: true

0 comments on commit b3ba6dc

Please sign in to comment.