通知公告模块“创建者”显示使用用户表的用户名称

This commit is contained in:
dataprince 2023-12-03 14:34:43 +08:00
parent 48043d1261
commit 41cfdd4f74
4 changed files with 15 additions and 8 deletions

View File

@ -78,7 +78,7 @@
<dict-tag :options="sys_notice_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="创建者" align="center" prop="createBy" width="100" />
<el-table-column label="创建者" align="center" prop="createByName" width="100" />
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>

View File

@ -1,7 +1,6 @@
package com.ruoyi.system.domain.vo;
import com.ruoyi.common.translation.annotation.Translation;
import com.ruoyi.common.translation.constant.TransConstant;
import com.mybatisflex.annotation.RelationOneToOne;
import lombok.Data;
import java.io.Serial;
@ -56,10 +55,16 @@ public class SysNoticeVo implements Serializable {
*/
private Long createBy;
/**
* 创建人名称
*/
@Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "createBy")
@RelationOneToOne(
selfField = "createBy",
targetTable = "sys_user",
targetField = "userId",
valueField = "userName"
)
private String createByName;
/**

View File

@ -5,8 +5,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.mybatisflex.annotation.ColumnMask;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.core.mask.Masks;
import com.ruoyi.common.translation.annotation.Translation;
import com.ruoyi.common.translation.constant.TransConstant;
import com.ruoyi.system.domain.SysUser;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;

View File

@ -13,6 +13,7 @@ import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.system.domain.bo.SysNoticeBo;
import com.ruoyi.system.domain.vo.SysNoticeVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.mapper.SysNoticeMapper;
@ -28,6 +29,9 @@ import static com.ruoyi.system.domain.table.SysNoticeTableDef.SYS_NOTICE;
*/
@Service
public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
@Resource
private SysNoticeMapper noticeMapper;
@Override
public QueryWrapper query() {
return super.query().from(SYS_NOTICE);
@ -75,7 +79,7 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
@Override
public List<SysNoticeVo> selectNoticeList(SysNoticeBo noticeBo) {
QueryWrapper queryWrapper = buildQueryWrapper(noticeBo);
return this.listAs(queryWrapper, SysNoticeVo.class);
return noticeMapper.selectListWithRelationsByQueryAs(queryWrapper, SysNoticeVo.class);
}
/**
@ -87,7 +91,7 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
@Override
public TableDataInfo<SysNoticeVo> selectPage(SysNoticeBo noticeBo) {
QueryWrapper queryWrapper = buildQueryWrapper(noticeBo);
Page<SysNoticeVo> page = this.pageAs(PageQuery.build(), queryWrapper, SysNoticeVo.class);
Page<SysNoticeVo> page = noticeMapper.paginateWithRelationsAs(PageQuery.build(), queryWrapper, SysNoticeVo.class);
return TableDataInfo.build(page);
}