1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 15:01: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)); 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") @GetMapping("/complete")
public ResponseResult getComplete() { public ResponseResult getComplete() {
Long userId = WebUtil.getLoginUser().getUser().getId(); Long userId = WebUtil.getLoginUser().getUser().getId();

View File

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

View File

@@ -17,6 +17,8 @@ import java.util.List;
public interface IWorkService extends IService<Work> { public interface IWorkService extends IService<Work> {
List<Work> getAll(); List<Work> getAll();
List<Work> getTodo(Long userId); List<Work> getTodo(Long userId);
List<Work> getCard(Long userId);
List<Work> getComplete(Long userId); List<Work> getComplete(Long userId);
Work getOne(Long workId); 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.text.DecimalFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -55,6 +58,16 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
return workList; 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 @Override
public List<Work> getComplete(Long userId) { public List<Work> getComplete(Long userId) {
List<Work> workList = workMapper.getComplete(userId); List<Work> workList = workMapper.getComplete(userId);
@@ -100,6 +113,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
} }
@Override @Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean addWork(Work work) { public boolean addWork(Work work) {
boolean flag = true; boolean flag = true;
if (workMapper.insert(work) <= 0) { if (workMapper.insert(work) <= 0) {
@@ -119,6 +133,7 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
} }
@Override @Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean deleteByWorkId(Long workId) { public boolean deleteByWorkId(Long workId) {
boolean flag = false; boolean flag = false;
if (userWorkMapper.delete(new QueryWrapper<UserWork>().eq("work_id", workId)) > 0 && workMapper.deleteById(workId) > 0) { 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 @Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean updateStatus(UserWork userWork) { public boolean updateStatus(UserWork userWork) {
return userWorkMapper.update(userWork, new UpdateWrapper<UserWork>().eq("work_id", userWork.getWorkId()).eq("user_id", userWork.getUserId())) > 0; return userWorkMapper.update(userWork, new UpdateWrapper<UserWork>().eq("work_id", userWork.getWorkId()).eq("user_id", userWork.getUserId())) > 0;
} }
@Override @Override
@Transactional(isolation = Isolation.READ_COMMITTED,propagation = Propagation.REQUIRED)
public boolean updateWork(Work work) { public boolean updateWork(Work work) {
boolean flag = true; boolean flag = true;
if (userWorkMapper.delete(new QueryWrapper<UserWork>().eq("work_id", work.getId())) <= 0) { if (userWorkMapper.delete(new QueryWrapper<UserWork>().eq("work_id", work.getId())) <= 0) {

View File

@@ -93,6 +93,28 @@
and tuw.deleted = 0 and tuw.deleted = 0
order by w.deadline asc, w.id desc; order by w.deadline asc, w.id desc;
</select> </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 id="getComplete" parameterType="long" resultMap="workMap">
select w.id, select w.id,
content, content,

View File

@@ -0,0 +1 @@
<svg t="1684120425438" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4491" width="16" height="16"><path d="M874.666667 938.666667H149.333333c-36.266667 0-64-27.733333-64-64V277.333333c0-36.266667 27.733333-64 64-64h725.333334c36.266667 0 64 27.733333 64 64v597.333334c0 36.266667-27.733333 64-64 64zM149.333333 256c-12.8 0-21.333333 8.533333-21.333333 21.333333v597.333334c0 12.8 8.533333 21.333333 21.333333 21.333333h725.333334c12.8 0 21.333333-8.533333 21.333333-21.333333V277.333333c0-12.8-8.533333-21.333333-21.333333-21.333333H149.333333z" p-id="4492"></path><path d="M362.666667 341.333333c-12.8 0-21.333333-8.533333-21.333334-21.333333V149.333333c0-12.8 8.533333-21.333333 21.333334-21.333333s21.333333 8.533333 21.333333 21.333333v170.666667c0 12.8-8.533333 21.333333-21.333333 21.333333zM746.666667 512H490.666667c-12.8 0-21.333333-8.533333-21.333334-21.333333s8.533333-21.333333 21.333334-21.333334h256c12.8 0 21.333333 8.533333 21.333333 21.333334s-8.533333 21.333333-21.333333 21.333333zM746.666667 725.333333H490.666667c-12.8 0-21.333333-8.533333-21.333334-21.333333s8.533333-21.333333 21.333334-21.333333h256c12.8 0 21.333333 8.533333 21.333333 21.333333s-8.533333 21.333333-21.333333 21.333333zM661.333333 341.333333c-12.8 0-21.333333-8.533333-21.333333-21.333333V149.333333c0-12.8 8.533333-21.333333 21.333333-21.333333s21.333333 8.533333 21.333334 21.333333v170.666667c0 12.8-8.533333 21.333333-21.333334 21.333333zM341.333333 789.333333c-46.933333 0-85.333333-38.4-85.333333-85.333333s38.4-85.333333 85.333333-85.333333 85.333333 38.4 85.333334 85.333333-38.4 85.333333-85.333334 85.333333z m0-128c-23.466667 0-42.666667 19.2-42.666666 42.666667s19.2 42.666667 42.666666 42.666667 42.666667-19.2 42.666667-42.666667-19.2-42.666667-42.666667-42.666667zM324.266667 554.666667c-6.4 0-10.666667-2.133333-14.933334-6.4l-46.933333-49.066667c-8.533333-8.533333-8.533333-21.333333 0-29.866667 8.533333-8.533333 21.333333-8.533333 29.866667 0l32 34.133334 66.133333-68.266667c8.533333-8.533333 21.333333-8.533333 29.866667 0 8.533333 8.533333 8.533333 21.333333 0 29.866667l-81.066667 85.333333c-2.133333 2.133333-8.533333 4.266667-14.933333 4.266667z" p-id="4493"></path></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,94 @@
<template>
<el-card style="min-width: 640px">
<template #header>
<div class="card-header">
<h2>待办工作</h2>
<el-button class="button" text @click="pushTodo">查看更多</el-button>
</div>
</template>
<div v-for="item in tableData" :key="item" class="text item">
<el-row style="width: 100%">
<el-col :span="1" />
<el-col :span="1">
<el-avatar style="background-color: #5495f1">
<el-icon
color="white"
:size="SIZE_ICON_LG()"
style="vertical-align: center"
>
<icon-pinnacle-workpage />
</el-icon>
</el-avatar>
</el-col>
<el-col :span="1" />
<el-col :span="7"
><el-text size="large" style="color: black">{{ item.content }}</el-text>
</el-col>
<el-col :span="4" />
<el-col :span="7" style="text-align: right"
><el-text type="info">{{ formatDate(item.deadline) }}</el-text></el-col
>
<el-col :span="2" style="text-align: right"
><el-text type="info">截止</el-text></el-col
>
<el-col :span="1" />
</el-row>
</div>
</el-card>
</template>
<script lang="ts">
import request from '@/services'
import { SIZE_ICON_LG, SIZE_ICON_MD } from '@/constants/Common.constants'
export default {
data() {
return {
tableData: []
}
},
methods: {
SIZE_ICON_LG() {
return SIZE_ICON_LG
},
SIZE_ICON_MD() {
return SIZE_ICON_MD
},
formatDate(time) {
return new Date(time).toLocaleString()
},
getTableData() {
request
.get('/work/card')
.then((response) => {
this.tableData = response.data.data
})
.catch((reportError) => {
console.log(reportError)
})
},
pushTodo() {
this.$router.push('/work/task')
}
},
created() {
this.getTableData()
}
}
</script>
<style>
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
</style>