Kaynağa Gözat

feat:【system】短信管理的优化:api 拆分

YunaiV 4 ay önce
ebeveyn
işleme
968f345839

+ 45 - 0
src/api/system/sms/channel/index.ts

@@ -0,0 +1,45 @@
+import type { PageParam, PageResult } from '@/http/types'
+import { http } from '@/http/http'
+
+/** 短信渠道信息 */
+export interface SmsChannel {
+  id?: number
+  code: string
+  status: number
+  signature: string
+  remark?: string
+  apiKey: string
+  apiSecret?: string
+  callbackUrl?: string
+  createTime?: Date
+}
+
+/** 获取短信渠道分页列表 */
+export function getSmsChannelPage(params: PageParam) {
+  return http.get<PageResult<SmsChannel>>('/system/sms-channel/page', params)
+}
+
+/** 获取短信渠道精简列表 */
+export function getSimpleSmsChannelList() {
+  return http.get<SmsChannel[]>('/system/sms-channel/simple-list')
+}
+
+/** 获取短信渠道详情 */
+export function getSmsChannel(id: number) {
+  return http.get<SmsChannel>(`/system/sms-channel/get?id=${id}`)
+}
+
+/** 创建短信渠道 */
+export function createSmsChannel(data: SmsChannel) {
+  return http.post<number>('/system/sms-channel/create', data)
+}
+
+/** 更新短信渠道 */
+export function updateSmsChannel(data: SmsChannel) {
+  return http.put<boolean>('/system/sms-channel/update', data)
+}
+
+/** 删除短信渠道 */
+export function deleteSmsChannel(id: number) {
+  return http.delete<boolean>(`/system/sms-channel/delete?id=${id}`)
+}

+ 0 - 138
src/api/system/sms/index.ts

@@ -1,138 +0,0 @@
-import type { PageParam, PageResult } from '@/http/types'
-import { http } from '@/http/http'
-
-// TODO @AI:拆成三个文件:channel.ts、template.ts、log.ts
-
-// ==================== 短信渠道 ====================
-
-/** 短信渠道信息 */
-export interface SmsChannel {
-  id?: number
-  code: string
-  status: number
-  signature: string
-  remark?: string
-  apiKey: string
-  apiSecret?: string
-  callbackUrl?: string
-  createTime?: Date
-}
-
-/** 获取短信渠道分页列表 */
-export function getSmsChannelPage(params: PageParam) {
-  return http.get<PageResult<SmsChannel>>('/system/sms-channel/page', params)
-}
-
-/** 获取短信渠道精简列表 */
-export function getSimpleSmsChannelList() {
-  return http.get<SmsChannel[]>('/system/sms-channel/simple-list')
-}
-
-/** 获取短信渠道详情 */
-export function getSmsChannel(id: number) {
-  return http.get<SmsChannel>(`/system/sms-channel/get?id=${id}`)
-}
-
-/** 创建短信渠道 */
-export function createSmsChannel(data: SmsChannel) {
-  return http.post<number>('/system/sms-channel/create', data)
-}
-
-/** 更新短信渠道 */
-export function updateSmsChannel(data: SmsChannel) {
-  return http.put<boolean>('/system/sms-channel/update', data)
-}
-
-/** 删除短信渠道 */
-export function deleteSmsChannel(id: number) {
-  return http.delete<boolean>(`/system/sms-channel/delete?id=${id}`)
-}
-
-// ==================== 短信模板 ====================
-
-/** 短信模板信息 */
-export interface SmsTemplate {
-  id?: number
-  type?: number
-  status: number
-  code: string
-  name: string
-  content: string
-  remark?: string
-  apiTemplateId: string
-  channelId?: number
-  channelCode?: string
-  params?: string[]
-  createTime?: Date
-}
-
-/** 发送短信请求 */
-export interface SmsSendReqVO {
-  mobile: string
-  templateCode: string
-  templateParams: Record<string, any>
-}
-
-/** 获取短信模板分页列表 */
-export function getSmsTemplatePage(params: PageParam) {
-  return http.get<PageResult<SmsTemplate>>('/system/sms-template/page', params)
-}
-
-/** 获取短信模板详情 */
-export function getSmsTemplate(id: number) {
-  return http.get<SmsTemplate>(`/system/sms-template/get?id=${id}`)
-}
-
-/** 创建短信模板 */
-export function createSmsTemplate(data: SmsTemplate) {
-  return http.post<number>('/system/sms-template/create', data)
-}
-
-/** 更新短信模板 */
-export function updateSmsTemplate(data: SmsTemplate) {
-  return http.put<boolean>('/system/sms-template/update', data)
-}
-
-/** 删除短信模板 */
-export function deleteSmsTemplate(id: number) {
-  return http.delete<boolean>(`/system/sms-template/delete?id=${id}`)
-}
-
-/** 发送短信 */
-export function sendSms(data: SmsSendReqVO) {
-  return http.post<number>('/system/sms-template/send-sms', data)
-}
-
-// ==================== 短信日志 ====================
-
-/** 短信日志信息 */
-export interface SmsLog {
-  id?: number
-  channelId?: number
-  channelCode: string
-  templateId?: number
-  templateCode: string
-  templateType?: number
-  templateContent: string
-  templateParams?: Record<string, any>
-  apiTemplateId: string
-  mobile: string
-  userId?: number
-  userType?: number
-  sendStatus?: number
-  sendTime?: string
-  apiSendCode?: string
-  apiSendMsg?: string
-  apiRequestId?: string
-  apiSerialNo?: string
-  receiveStatus?: number
-  receiveTime?: string
-  apiReceiveCode?: string
-  apiReceiveMsg?: string
-  createTime?: string
-}
-
-/** 获取短信日志分页列表 */
-export function getSmsLogPage(params: PageParam) {
-  return http.get<PageResult<SmsLog>>('/system/sms-log/page', params)
-}

+ 34 - 0
src/api/system/sms/log/index.ts

@@ -0,0 +1,34 @@
+import type { PageParam, PageResult } from '@/http/types'
+import { http } from '@/http/http'
+
+/** 短信日志信息 */
+export interface SmsLog {
+  id?: number
+  channelId?: number
+  channelCode: string
+  templateId?: number
+  templateCode: string
+  templateType?: number
+  templateContent: string
+  templateParams?: Record<string, any>
+  apiTemplateId: string
+  mobile: string
+  userId?: number
+  userType?: number
+  sendStatus?: number
+  sendTime?: string
+  apiSendCode?: string
+  apiSendMsg?: string
+  apiRequestId?: string
+  apiSerialNo?: string
+  receiveStatus?: number
+  receiveTime?: string
+  apiReceiveCode?: string
+  apiReceiveMsg?: string
+  createTime?: string
+}
+
+/** 获取短信日志分页列表 */
+export function getSmsLogPage(params: PageParam) {
+  return http.get<PageResult<SmsLog>>('/system/sms-log/page', params)
+}

+ 55 - 0
src/api/system/sms/template/index.ts

@@ -0,0 +1,55 @@
+import type { PageParam, PageResult } from '@/http/types'
+import { http } from '@/http/http'
+
+/** 短信模板信息 */
+export interface SmsTemplate {
+  id?: number
+  type?: number
+  status: number
+  code: string
+  name: string
+  content: string
+  remark?: string
+  apiTemplateId: string
+  channelId?: number
+  channelCode?: string
+  params?: string[]
+  createTime?: Date
+}
+
+/** 发送短信请求 */
+export interface SmsSendReqVO {
+  mobile: string
+  templateCode: string
+  templateParams: Record<string, any>
+}
+
+/** 获取短信模板分页列表 */
+export function getSmsTemplatePage(params: PageParam) {
+  return http.get<PageResult<SmsTemplate>>('/system/sms-template/page', params)
+}
+
+/** 获取短信模板详情 */
+export function getSmsTemplate(id: number) {
+  return http.get<SmsTemplate>(`/system/sms-template/get?id=${id}`)
+}
+
+/** 创建短信模板 */
+export function createSmsTemplate(data: SmsTemplate) {
+  return http.post<number>('/system/sms-template/create', data)
+}
+
+/** 更新短信模板 */
+export function updateSmsTemplate(data: SmsTemplate) {
+  return http.put<boolean>('/system/sms-template/update', data)
+}
+
+/** 删除短信模板 */
+export function deleteSmsTemplate(id: number) {
+  return http.delete<boolean>(`/system/sms-template/delete?id=${id}`)
+}
+
+/** 发送短信 */
+export function sendSms(data: SmsSendReqVO) {
+  return http.post<number>('/system/sms-template/send-sms', data)
+}

+ 2 - 2
src/pages-system/sms/channel/detail/index.vue

@@ -47,10 +47,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsChannel } from '@/api/system/sms'
+import type { SmsChannel } from '@/api/system/sms/channel'
 import { onMounted, ref } from 'vue'
 import { useToast } from 'wot-design-uni'
-import { deleteSmsChannel, getSmsChannel } from '@/api/system/sms'
+import { deleteSmsChannel, getSmsChannel } from '@/api/system/sms/channel'
 import { useAccess } from '@/hooks/useAccess'
 import { navigateBackPlus } from '@/utils'
 import { DICT_TYPE } from '@/utils/constants'

+ 2 - 2
src/pages-system/sms/channel/form/index.vue

@@ -88,10 +88,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsChannel } from '@/api/system/sms'
+import type { SmsChannel } from '@/api/system/sms/channel'
 import { computed, onMounted, ref } from 'vue'
 import { useToast } from 'wot-design-uni'
-import { createSmsChannel, getSmsChannel, updateSmsChannel } from '@/api/system/sms'
+import { createSmsChannel, getSmsChannel, updateSmsChannel } from '@/api/system/sms/channel'
 import { getIntDictOptions, getStrDictOptions } from '@/hooks/useDict'
 import { navigateBackPlus } from '@/utils'
 import { DICT_TYPE } from '@/utils/constants'

+ 2 - 2
src/pages-system/sms/components/channel-list.vue

@@ -56,10 +56,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsChannel } from '@/api/system/sms'
+import type { SmsChannel } from '@/api/system/sms/channel'
 import type { LoadMoreState } from '@/http/types'
 import { ref } from 'vue'
-import { getSmsChannelPage } from '@/api/system/sms'
+import { getSmsChannelPage } from '@/api/system/sms/channel'
 import { useAccess } from '@/hooks/useAccess'
 import { DICT_TYPE } from '@/utils/constants'
 import { formatDateTime } from '@/utils/date'

+ 2 - 2
src/pages-system/sms/components/log-list.vue

@@ -51,10 +51,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsLog } from '@/api/system/sms'
+import type { SmsLog } from '@/api/system/sms/log'
 import type { LoadMoreState } from '@/http/types'
 import { ref } from 'vue'
-import { getSmsLogPage } from '@/api/system/sms'
+import { getSmsLogPage } from '@/api/system/sms/log'
 import { DICT_TYPE } from '@/utils/constants'
 import { formatDateTime } from '@/utils/date'
 import LogSearchForm from './log-search-form.vue'

+ 2 - 2
src/pages-system/sms/components/template-list.vue

@@ -60,10 +60,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsTemplate } from '@/api/system/sms'
+import type { SmsTemplate } from '@/api/system/sms/template'
 import type { LoadMoreState } from '@/http/types'
 import { ref } from 'vue'
-import { getSmsTemplatePage } from '@/api/system/sms'
+import { getSmsTemplatePage } from '@/api/system/sms/template'
 import { useAccess } from '@/hooks/useAccess'
 import { DICT_TYPE } from '@/utils/constants'
 import { formatDateTime } from '@/utils/date'

+ 2 - 2
src/pages-system/sms/log/detail/index.vue

@@ -41,10 +41,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsLog } from '@/api/system/sms'
+import type { SmsLog } from '@/api/system/sms/log'
 import { onMounted, ref } from 'vue'
 import { useToast } from 'wot-design-uni'
-import { getSmsLogPage } from '@/api/system/sms'
+import { getSmsLogPage } from '@/api/system/sms/log'
 import { navigateBackPlus } from '@/utils'
 import { DICT_TYPE } from '@/utils/constants'
 import { formatDateTime } from '@/utils/date'

+ 2 - 2
src/pages-system/sms/template/detail/components/send-form.vue

@@ -44,10 +44,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsTemplate } from '@/api/system/sms'
+import type { SmsTemplate } from '@/api/system/sms/template'
 import { computed, ref, watch } from 'vue'
 import { useToast } from 'wot-design-uni'
-import { sendSms } from '@/api/system/sms'
+import { sendSms } from '@/api/system/sms/template'
 
 const props = defineProps<{
   modelValue: boolean

+ 2 - 2
src/pages-system/sms/template/detail/index.vue

@@ -59,10 +59,10 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsTemplate } from '@/api/system/sms'
+import type { SmsTemplate } from '@/api/system/sms/template'
 import { onMounted, ref } from 'vue'
 import { useToast } from 'wot-design-uni'
-import { deleteSmsTemplate, getSmsTemplate } from '@/api/system/sms'
+import { deleteSmsTemplate, getSmsTemplate } from '@/api/system/sms/template'
 import { useAccess } from '@/hooks/useAccess'
 import { navigateBackPlus } from '@/utils'
 import { DICT_TYPE } from '@/utils/constants'

+ 4 - 2
src/pages-system/sms/template/form/index.vue

@@ -96,10 +96,12 @@
 </template>
 
 <script lang="ts" setup>
-import type { SmsChannel, SmsTemplate } from '@/api/system/sms'
+import type { SmsChannel } from '@/api/system/sms/channel'
+import type { SmsTemplate } from '@/api/system/sms/template'
 import { computed, onMounted, ref } from 'vue'
 import { useToast } from 'wot-design-uni'
-import { createSmsTemplate, getSimpleSmsChannelList, getSmsTemplate, updateSmsTemplate } from '@/api/system/sms'
+import { getSimpleSmsChannelList } from '@/api/system/sms/channel'
+import { createSmsTemplate, getSmsTemplate, updateSmsTemplate } from '@/api/system/sms/template'
 import { getIntDictOptions } from '@/hooks/useDict'
 import { navigateBackPlus } from '@/utils'
 import { DICT_TYPE } from '@/utils/constants'