12 changed files with 1060 additions and 1 deletions
@ -0,0 +1,63 @@ |
|||
import request from '@/utils/request'; |
|||
import { AxiosPromise } from 'axios'; |
|||
import { QuickReplyVO, QuickReplyForm, QuickReplyQuery } from '@/api/im/quickReply/types'; |
|||
|
|||
/** |
|||
* 查询快捷回复列表 |
|||
* @param query |
|||
* @returns {*} |
|||
*/ |
|||
|
|||
export const listQuickReply = (query?: QuickReplyQuery): AxiosPromise<QuickReplyVO[]> => { |
|||
return request({ |
|||
url: '/im/quickReply/list', |
|||
method: 'get', |
|||
params: query |
|||
}); |
|||
}; |
|||
|
|||
/** |
|||
* 查询快捷回复详细 |
|||
* @param id |
|||
*/ |
|||
export const getQuickReply = (id: string | number): AxiosPromise<QuickReplyVO> => { |
|||
return request({ |
|||
url: '/im/quickReply/' + id, |
|||
method: 'get' |
|||
}); |
|||
}; |
|||
|
|||
/** |
|||
* 新增快捷回复 |
|||
* @param data |
|||
*/ |
|||
export const addQuickReply = (data: QuickReplyForm) => { |
|||
return request({ |
|||
url: '/im/quickReply', |
|||
method: 'post', |
|||
data: data |
|||
}); |
|||
}; |
|||
|
|||
/** |
|||
* 修改快捷回复 |
|||
* @param data |
|||
*/ |
|||
export const updateQuickReply = (data: QuickReplyForm) => { |
|||
return request({ |
|||
url: '/im/quickReply', |
|||
method: 'put', |
|||
data: data |
|||
}); |
|||
}; |
|||
|
|||
/** |
|||
* 删除快捷回复 |
|||
* @param id |
|||
*/ |
|||
export const delQuickReply = (id: string | number | Array<string | number>) => { |
|||
return request({ |
|||
url: '/im/quickReply/' + id, |
|||
method: 'delete' |
|||
}); |
|||
}; |
|||
@ -0,0 +1,95 @@ |
|||
export interface QuickReplyVO { |
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
id: string | number; |
|||
|
|||
/** |
|||
* 快捷回复名称 |
|||
*/ |
|||
replyName: string; |
|||
|
|||
/** |
|||
* 0-文本,1-图片 |
|||
*/ |
|||
replyType: number; |
|||
|
|||
/** |
|||
* 快捷回复标题 |
|||
*/ |
|||
replyTitle: string; |
|||
|
|||
/** |
|||
* 快捷回复内容 |
|||
*/ |
|||
replyContent: string; |
|||
|
|||
/** |
|||
* 快捷回复内容Url |
|||
*/ |
|||
replyContentUrl: string; |
|||
} |
|||
|
|||
export interface QuickReplyForm extends BaseEntity { |
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
id?: string | number; |
|||
|
|||
/** |
|||
* 快捷回复名称 |
|||
*/ |
|||
replyName?: string; |
|||
|
|||
/** |
|||
* 0-文本,1-图片 |
|||
*/ |
|||
replyType?: number; |
|||
|
|||
/** |
|||
* 快捷回复标题 |
|||
*/ |
|||
replyTitle?: string; |
|||
|
|||
/** |
|||
* 快捷回复内容 |
|||
*/ |
|||
replyContent?: string; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
remark?: string; |
|||
|
|||
} |
|||
|
|||
export interface QuickReplyQuery extends PageQuery { |
|||
|
|||
/** |
|||
* 快捷回复名称 |
|||
*/ |
|||
replyName?: string; |
|||
|
|||
/** |
|||
* 0-文本,1-图片 |
|||
*/ |
|||
replyType?: number; |
|||
|
|||
/** |
|||
* 快捷回复标题 |
|||
*/ |
|||
replyTitle?: string; |
|||
|
|||
/** |
|||
* 快捷回复内容 |
|||
*/ |
|||
replyContent?: string; |
|||
|
|||
/** |
|||
* 日期范围参数 |
|||
*/ |
|||
params?: any; |
|||
} |
|||
|
|||
|
|||
|
|||
@ -0,0 +1,269 @@ |
|||
<template> |
|||
<div class="p-2"> |
|||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> |
|||
<div v-show="showSearch" class="mb-[10px]"> |
|||
<el-card shadow="hover"> |
|||
<el-form ref="queryFormRef" :model="queryParams" :inline="true"> |
|||
<el-form-item label="快捷回复名称" prop="replyName"> |
|||
<el-input v-model="queryParams.replyName" placeholder="请输入快捷回复名称" clearable @keyup.enter="handleQuery" /> |
|||
</el-form-item> |
|||
<el-form-item label="0-文本,1-图片" prop="replyType"> |
|||
<el-select v-model="queryParams.replyType" placeholder="请选择0-文本,1-图片" clearable > |
|||
<el-option v-for="dict in file_type" :key="dict.value" :label="dict.label" :value="dict.value"/> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="快捷回复标题" prop="replyTitle"> |
|||
<el-input v-model="queryParams.replyTitle" placeholder="请输入快捷回复标题" clearable @keyup.enter="handleQuery" /> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> |
|||
<el-button icon="Refresh" @click="resetQuery">重置</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
</el-card> |
|||
</div> |
|||
</transition> |
|||
|
|||
<el-card shadow="never"> |
|||
<template #header> |
|||
<el-row :gutter="10" class="mb8"> |
|||
<el-col :span="1.5"> |
|||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['im:quickReply:add']">新增</el-button> |
|||
</el-col> |
|||
<el-col :span="1.5"> |
|||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['im:quickReply:edit']">修改</el-button> |
|||
</el-col> |
|||
<el-col :span="1.5"> |
|||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['im:quickReply:remove']">删除</el-button> |
|||
</el-col> |
|||
<el-col :span="1.5"> |
|||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['im:quickReply:export']">导出</el-button> |
|||
</el-col> |
|||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
|||
</el-row> |
|||
</template> |
|||
|
|||
<el-table v-loading="loading" :data="quickReplyList" @selection-change="handleSelectionChange"> |
|||
<el-table-column type="selection" width="55" align="center" /> |
|||
<el-table-column label="主键ID" align="center" prop="id" v-if="true" /> |
|||
<el-table-column label="快捷回复名称" align="center" prop="replyName" /> |
|||
<el-table-column label="0-文本,1-图片" align="center" prop="replyType"> |
|||
<template #default="scope"> |
|||
<dict-tag :options="file_type" :value="scope.row.replyType"/> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="快捷回复标题" align="center" prop="replyTitle" /> |
|||
<el-table-column label="快捷回复内容" align="center" prop="replyContentUrl" width="100"> |
|||
<template #default="scope"> |
|||
<image-preview :src="scope.row.replyContentUrl" :width="50" :height="50"/> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
|||
<template #default="scope"> |
|||
<el-tooltip content="修改" placement="top"> |
|||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['im:quickReply:edit']"></el-button> |
|||
</el-tooltip> |
|||
<el-tooltip content="删除" placement="top"> |
|||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['im:quickReply:remove']"></el-button> |
|||
</el-tooltip> |
|||
</template> |
|||
</el-table-column> |
|||
</el-table> |
|||
|
|||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> |
|||
</el-card> |
|||
<!-- 添加或修改快捷回复对话框 --> |
|||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> |
|||
<el-form ref="quickReplyFormRef" :model="form" :rules="rules" label-width="80px"> |
|||
<el-form-item label="快捷回复名称" prop="replyName"> |
|||
<el-input v-model="form.replyName" placeholder="请输入快捷回复名称" /> |
|||
</el-form-item> |
|||
<el-form-item label="0-文本,1-图片" prop="replyType"> |
|||
<el-select v-model="form.replyType" placeholder="请选择0-文本,1-图片"> |
|||
<el-option |
|||
v-for="dict in file_type" |
|||
:key="dict.value" |
|||
:label="dict.label" |
|||
:value="parseInt(dict.value)" |
|||
></el-option> |
|||
</el-select> |
|||
</el-form-item> |
|||
<el-form-item label="快捷回复标题" prop="replyTitle"> |
|||
<el-input v-model="form.replyTitle" placeholder="请输入快捷回复标题" /> |
|||
</el-form-item> |
|||
<el-form-item label="快捷回复内容" prop="replyContent"> |
|||
<image-upload v-model="form.replyContent"/> |
|||
</el-form-item> |
|||
<el-form-item label="备注" prop="remark"> |
|||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
|||
</el-form-item> |
|||
</el-form> |
|||
<template #footer> |
|||
<div class="dialog-footer"> |
|||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button> |
|||
<el-button @click="cancel">取 消</el-button> |
|||
</div> |
|||
</template> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script setup name="QuickReply" lang="ts"> |
|||
import { listQuickReply, getQuickReply, delQuickReply, addQuickReply, updateQuickReply } from '@/api/im/quickReply'; |
|||
import { QuickReplyVO, QuickReplyQuery, QuickReplyForm } from '@/api/im/quickReply/types'; |
|||
|
|||
const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
|||
const { file_type } = toRefs<any>(proxy?.useDict('file_type')); |
|||
|
|||
const quickReplyList = ref<QuickReplyVO[]>([]); |
|||
const buttonLoading = ref(false); |
|||
const loading = ref(true); |
|||
const showSearch = ref(true); |
|||
const ids = ref<Array<string | number>>([]); |
|||
const single = ref(true); |
|||
const multiple = ref(true); |
|||
const total = ref(0); |
|||
|
|||
const queryFormRef = ref<ElFormInstance>(); |
|||
const quickReplyFormRef = ref<ElFormInstance>(); |
|||
|
|||
const dialog = reactive<DialogOption>({ |
|||
visible: false, |
|||
title: '' |
|||
}); |
|||
|
|||
const initFormData: QuickReplyForm = { |
|||
id: undefined, |
|||
replyName: undefined, |
|||
replyType: undefined, |
|||
replyTitle: undefined, |
|||
replyContent: undefined, |
|||
remark: undefined, |
|||
} |
|||
const data = reactive<PageData<QuickReplyForm, QuickReplyQuery>>({ |
|||
form: {...initFormData}, |
|||
queryParams: { |
|||
pageNum: 1, |
|||
pageSize: 10, |
|||
replyName: undefined, |
|||
replyType: undefined, |
|||
replyTitle: undefined, |
|||
replyContent: undefined, |
|||
params: { |
|||
} |
|||
}, |
|||
rules: { |
|||
id: [ |
|||
{ required: true, message: "主键ID不能为空", trigger: "blur" } |
|||
], |
|||
replyName: [ |
|||
{ required: true, message: "快捷回复名称不能为空", trigger: "blur" } |
|||
], |
|||
replyType: [ |
|||
{ required: true, message: "0-文本,1-图片不能为空", trigger: "change" } |
|||
], |
|||
replyTitle: [ |
|||
{ required: true, message: "快捷回复标题不能为空", trigger: "blur" } |
|||
], |
|||
replyContent: [ |
|||
{ required: true, message: "快捷回复内容不能为空", trigger: "blur" } |
|||
], |
|||
} |
|||
}); |
|||
|
|||
const { queryParams, form, rules } = toRefs(data); |
|||
|
|||
/** 查询快捷回复列表 */ |
|||
const getList = async () => { |
|||
loading.value = true; |
|||
const res = await listQuickReply(queryParams.value); |
|||
quickReplyList.value = res.rows; |
|||
total.value = res.total; |
|||
loading.value = false; |
|||
} |
|||
|
|||
/** 取消按钮 */ |
|||
const cancel = () => { |
|||
reset(); |
|||
dialog.visible = false; |
|||
} |
|||
|
|||
/** 表单重置 */ |
|||
const reset = () => { |
|||
form.value = {...initFormData}; |
|||
quickReplyFormRef.value?.resetFields(); |
|||
} |
|||
|
|||
/** 搜索按钮操作 */ |
|||
const handleQuery = () => { |
|||
queryParams.value.pageNum = 1; |
|||
getList(); |
|||
} |
|||
|
|||
/** 重置按钮操作 */ |
|||
const resetQuery = () => { |
|||
queryFormRef.value?.resetFields(); |
|||
handleQuery(); |
|||
} |
|||
|
|||
/** 多选框选中数据 */ |
|||
const handleSelectionChange = (selection: QuickReplyVO[]) => { |
|||
ids.value = selection.map(item => item.id); |
|||
single.value = selection.length != 1; |
|||
multiple.value = !selection.length; |
|||
} |
|||
|
|||
/** 新增按钮操作 */ |
|||
const handleAdd = () => { |
|||
reset(); |
|||
dialog.visible = true; |
|||
dialog.title = "添加快捷回复"; |
|||
} |
|||
|
|||
/** 修改按钮操作 */ |
|||
const handleUpdate = async (row?: QuickReplyVO) => { |
|||
reset(); |
|||
const _id = row?.id || ids.value[0] |
|||
const res = await getQuickReply(_id); |
|||
Object.assign(form.value, res.data); |
|||
dialog.visible = true; |
|||
dialog.title = "修改快捷回复"; |
|||
} |
|||
|
|||
/** 提交按钮 */ |
|||
const submitForm = () => { |
|||
quickReplyFormRef.value?.validate(async (valid: boolean) => { |
|||
if (valid) { |
|||
buttonLoading.value = true; |
|||
if (form.value.id) { |
|||
await updateQuickReply(form.value).finally(() => buttonLoading.value = false); |
|||
} else { |
|||
await addQuickReply(form.value).finally(() => buttonLoading.value = false); |
|||
} |
|||
proxy?.$modal.msgSuccess("操作成功"); |
|||
dialog.visible = false; |
|||
await getList(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (row?: QuickReplyVO) => { |
|||
const _ids = row?.id || ids.value; |
|||
await proxy?.$modal.confirm('是否确认删除快捷回复编号为"' + _ids + '"的数据项?').finally(() => loading.value = false); |
|||
await delQuickReply(_ids); |
|||
proxy?.$modal.msgSuccess("删除成功"); |
|||
await getList(); |
|||
} |
|||
|
|||
/** 导出按钮操作 */ |
|||
const handleExport = () => { |
|||
proxy?.download('im/quickReply/export', { |
|||
...queryParams.value |
|||
}, `quickReply_${new Date().getTime()}.xlsx`) |
|||
} |
|||
|
|||
onMounted(() => { |
|||
getList(); |
|||
}); |
|||
</script> |
|||
@ -0,0 +1,105 @@ |
|||
package org.dromara.im.controller; |
|||
|
|||
import java.util.List; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.im.domain.vo.ImQuickReplyVo; |
|||
import org.dromara.im.domain.bo.ImQuickReplyBo; |
|||
import org.dromara.im.service.IImQuickReplyService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* 快捷回复 |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-13 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/im/quickReply") |
|||
public class ImQuickReplyController extends BaseController { |
|||
|
|||
private final IImQuickReplyService imQuickReplyService; |
|||
|
|||
/** |
|||
* 查询快捷回复列表 |
|||
*/ |
|||
@SaCheckPermission("im:quickReply:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo<ImQuickReplyVo> list(ImQuickReplyBo bo, PageQuery pageQuery) { |
|||
return imQuickReplyService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 导出快捷回复列表 |
|||
*/ |
|||
@SaCheckPermission("im:quickReply:export") |
|||
@Log(title = "快捷回复", businessType = BusinessType.EXPORT) |
|||
//@PostMapping("/export")
|
|||
public void export(ImQuickReplyBo bo, HttpServletResponse response) { |
|||
List<ImQuickReplyVo> list = imQuickReplyService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "快捷回复", ImQuickReplyVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取快捷回复详细信息 |
|||
* |
|||
* @param id 主键 |
|||
*/ |
|||
@SaCheckPermission("im:quickReply:query") |
|||
@GetMapping("/{id}") |
|||
public R<ImQuickReplyVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable Long id) { |
|||
return R.ok(imQuickReplyService.queryById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增快捷回复 |
|||
*/ |
|||
@SaCheckPermission("im:quickReply:add") |
|||
@Log(title = "快捷回复", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ImQuickReplyBo bo) { |
|||
return toAjax(imQuickReplyService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改快捷回复 |
|||
*/ |
|||
@SaCheckPermission("im:quickReply:edit") |
|||
@Log(title = "快捷回复", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ImQuickReplyBo bo) { |
|||
return toAjax(imQuickReplyService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除快捷回复 |
|||
* |
|||
* @param ids 主键串 |
|||
*/ |
|||
@SaCheckPermission("im:quickReply:remove") |
|||
@Log(title = "快捷回复", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] ids) { |
|||
return toAjax(imQuickReplyService.deleteWithValidByIds(List.of(ids), true)); |
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
package org.dromara.im.domain; |
|||
|
|||
import com.fhs.core.trans.vo.TransPojo; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import java.util.Date; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 快捷回复对象 im_quick_reply |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-13 |
|||
*/ |
|||
@Data |
|||
@TableName("im_quick_reply") |
|||
public class ImQuickReply implements TransPojo { |
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@TableId(value = "id") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 唯一token |
|||
*/ |
|||
private String uniqueToken; |
|||
|
|||
/** |
|||
* 快捷回复名称 |
|||
*/ |
|||
private String replyName; |
|||
|
|||
/** |
|||
* 0-文本,1-图片 |
|||
*/ |
|||
private Long replyType; |
|||
|
|||
/** |
|||
* 快捷回复标题 |
|||
*/ |
|||
private String replyTitle; |
|||
|
|||
/** |
|||
* 快捷回复内容 |
|||
*/ |
|||
private String replyContent; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 创建者ID |
|||
*/ |
|||
private Long creatorId; |
|||
|
|||
/** |
|||
* 更新者ID |
|||
*/ |
|||
private Long updaterId; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package org.dromara.im.domain.bo; |
|||
|
|||
import org.dromara.im.domain.ImQuickReply; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
import org.dromara.common.translation.annotation.Translation; |
|||
import java.util.Date; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import org.dromara.common.translation.constant.TransConstant; |
|||
|
|||
/** |
|||
* 快捷回复业务对象 im_quick_reply |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-13 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
@AutoMapper(target = ImQuickReply.class, reverseConvertGenerate = false) |
|||
public class ImQuickReplyBo extends BaseEntity { |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class }) |
|||
private Long id; |
|||
|
|||
/** |
|||
* 快捷回复名称 |
|||
*/ |
|||
@NotBlank(message = "快捷回复名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String replyName; |
|||
|
|||
/** |
|||
* 0-文本,1-图片 |
|||
*/ |
|||
@NotNull(message = "0-文本,1-图片不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private Long replyType; |
|||
|
|||
/** |
|||
* 快捷回复标题 |
|||
*/ |
|||
@NotBlank(message = "快捷回复标题不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String replyTitle; |
|||
|
|||
/** |
|||
* 快捷回复内容 |
|||
*/ |
|||
@NotBlank(message = "快捷回复内容不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String replyContent; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
package org.dromara.im.domain.vo; |
|||
|
|||
import org.dromara.common.translation.annotation.Translation; |
|||
import java.util.Date; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import org.dromara.common.translation.constant.TransConstant; |
|||
import org.dromara.im.domain.ImQuickReply; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import org.dromara.common.excel.annotation.ExcelDictFormat; |
|||
import org.dromara.common.excel.convert.ExcelDictConvert; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 快捷回复视图对象 im_quick_reply |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-13 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = ImQuickReply.class) |
|||
public class ImQuickReplyVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
@ExcelProperty(value = "主键ID") |
|||
private Long id; |
|||
|
|||
/** |
|||
* 快捷回复名称 |
|||
*/ |
|||
@ExcelProperty(value = "快捷回复名称") |
|||
private String replyName; |
|||
|
|||
/** |
|||
* 0-文本,1-图片 |
|||
*/ |
|||
@ExcelProperty(value = "0-文本,1-图片", converter = ExcelDictConvert.class) |
|||
@ExcelDictFormat(dictType = "file_type") |
|||
private Long replyType; |
|||
|
|||
/** |
|||
* 快捷回复标题 |
|||
*/ |
|||
@ExcelProperty(value = "快捷回复标题") |
|||
private String replyTitle; |
|||
|
|||
/** |
|||
* 快捷回复内容 |
|||
*/ |
|||
@ExcelProperty(value = "快捷回复内容") |
|||
private String replyContent; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package org.dromara.im.mapper; |
|||
|
|||
import org.dromara.im.domain.ImQuickReply; |
|||
import org.dromara.im.domain.vo.ImQuickReplyVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 快捷回复Mapper接口 |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-13 |
|||
*/ |
|||
public interface ImQuickReplyMapper extends BaseMapperPlus<ImQuickReply, ImQuickReplyVo> { |
|||
|
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
package org.dromara.im.service; |
|||
|
|||
import org.dromara.im.domain.vo.ImQuickReplyVo; |
|||
import org.dromara.im.domain.bo.ImQuickReplyBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 快捷回复Service接口 |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-13 |
|||
*/ |
|||
public interface IImQuickReplyService { |
|||
|
|||
/** |
|||
* 查询快捷回复 |
|||
* |
|||
* @param id 主键 |
|||
* @return 快捷回复 |
|||
*/ |
|||
ImQuickReplyVo queryById(Long id); |
|||
|
|||
/** |
|||
* 分页查询快捷回复列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 快捷回复分页列表 |
|||
*/ |
|||
TableDataInfo<ImQuickReplyVo> queryPageList(ImQuickReplyBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的快捷回复列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 快捷回复列表 |
|||
*/ |
|||
List<ImQuickReplyVo> queryList(ImQuickReplyBo bo); |
|||
|
|||
/** |
|||
* 新增快捷回复 |
|||
* |
|||
* @param bo 快捷回复 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(ImQuickReplyBo bo); |
|||
|
|||
/** |
|||
* 修改快捷回复 |
|||
* |
|||
* @param bo 快捷回复 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(ImQuickReplyBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除快捷回复信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
} |
|||
@ -0,0 +1,192 @@ |
|||
package org.dromara.im.service.impl; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.dromara.common.satoken.utils.LoginHelper; |
|||
import org.dromara.im.constant.ImConstant; |
|||
import org.dromara.im.service.IImAgentService; |
|||
import org.dromara.im.util.LambdaQueryWrapperHelper; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.im.domain.bo.ImQuickReplyBo; |
|||
import org.dromara.im.domain.vo.ImQuickReplyVo; |
|||
import org.dromara.im.domain.ImQuickReply; |
|||
import org.dromara.im.mapper.ImQuickReplyMapper; |
|||
import org.dromara.im.service.IImQuickReplyService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 快捷回复Service业务层处理 |
|||
* |
|||
* @author Blue |
|||
* @date 2026-04-13 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
@DS(ImConstant.DS_IM_PLATFORM) |
|||
public class ImQuickReplyServiceImpl implements IImQuickReplyService { |
|||
|
|||
private final ImQuickReplyMapper baseMapper; |
|||
|
|||
private final IImAgentService imAgentService; |
|||
|
|||
/** |
|||
* 查询快捷回复 |
|||
* |
|||
* @param id 主键 |
|||
* @return 快捷回复 |
|||
*/ |
|||
@Override |
|||
public ImQuickReplyVo queryById(Long id){ |
|||
LambdaQueryWrapper<ImQuickReply> lqw = Wrappers.lambdaQuery(); |
|||
lqw.eq(ImQuickReply::getId, id); |
|||
|
|||
if(!LoginHelper.isSuperAdmin()) { |
|||
LambdaQueryWrapperHelper.appendToken(lqw, ImQuickReply::getUniqueToken); |
|||
} |
|||
|
|||
return baseMapper.selectVoOne(lqw); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询快捷回复列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 快捷回复分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<ImQuickReplyVo> queryPageList(ImQuickReplyBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<ImQuickReply> lqw = buildQueryWrapper(bo); |
|||
Page<ImQuickReplyVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的快捷回复列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 快捷回复列表 |
|||
*/ |
|||
@Override |
|||
public List<ImQuickReplyVo> queryList(ImQuickReplyBo bo) { |
|||
LambdaQueryWrapper<ImQuickReply> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<ImQuickReply> buildQueryWrapper(ImQuickReplyBo bo) { |
|||
LambdaQueryWrapper<ImQuickReply> lqw = Wrappers.lambdaQuery(); |
|||
lqw.like(StringUtils.isNotBlank(bo.getReplyName()), ImQuickReply::getReplyName, bo.getReplyName()); |
|||
lqw.eq(bo.getReplyType() != null, ImQuickReply::getReplyType, bo.getReplyType()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getReplyTitle()), ImQuickReply::getReplyTitle, bo.getReplyTitle()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getReplyContent()), ImQuickReply::getReplyContent, bo.getReplyContent()); |
|||
|
|||
if(!LoginHelper.isSuperAdmin()) { |
|||
LambdaQueryWrapperHelper.appendToken(lqw, ImQuickReply::getUniqueToken); |
|||
} |
|||
|
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增快捷回复 |
|||
* |
|||
* @param bo 快捷回复 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(ImQuickReplyBo bo) { |
|||
ImQuickReply add = MapstructUtils.convert(bo, ImQuickReply.class); |
|||
|
|||
// 如果不是超级管理员,则设置 uniqueToken
|
|||
if(!LoginHelper.isSuperAdmin()) { |
|||
if (add != null) { |
|||
add.setUniqueToken(imAgentService.getTokenByUserId()); |
|||
} |
|||
} |
|||
|
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setId(add.getId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改快捷回复 |
|||
* |
|||
* @param bo 快捷回复 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(ImQuickReplyBo bo) { |
|||
ImQuickReply update = MapstructUtils.convert(bo, ImQuickReply.class); |
|||
if (update == null) { |
|||
return false; |
|||
} |
|||
validEntityBeforeSave(update); |
|||
|
|||
LambdaUpdateWrapper<ImQuickReply> updateWrapper = new LambdaUpdateWrapper<>(); |
|||
updateWrapper.eq(ImQuickReply::getId, update.getId()); |
|||
|
|||
if(!LoginHelper.isSuperAdmin()) { |
|||
// 使用当前用户的 token 而不是从 bo 中获取,防止篡改
|
|||
updateWrapper.eq(ImQuickReply::getUniqueToken, imAgentService.getTokenByUserId()); |
|||
} |
|||
|
|||
updateWrapper.set(ImQuickReply::getReplyName, update.getReplyName()); |
|||
updateWrapper.set(ImQuickReply::getReplyType, update.getReplyType()); |
|||
updateWrapper.set(ImQuickReply::getReplyTitle, update.getReplyTitle()); |
|||
updateWrapper.set(ImQuickReply::getReplyContent, update.getReplyContent()); |
|||
updateWrapper.set(ImQuickReply::getRemark, update.getRemark()); |
|||
|
|||
updateWrapper.set(ImQuickReply::getUpdaterId, LoginHelper.getUserId()); |
|||
updateWrapper.set(ImQuickReply::getUpdatedTime, DateUtil.date()); |
|||
|
|||
return baseMapper.update(null, updateWrapper) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(ImQuickReply entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除快捷回复信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
if (ids == null || ids.isEmpty()) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
LambdaUpdateWrapper<ImQuickReply> updateWrapper = new LambdaUpdateWrapper<>(); |
|||
updateWrapper.in(ImQuickReply::getId, ids); |
|||
|
|||
if(!LoginHelper.isSuperAdmin()) { |
|||
// 添加 uniqueToken 条件,确保只能删除当前用户的记录
|
|||
updateWrapper.eq(ImQuickReply::getUniqueToken, imAgentService.getTokenByUserId()); |
|||
} |
|||
|
|||
return baseMapper.delete(updateWrapper) > 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="org.dromara.im.mapper.ImQuickReplyMapper"> |
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue