PostController.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.sqx.modules.post.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.sqx.common.utils.Result;
  4. import com.sqx.modules.app.annotation.Login;
  5. import com.sqx.modules.post.entity.PostEntity;
  6. import com.sqx.modules.post.service.PostService;
  7. import com.sqx.modules.post.service.ViewPostService;
  8. import io.swagger.annotations.ApiOperation;
  9. import org.joda.time.LocalDateTime;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. @RestController
  13. @RequestMapping("/app/post")
  14. public class PostController {
  15. @Autowired
  16. private PostService postService;
  17. @Autowired
  18. private ViewPostService viewPostService;
  19. @GetMapping("getPostListOfUser")
  20. @ApiOperation("获取岗位列表")
  21. public Result getPostListOfUser() {
  22. return Result.success().put("data", postService.getPostListOfUser());
  23. }
  24. @Login
  25. @GetMapping("getPostOnly")
  26. @ApiOperation("获取岗位详细信息")
  27. public Result getPostListOne(Integer postId,@RequestAttribute("userId") Long userId) {
  28. viewPostService.addViewPost(postId,userId);
  29. return Result.success().put("data", postService.getPostListOne(postId));
  30. }
  31. @Login
  32. @GetMapping("getPostOnlyHr")
  33. @ApiOperation("获取岗位详细信息")
  34. public Result getPostListOneByHr(Integer postId) {
  35. return Result.success().put("data", postService.getPostListOne(postId));
  36. }
  37. @Login
  38. @PostMapping("addPost")
  39. @ApiOperation("增加岗位")
  40. public void addPost(@RequestAttribute("userId") Long userId,@RequestBody PostEntity postEntity) {
  41. postEntity.setUserId(userId);
  42. postService.saveOrUpdate(postEntity);
  43. }
  44. @PostMapping("changePostStatus")
  45. @ApiOperation("更改岗位状态岗位列表")
  46. public void changePostStatus(Integer postId, Integer status) {
  47. PostEntity postEntity1 = postService.getById(postId);
  48. postEntity1.setStatus(status);
  49. postService.updateById(postEntity1);
  50. }
  51. @GetMapping("findPost")
  52. @ApiOperation("查找岗位列表")
  53. public Result findPost(String address, Integer wage, Integer edu, Integer companyPeople, String key) {
  54. return Result.success().put("data", postService.findPost(address, wage, edu, companyPeople, key));
  55. }
  56. @PostMapping("changePost")
  57. @ApiOperation("更改岗位状态岗位列表")
  58. public Result changePost(@RequestBody PostEntity postEntity) {
  59. postEntity.setUpdateTime(String.valueOf(LocalDateTime.now()));
  60. postService.saveOrUpdate(postEntity);
  61. return Result.success();
  62. }
  63. @Login
  64. @GetMapping("getMyPost")
  65. @ApiOperation("获取我发布的岗位详细信息")
  66. public Result getPostListOne(@RequestAttribute("userId") Integer userId) {
  67. QueryWrapper<PostEntity> queryWrapper = new QueryWrapper<>();
  68. queryWrapper.eq("user_id",userId);
  69. return Result.success().put("data", postService.getBaseMapper().selectList(queryWrapper));
  70. }
  71. }