From a268161b7430d649c7d12c50422447ebf769b4e4 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Wed, 6 Dec 2023 23:58:36 +0800 Subject: [PATCH 1/4] =?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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../officialsite/config/SecurityConfig.java | 5 -- .../officialsite/hiring/HireController.java | 47 +++++++++++++++++++ .../officialsite/hiring/HireRepository.java | 13 +++++ .../dl/officialsite/hiring/HireService.java | 35 ++++++++++++++ .../com/dl/officialsite/hiring/Hiring.java | 35 +++++++++++--- .../dl/officialsite/hiring/vo/HiringVO.java | 32 +++++++++++++ .../dl/officialsite/mail/EmailService.java | 1 - 7 files changed, 155 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/dl/officialsite/hiring/HireController.java create mode 100644 src/main/java/com/dl/officialsite/hiring/HireRepository.java create mode 100644 src/main/java/com/dl/officialsite/hiring/HireService.java create mode 100644 src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java diff --git a/src/main/java/com/dl/officialsite/config/SecurityConfig.java b/src/main/java/com/dl/officialsite/config/SecurityConfig.java index 8b60693f..c97a4608 100644 --- a/src/main/java/com/dl/officialsite/config/SecurityConfig.java +++ b/src/main/java/com/dl/officialsite/config/SecurityConfig.java @@ -1,16 +1,11 @@ package com.dl.officialsite.config; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.firewall.StrictHttpFirewall; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfigurationSource; diff --git a/src/main/java/com/dl/officialsite/hiring/HireController.java b/src/main/java/com/dl/officialsite/hiring/HireController.java new file mode 100644 index 00000000..ae7553c8 --- /dev/null +++ b/src/main/java/com/dl/officialsite/hiring/HireController.java @@ -0,0 +1,47 @@ +package com.dl.officialsite.hiring; + +import com.dl.officialsite.common.base.BaseResponse; +import com.dl.officialsite.hiring.vo.HiringVO; +import java.util.List; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @ClassName HireController + * @Author jackchen + * @Date 2023/11/7 10:45 + * @Description HireController + **/ +@RestController +@RequestMapping("/hire") +public class HireController { + + @Autowired + private HireService hireService; + + /** + * 添加简历 + */ + @PostMapping + public BaseResponse add(@RequestBody HiringVO hiringVO) { + Hiring hiring = new Hiring(); + BeanUtils.copyProperties(hiringVO, hiring); + hireService.add(hiring); + return BaseResponse.successWithData(null); + } + + /** + * 查询所有简历 + */ + @GetMapping + public BaseResponse all() { + List list = hireService.all(); + return BaseResponse.successWithData(list); + } + +} diff --git a/src/main/java/com/dl/officialsite/hiring/HireRepository.java b/src/main/java/com/dl/officialsite/hiring/HireRepository.java new file mode 100644 index 00000000..ff645282 --- /dev/null +++ b/src/main/java/com/dl/officialsite/hiring/HireRepository.java @@ -0,0 +1,13 @@ +package com.dl.officialsite.hiring; + +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * @ClassName HireRepository + * @Author jackchen + * @Date 2023/11/7 10:45 + * @Description TODO + **/ +public interface HireRepository extends JpaRepository { + +} diff --git a/src/main/java/com/dl/officialsite/hiring/HireService.java b/src/main/java/com/dl/officialsite/hiring/HireService.java new file mode 100644 index 00000000..2f09ae69 --- /dev/null +++ b/src/main/java/com/dl/officialsite/hiring/HireService.java @@ -0,0 +1,35 @@ +package com.dl.officialsite.hiring; + +import com.dl.officialsite.hiring.vo.HiringVO; +import java.util.ArrayList; +import java.util.List; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @ClassName HireService + * @Author jackchen + * @Date 2023/11/7 10:45 + * @Description HireService + **/ +@Service +public class HireService { + + @Autowired + private HireRepository hireRepository; + + public void add(Hiring hiring) { + hireRepository.save(hiring); + } + + public List all() { + List hiringVOList = new ArrayList<>(); + List all = hireRepository.findAll(); + all.forEach(hiring -> { + HiringVO hiringVO = new HiringVO(); + BeanUtils.copyProperties(hiring, hiringVO); + }); + return hiringVOList; + } +} diff --git a/src/main/java/com/dl/officialsite/hiring/Hiring.java b/src/main/java/com/dl/officialsite/hiring/Hiring.java index d429496e..99daf3f9 100644 --- a/src/main/java/com/dl/officialsite/hiring/Hiring.java +++ b/src/main/java/com/dl/officialsite/hiring/Hiring.java @@ -1,16 +1,37 @@ package com.dl.officialsite.hiring; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import lombok.Data; +@Data +@Entity +@Table(name = "hrie") public class Hiring { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String headline; - private String employer; - private String jd; - private String role; - private String requirement; - private String locate; - private String salary; - private String memo; + + private String employer; + + private String jd; + + private String role; + + private String requirement; + + private String locate; + + private String salary; + + private String memo; private String contact; diff --git a/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java b/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java new file mode 100644 index 00000000..5147ada1 --- /dev/null +++ b/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java @@ -0,0 +1,32 @@ +package com.dl.officialsite.hiring.vo; + +import lombok.Data; + +/** + * @ClassName HiringVO + * @Author jackchen + * @Date 2023/11/7 10:47 + * @Description HiringVO + **/ +@Data +public class HiringVO { + + + private Long id; + + private String headline; + + private String employer; + + private String jd; + + private String role; + + private String requirement; + + private String locate; + + private String salary; + + private String memo; +} diff --git a/src/main/java/com/dl/officialsite/mail/EmailService.java b/src/main/java/com/dl/officialsite/mail/EmailService.java index 9002c01d..28479fdd 100644 --- a/src/main/java/com/dl/officialsite/mail/EmailService.java +++ b/src/main/java/com/dl/officialsite/mail/EmailService.java @@ -1,7 +1,6 @@ package com.dl.officialsite.mail; import java.util.List; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; From 60e56591af3742535aca40bf9aadcb5e20193ba6 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Thu, 7 Dec 2023 01:03:11 +0800 Subject: [PATCH 2/4] =?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=84add,detail,all?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../officialsite/hiring/HireController.java | 30 +++++++++++---- .../officialsite/hiring/HireRepository.java | 1 - .../dl/officialsite/hiring/HireService.java | 37 ++++++++++++++++++- .../com/dl/officialsite/hiring/Hiring.java | 20 ++-------- .../dl/officialsite/hiring/HiringSkill.java | 29 +++++++++++++++ .../hiring/HiringSkillRepository.java | 17 +++++++++ .../dl/officialsite/hiring/vo/HiringVO.java | 21 +++-------- 7 files changed, 112 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/dl/officialsite/hiring/HiringSkill.java create mode 100644 src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java diff --git a/src/main/java/com/dl/officialsite/hiring/HireController.java b/src/main/java/com/dl/officialsite/hiring/HireController.java index ae7553c8..372cc661 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireController.java +++ b/src/main/java/com/dl/officialsite/hiring/HireController.java @@ -3,12 +3,12 @@ import com.dl.officialsite.common.base.BaseResponse; import com.dl.officialsite.hiring.vo.HiringVO; import java.util.List; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -29,19 +29,35 @@ public class HireController { */ @PostMapping public BaseResponse add(@RequestBody HiringVO hiringVO) { - Hiring hiring = new Hiring(); - BeanUtils.copyProperties(hiringVO, hiring); - hireService.add(hiring); + hireService.add(hiringVO); return BaseResponse.successWithData(null); } /** - * 查询所有简历 + * 查询简历详情 */ @GetMapping + public BaseResponse detail(@RequestParam Long id) { + HiringVO hiringVO = hireService.detail(id); + return BaseResponse.successWithData(hiringVO); + } + + /** + * 查询所有简历 + */ + @GetMapping("/all") public BaseResponse all() { - List list = hireService.all(); - return BaseResponse.successWithData(list); + List hiring = hireService.all(); + return BaseResponse.successWithData(hiring); + } + + /** + * 按照类型查看简历 + */ + @GetMapping("/type") + public BaseResponse all(@RequestParam List type) { + List hiringVOList = hireService.selectByType(type); + return BaseResponse.successWithData(hiringVOList); } } diff --git a/src/main/java/com/dl/officialsite/hiring/HireRepository.java b/src/main/java/com/dl/officialsite/hiring/HireRepository.java index ff645282..8093df5b 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireRepository.java +++ b/src/main/java/com/dl/officialsite/hiring/HireRepository.java @@ -9,5 +9,4 @@ * @Description TODO **/ public interface HireRepository extends JpaRepository { - } diff --git a/src/main/java/com/dl/officialsite/hiring/HireService.java b/src/main/java/com/dl/officialsite/hiring/HireService.java index 2f09ae69..093be096 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireService.java +++ b/src/main/java/com/dl/officialsite/hiring/HireService.java @@ -3,6 +3,7 @@ import com.dl.officialsite.hiring.vo.HiringVO; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,17 +20,49 @@ public class HireService { @Autowired private HireRepository hireRepository; - public void add(Hiring hiring) { + @Autowired + private HiringSkillRepository hiringSkillRepository; + + public void add(HiringVO hiringVO) { + Hiring hiring = new Hiring(); + BeanUtils.copyProperties(hiringVO, hiring); hireRepository.save(hiring); + hiringVO.getSkill().forEach(skill -> { + HiringSkill hiringSkill = new HiringSkill(); + hiringSkill.setHiringId(hiring.getId()); + hiringSkill.setSkill(skill); + hiringSkillRepository.save(hiringSkill); + }); } public List all() { - List hiringVOList = new ArrayList<>(); + List hiringVOList = new ArrayList<>();; List all = hireRepository.findAll(); all.forEach(hiring -> { + List skills = hiringSkillRepository.findByHiringId(hiring.getId()).stream() + .map(HiringSkill::getSkill) + .collect(Collectors.toList()); HiringVO hiringVO = new HiringVO(); BeanUtils.copyProperties(hiring, hiringVO); + hiringVO.setSkill(skills); + hiringVOList.add(hiringVO); }); return hiringVOList; } + + public HiringVO detail(Long id) { + HiringVO hiringVO = new HiringVO(); + Hiring hiring = hireRepository.findById(id).get(); + BeanUtils.copyProperties(hiring, hiringVO); + List hiringSkills = hiringSkillRepository.findByHiringId(id); + List skills = hiringSkills.stream().map(HiringSkill::getSkill) + .collect(Collectors.toList()); + hiringVO.setSkill(skills); + return hiringVO; + } + + public List selectByType(List type) { + //todo 后面想想怎么做 + return null; + } } diff --git a/src/main/java/com/dl/officialsite/hiring/Hiring.java b/src/main/java/com/dl/officialsite/hiring/Hiring.java index 99daf3f9..3369ddb7 100644 --- a/src/main/java/com/dl/officialsite/hiring/Hiring.java +++ b/src/main/java/com/dl/officialsite/hiring/Hiring.java @@ -10,29 +10,15 @@ @Data @Entity -@Table(name = "hrie") +@Table(name = "hiring") public class Hiring { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - private String headline; + private String position; - private String employer; - - private String jd; - - private String role; - - private String requirement; - - private String locate; - - private String salary; - - private String memo; - - private String contact; + private String description; } diff --git a/src/main/java/com/dl/officialsite/hiring/HiringSkill.java b/src/main/java/com/dl/officialsite/hiring/HiringSkill.java new file mode 100644 index 00000000..45193938 --- /dev/null +++ b/src/main/java/com/dl/officialsite/hiring/HiringSkill.java @@ -0,0 +1,29 @@ +package com.dl.officialsite.hiring; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import lombok.Data; + +/** + * @ClassName HiringSkill + * @Author jackchen + * @Date 2023/12/7 00:33 + * @Description TODO + **/ +@Data +@Entity +@Table(name = "hiring_skill") +public class HiringSkill { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private Long hiringId; + + private String skill; + +} diff --git a/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java b/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java new file mode 100644 index 00000000..63d5b7c3 --- /dev/null +++ b/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java @@ -0,0 +1,17 @@ +package com.dl.officialsite.hiring; + +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +/** + * @ClassName HiringSkillRepository + * @Author jackchen + * @Date 2023/12/7 00:36 + * @Description HiringSkillRepository + **/ +public interface HiringSkillRepository extends JpaRepository { + + @Query(value = "select * from hiring_skill where hiring_id = :hiring_id",nativeQuery = true) + List findByHiringId(Long hiring_id); +} 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 5147ada1..99922449 100644 --- a/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java +++ b/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java @@ -1,32 +1,21 @@ package com.dl.officialsite.hiring.vo; +import java.util.List; import lombok.Data; /** * @ClassName HiringVO * @Author jackchen - * @Date 2023/11/7 10:47 + * @Date 2023/12/7 00:37 * @Description HiringVO **/ @Data public class HiringVO { - private Long id; + private String position; - private String headline; + private String description; - private String employer; - - private String jd; - - private String role; - - private String requirement; - - private String locate; - - private String salary; - - private String memo; + private List skill; } From 3eab4cf96c3dffcd67ff53ecdd79bfca37180305 Mon Sep 17 00:00:00 2001 From: chengpengxiang <15503679582@163.com> Date: Sat, 9 Dec 2023 12:32:59 +0800 Subject: [PATCH 3/4] =?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=84add,detail,all?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constants/Constants.java | 10 +++ .../officialsite/common/enums/CodeEnums.java | 4 +- .../officialsite/hiring/HireController.java | 21 ++++-- .../dl/officialsite/hiring/HireService.java | 65 +++++++++++++++---- .../com/dl/officialsite/hiring/Hiring.java | 23 +++++++ .../dl/officialsite/hiring/HiringSkill.java | 2 + .../hiring/HiringSkillRepository.java | 6 +- .../dl/officialsite/hiring/vo/HiringVO.java | 22 ++++++- 8 files changed, 130 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/dl/officialsite/common/constants/Constants.java b/src/main/java/com/dl/officialsite/common/constants/Constants.java index 30059984..26ddd8fa 100644 --- a/src/main/java/com/dl/officialsite/common/constants/Constants.java +++ b/src/main/java/com/dl/officialsite/common/constants/Constants.java @@ -22,4 +22,14 @@ public class Constants { public static final int REQUEST_TEAM = 1; public static final int EXIT_TEAM = 2; + + /** + * 主要技术类型 + */ + public static final int HIRING_MAIN_SKILL = 1; + + /** + * 辅助技术类型 + */ + public static final int HIRING_OTHER_SKILL = 2; } diff --git a/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java b/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java index f3affe0c..3a88cb28 100644 --- a/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java +++ b/src/main/java/com/dl/officialsite/common/enums/CodeEnums.java @@ -19,7 +19,9 @@ public enum CodeEnums { TEAM_NOT_EXIST("1005", "team not exist"), LOGIN_IN("2001", "please login"), TEAM_ADMIN_NOT_EXIST("1006", "team admin not exist"), - MEMBER_ALREADY_REQUEST_TEAM("1007", "member already request team"); + MEMBER_ALREADY_REQUEST_TEAM("1007", "member already request team"), + + NOT_FOUND_JD("1008", "not found jd"); private String code; diff --git a/src/main/java/com/dl/officialsite/hiring/HireController.java b/src/main/java/com/dl/officialsite/hiring/HireController.java index 372cc661..a6872a5e 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireController.java +++ b/src/main/java/com/dl/officialsite/hiring/HireController.java @@ -4,6 +4,10 @@ import com.dl.officialsite.hiring.vo.HiringVO; import java.util.List; 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.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -28,7 +32,7 @@ public class HireController { * 添加简历 */ @PostMapping - public BaseResponse add(@RequestBody HiringVO hiringVO) { + public BaseResponse add(@RequestParam String address,@RequestBody HiringVO hiringVO) { hireService.add(hiringVO); return BaseResponse.successWithData(null); } @@ -37,7 +41,7 @@ public BaseResponse add(@RequestBody HiringVO hiringVO) { * 查询简历详情 */ @GetMapping - public BaseResponse detail(@RequestParam Long id) { + public BaseResponse detail(@RequestParam String address,@RequestParam Long id) { HiringVO hiringVO = hireService.detail(id); return BaseResponse.successWithData(hiringVO); } @@ -46,17 +50,20 @@ public BaseResponse detail(@RequestParam Long id) { * 查询所有简历 */ @GetMapping("/all") - public BaseResponse all() { - List hiring = hireService.all(); - return BaseResponse.successWithData(hiring); + public BaseResponse all(@RequestParam String address, + @RequestParam(defaultValue = "1") Integer pageNumber, + @RequestParam(defaultValue = "10") Integer pageSize) { + Pageable pageable = PageRequest.of(pageNumber - 1, pageSize, Sort.by(Sort.Direction.DESC, "createTime")); + Page all = hireService.all(pageable); + return BaseResponse.successWithData(all); } /** * 按照类型查看简历 */ @GetMapping("/type") - public BaseResponse all(@RequestParam List type) { - List hiringVOList = hireService.selectByType(type); + public BaseResponse all(@RequestParam String address,@RequestParam List skills) { + List hiringVOList = hireService.selectBySkills(skills); return BaseResponse.successWithData(hiringVOList); } diff --git a/src/main/java/com/dl/officialsite/hiring/HireService.java b/src/main/java/com/dl/officialsite/hiring/HireService.java index 093be096..412cf5fe 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireService.java +++ b/src/main/java/com/dl/officialsite/hiring/HireService.java @@ -1,11 +1,18 @@ package com.dl.officialsite.hiring; +import static com.dl.officialsite.common.enums.CodeEnums.NOT_FOUND_JD; + +import com.dl.officialsite.common.constants.Constants; +import com.dl.officialsite.common.exception.BizException; import com.dl.officialsite.hiring.vo.HiringVO; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; /** @@ -27,42 +34,74 @@ public void add(HiringVO hiringVO) { Hiring hiring = new Hiring(); BeanUtils.copyProperties(hiringVO, hiring); hireRepository.save(hiring); - hiringVO.getSkill().forEach(skill -> { + hiringVO.getMainSkills().forEach(mainSkill -> { + HiringSkill hiringSkill = new HiringSkill(); + hiringSkill.setHiringId(hiring.getId()); + hiringSkill.setSkill(mainSkill); + hiringSkill.setType(Constants.HIRING_MAIN_SKILL); + hiringSkillRepository.save(hiringSkill); + }); + + hiringVO.getOtherSkills().forEach(otherSkill -> { HiringSkill hiringSkill = new HiringSkill(); hiringSkill.setHiringId(hiring.getId()); - hiringSkill.setSkill(skill); + hiringSkill.setSkill(otherSkill); + hiringSkill.setType(Constants.HIRING_OTHER_SKILL); hiringSkillRepository.save(hiringSkill); }); } - public List all() { + public Page all(Pageable pageable) { List hiringVOList = new ArrayList<>();; - List all = hireRepository.findAll(); - all.forEach(hiring -> { + Page hiringPage = hireRepository.findAll(pageable); + hiringPage.getContent().forEach(hiring -> { List skills = hiringSkillRepository.findByHiringId(hiring.getId()).stream() .map(HiringSkill::getSkill) .collect(Collectors.toList()); HiringVO hiringVO = new HiringVO(); BeanUtils.copyProperties(hiring, hiringVO); - hiringVO.setSkill(skills); + hiringVO.setMainSkills(skills); hiringVOList.add(hiringVO); }); - return hiringVOList; + Page hiringVOPage = new PageImpl<>(hiringVOList, pageable, hiringPage.getTotalElements()); + return hiringVOPage; } public HiringVO detail(Long id) { HiringVO hiringVO = new HiringVO(); - Hiring hiring = hireRepository.findById(id).get(); + Hiring hiring = hireRepository.findById(id) + .orElseThrow(() -> new BizException(NOT_FOUND_JD.getCode(), NOT_FOUND_JD.getMsg())); BeanUtils.copyProperties(hiring, hiringVO); List hiringSkills = hiringSkillRepository.findByHiringId(id); - List skills = hiringSkills.stream().map(HiringSkill::getSkill) + List mailSkills = hiringSkills.stream() + .filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL) + .map(HiringSkill::getSkill) + .collect(Collectors.toList()); + hiringVO.setMainSkills(mailSkills); + List otherSkills = hiringSkills.stream() + .filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_OTHER_SKILL) + .map(HiringSkill::getSkill) .collect(Collectors.toList()); - hiringVO.setSkill(skills); + hiringVO.setOtherSkills(otherSkills); return hiringVO; } - public List selectByType(List type) { - //todo 后面想想怎么做 - return null; + public List selectBySkills(List skills) { + //使用in查询 + List hiringSkills = hiringSkillRepository.findBySkill(skills); + //去重通过hiringId + List hiringIds = hiringSkills.stream().map(HiringSkill::getHiringId).distinct().collect(Collectors.toList()); + List hiringVOList = new ArrayList<>(); + hireRepository.findAllById(hiringIds).forEach(hiring -> { + HiringVO hiringVO = new HiringVO(); + BeanUtils.copyProperties(hiring, hiringVO); + List mainSkills = hiringSkills.stream() + .filter(hiringSkill -> hiringSkill.getHiringId().equals(hiring.getId())) + .map(HiringSkill::getSkill) + .collect(Collectors.toList()); + hiringVO.setMainSkills(mainSkills); + hiringVOList.add(hiringVO); + }); + return hiringVOList; } } diff --git a/src/main/java/com/dl/officialsite/hiring/Hiring.java b/src/main/java/com/dl/officialsite/hiring/Hiring.java index 3369ddb7..19475a97 100644 --- a/src/main/java/com/dl/officialsite/hiring/Hiring.java +++ b/src/main/java/com/dl/officialsite/hiring/Hiring.java @@ -1,12 +1,15 @@ package com.dl.officialsite.hiring; +import java.util.Date; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import lombok.Data; +import org.hibernate.annotations.CreationTimestamp; @Data @Entity @@ -21,4 +24,24 @@ public class Hiring { private String description; + private String location; + + private String email; + + private String company; + + private String invoice; + + private int minYearlySalary; + + private int maxYearlySalary; + + private String benefits; + + private String twitter; + + @CreationTimestamp + @Column(updatable = false, nullable = false) + private Date createTime; + } diff --git a/src/main/java/com/dl/officialsite/hiring/HiringSkill.java b/src/main/java/com/dl/officialsite/hiring/HiringSkill.java index 45193938..c918c16f 100644 --- a/src/main/java/com/dl/officialsite/hiring/HiringSkill.java +++ b/src/main/java/com/dl/officialsite/hiring/HiringSkill.java @@ -26,4 +26,6 @@ public class HiringSkill { private String skill; + private int type; + } diff --git a/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java b/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java index 63d5b7c3..b5db6062 100644 --- a/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java +++ b/src/main/java/com/dl/officialsite/hiring/HiringSkillRepository.java @@ -3,6 +3,7 @@ import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; /** * @ClassName HiringSkillRepository @@ -13,5 +14,8 @@ public interface HiringSkillRepository extends JpaRepository { @Query(value = "select * from hiring_skill where hiring_id = :hiring_id",nativeQuery = true) - List findByHiringId(Long hiring_id); + List findByHiringId(@Param("hiring_id")Long hiring_id); + + @Query(value = "select * from hiring_skill where skill in (:skills)",nativeQuery = true) + List findBySkill(@Param("skills")List skills); } 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 99922449..29ced17e 100644 --- a/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java +++ b/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java @@ -12,10 +12,30 @@ @Data public class HiringVO { + private Long id; private String position; private String description; - private List skill; + private String location; + + private String email; + + private List mainSkills; + + private List otherSkills; + + private String company; + + private String invoice; + + private int minYearlySalary; + + private int maxYearlySalary; + + private String benefits; + + private String twitter; + } 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 4/4] =?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; +}