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

Add homepage work card

This commit is contained in:
GGB
2023-05-15 11:24:49 +08:00
parent e303711bfd
commit c7efa1980a
7 changed files with 144 additions and 1 deletions

View File

@@ -50,6 +50,13 @@ public class WorkController {
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getTodo(userId));
}
@GetMapping("/card")
public ResponseResult getCard() {
// Long userId = WebUtil.getLoginUser().getUser().getId();
long userId = 1;
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getCard(userId));
}
@GetMapping("/complete")
public ResponseResult getComplete() {
Long userId = WebUtil.getLoginUser().getUser().getId();

View File

@@ -19,7 +19,7 @@ public interface WorkMapper extends BaseMapper<Work> {
List<Work> getAll();
List<Work> getTodo(Long userId);
List<Work> getCard(Long userId);
List<Work> getComplete(Long userId);
Work getWork(Long workId);

View File

@@ -17,6 +17,8 @@ import java.util.List;
public interface IWorkService extends IService<Work> {
List<Work> getAll();
List<Work> getTodo(Long userId);
List<Work> getCard(Long userId);
List<Work> getComplete(Long userId);
Work getOne(Long workId);

View File

@@ -13,6 +13,9 @@ import com.cfive.pinnacle.service.IWorkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
@@ -55,6 +58,16 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
return workList;
}
@Override
public List<Work> getCard(Long userId) {
List<Work> workList = workMapper.getCard(userId);
for (Work work:
workList) {
work.setPublisherName(getUserName(work.getPublisherId()));
}
return workList;
}
@Override
public List<Work> getComplete(Long userId) {
List<Work> workList = workMapper.getComplete(userId);
@@ -100,6 +113,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean addWork(Work work) {
boolean flag = true;
if (workMapper.insert(work) <= 0) {
@@ -119,6 +133,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean deleteByWorkId(Long workId) {
boolean flag = false;
if (userWorkMapper.delete(new QueryWrapper<UserWork>().eq("work_id", workId)) > 0 && workMapper.deleteById(workId) > 0) {
@@ -128,11 +143,13 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean updateStatus(UserWork userWork) {
return userWorkMapper.update(userWork, new UpdateWrapper<UserWork>().eq("work_id", userWork.getWorkId()).eq("user_id", userWork.getUserId())) > 0;
}
@Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean updateWork(Work work) {
boolean flag = true;
if (userWorkMapper.delete(new QueryWrapper<UserWork>().eq("work_id", work.getId())) <= 0) {

View File

@@ -93,6 +93,28 @@
and tuw.deleted = 0
order by w.deadline asc, w.id desc;
</select>
<select id="getCard" parameterType="long" resultMap="workMap">
select w.id,
content,
publisher_id,
create_time,
deadline,
tuw.user_id worker_id,
u.username worker_name,
tuw.status status
from t_work w,
t_user u,
t_user_work tuw
where w.id = tuw.work_id
and tuw.user_id = u.id
and tuw.user_id = #{userId}
and status = false
and w.deleted = 0
and tuw.deleted = 0
order by w.deadline asc, w.id desc
limit 5;
</select>
<select id="getComplete" parameterType="long" resultMap="workMap">
select w.id,
content,