Skip to content

Commit

Permalink
Merge pull request #76 from cheng521521/main
Browse files Browse the repository at this point in the history
feat:添加招聘模块的update,批量更新,批量添加成员
  • Loading branch information
yanyanho authored Dec 10, 2023
2 parents 3ff23ed + c66ee58 commit 6bf3968
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ https://github.com/spruceid/siwe-go/blob/main/message.go
```
ssh [email protected]
./gradlew build -x test
scp ./dist/apps/dl.jar [email protected]:/root/Official-website-backend/dist/app
scp ./dist/apps/dl.jar [email protected]:/root/Official-website-backend/dist/apps
```

Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/dl/officialsite/hiring/HireController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -77,4 +77,13 @@ public BaseResponse all(@RequestParam String address,@RequestParam List<String>
return BaseResponse.successWithData(hiringVOList);
}

/**
* 按照创建者查看简历
*/
@GetMapping("/address")
public BaseResponse all(@RequestParam String address) {
List<HiringVO> hiringVOList = hireService.selectByAddress(address);
return BaseResponse.successWithData(hiringVOList);
}

}
10 changes: 10 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/HireRepository.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,4 +12,11 @@
* @Description TODO
**/
public interface HireRepository extends JpaRepository<Hiring, Long> {


/**
* 根据地址查询所有简历
*/
@Query(value = "select * from hiring where address = :address", nativeQuery = true)
List<Hiring> findAllByAddress(@Param("address")String address);
}
33 changes: 32 additions & 1 deletion src/main/java/com/dl/officialsite/hiring/HireService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -50,6 +50,8 @@ public void add(HiringVO hiringVO) {
hiringSkill.setHiringId(hiring.getId());
hiringSkillRepository.save(hiringSkill);
});
hiringVO.setId(hiring.getId());
return hiringVO;
}

public Page<HiringVO> all(Pageable pageable) {
Expand Down Expand Up @@ -172,4 +174,33 @@ public void update(HiringVO hiringVO) {
hiringSkillRepository.save(hiringSkill);
});
}

public List<HiringVO> selectByAddress(String address) {
List<HiringVO> list = new ArrayList<>();
hireRepository.findAllByAddress(address).forEach(hiring -> {
HiringVO hiringVO = new HiringVO();
BeanUtils.copyProperties(hiring, hiringVO);
List<HiringSkill> hiringSkills = hiringSkillRepository.findByHiringId(hiring.getId());
List<HiringSkillVO> 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<HiringSkillVO> 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;
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/Hiring.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ public class Hiring {
@Column(updatable = false, nullable = false)
private Date createTime;

private String address;

}
12 changes: 12 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/vo/HiringVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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<HiringSkillVO> mainSkills;

private List<HiringSkillVO> otherSkills;

@NotBlank(message = "公司不能为空")
private String company;

private String invoice;

@NotNull(message = "最小年薪不能为空")
private int minYearlySalary;

@NotNull(message = "最大年薪不能为空")
private int maxYearlySalary;

private String benefits;
Expand All @@ -42,4 +52,6 @@ public class HiringVO {

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

private String address;
}
8 changes: 3 additions & 5 deletions src/main/java/com/dl/officialsite/team/Team.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/dl/officialsite/team/TeamController.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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;
import com.dl.officialsite.team.vo.TeamMemberJoinVO;
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;
Expand All @@ -33,11 +36,21 @@ public class TeamController {
@Autowired
private TeamService teamService;

@GetMapping("/admin/list")
BaseResponse list(@RequestParam String address) {
List<String> 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);
}
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/dl/officialsite/team/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() + "团队成员退出";
Expand Down Expand Up @@ -234,7 +235,7 @@ public TeamsMembersVo getTeamById(Long teamId) {
TeamsMembersVo teamsMembersVo = new TeamsMembersVo();
Team team = optional.get();
List<Member> members = new ArrayList<>();
List<Long> memberIds = teamMemberRepository.findByTeamId(team.getId());
List<Long> memberIds = teamMemberRepository.findByTeamIdStatus(team.getId(), Constants.APPROVE_TEAM);
memberIds.stream().forEach(memberId -> {
Member member = memberRepository.findById(memberId).get();
members.add(member);
Expand All @@ -249,6 +250,7 @@ public TeamsMembersVo getTeamById(Long teamId) {
}

public void batchJoin(TeamMemberBatchJoinVO teamMembers) {

teamMembers.getMemberIds().forEach(memberId -> {
Optional<TeamMember> optional = teamMemberRepository.findByTeamAndMember(
teamMembers.getTeamId(), memberId);
Expand Down
60 changes: 60 additions & 0 deletions src/main/resources/application-cpx.yml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
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


0 comments on commit 6bf3968

Please sign in to comment.