1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Add employee personal information

This commit is contained in:
GGB
2023-05-28 22:11:30 +08:00
parent f772b39964
commit 11e122df0b
9 changed files with 129 additions and 80 deletions

View File

@@ -1,15 +1,22 @@
package com.cfive.pinnacle.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.cfive.pinnacle.entity.User;
import com.cfive.pinnacle.entity.UserWork;
import com.cfive.pinnacle.entity.Work;
import com.cfive.pinnacle.entity.common.ResponseCode;
import com.cfive.pinnacle.entity.common.ResponseResult;
import com.cfive.pinnacle.service.IUserWorkService;
import com.cfive.pinnacle.service.IWorkService;
import com.cfive.pinnacle.service.impl.UserWorkServiceImpl;
import com.cfive.pinnacle.service.impl.WorkServiceImpl;
import com.cfive.pinnacle.utils.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -27,87 +34,72 @@ import java.util.List;
public class WorkController {
@Autowired
private IWorkService workService;
@GetMapping
@PreAuthorize("hasAuthority('work:manage:get')")
public ResponseResult<List<Work>> getAll(String content) {
if (content != null) {
List<Work> workList = workService.getWorkByContent(content);
return ResponseResult.databaseSelectSuccess(workList);
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success",workList);
} else {
return ResponseResult.databaseSelectSuccess(workService.getAll());
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getAll());
}
}
@GetMapping("/todo")
@PreAuthorize("hasAuthority('work:self:get')")
public ResponseResult<List<Work>> getTodo() {
Long userId = WebUtil.getLoginUser().getUser().getId();
return ResponseResult.databaseSelectSuccess(workService.getTodo(userId));
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getTodo(userId));
}
@GetMapping("/card")
public ResponseResult<List<Work>> getCard() {
if (WebUtil.hasAuthority("work:self:home")) {
Long userId = WebUtil.getLoginUser().getUser().getId();
return ResponseResult.databaseSelectSuccess(workService.getCard(userId));
}
return ResponseResult.databaseSelectSuccess(List.of());
Long userId = WebUtil.getLoginUser().getUser().getId();
// long userId = 1;
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getCard(userId));
}
@GetMapping("/complete")
@PreAuthorize("hasAuthority('work:self:get')")
public ResponseResult<List<Work>> getComplete() {
Long userId = WebUtil.getLoginUser().getUser().getId();
return ResponseResult.databaseSelectSuccess(workService.getComplete(userId));
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getComplete(userId));
}
@GetMapping("/{workId}")
@PreAuthorize("hasAuthority('work:self:detail') and hasAuthority('work:self:get')")
public ResponseResult<Work> getOne(@PathVariable Long workId) {
return ResponseResult.databaseSelectSuccess(workService.getOne(workId));
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success",workService.getOne(workId));
}
@PostMapping
@PreAuthorize("hasAuthority('work:manage:add')")
public ResponseResult<Work> addWork(@RequestBody Work work) {
public ResponseResult<?> addWork(@RequestBody Work work) {
work.setPublisherId(WebUtil.getLoginUser().getUser().getId());
if (workService.addWork(work)) {
return ResponseResult.databaseSaveSuccess(work);
} else {
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "Add failed", null);
}
if(workService.addWork(work)){
return ResponseResult.build(ResponseCode.DATABASE_SAVE_OK, "success", null);
}else
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "error", null);
}
@DeleteMapping("/{id}")
@PreAuthorize("hasAuthority('work:manage:delete')")
public ResponseResult<?> deleteById(@PathVariable Long id) {
if (workService.deleteByWorkId(id)) {
return ResponseResult.databaseDeleteSuccess();
} else {
return ResponseResult.build(ResponseCode.DATABASE_DELETE_ERROR, "Delete failed", null);
}
if(workService.deleteByWorkId(id)){
return ResponseResult.build(ResponseCode.DATABASE_DELETE_OK, "success", null);
}else
return ResponseResult.build(ResponseCode.DATABASE_DELETE_ERROR, "error", null);
}
@PutMapping("/setStatus")
@PreAuthorize("hasAuthority('work:self:status') and hasAuthority('work:self:get')")
public ResponseResult<UserWork> updateStatus(@RequestBody UserWork userWork) {
@PutMapping("/set_status")
public ResponseResult<?> updateStatus(@RequestBody UserWork userWork) {
userWork.setUserId(WebUtil.getLoginUser().getUser().getId());
if (workService.updateStatus(userWork)) {
return ResponseResult.databaseUpdateSuccess(userWork);
} else {
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "Update failed", null);
}
if(workService.updateStatus(userWork)){
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", null);
}else
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "error", null);
}
@PutMapping
@PreAuthorize("hasAuthority('work:manage:modify')")
public ResponseResult<Work> updateWork(@RequestBody Work work) {
public ResponseResult<?> updateWork(@RequestBody Work work) {
work.setPublisherId(WebUtil.getLoginUser().getUser().getId());
if (workService.updateWork(work)) {
return ResponseResult.databaseUpdateSuccess(work);
} else {
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "Update failed", null);
}
if(workService.updateWork(work)){
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", null);
}else
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_ERROR, "error", null);
}
}

View File

@@ -36,42 +36,21 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
private UserMapper userMapper;
@Override
public List<Work> getAll() {
// List<Work> workList = workMapper.getAll();
// for (Work work:
// workList) {
// work.setProgress(getProgress(work.getId()));
// work.setPublisherName(getUserName(work.getPublisherId()));
// }
return workMapper.getAll();
}
@Override
public List<Work> getTodo(Long userId) {
// List<Work> workList = workMapper.getTodo(userId);
// for (Work work:
// workList) {
// work.setPublisherName(getUserName(work.getPublisherId()));
// }
return workMapper.getTodo(userId);
}
@Override
public List<Work> getCard(Long userId) {
// List<Work> workList = workMapper.getCard(userId);
// for (Work work:
// workList) {
// work.setPublisherName(getUserName(work.getPublisherId()));
// }
return workMapper.getCard(userId);
}
@Override
public List<Work> getComplete(Long userId) {
// List<Work> workList = workMapper.getComplete(userId);
// for (Work work:
// workList) {
// work.setPublisherName(getUserName(work.getPublisherId()));
// }
return workMapper.getComplete(userId);
}
@@ -85,12 +64,6 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
@Override
public List<Work> getWorkByContent(String content) {
// List<Work> workList = workMapper.getWorkByContent(content);
// for (Work work:
// workList) {
// work.setProgress(getProgress(work.getId()));
// work.setPublisherName(getUserName(work.getPublisherId()));
// }
return workMapper.getWorkByContent(content);
}