Skip to content

Commit

Permalink
mq
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron committed Dec 9, 2023
2 parents e36c744 + c7d8f4a commit 71240d1
Show file tree
Hide file tree
Showing 18 changed files with 502 additions and 42 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/common/constants/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions src/main/java/com/dl/officialsite/common/enums/CodeEnums.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ public enum CodeEnums {
TEAM_ADMIN_NOT_EXIST("1006", "team admin not exist"),
MEMBER_ALREADY_REQUEST_TEAM("1007", "member already request team"),

NOT_FOUND_JD("1008", "not found jd"),
//Sharing
SHARING_NOT_FOUND("5001", "Sharing not found"),
SHARING_NOT_OWNER("5002", "You are no sharing user"),

SHARING_LOCKED("5003", "Sharing locked, please contact admin to unlock");




private String code;

private String msg;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/dl/officialsite/config/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
80 changes: 80 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/HireController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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.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.PutMapping;
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;

/**
* @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(@RequestParam String address,@RequestBody HiringVO hiringVO) {
hireService.add(hiringVO);
return BaseResponse.successWithData(null);
}

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

/**
* 查询简历详情
*/
@GetMapping
public BaseResponse detail(@RequestParam String address,@RequestParam Long id) {
HiringVO hiringVO = hireService.detail(id);
return BaseResponse.successWithData(hiringVO);
}

/**
* 查询所有简历
*/
@GetMapping("/all")
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<HiringVO> all = hireService.all(pageable);
return BaseResponse.successWithData(all);
}

/**
* 按照类型查看简历
*/
@GetMapping("/type")
public BaseResponse all(@RequestParam String address,@RequestParam List<String> skills) {
List<HiringVO> hiringVOList = hireService.selectBySkills(skills);
return BaseResponse.successWithData(hiringVOList);
}

}
12 changes: 12 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/HireRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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<Hiring, Long> {
}
175 changes: 175 additions & 0 deletions src/main/java/com/dl/officialsite/hiring/HireService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
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.HiringSkillVO;
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;

/**
* @ClassName HireService
* @Author jackchen
* @Date 2023/11/7 10:45
* @Description HireService
**/
@Service
public class HireService {

@Autowired
private HireRepository hireRepository;

@Autowired
private HiringSkillRepository hiringSkillRepository;

public void add(HiringVO hiringVO) {
Hiring hiring = new Hiring();
BeanUtils.copyProperties(hiringVO, hiring);
hireRepository.save(hiring);
hiringVO.getMainSkills().forEach(mainSkill -> {
HiringSkill hiringSkill = new HiringSkill();
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();
BeanUtils.copyProperties(otherSkill, hiringSkill);
hiringSkill.setType(Constants.HIRING_OTHER_SKILL);
hiringSkill.setHiringId(hiring.getId());
hiringSkillRepository.save(hiringSkill);
});
}

public Page<HiringVO> all(Pageable pageable) {
List<HiringVO> hiringVOList = new ArrayList<>();;
Page<Hiring> hiringPage = hireRepository.findAll(pageable);
hiringPage.getContent().forEach(hiring -> {
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(mainSkills);
hiringVO.setOtherSkills(otherSkills);
hiringVOList.add(hiringVO);
});
Page<HiringVO> hiringVOPage = new PageImpl<>(hiringVOList, pageable, hiringPage.getTotalElements());
return hiringVOPage;
}

public HiringVO detail(Long id) {
HiringVO hiringVO = new HiringVO();
Hiring hiring = hireRepository.findById(id)
.orElseThrow(() -> new BizException(NOT_FOUND_JD.getCode(), NOT_FOUND_JD.getMsg()));
BeanUtils.copyProperties(hiring, hiringVO);
List<HiringSkill> hiringSkills = hiringSkillRepository.findByHiringId(id);
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);
return hiringVO;
}

public List<HiringVO> selectBySkills(List<String> skills) {
//使用in查询
List<HiringSkill> hiringSkills = hiringSkillRepository.findBySkill(skills);
//去重通过hiringId
List<Long> hiringIds = hiringSkills.stream().map(HiringSkill::getHiringId).distinct().collect(Collectors.toList());
List<HiringVO> hiringVOList = new ArrayList<>();
hireRepository.findAllById(hiringIds).forEach(hiring -> {
HiringVO hiringVO = new HiringVO();
BeanUtils.copyProperties(hiring, hiringVO);
List<HiringSkillVO> mainSkills = hiringSkills.stream()
.filter(hiringSkill -> hiringSkill.getHiringId().equals(hiring.getId()))
.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);
});
}
}
50 changes: 40 additions & 10 deletions src/main/java/com/dl/officialsite/hiring/Hiring.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
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
@Table(name = "hiring")
public class Hiring {
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 contact;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String position;

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;

}
Loading

0 comments on commit 71240d1

Please sign in to comment.