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

temp 2023/5/3

This commit is contained in:
GGB
2023-05-03 15:38:49 +08:00
parent 9b33b1061d
commit 41b6c77509
15 changed files with 187 additions and 123 deletions

View File

@@ -52,18 +52,23 @@ public class WorkController {
@PostMapping
public ResponseResult addWork(@RequestBody Work work) {
System.out.println(work);
return ResponseResult.build(ResponseCode.DATABASE_SAVE_OK, "success", workService.addWork(work));
}
@DeleteMapping("/{id}")
public ResponseResult deleteById(@PathVariable long id) {
public ResponseResult deleteById(@PathVariable Long id) {
System.out.println(id);
return ResponseResult.build(ResponseCode.DATABASE_DELETE_OK, "success", workService.deleteByWorkId(id));
}
@PutMapping("/setComplete")
public ResponseResult updateWork(@RequestBody UserWork userWork) {
return ResponseResult.build(ResponseCode.DATABASE_DELETE_OK, "success", userWorkService.updateById(userWork));
@PutMapping("/setStatus")
public ResponseResult updateStatus(@RequestBody UserWork userWork) {
System.out.println(userWork);
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", workService.updateStatus(userWork));
}
@PutMapping
public ResponseResult updateWork(@RequestBody Work work) {
return ResponseResult.build(ResponseCode.DATABASE_UPDATE_OK, "success", workService.updateWork(work));
}
}

View File

@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.annotation.Version;
import java.io.Serial;
import java.io.Serializable;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -29,6 +31,7 @@ public class User implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("id")
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
/**

View File

@@ -1,5 +1,6 @@
package com.cfive.pinnacle.service;
import com.cfive.pinnacle.entity.UserWork;
import com.cfive.pinnacle.entity.Work;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -23,4 +24,8 @@ public interface IWorkService extends IService<Work> {
String getUserName(Long userId);
boolean addWork(Work work);
boolean deleteByWorkId(Long wid);
boolean updateStatus(UserWork userWork);
boolean updateWork(Work work);
}

View File

@@ -17,5 +17,4 @@ import org.springframework.stereotype.Service;
@Service
public class UserWorkServiceImpl extends ServiceImpl<UserWorkMapper, UserWork> implements IUserWorkService {
}

View File

@@ -1,6 +1,7 @@
package com.cfive.pinnacle.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cfive.pinnacle.entity.User;
import com.cfive.pinnacle.entity.UserWork;
import com.cfive.pinnacle.entity.Work;
@@ -43,12 +44,22 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
@Override
public List<Work> getTodo(Long userId) {
return workMapper.getTodo(userId);
List<Work> workList = workMapper.getTodo(userId);
for (Work work:
workList) {
work.setPublisherName(getUserName(work.getPublisherId()));
}
return workList;
}
@Override
public List<Work> getComplete(Long userId) {
return workMapper.getComplete(userId);
List<Work> workList = workMapper.getComplete(userId);
for (Work work:
workList) {
work.setPublisherName(getUserName(work.getPublisherId()));
}
return workList;
}
@Override
@@ -67,9 +78,9 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
@Override
public boolean addWork(Work work) {
boolean flag = false;
if (workMapper.insert(work) > 0) {
flag = true;
boolean flag = true;
if (workMapper.insert(work) <= 0) {
flag = false;
}
long workId = work.getId();
for (User user :
@@ -93,5 +104,31 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
return flag;
}
@Override
public boolean updateStatus(UserWork userWork) {
return userWorkMapper.update(userWork, new UpdateWrapper<UserWork>().eq("work_id", userWork.getWorkId()).eq("user_id", userWork.getUserId())) > 0;
}
@Override
public boolean updateWork(Work work) {
boolean flag = true;
if (userWorkMapper.delete(new QueryWrapper<UserWork>().eq("work_id", work.getId())) <= 0) {
flag = false;
}
if (workMapper.updateById(work)<=0) {
flag = false;
}
for (User user :
work.getWorker()) {
UserWork userWork = new UserWork();
userWork.setWorkId(work.getId());
userWork.setUserId(user.getId());
if (userWorkMapper.insert(userWork) <= 0) {
flag = false;
}
}
return flag;
}
}