From 6bc593c590472d3656f9725e301d19113c3675c8 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Sat, 9 Dec 2023 15:38:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E6=8B=9B=E8=81=98?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84update,=E6=89=B9=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0,=E6=89=B9=E9=87=8F=E6=B7=BB=E5=8A=A0=E6=88=90?= =?UTF-8?q?=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- .../officialsite/OfficialSiteApplication.java | 1 + .../officialsite/hiring/HireController.java | 10 ++ .../dl/officialsite/hiring/HireService.java | 94 ++++++++++++++++--- .../hiring/HiringSkillRepository.java | 7 ++ .../officialsite/hiring/vo/HiringSkillVO.java | 19 ++++ .../dl/officialsite/hiring/vo/HiringVO.java | 8 +- .../redpacket/RedPacketService.java | 28 +----- .../dl/officialsite/team/TeamController.java | 10 ++ .../com/dl/officialsite/team/TeamService.java | 23 +++++ .../team/vo/TeamMemberBatchJoinVO.java | 18 ++++ 11 files changed, 181 insertions(+), 41 deletions(-) create mode 100644 src/main/java/com/dl/officialsite/hiring/vo/HiringSkillVO.java create mode 100644 src/main/java/com/dl/officialsite/team/vo/TeamMemberBatchJoinVO.java diff --git a/README.md b/README.md index b0460732..c095715d 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/src/main/java/com/dl/officialsite/OfficialSiteApplication.java b/src/main/java/com/dl/officialsite/OfficialSiteApplication.java index f97c6cb4..9281ccd2 100644 --- a/src/main/java/com/dl/officialsite/OfficialSiteApplication.java +++ b/src/main/java/com/dl/officialsite/OfficialSiteApplication.java @@ -15,6 +15,7 @@ public class OfficialSiteApplication { public static void main(String[] args) { + SpringApplication.run(OfficialSiteApplication.class, args); } diff --git a/src/main/java/com/dl/officialsite/hiring/HireController.java b/src/main/java/com/dl/officialsite/hiring/HireController.java index a6872a5e..2f30e924 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireController.java +++ b/src/main/java/com/dl/officialsite/hiring/HireController.java @@ -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; @@ -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); + } + /** * 查询简历详情 */ diff --git a/src/main/java/com/dl/officialsite/hiring/HireService.java b/src/main/java/com/dl/officialsite/hiring/HireService.java index 412cf5fe..5d516828 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireService.java +++ b/src/main/java/com/dl/officialsite/hiring/HireService.java @@ -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; @@ -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); }); } @@ -55,12 +56,28 @@ public Page all(Pageable pageable) { List hiringVOList = new ArrayList<>();; Page hiringPage = hireRepository.findAll(pageable); hiringPage.getContent().forEach(hiring -> { - List skills = hiringSkillRepository.findByHiringId(hiring.getId()).stream() - .map(HiringSkill::getSkill) + List 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 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 hiringVOPage = new PageImpl<>(hiringVOList, pageable, hiringPage.getTotalElements()); @@ -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 hiringSkills = hiringSkillRepository.findByHiringId(id); - List mailSkills = hiringSkills.stream() + List 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 otherSkills = hiringSkills.stream() + List 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; @@ -95,13 +120,56 @@ public List selectBySkills(List skills) { hireRepository.findAllById(hiringIds).forEach(hiring -> { HiringVO hiringVO = new HiringVO(); BeanUtils.copyProperties(hiring, hiringVO); - List mainSkills = hiringSkills.stream() + List 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 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); + }); + } } diff --git a/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java b/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java index b5db6062..93481ea5 100644 --- a/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java +++ b/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java @@ -2,8 +2,10 @@ 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 @@ -11,6 +13,7 @@ * @Date 2023/12/7 00:36 * @Description HiringSkillRepository **/ +@Transactional public interface HiringSkillRepository extends JpaRepository { @Query(value = "select * from hiring_skill where hiring_id = :hiring_id",nativeQuery = true) @@ -18,4 +21,8 @@ public interface HiringSkillRepository extends JpaRepository @Query(value = "select * from hiring_skill where skill in (:skills)",nativeQuery = true) List findBySkill(@Param("skills")List skills); + + @Query(value = "delete from hiring_skill where hiring_id = :hiring_id",nativeQuery = true) + @Modifying + void deleteByHiringId(@Param("hiring_id")Long hiring_id); } diff --git a/src/main/java/com/dl/officialsite/hiring/vo/HiringSkillVO.java b/src/main/java/com/dl/officialsite/hiring/vo/HiringSkillVO.java new file mode 100644 index 00000000..423bc774 --- /dev/null +++ b/src/main/java/com/dl/officialsite/hiring/vo/HiringSkillVO.java @@ -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; +} diff --git a/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java b/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java index 29ced17e..621e927a 100644 --- a/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java +++ b/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java @@ -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; @@ -22,9 +24,9 @@ public class HiringVO { private String email; - private List mainSkills; + private List mainSkills; - private List otherSkills; + private List otherSkills; private String company; @@ -38,4 +40,6 @@ public class HiringVO { private String twitter; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; } diff --git a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java index 73778680..40f41cdf 100644 --- a/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java +++ b/src/main/java/com/dl/officialsite/redpacket/RedPacketService.java @@ -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; @@ -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 @@ -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 diff --git a/src/main/java/com/dl/officialsite/team/TeamController.java b/src/main/java/com/dl/officialsite/team/TeamController.java index ae8f5349..9f46995d 100644 --- a/src/main/java/com/dl/officialsite/team/TeamController.java +++ b/src/main/java/com/dl/officialsite/team/TeamController.java @@ -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; @@ -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); + } + /** * 退出团队 */ diff --git a/src/main/java/com/dl/officialsite/team/TeamService.java b/src/main/java/com/dl/officialsite/team/TeamService.java index dc5b78e3..14132b4e 100644 --- a/src/main/java/com/dl/officialsite/team/TeamService.java +++ b/src/main/java/com/dl/officialsite/team/TeamService.java @@ -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; @@ -246,4 +247,26 @@ public TeamsMembersVo getTeamById(Long teamId) { CodeEnums.TEAM_NOT_EXIST.getMsg()); } } + + public void batchJoin(TeamMemberBatchJoinVO teamMembers) { + teamMembers.getMemberIds().forEach(memberId -> { + Optional 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); + } + }); + } } \ No newline at end of file diff --git a/src/main/java/com/dl/officialsite/team/vo/TeamMemberBatchJoinVO.java b/src/main/java/com/dl/officialsite/team/vo/TeamMemberBatchJoinVO.java new file mode 100644 index 00000000..42fd15ae --- /dev/null +++ b/src/main/java/com/dl/officialsite/team/vo/TeamMemberBatchJoinVO.java @@ -0,0 +1,18 @@ +package com.dl.officialsite.team.vo; + +import java.util.List; +import lombok.Data; + +/** + * @ClassName TeamMemberBatchJoinVO + * @Author jackchen + * @Date 2023/12/9 15:14 + * @Description TODO + **/ +@Data +public class TeamMemberBatchJoinVO { + + private Long teamId; + + private List memberIds; +}