diff --git a/README.md b/README.md index c095715d..8e54d938 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ https://github.com/spruceid/siwe-go/blob/main/message.go ``` ssh root@43.135.22.107 ./gradlew build -x test - scp ./dist/apps/dl.jar root@43.135.22.107:/root/Official-website-backend/dist/app + scp ./dist/apps/dl.jar root@43.135.22.107:/root/Official-website-backend/dist/apps ``` diff --git a/src/main/java/com/dl/officialsite/hiring/HireController.java b/src/main/java/com/dl/officialsite/hiring/HireController.java index 2f30e924..b4019793 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireController.java +++ b/src/main/java/com/dl/officialsite/hiring/HireController.java @@ -34,8 +34,8 @@ public class HireController { */ @PostMapping public BaseResponse add(@RequestParam String address,@RequestBody HiringVO hiringVO) { - hireService.add(hiringVO); - return BaseResponse.successWithData(null); + HiringVO hiringVO1 = hireService.add(hiringVO); + return BaseResponse.successWithData(hiringVO1); } /** @@ -77,4 +77,13 @@ public BaseResponse all(@RequestParam String address,@RequestParam List return BaseResponse.successWithData(hiringVOList); } + /** + * 按照创建者查看简历 + */ + @GetMapping("/address") + public BaseResponse all(@RequestParam String address) { + List hiringVOList = hireService.selectByAddress(address); + 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 8093df5b..20656c98 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireRepository.java +++ b/src/main/java/com/dl/officialsite/hiring/HireRepository.java @@ -1,6 +1,9 @@ package com.dl.officialsite.hiring; +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 HireRepository @@ -9,4 +12,11 @@ * @Description TODO **/ public interface HireRepository extends JpaRepository { + + + /** + * 根据地址查询所有简历 + */ + @Query(value = "select * from hiring where address = :address", nativeQuery = true) + List findAllByAddress(@Param("address")String address); } diff --git a/src/main/java/com/dl/officialsite/hiring/HireService.java b/src/main/java/com/dl/officialsite/hiring/HireService.java index 5d516828..3b329f3d 100644 --- a/src/main/java/com/dl/officialsite/hiring/HireService.java +++ b/src/main/java/com/dl/officialsite/hiring/HireService.java @@ -31,7 +31,7 @@ public class HireService { @Autowired private HiringSkillRepository hiringSkillRepository; - public void add(HiringVO hiringVO) { + public HiringVO add(HiringVO hiringVO) { Hiring hiring = new Hiring(); BeanUtils.copyProperties(hiringVO, hiring); hireRepository.save(hiring); @@ -50,6 +50,8 @@ public void add(HiringVO hiringVO) { hiringSkill.setHiringId(hiring.getId()); hiringSkillRepository.save(hiringSkill); }); + hiringVO.setId(hiring.getId()); + return hiringVO; } public Page all(Pageable pageable) { @@ -172,4 +174,33 @@ public void update(HiringVO hiringVO) { hiringSkillRepository.save(hiringSkill); }); } + + public List selectByAddress(String address) { + List list = new ArrayList<>(); + hireRepository.findAllByAddress(address).forEach(hiring -> { + HiringVO hiringVO = new HiringVO(); + BeanUtils.copyProperties(hiring, hiringVO); + List hiringSkills = hiringSkillRepository.findByHiringId(hiring.getId()); + List mailSkills = hiringSkills.stream() + .filter(hiringSkill -> hiringSkill.getType() == Constants.HIRING_MAIN_SKILL) + .map(hiringSkill -> { + HiringSkillVO hiringSkillVO = new HiringSkillVO(); + BeanUtils.copyProperties(hiringSkill, hiringSkillVO); + return hiringSkillVO; + }) + .collect(Collectors.toList()); + hiringVO.setMainSkills(mailSkills); + List otherSkills = hiringSkills.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.setOtherSkills(otherSkills); + list.add(hiringVO); + }); + return list; + } } diff --git a/src/main/java/com/dl/officialsite/hiring/Hiring.java b/src/main/java/com/dl/officialsite/hiring/Hiring.java index 19475a97..416a8c66 100644 --- a/src/main/java/com/dl/officialsite/hiring/Hiring.java +++ b/src/main/java/com/dl/officialsite/hiring/Hiring.java @@ -44,4 +44,6 @@ public class Hiring { @Column(updatable = false, nullable = false) private Date createTime; + private String address; + } 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 621e927a..2e14b796 100644 --- a/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java +++ b/src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; import java.util.List; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import lombok.Data; /** @@ -16,24 +18,32 @@ public class HiringVO { private Long id; + @NotBlank(message = "职位不能为空") private String position; + @NotBlank(message = "描述不能为空") private String description; + @NotBlank(message = "工作地点不能为空") private String location; + @NotBlank(message = "email不能为空") private String email; + @NotNull(message = "工作类型不能为空") private List mainSkills; private List otherSkills; + @NotBlank(message = "公司不能为空") private String company; private String invoice; + @NotNull(message = "最小年薪不能为空") private int minYearlySalary; + @NotNull(message = "最大年薪不能为空") private int maxYearlySalary; private String benefits; @@ -42,4 +52,6 @@ public class HiringVO { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createTime; + + private String address; } diff --git a/src/main/java/com/dl/officialsite/team/Team.java b/src/main/java/com/dl/officialsite/team/Team.java index 59272aaa..c99b8101 100644 --- a/src/main/java/com/dl/officialsite/team/Team.java +++ b/src/main/java/com/dl/officialsite/team/Team.java @@ -1,15 +1,10 @@ package com.dl.officialsite.team; -import com.dl.officialsite.member.Member; - -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import java.util.List; import javax.persistence.Table; -import javax.persistence.UniqueConstraint; import lombok.Data; @Data @@ -20,8 +15,11 @@ public class Team { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + //team名称 private String teamName; + //团队简介 private String teamProfile; + //管理员 private String administrator; // dao admin , core contributor, builder diff --git a/src/main/java/com/dl/officialsite/team/TeamController.java b/src/main/java/com/dl/officialsite/team/TeamController.java index 9f46995d..2f421a66 100644 --- a/src/main/java/com/dl/officialsite/team/TeamController.java +++ b/src/main/java/com/dl/officialsite/team/TeamController.java @@ -1,6 +1,8 @@ package com.dl.officialsite.team; 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.member.Member; import com.dl.officialsite.team.vo.TeamMemberApproveVO; import com.dl.officialsite.team.vo.TeamMemberBatchJoinVO; @@ -8,6 +10,7 @@ import com.dl.officialsite.team.vo.TeamQueryVo; import com.dl.officialsite.team.vo.TeamVO; import com.dl.officialsite.team.vo.TeamsMembersVo; +import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -33,11 +36,21 @@ public class TeamController { @Autowired private TeamService teamService; + @GetMapping("/admin/list") + BaseResponse list(@RequestParam String address) { + List list = new ArrayList<>(); + list.add("0x4DDE628ef50dE13E6E369353128A0d7899B54B6b"); + return BaseResponse.successWithData(list); + } + /** * 新增团队 */ @PutMapping BaseResponse create(@RequestBody TeamVO team, @RequestParam String address) { + if (!address.equals("0x4DDE628ef50dE13E6E369353128A0d7899B54B6b")) { + throw new BizException(CodeEnums.TEAM_NOT_EXIST.getCode(), CodeEnums.TEAM_NOT_EXIST.getMsg()); + } teamService.add(team); return BaseResponse.successWithData(team); } diff --git a/src/main/java/com/dl/officialsite/team/TeamService.java b/src/main/java/com/dl/officialsite/team/TeamService.java index 14132b4e..7c74beb4 100644 --- a/src/main/java/com/dl/officialsite/team/TeamService.java +++ b/src/main/java/com/dl/officialsite/team/TeamService.java @@ -185,10 +185,11 @@ public void approve(TeamMemberApproveVO teamMemberApproveVO) { public void exit(TeamMemberJoinVO teamMember) { - TeamMember teamMember1 = new TeamMember(); - BeanUtils.copyProperties(teamMember, teamMember1); - teamMember1.setStatus(Constants.EXIT_TEAM); - teamMemberRepository.save(teamMember1); + teamMemberRepository.findByTeamAndMember(teamMember.getTeamId(), + teamMember.getMemberId()).ifPresent(teamMember2 -> { + teamMember2.setStatus(Constants.EXIT_TEAM); + teamMemberRepository.save(teamMember2); + }); Team team = teamRepository.findById(teamMember.getTeamId()).get(); Member member = memberRepository.findById(teamMember.getMemberId()).get(); String subject = team.getTeamName() + "团队成员退出"; @@ -234,7 +235,7 @@ public TeamsMembersVo getTeamById(Long teamId) { TeamsMembersVo teamsMembersVo = new TeamsMembersVo(); Team team = optional.get(); List members = new ArrayList<>(); - List memberIds = teamMemberRepository.findByTeamId(team.getId()); + List memberIds = teamMemberRepository.findByTeamIdStatus(team.getId(), Constants.APPROVE_TEAM); memberIds.stream().forEach(memberId -> { Member member = memberRepository.findById(memberId).get(); members.add(member); @@ -249,6 +250,7 @@ public TeamsMembersVo getTeamById(Long teamId) { } public void batchJoin(TeamMemberBatchJoinVO teamMembers) { + teamMembers.getMemberIds().forEach(memberId -> { Optional optional = teamMemberRepository.findByTeamAndMember( teamMembers.getTeamId(), memberId); diff --git a/src/main/resources/application-cpx.yml b/src/main/resources/application-cpx.yml new file mode 100644 index 00000000..1b800839 --- /dev/null +++ b/src/main/resources/application-cpx.yml @@ -0,0 +1,60 @@ +server: + port: 8080 + servlet: + session: + timeout: 60m + cookie: + max-age: -1 +spring: + datasource: + url: jdbc:mysql://127.0.0.1:3306/blog?allowPublicKeyRetrieval=true&useSSL=false +#type: com.alibaba.druid.pool.DruidDataSource + username: root + #password: 12345678 + password: root + maximum-pool-size: 20 + + jpa: + hibernate: + ddl-auto: update + generate-ddl: true + show-sql: true + database-platform: org.hibernate.dialect.MySQL5Dialect + mail: + host: smtp.163.com + port: 465 + username: 15503679582@163.com + password: OXWEDGWEOGIGVWJN + properties: + mail: + smtp: + auth: true + ssl: + enable: true + session: + store-type: jdbc + jdbc: + initialize-schema: always + cleanup-cron: 0 */3 * * * * + timeout: 7200 + +logging: + level: + org.springframework.security: debug + +ipfs: + url: /ip4/127.0.0.1/tcp/5001 + +web3j: + client-address: "https://polygon-rpc.com" + +oauth: + registrations: + github: + clientId: "Iv1.74aecf988af67044" + clientSecret: "d0f38f58e98bb3dbb9a6bf6a2e1211a4feb24767" + accessTokenUri: https://github.com/login/oauth/access_token + userAuthorizationUri: https://github.com/login/oauth/authorize + userInfoUri: https://api.github.com/user + +