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

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

View File

@ -1,7 +1,6 @@
package com.ruoyi.system.domain.vo; package com.ruoyi.system.domain.vo;
import com.ruoyi.common.translation.annotation.Translation; import com.mybatisflex.annotation.RelationOneToOne;
import com.ruoyi.common.translation.constant.TransConstant;
import lombok.Data; import lombok.Data;
import java.io.Serial; import java.io.Serial;
@ -56,10 +55,16 @@ public class SysNoticeVo implements Serializable {
*/ */
private Long createBy; 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; private String createByName;
/** /**

View File

@ -5,8 +5,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.mybatisflex.annotation.ColumnMask; import com.mybatisflex.annotation.ColumnMask;
import com.mybatisflex.annotation.RelationOneToOne; import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.core.mask.Masks; 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 com.ruoyi.system.domain.SysUser;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data; 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.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.system.domain.bo.SysNoticeBo; import com.ruoyi.system.domain.bo.SysNoticeBo;
import com.ruoyi.system.domain.vo.SysNoticeVo; import com.ruoyi.system.domain.vo.SysNoticeVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.mapper.SysNoticeMapper; import com.ruoyi.system.mapper.SysNoticeMapper;
@ -28,6 +29,9 @@ import static com.ruoyi.system.domain.table.SysNoticeTableDef.SYS_NOTICE;
*/ */
@Service @Service
public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService { public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
@Resource
private SysNoticeMapper noticeMapper;
@Override @Override
public QueryWrapper query() { public QueryWrapper query() {
return super.query().from(SYS_NOTICE); return super.query().from(SYS_NOTICE);
@ -75,7 +79,7 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
@Override @Override
public List<SysNoticeVo> selectNoticeList(SysNoticeBo noticeBo) { public List<SysNoticeVo> selectNoticeList(SysNoticeBo noticeBo) {
QueryWrapper queryWrapper = buildQueryWrapper(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 @Override
public TableDataInfo<SysNoticeVo> selectPage(SysNoticeBo noticeBo) { public TableDataInfo<SysNoticeVo> selectPage(SysNoticeBo noticeBo) {
QueryWrapper queryWrapper = buildQueryWrapper(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); return TableDataInfo.build(page);
} }