Skip to content

Commit

Permalink
Merge pull request #71 from cheng521521/main
Browse files Browse the repository at this point in the history
feat:添加招聘模块的update,批量更新,批量添加成员
  • Loading branch information
yanyanho authored Dec 9, 2023
2 parents 93ea091 + 6bc593c commit c7d8f4a
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 41 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ https://github.com/spruceid/siwe-go/blob/main/message.go

## build
```
ssh root@81.69.8.95
ssh root@43.135.22.107
./gradlew build -x test
scp ./dist/apps/dl.jar root@81.69.8.95:/root/Dapp-Learning-Official-web/dist/apps
scp ./dist/apps/dl.jar root@43.135.22.107:/root/Official-website-backend/dist/app
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class OfficialSiteApplication {

public static void main(String[] args) {

SpringApplication.run(OfficialSiteApplication.class, args);
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/HireController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -37,6 +38,15 @@ public BaseResponse add(@RequestParam String address,@RequestBody HiringVO hirin
return BaseResponse.successWithData(null);
}

/**
* 修改简历
*/
@PutMapping
public BaseResponse update(@RequestParam String address,@RequestBody HiringVO hiringVO) {
hireService.update(hiringVO);
return BaseResponse.successWithData(null);
}

/**
* 查询简历详情
*/
Expand Down
94 changes: 81 additions & 13 deletions src/main/java/com/dl/officialsite/hiring/HireService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.dl.officialsite.common.constants.Constants;
import com.dl.officialsite.common.exception.BizException;
import com.dl.officialsite.hiring.vo.HiringSkillVO;
import com.dl.officialsite.hiring.vo.HiringVO;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -36,17 +37,17 @@ public void add(HiringVO hiringVO) {
hireRepository.save(hiring);
hiringVO.getMainSkills().forEach(mainSkill -> {
HiringSkill hiringSkill = new HiringSkill();
hiringSkill.setHiringId(hiring.getId());
hiringSkill.setSkill(mainSkill);
BeanUtils.copyProperties(mainSkill, hiringSkill);
hiringSkill.setType(Constants.HIRING_MAIN_SKILL);
hiringSkill.setHiringId(hiring.getId());
hiringSkillRepository.save(hiringSkill);
});

hiringVO.getOtherSkills().forEach(otherSkill -> {
HiringSkill hiringSkill = new HiringSkill();
hiringSkill.setHiringId(hiring.getId());
hiringSkill.setSkill(otherSkill);
BeanUtils.copyProperties(otherSkill, hiringSkill);
hiringSkill.setType(Constants.HIRING_OTHER_SKILL);
hiringSkill.setHiringId(hiring.getId());
hiringSkillRepository.save(hiringSkill);
});
}
Expand All @@ -55,12 +56,28 @@ public Page<HiringVO> all(Pageable pageable) {
List<HiringVO> hiringVOList = new ArrayList<>();;
Page<Hiring> hiringPage = hireRepository.findAll(pageable);
hiringPage.getContent().forEach(hiring -> {
List<String> skills = hiringSkillRepository.findByHiringId(hiring.getId()).stream()
.map(HiringSkill::getSkill)
List<HiringSkillVO> mainSkills = hiringSkillRepository.findByHiringId(hiring.getId())
.stream()
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL)
.map(hiringSkill -> {
HiringSkillVO hiringSkillVO = new HiringSkillVO();
BeanUtils.copyProperties(hiringSkill, hiringSkillVO);
return hiringSkillVO;
})
.collect(Collectors.toList());
List<HiringSkillVO> otherSkills = hiringSkillRepository.findByHiringId(hiring.getId())
.stream()
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL)
.map(hiringSkill -> {
HiringSkillVO hiringSkillVO = new HiringSkillVO();
BeanUtils.copyProperties(hiringSkill, hiringSkillVO);
return hiringSkillVO;
})
.collect(Collectors.toList());
HiringVO hiringVO = new HiringVO();
BeanUtils.copyProperties(hiring, hiringVO);
hiringVO.setMainSkills(skills);
hiringVO.setMainSkills(mainSkills);
hiringVO.setOtherSkills(otherSkills);
hiringVOList.add(hiringVO);
});
Page<HiringVO> hiringVOPage = new PageImpl<>(hiringVOList, pageable, hiringPage.getTotalElements());
Expand All @@ -73,14 +90,22 @@ public HiringVO detail(Long id) {
.orElseThrow(() -> new BizException(NOT_FOUND_JD.getCode(), NOT_FOUND_JD.getMsg()));
BeanUtils.copyProperties(hiring, hiringVO);
List<HiringSkill> hiringSkills = hiringSkillRepository.findByHiringId(id);
List<String> mailSkills = hiringSkills.stream()
List<HiringSkillVO> mailSkills = hiringSkills.stream()
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL)
.map(HiringSkill::getSkill)
.map(hiringSkill -> {
HiringSkillVO hiringSkillVO = new HiringSkillVO();
BeanUtils.copyProperties(hiringSkill, hiringSkillVO);
return hiringSkillVO;
})
.collect(Collectors.toList());
hiringVO.setMainSkills(mailSkills);
List<String> otherSkills = hiringSkills.stream()
List<HiringSkillVO> otherSkills = hiringSkills.stream()
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL)
.map(HiringSkill::getSkill)
.map(hiringSkill -> {
HiringSkillVO hiringSkillVO = new HiringSkillVO();
BeanUtils.copyProperties(hiringSkill, hiringSkillVO);
return hiringSkillVO;
})
.collect(Collectors.toList());
hiringVO.setOtherSkills(otherSkills);
return hiringVO;
Expand All @@ -95,13 +120,56 @@ public List<HiringVO> selectBySkills(List<String> skills) {
hireRepository.findAllById(hiringIds).forEach(hiring -> {
HiringVO hiringVO = new HiringVO();
BeanUtils.copyProperties(hiring, hiringVO);
List<String> mainSkills = hiringSkills.stream()
List<HiringSkillVO> mainSkills = hiringSkills.stream()
.filter(hiringSkill -> hiringSkill.getHiringId().equals(hiring.getId()))
.map(HiringSkill::getSkill)
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL)
.map(hiringSkill -> {
HiringSkillVO hiringSkillVO = new HiringSkillVO();
BeanUtils.copyProperties(hiringSkill, hiringSkillVO);
return hiringSkillVO;
})
.collect(Collectors.toList());

List<HiringSkillVO> otherSkills = hiringSkills.stream()
.filter(hiringSkill -> hiringSkill.getHiringId().equals(hiring.getId()))
.filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL)
.map(hiringSkill -> {
HiringSkillVO hiringSkillVO = new HiringSkillVO();
BeanUtils.copyProperties(hiringSkill, hiringSkillVO);
return hiringSkillVO;
})
.collect(Collectors.toList());
hiringVO.setMainSkills(mainSkills);
hiringVO.setOtherSkills(otherSkills);
hiringVOList.add(hiringVO);
});
return hiringVOList;
}

/**
* 修改简历
* @param hiringVO
*/
public void update(HiringVO hiringVO) {
Hiring hiring = hireRepository.findById(hiringVO.getId())
.orElseThrow(() -> new BizException(NOT_FOUND_JD.getCode(), NOT_FOUND_JD.getMsg()));
BeanUtils.copyProperties(hiringVO, hiring);
hireRepository.save(hiring);
//删除原有的技能
hiringSkillRepository.deleteByHiringId(hiring.getId());
//添加新的技能
hiringVO.getMainSkills().forEach(mainSkill -> {
HiringSkill hiringSkill = new HiringSkill();
BeanUtils.copyProperties(mainSkill, hiringSkill);
hiringSkill.setHiringId(hiring.getId());
hiringSkillRepository.save(hiringSkill);
});

hiringVO.getOtherSkills().forEach(otherSkill -> {
HiringSkill hiringSkill = new HiringSkill();
BeanUtils.copyProperties(otherSkill, hiringSkill);
hiringSkill.setHiringId(hiring.getId());
hiringSkillRepository.save(hiringSkill);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@

import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
* @ClassName HiringSkillRepository
* @Author jackchen
* @Date 2023/12/7 00:36
* @Description HiringSkillRepository
**/
@Transactional
public interface HiringSkillRepository extends JpaRepository<HiringSkill, Long> {

@Query(value = "select * from hiring_skill where hiring_id = :hiring_id",nativeQuery = true)
List<HiringSkill> findByHiringId(@Param("hiring_id")Long hiring_id);

@Query(value = "select * from hiring_skill where skill in (:skills)",nativeQuery = true)
List<HiringSkill> findBySkill(@Param("skills")List<String> skills);

@Query(value = "delete from hiring_skill where hiring_id = :hiring_id",nativeQuery = true)
@Modifying
void deleteByHiringId(@Param("hiring_id")Long hiring_id);
}
19 changes: 19 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/vo/HiringSkillVO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.dl.officialsite.hiring.vo;

import lombok.Data;

/**
* @ClassName HiringSkillVO
* @Author jackchen
* @Date 2023/12/9 14:34
* @Description HiringSkillVO
**/
@Data
public class HiringSkillVO {

private Long id;

private String skill;

private int type;
}
8 changes: 6 additions & 2 deletions src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dl.officialsite.hiring.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.List;
import lombok.Data;

Expand All @@ -22,9 +24,9 @@ public class HiringVO {

private String email;

private List<String> mainSkills;
private List<HiringSkillVO> mainSkills;

private List<String> otherSkills;
private List<HiringSkillVO> otherSkills;

private String company;

Expand All @@ -38,4 +40,6 @@ public class HiringVO {

private String twitter;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}
28 changes: 4 additions & 24 deletions src/main/java/com/dl/officialsite/redpacket/RedPacketService.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
package com.dl.officialsite.redpacket;


import com.dl.officialsite.common.constants.Constants;
import com.dl.officialsite.common.enums.CodeEnums;
import com.dl.officialsite.common.exception.BizException;
import com.dl.officialsite.mail.EmailService;
import com.dl.officialsite.member.Member;
import com.dl.officialsite.member.MemberRepository;
import com.dl.officialsite.team.Team;
import com.dl.officialsite.team.TeamMember;
import com.dl.officialsite.team.TeamMemberRepository;
import com.dl.officialsite.team.TeamRepository;
import com.dl.officialsite.team.vo.*;
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 @@ -23,22 +15,9 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

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.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
* @ClassName TeamService
Expand All @@ -58,6 +37,7 @@ public class RedPacketService {
@Scheduled(cron = "0 0/2 * * * ? ")
public void updateRedpacketStatus() throws IOException {
log.info("schedule task begin --------------------- ");
System.out.println("验证是否是新代码--------------");
HttpPost request = new HttpPost("http://api.studio.thegraph.com/proxy/55957/dapp-learning-redpacket/version/latest");
request.setHeader("Content-Type", "application/json");
// Define your GraphQL query
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/dl/officialsite/team/TeamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.dl.officialsite.common.base.BaseResponse;
import com.dl.officialsite.member.Member;
import com.dl.officialsite.team.vo.TeamMemberApproveVO;
import com.dl.officialsite.team.vo.TeamMemberBatchJoinVO;
import com.dl.officialsite.team.vo.TeamMemberJoinVO;
import com.dl.officialsite.team.vo.TeamQueryVo;
import com.dl.officialsite.team.vo.TeamVO;
Expand Down Expand Up @@ -50,6 +51,15 @@ BaseResponse join(@RequestBody TeamMemberJoinVO teamMember, @RequestParam String
return BaseResponse.successWithData(null);
}

/**
* 批量加入团队
*/
@PostMapping("/join/batch")
BaseResponse batchJoin(@RequestBody TeamMemberBatchJoinVO teamMembers, @RequestParam String address) {
teamService.batchJoin(teamMembers);
return BaseResponse.successWithData(null);
}

/**
* 退出团队
*/
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/dl/officialsite/team/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dl.officialsite.member.Member;
import com.dl.officialsite.member.MemberRepository;
import com.dl.officialsite.team.vo.TeamMemberApproveVO;
import com.dl.officialsite.team.vo.TeamMemberBatchJoinVO;
import com.dl.officialsite.team.vo.TeamMemberJoinVO;
import com.dl.officialsite.team.vo.TeamQueryVo;
import com.dl.officialsite.team.vo.TeamVO;
Expand Down Expand Up @@ -246,4 +247,26 @@ public TeamsMembersVo getTeamById(Long teamId) {
CodeEnums.TEAM_NOT_EXIST.getMsg());
}
}

public void batchJoin(TeamMemberBatchJoinVO teamMembers) {
teamMembers.getMemberIds().forEach(memberId -> {
Optional<TeamMember> optional = teamMemberRepository.findByTeamAndMember(
teamMembers.getTeamId(), memberId);
if (optional.isPresent()) {
TeamMember teamMember2 = optional.get();
if (teamMember2.getStatus() == Constants.REQUEST_TEAM) {
throw new BizException(CodeEnums.MEMBER_ALREADY_REQUEST_TEAM.getCode(),
CodeEnums.MEMBER_ALREADY_REQUEST_TEAM.getMsg());
}
teamMember2.setStatus(Constants.APPROVE_TEAM);
teamMemberRepository.save(teamMember2);
} else {
TeamMember teamMember1 = new TeamMember();
teamMember1.setMemberId(memberId);
teamMember1.setTeamId(teamMembers.getTeamId());
teamMember1.setStatus(Constants.APPROVE_TEAM);
teamMemberRepository.save(teamMember1);
}
});
}
}
Loading

0 comments on commit c7d8f4a

Please sign in to comment.