mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-09-26 20:21:19 +08:00
大量更改,主要是int,float类型支持null、字符串
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
|
||||
import config from '@/config'
|
||||
import queryString from 'query-string'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { clearEmpty } from '@/utils/util'
|
||||
|
||||
export type type_system_log_sms = {
|
||||
Id?: number
|
||||
Scene?: number
|
||||
Mobile?: string
|
||||
Content?: string
|
||||
Status?: number
|
||||
Results?: string
|
||||
SendTime?: string
|
||||
CreateTime?: string
|
||||
UpdateTime?: string
|
||||
}
|
||||
// 查询
|
||||
export type type_system_log_sms_query = {
|
||||
Scene?: number
|
||||
Mobile?: string
|
||||
Content?: string
|
||||
Status?: number
|
||||
Results?: string
|
||||
SendTimeStart?: string
|
||||
SendTimeEnd?: string
|
||||
CreateTimeStart?: string
|
||||
CreateTimeEnd?: string
|
||||
UpdateTimeStart?: string
|
||||
UpdateTimeEnd?: string
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_system_log_sms_edit = {
|
||||
Id?: number
|
||||
Scene?: number
|
||||
Mobile?: string
|
||||
Content?: string
|
||||
Status?: number
|
||||
Results?: string
|
||||
SendTime?: string
|
||||
}
|
||||
|
||||
// 系统短信日志列表
|
||||
export function system_log_sms_list(params?: type_system_log_sms_query) {
|
||||
return request.get<Pages<type_system_log_sms>>({
|
||||
url: '/system_log_sms/list',
|
||||
params: clearEmpty(params)
|
||||
})
|
||||
}
|
||||
// 系统短信日志列表-所有
|
||||
export function system_log_sms_list_all(params?: type_system_log_sms_query) {
|
||||
return request.get<type_system_log_sms[]>({
|
||||
url: '/system_log_sms/listAll',
|
||||
params: clearEmpty(params)
|
||||
})
|
||||
}
|
||||
|
||||
// 系统短信日志详情
|
||||
export function system_log_sms_detail(Id: number | string) {
|
||||
return request.get<type_system_log_sms>({ url: '/system_log_sms/detail', params: { Id } })
|
||||
}
|
||||
|
||||
// 系统短信日志新增
|
||||
export function system_log_sms_add(data: type_system_log_sms_edit) {
|
||||
return request.post<null>({ url: '/system_log_sms/add', data })
|
||||
}
|
||||
|
||||
// 系统短信日志编辑
|
||||
export function system_log_sms_edit(data: type_system_log_sms_edit) {
|
||||
return request.post<null>({ url: '/system_log_sms/edit', data })
|
||||
}
|
||||
|
||||
// 系统短信日志删除
|
||||
export function system_log_sms_delete(Id: number | string) {
|
||||
return request.post<null>({ url: '/system_log_sms/del', data: { Id } })
|
||||
}
|
||||
|
||||
// 系统短信日志导入
|
||||
export const system_log_sms_import_file = '/system_log_sms/ImportFile'
|
||||
|
||||
// 系统短信日志导出
|
||||
export function system_log_sms_export_file(params: any) {
|
||||
return (window.location.href =
|
||||
`${config.baseUrl}${config.urlPrefix}/system_log_sms/ExportFile?token=${getToken()}&` +
|
||||
queryString.stringify(clearEmpty(params)))
|
||||
}
|
72
admin/src/api/user/protocol.ts
Normal file
72
admin/src/api/user/protocol.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import request from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
|
||||
import config from '@/config'
|
||||
import queryString from 'query-string'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { clearEmpty } from '@/utils/util'
|
||||
|
||||
export type type_user_protocol = {
|
||||
Id?: number
|
||||
Title?: string
|
||||
Content?: string
|
||||
Sort?: number
|
||||
IsDelete?: number
|
||||
CreateTime?: string
|
||||
UpdateTime?: string
|
||||
DeleteTime?: string
|
||||
}
|
||||
// 查询
|
||||
export type type_user_protocol_query = {
|
||||
Title?: string
|
||||
Content?: string
|
||||
Sort?: number
|
||||
CreateTimeStart?: string
|
||||
CreateTimeEnd?: string
|
||||
UpdateTimeStart?: string
|
||||
UpdateTimeEnd?: string
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_user_protocol_edit = {
|
||||
Id?: number
|
||||
Title?: string
|
||||
Content?: string
|
||||
Sort?: number
|
||||
}
|
||||
|
||||
// 用户协议列表
|
||||
export function user_protocol_list(params?: type_user_protocol_query) {
|
||||
return request.get<Pages<type_user_protocol>>({ url: '/user_protocol/list', params: clearEmpty(params) })
|
||||
}
|
||||
// 用户协议列表-所有
|
||||
export function user_protocol_list_all(params?: type_user_protocol_query) {
|
||||
return request.get<type_user_protocol[]>({ url: '/user_protocol/listAll', params: clearEmpty(params) })
|
||||
}
|
||||
|
||||
// 用户协议详情
|
||||
export function user_protocol_detail(Id: number | string) {
|
||||
return request.get<type_user_protocol>({ url: '/user_protocol/detail', params: { Id } })
|
||||
}
|
||||
|
||||
// 用户协议新增
|
||||
export function user_protocol_add(data: type_user_protocol_edit) {
|
||||
return request.post<null>({ url: '/user_protocol/add', data })
|
||||
}
|
||||
|
||||
// 用户协议编辑
|
||||
export function user_protocol_edit(data: type_user_protocol_edit) {
|
||||
return request.post<null>({ url: '/user_protocol/edit', data })
|
||||
}
|
||||
|
||||
// 用户协议删除
|
||||
export function user_protocol_delete(Id: number | string) {
|
||||
return request.post<null>({ url: '/user_protocol/del', data: { Id } })
|
||||
}
|
||||
|
||||
// 用户协议导入
|
||||
export const user_protocol_import_file = '/user_protocol/ImportFile'
|
||||
|
||||
// 用户协议导出
|
||||
export function user_protocol_export_file(params: any) {
|
||||
return (window.location.href =`${config.baseUrl}${config.urlPrefix}/user_protocol/ExportFile?token=${getToken()}&` + queryString.stringify(clearEmpty(params)))
|
||||
}
|
@@ -1,183 +0,0 @@
|
||||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
:title="popupTitle"
|
||||
:async="true"
|
||||
width="550px"
|
||||
:clickModalClose="true"
|
||||
@confirm="handleSubmit"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||
<el-form-item label="场景编号" prop="Scene">
|
||||
<el-input v-model="formData.Scene" type="number" placeholder="请输入场景编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="Mobile">
|
||||
<el-input v-model="formData.Mobile" placeholder="请输入手机号码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发送内容" prop="Content">
|
||||
<editor v-model="formData.Content" :height="500" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="Status">
|
||||
<el-radio-group
|
||||
v-model="formData.Status"
|
||||
placeholder="请选择发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
>
|
||||
<el-radio label="0">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="短信结果" prop="Results">
|
||||
<el-input
|
||||
v-model="formData.Results"
|
||||
placeholder="请输入短信结果"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 4, maxRows: 6 }"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="发送时间" prop="SendTime">
|
||||
<el-date-picker
|
||||
class="flex-1 !flex"
|
||||
v-model="formData.SendTime"
|
||||
type="datetime"
|
||||
clearable
|
||||
value-format="YYYY-MM-DD hh:mm:ss"
|
||||
placeholder="请选择发送时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import {
|
||||
system_log_sms_edit,
|
||||
system_log_sms_add,
|
||||
system_log_sms_detail
|
||||
} from '@/api/system_log_sms'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
},
|
||||
listAllData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑系统短信日志' : '新增系统短信日志'
|
||||
})
|
||||
|
||||
const formData = reactive({
|
||||
Id: null,
|
||||
Scene: null,
|
||||
Mobile: null,
|
||||
Content: null,
|
||||
Status: null,
|
||||
Results: null,
|
||||
SendTime: null
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
Id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入id',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Scene: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入场景编号',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入手机号码',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Content: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入发送内容',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Status: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择发送状态:[0=发送中, 1=发送成功, 2=发送失败]',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Results: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入短信结果',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
SendTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择发送时间',
|
||||
trigger: ['blur']
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
mode.value == 'edit' ? await system_log_sms_edit(data) : await system_log_sms_add(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
emit('success')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
const setFormData = async (data: Record<string, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
try {
|
||||
const data = await system_log_sms_detail(row.Id)
|
||||
setFormData(data)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail
|
||||
})
|
||||
</script>
|
129
admin/src/views/user/protocol/edit.vue
Normal file
129
admin/src/views/user/protocol/edit.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<div class="edit-popup">
|
||||
<popup
|
||||
ref="popupRef"
|
||||
:title="popupTitle"
|
||||
:async="true"
|
||||
width="550px"
|
||||
:clickModalClose="true"
|
||||
@confirm="handleSubmit"
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||
<el-form-item label="标题" prop="Title">
|
||||
<el-input v-model="formData.Title" placeholder="请输入标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="协议内容" prop="Content">
|
||||
<editor v-model="formData.Content" :height="500" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="Sort">
|
||||
<el-input v-model="formData.Sort" type="number" placeholder="请输入排序" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</popup>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { user_protocol_edit, user_protocol_add, user_protocol_detail } from '@/api/user/protocol'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
import type { PropType } from 'vue'
|
||||
defineProps({
|
||||
dictData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
},
|
||||
listAllData: {
|
||||
type: Object as PropType<Record<string, any[]>>,
|
||||
default: () => ({})
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||
const mode = ref('add')
|
||||
const popupTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑用户协议' : '新增用户协议'
|
||||
})
|
||||
|
||||
const formData = reactive({
|
||||
Id: null,
|
||||
Title: null,
|
||||
Content: null,
|
||||
Sort: null
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
Id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入标题',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Content: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入协议内容',
|
||||
trigger: ['blur']
|
||||
}
|
||||
]
|
||||
// Sort: [
|
||||
// {
|
||||
// required: true,
|
||||
// message: '请输入排序',
|
||||
// trigger: ['blur']
|
||||
// }
|
||||
// ],
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
mode.value == 'edit' ? await user_protocol_edit(data) : await user_protocol_add(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
emit('success')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
popupRef.value?.open()
|
||||
}
|
||||
|
||||
const setFormData = async (data: Record<string, any>) => {
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
try {
|
||||
const data = await user_protocol_detail(row.Id)
|
||||
setFormData(data)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
emit('close')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData,
|
||||
getDetail
|
||||
})
|
||||
</script>
|
@@ -3,22 +3,8 @@
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true" label-width="70px"
|
||||
label-position="left">
|
||||
<el-form-item label="手机号码" prop="Mobile" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Mobile" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="Status" class="w-[280px]">
|
||||
<el-select
|
||||
v-model="queryParams.Status"
|
||||
clearable
|
||||
>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发送时间" prop="SendTime" class="w-[280px]">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.SendTimeStart"
|
||||
v-model:endTime="queryParams.SendTimeEnd"
|
||||
/>
|
||||
<el-form-item label="标题" prop="Title" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Title" />
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="CreateTime" class="w-[280px]">
|
||||
<daterange-picker
|
||||
@@ -40,7 +26,7 @@
|
||||
</el-card>
|
||||
<el-card class="!border-none mt-4" shadow="never">
|
||||
<div>
|
||||
<el-button v-perms="['admin:system_log_sms:add']" type="primary" @click="handleAdd()">
|
||||
<el-button v-perms="['admin:user_protocol:add']" type="primary" @click="handleAdd()">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
@@ -48,7 +34,7 @@
|
||||
</el-button>
|
||||
<upload
|
||||
class="ml-3 mr-3"
|
||||
:url="system_log_sms_import_file"
|
||||
:url="user_protocol_import_file"
|
||||
:data="{ cid: 0 }"
|
||||
type="file"
|
||||
:show-progress="true"
|
||||
@@ -74,18 +60,15 @@
|
||||
v-loading="pager.loading"
|
||||
:data="pager.lists"
|
||||
>
|
||||
<el-table-column label="场景编号" prop="Scene" min-width="130" />
|
||||
<el-table-column label="手机号码" prop="Mobile" min-width="130" />
|
||||
<el-table-column label="发送内容" prop="Content" min-width="130" />
|
||||
<el-table-column label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="Status" min-width="130" />
|
||||
<el-table-column label="短信结果" prop="Results" min-width="130" />
|
||||
<el-table-column label="发送时间" prop="SendTime" min-width="130" />
|
||||
<el-table-column label="标题" prop="Title" min-width="130" />
|
||||
<el-table-column label="协议内容" prop="Content" min-width="130" />
|
||||
<el-table-column label="排序" prop="Sort" min-width="130" />
|
||||
<el-table-column label="创建时间" prop="CreateTime" min-width="130" />
|
||||
<el-table-column label="更新时间" prop="UpdateTime" min-width="130" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['admin:system_log_sms:edit']"
|
||||
v-perms="['admin:user_protocol:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
@@ -93,7 +76,7 @@
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['admin:system_log_sms:del']"
|
||||
v-perms="['admin:user_protocol:del']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.Id)"
|
||||
@@ -116,8 +99,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { system_log_sms_delete, system_log_sms_list,system_log_sms_import_file, system_log_sms_export_file } from '@/api/system_log_sms'
|
||||
import type { type_system_log_sms,type_system_log_sms_query } from "@/api/system_log_sms";
|
||||
import { user_protocol_delete, user_protocol_list,user_protocol_import_file, user_protocol_export_file } from '@/api/user/protocol'
|
||||
import type { type_user_protocol,type_user_protocol_query } from "@/api/user/protocol";
|
||||
|
||||
|
||||
import { useDictData,useListAllData } from '@/hooks/useDictOptions'
|
||||
@@ -127,26 +110,22 @@ import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
defineOptions({
|
||||
name:"system_log_sms"
|
||||
name:"user_protocol"
|
||||
})
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
const showEdit = ref(false)
|
||||
const queryParams = reactive<type_system_log_sms_query>({
|
||||
Scene: null,
|
||||
Mobile: null,
|
||||
const queryParams = reactive<type_user_protocol_query>({
|
||||
Title: null,
|
||||
Content: null,
|
||||
Status: null,
|
||||
Results: null,
|
||||
SendTimeStart: null,
|
||||
SendTimeEnd: null,
|
||||
Sort: null,
|
||||
CreateTimeStart: null,
|
||||
CreateTimeEnd: null,
|
||||
UpdateTimeStart: null,
|
||||
UpdateTimeEnd: null,
|
||||
})
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging<type_system_log_sms>({
|
||||
fetchFun: system_log_sms_list,
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging<type_user_protocol>({
|
||||
fetchFun: user_protocol_list,
|
||||
params: queryParams
|
||||
})
|
||||
|
||||
@@ -167,7 +146,7 @@ const handleEdit = async (data: any) => {
|
||||
const handleDelete = async (Id: number) => {
|
||||
try {
|
||||
await feedback.confirm('确定要删除?')
|
||||
await system_log_sms_delete( Id )
|
||||
await user_protocol_delete( Id )
|
||||
feedback.msgSuccess('删除成功')
|
||||
getLists()
|
||||
} catch (error) {}
|
||||
@@ -175,7 +154,7 @@ const handleDelete = async (Id: number) => {
|
||||
const exportFile = async () => {
|
||||
try {
|
||||
await feedback.confirm('确定要导出?')
|
||||
await system_log_sms_export_file(queryParams)
|
||||
await user_protocol_export_file(queryParams)
|
||||
} catch (error) {}
|
||||
}
|
||||
getLists()
|
5
docs/.vscode/settings.json
vendored
Normal file
5
docs/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"vitepress"
|
||||
]
|
||||
}
|
8
server/.vscode/settings.json
vendored
8
server/.vscode/settings.json
vendored
@@ -15,15 +15,23 @@
|
||||
"Inno",
|
||||
"Itoa",
|
||||
"jinzhu",
|
||||
"longtext",
|
||||
"mapstructure",
|
||||
"mediumint",
|
||||
"mediumtext",
|
||||
"nvarchar",
|
||||
"oneof",
|
||||
"qrtz",
|
||||
"rmvb",
|
||||
"singleflight",
|
||||
"smallint",
|
||||
"strconv",
|
||||
"struct",
|
||||
"tinyint",
|
||||
"tinytext",
|
||||
"typeof",
|
||||
"uniapp",
|
||||
"varchar",
|
||||
"Warnf",
|
||||
"webp",
|
||||
"x_admin"
|
||||
|
@@ -28,6 +28,11 @@ var SqlConstants = sqlConstants{
|
||||
ColumnTypeTime: []string{"datetime", "time", "date", "timestamp"},
|
||||
//数据库数字类型
|
||||
ColumnTypeNumber: []string{"tinyint", "smallint", "mediumint", "int", "integer", "bit", "bigint", "float", "double", "decimal"},
|
||||
// int类型
|
||||
ColumnTypeInt: []string{"tinyint", "smallint", "mediumint", "int", "integer", "bit", "bigint"},
|
||||
// float类型
|
||||
ColumnTypeFloat: []string{"float", "double", "decimal"},
|
||||
|
||||
//时间日期字段名
|
||||
ColumnTimeName: []string{"create_time", "update_time", "delete_time", "start_time", "end_time", "client_time"},
|
||||
//页面不需要插入字段
|
||||
@@ -74,6 +79,10 @@ type sqlConstants struct {
|
||||
ColumnTypeText []string
|
||||
ColumnTypeTime []string
|
||||
ColumnTypeNumber []string
|
||||
|
||||
ColumnTypeInt []string
|
||||
ColumnTypeFloat []string
|
||||
|
||||
ColumnTimeName []string
|
||||
ColumnNameNotAdd []string
|
||||
ColumnNameNotEdit []string
|
||||
|
@@ -13,7 +13,7 @@ import (
|
||||
- 下载并解压压缩包后,直接复制server、admin文件夹到项目根目录即可
|
||||
|
||||
2. 注册路由
|
||||
请在 admin/entry.go 文件引入{{{ toUpperCamelCase .ModuleName }}}Route注册路由
|
||||
请在 router/admin/entry.go 文件引入 {{{ toUpperCamelCase .ModuleName }}}Route 注册路由
|
||||
|
||||
3. 后台手动添加菜单和按钮
|
||||
admin:{{{ .ModuleName }}}:add
|
||||
@@ -26,7 +26,7 @@ admin:{{{.ModuleName }}}:ExportFile
|
||||
admin:{{{.ModuleName }}}:ImportFile
|
||||
|
||||
// 列表-先添加菜单获取菜单id
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '{{{nameToPath .FunctionName }}}', '{{{nameToPath .ModuleName }}}/index', '{{{ .ModuleName }}}/index', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '{{{ .FunctionName }}}', '{{{nameToPath .ModuleName }}}/index', '{{{nameToPath .ModuleName }}}/index', 0, 1, 0, now(), now());
|
||||
按钮-替换pid参数为菜单id
|
||||
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '{{{ .FunctionName }}}添加','admin:{{{ .ModuleName }}}:add', 0, 1, 0, now(), now());
|
||||
|
@@ -106,7 +106,7 @@ func (service {{{ toCamelCase .EntityName }}}Service) ListAll(listReq {{{ toUppe
|
||||
|
||||
// Detail {{{ .FunctionName }}}详情
|
||||
func (service {{{ toCamelCase .EntityName }}}Service) Detail({{{ toUpperCamelCase .PrimaryKey }}} int) (res {{{ toUpperCamelCase .EntityName }}}Resp, e error) {
|
||||
var obj = model.SystemLogSms{}
|
||||
var obj = model.{{{ toUpperCamelCase .EntityName }}}{}
|
||||
err := cacheUtil.GetCache({{{ toUpperCamelCase .PrimaryKey }}}, &obj)
|
||||
if err != nil {
|
||||
err := service.db.Where("{{{ $.PrimaryKey }}} = ?{{{ if contains .AllFields "is_delete" }}} AND is_delete = ?{{{ end }}}", {{{ toUpperCamelCase .PrimaryKey }}}{{{ if contains .AllFields "is_delete" }}}, 0{{{ end }}}).Limit(1).First(&obj).Error
|
||||
@@ -180,7 +180,7 @@ func (service {{{ toCamelCase .EntityName }}}Service) Del({{{ toUpperCamelCase .
|
||||
{{{- if contains .AllFields "is_delete" }}}
|
||||
obj.IsDelete = 1
|
||||
{{{- if contains .AllFields "delete_time" }}}
|
||||
obj.DeleteTime = core.NowTime()
|
||||
obj.DeleteTime = util.NullTimeUtil.Now()
|
||||
{{{- end }}}
|
||||
err = service.db.Save(&obj).Error
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
@@ -198,9 +198,9 @@ func (service {{{ toCamelCase .EntityName }}}Service) GetExcelCol() []excel2.Col
|
||||
{{{- range .Columns }}}
|
||||
{{{- if and (.IsList) (not .IsPk) }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{Name: "{{{.ColumnComment}}}", Key: "{{{ toUpperCamelCase .GoField }}}", Width: 15,Encode: util.NullTimeUtil.EncodeTime, Decode: util.NullTimeUtil.DecodeTime },
|
||||
{Name: "{{{.ColumnComment}}}", Key: "{{{ toUpperCamelCase .GoField }}}", Width: 15, Decode: util.NullTimeUtil.DecodeTime },
|
||||
{{{- else if eq .GoType "int" }}}
|
||||
{Name: "{{{.ColumnComment}}}", Key: "{{{ toUpperCamelCase .GoField }}}", Width: 15,Encode: core.EncodeInt, Decode: core.DecodeInt},
|
||||
{Name: "{{{.ColumnComment}}}", Key: "{{{ toUpperCamelCase .GoField }}}", Width: 15, Decode: core.DecodeInt},
|
||||
{{{- else }}}
|
||||
{Name: "{{{.ColumnComment}}}", Key: "{{{ toUpperCamelCase .GoField }}}", Width: 15},
|
||||
{{{- end }}}
|
||||
|
@@ -32,7 +32,7 @@
|
||||
import {ref} from "vue";
|
||||
import { onLoad,onShow } from "@dcloudio/uni-app";
|
||||
import { useDictData,useListAllData } from "@/hooks/useDictOptions";
|
||||
import { {{{ .ModuleName }}}_detail } from "@/api/{{{ .ModuleName }}}";
|
||||
import { {{{ .ModuleName }}}_detail } from "@/api/{{{nameToPath .ModuleName }}}";
|
||||
|
||||
|
||||
import {
|
||||
|
@@ -41,7 +41,7 @@
|
||||
{{{ .ModuleName }}}_edit,
|
||||
{{{ .ModuleName }}}_add
|
||||
} from "@/api/{{{ .ModuleName }}}";
|
||||
import type { type_{{{ .ModuleName }}}_edit } from "@/api/{{{ .ModuleName }}}";
|
||||
import type { type_{{{ .ModuleName }}}_edit } from "@/api/{{{nameToPath .ModuleName }}}";
|
||||
|
||||
import {
|
||||
toast,
|
||||
|
@@ -63,8 +63,8 @@ import {
|
||||
onReachBottom,
|
||||
onPageScroll,
|
||||
} from "@dcloudio/uni-app";
|
||||
import { {{{ .ModuleName }}}_list } from "@/api/{{{ .ModuleName }}}";
|
||||
import type { type_{{{ .ModuleName }}},type_{{{.ModuleName}}}_query } from "@/api/{{{ .ModuleName }}}";
|
||||
import { {{{ .ModuleName }}}_list } from "@/api/{{{nameToPath .ModuleName }}}";
|
||||
import type { type_{{{ .ModuleName }}},type_{{{.ModuleName}}}_query } from "@/api/{{{nameToPath .ModuleName }}}";
|
||||
|
||||
import { usePaging } from "@/hooks/usePaging";
|
||||
import { toPath } from "@/utils/utils";
|
||||
|
@@ -44,7 +44,7 @@
|
||||
useDictData,useListAllData
|
||||
} from "@/hooks/useDictOptions";
|
||||
import xDateRange from "@/components/x-date-range/x-date-range.vue";
|
||||
import type {type_{{{.ModuleName}}}_query} from "@/api/{{{.ModuleName}}}";
|
||||
import type {type_{{{.ModuleName}}}_query} from "@/api/{{{nameToPath .ModuleName}}}";
|
||||
{{{- if ge (len .DictFields) 1 }}}
|
||||
{{{- $dictSize := sub (len .DictFields) 1 }}}
|
||||
const { dictData } = useDictData<{
|
||||
|
@@ -8,7 +8,7 @@ import { clearEmpty } from '@/utils/util'
|
||||
|
||||
export type type_{{{.ModuleName}}} = {
|
||||
{{{- range .Columns }}}
|
||||
{{{toUpperCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{toUpperCamelCase .GoField }}}?: {{{goToTsType .GoType}}}
|
||||
{{{- end }}}
|
||||
}
|
||||
// 查询
|
||||
@@ -16,10 +16,10 @@ export type type_{{{.ModuleName}}}_query = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if .IsQuery }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
{{{toUpperCamelCase .GoField }}}Start?: string;
|
||||
{{{toUpperCamelCase .GoField }}}End?: string;
|
||||
{{{toUpperCamelCase .GoField }}}Start?: string
|
||||
{{{toUpperCamelCase .GoField }}}End?: string
|
||||
{{{- else }}}
|
||||
{{{toUpperCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{toUpperCamelCase .GoField }}}?: {{{goToTsType .GoType}}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
@@ -28,7 +28,7 @@ export type type_{{{.ModuleName}}}_query = {
|
||||
export type type_{{{.ModuleName}}}_edit = {
|
||||
{{{- range .Columns }}}
|
||||
{{{- if or .IsEdit .IsInsert }}}
|
||||
{{{toUpperCamelCase .GoField }}}?: {{{goToTsType .GoType}}};
|
||||
{{{toUpperCamelCase .GoField }}}?: {{{goToTsType .GoType}}}
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
}
|
||||
|
@@ -163,7 +163,7 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { {{{ if and .Table.TreePrimary .Table.TreeParent }}}{{{ .ModuleName }}}_lists,{{{ end }}} {{{ .ModuleName }}}_edit, {{{ .ModuleName }}}_add, {{{ .ModuleName }}}_detail } from '@/api/{{{ .ModuleName }}}'
|
||||
import { {{{ if and .Table.TreePrimary .Table.TreeParent }}}{{{ .ModuleName }}}_lists,{{{ end }}} {{{ .ModuleName }}}_edit, {{{ .ModuleName }}}_add, {{{ .ModuleName }}}_detail } from '@/api/{{{nameToPath .ModuleName }}}'
|
||||
import Popup from '@/components/popup/index.vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
import type { PropType } from 'vue'
|
||||
|
@@ -148,8 +148,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { {{{ .ModuleName }}}_delete, {{{ .ModuleName }}}_list } from '@/api/{{{ .ModuleName }}}'
|
||||
import type { type_{{{ .ModuleName }}},type_{{{.ModuleName}}}_query } from "@/api/{{{ .ModuleName }}}";
|
||||
import { {{{ .ModuleName }}}_delete, {{{ .ModuleName }}}_list } from '@/api/{{{nameToPath .ModuleName }}}'
|
||||
import type { type_{{{ .ModuleName }}},type_{{{.ModuleName}}}_query } from "@/api/{{{nameToPath .ModuleName }}}";
|
||||
|
||||
import EditPopup from './edit.vue'
|
||||
import feedback from '@/utils/feedback'
|
||||
|
@@ -162,8 +162,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { {{{ .ModuleName }}}_delete, {{{ .ModuleName }}}_list,{{{.ModuleName}}}_import_file, {{{.ModuleName}}}_export_file } from '@/api/{{{ .ModuleName }}}'
|
||||
import type { type_{{{ .ModuleName }}},type_{{{.ModuleName}}}_query } from "@/api/{{{ .ModuleName }}}";
|
||||
import { {{{ .ModuleName }}}_delete, {{{ .ModuleName }}}_list,{{{.ModuleName}}}_import_file, {{{.ModuleName}}}_export_file } from '@/api/{{{nameToPath .ModuleName }}}'
|
||||
import type { type_{{{ .ModuleName }}},type_{{{.ModuleName}}}_query } from "@/api/{{{nameToPath .ModuleName }}}";
|
||||
|
||||
|
||||
import { useDictData,useListAllData } from '@/hooks/useDictOptions'
|
||||
|
@@ -24,7 +24,7 @@ var TemplateUtil = templateUtil{
|
||||
"toUpperCamelCase": util.StringUtil.ToUpperCamelCase,
|
||||
"contains": util.ToolsUtil.Contains,
|
||||
"goToTsType": GenUtil.GoToTsType,
|
||||
"goToParamType": GenUtil.GoToParamType,
|
||||
// "goToParamType": GenUtil.GoToParamType,
|
||||
"goWithAddEditType": GenUtil.GoWithAddEditType,
|
||||
"goWithRespType": GenUtil.GoWithRespType,
|
||||
"getPageResp": GenUtil.GetPageResp,
|
||||
@@ -227,18 +227,18 @@ func (tu templateUtil) GetFilePaths(tplCodeMap map[string]string, ModuleName str
|
||||
//模板文件对应的输出文件
|
||||
fmtMap := map[string]string{
|
||||
"gocode/model.go.tpl": strings.Join([]string{"server/model/", ModuleName, ".go"}, ""),
|
||||
"gocode/route.go.tpl": strings.Join([]string{"server/admin/", ModuleName, "_route.go"}, ""),
|
||||
"gocode/route.go.tpl": strings.Join([]string{"server/router/admin/", ModuleName, "_route.go"}, ""),
|
||||
|
||||
"gocode/schema.go.tpl": strings.Join([]string{"server/admin/", ModuleName, "/", ModuleName, "_schema.go"}, ""), //"server/admin/%s/%s_schema.go"
|
||||
"gocode/service.go.tpl": strings.Join([]string{"server/admin/", ModuleName, "/", ModuleName, "_service.go"}, ""), //"server/admin/%s/%s_service.go",
|
||||
// "server/admin/%s_route.go",
|
||||
"gocode/controller.go.tpl": strings.Join([]string{"server/admin/", ModuleName, "/", ModuleName, "_ctl.go"}, ""), //"server/admin/%s/%s_ctl.go",
|
||||
|
||||
"vue/api.ts.tpl": strings.Join([]string{"admin/src/api/", ModuleName, ".ts"}, ""), // "admin/src/api/%s.ts",
|
||||
"vue/api.ts.tpl": strings.Join([]string{"admin/src/api/", GenUtil.NameToPath(ModuleName), ".ts"}, ""), // "admin/src/api/%s.ts",
|
||||
"vue/edit.vue.tpl": strings.Join([]string{"admin/src/views/", GenUtil.NameToPath(ModuleName), "/edit.vue"}, ""), // "admin/src/views/%s/edit.vue",
|
||||
"vue/index.vue.tpl": strings.Join([]string{"admin/src/views/", GenUtil.NameToPath(ModuleName), "/index.vue"}, ""), // "admin/src/views/%s/index.vue",
|
||||
"vue/index-tree.vue.tpl": strings.Join([]string{"admin/src/views/", GenUtil.NameToPath(ModuleName), "/index-tree.vue"}, ""), // "admin/src/views/%s/index-tree.vue",
|
||||
"vue/index-tree.vue.tpl": strings.Join([]string{"admin/src/views/", GenUtil.NameToPath(ModuleName), "/index.vue"}, ""), // "admin/src/views/%s/index-tree.vue",
|
||||
|
||||
"uniapp/api.ts.tpl": strings.Join([]string{"x_admin_app/api/", ModuleName, ".ts"}, ""),
|
||||
"uniapp/api.ts.tpl": strings.Join([]string{"x_admin_app/api/", GenUtil.NameToPath(ModuleName), ".ts"}, ""),
|
||||
"uniapp/edit.vue.tpl": strings.Join([]string{"x_admin_app/pages/", GenUtil.NameToPath(ModuleName), "/edit.vue"}, ""),
|
||||
"uniapp/index.vue.tpl": strings.Join([]string{"x_admin_app/pages/", GenUtil.NameToPath(ModuleName), "/index.vue"}, ""),
|
||||
"uniapp/search.vue.tpl": strings.Join([]string{"x_admin_app/pages/", GenUtil.NameToPath(ModuleName), "/search.vue"}, ""),
|
||||
|
@@ -109,14 +109,18 @@ func (gu genUtil) InitColumn(tableId uint, column gen_model.GenTableColumn) gen_
|
||||
//时间字段
|
||||
col.GoType = GoConstants.TypeDate
|
||||
col.HtmlType = HtmlConstants.HtmlDatetime
|
||||
} else if util.ToolsUtil.Contains(SqlConstants.ColumnTypeNumber, columnType) {
|
||||
//数字字段
|
||||
} else if util.ToolsUtil.Contains(SqlConstants.ColumnTypeInt, columnType) {
|
||||
//int数字字段
|
||||
col.HtmlType = HtmlConstants.HtmlInputNumber
|
||||
if strings.Contains(columnType, ",") {
|
||||
col.GoType = GoConstants.TypeFloat
|
||||
} else {
|
||||
|
||||
col.GoType = GoConstants.TypeInt
|
||||
}
|
||||
|
||||
} else if util.ToolsUtil.Contains(SqlConstants.ColumnTypeFloat, columnType) {
|
||||
// float数字字段
|
||||
col.HtmlType = HtmlConstants.HtmlInputNumber
|
||||
|
||||
col.GoType = GoConstants.TypeFloat
|
||||
|
||||
}
|
||||
//非必填字段
|
||||
if util.ToolsUtil.Contains(SqlConstants.ColumnNameNotEdit, col.ColumnName) {
|
||||
@@ -280,22 +284,22 @@ func (gu genUtil) GoWithRespType(s string) string {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Go类型转可为Param类型
|
||||
* @description: Go类型转为Param类型
|
||||
*/
|
||||
func (gu genUtil) GoToParamType(s string) string {
|
||||
if s == "int" || s == "int8" || s == "int16" || s == "int32" || s == "int64" {
|
||||
return "int"
|
||||
} else if s == "float" || s == "float32" || s == "float64" {
|
||||
return "float"
|
||||
} else if s == "string" {
|
||||
return "string"
|
||||
} else if s == "bool" {
|
||||
return "bool"
|
||||
} else if s == "core.NullTime" {
|
||||
return "string"
|
||||
}
|
||||
return "string"
|
||||
}
|
||||
// func (gu genUtil) GoToParamType(s string) string {
|
||||
// if s == "int" || s == "int8" || s == "int16" || s == "int32" || s == "int64" {
|
||||
// return "int"
|
||||
// } else if s == "float" || s == "float32" || s == "float64" {
|
||||
// return "float"
|
||||
// } else if s == "string" {
|
||||
// return "string"
|
||||
// } else if s == "bool" {
|
||||
// return "bool"
|
||||
// } else if s == "core.NullTime" {
|
||||
// return "string"
|
||||
// }
|
||||
// return "string"
|
||||
// }
|
||||
|
||||
// 拼接字符串
|
||||
func (gu genUtil) GetPageResp(s string) string {
|
||||
|
@@ -10,14 +10,6 @@ import (
|
||||
)
|
||||
|
||||
func LogRoute(rg *gin.RouterGroup) {
|
||||
// db := core.GetDB()
|
||||
// permSrv := NewSystemAuthPermService(db)
|
||||
// roleSrv := NewSystemAuthRoleService(db, permSrv)
|
||||
// adminSrv := NewSystemAuthAdminService(db, permSrv, roleSrv)
|
||||
// service := NewSystemLoginService(db, adminSrv)
|
||||
|
||||
// authSrv := NewSystemLogsServer(db)
|
||||
|
||||
handle := logHandler{}
|
||||
|
||||
rg = rg.Group("/system", middleware.TokenAuth())
|
||||
|
@@ -73,8 +73,6 @@ func (menuSrv systemAuthMenuService) List() (res interface{}, e error) {
|
||||
var menuResps []SystemAuthMenuResp
|
||||
util.ConvertUtil.Copy(&menuResps, menus)
|
||||
return menuResps, nil
|
||||
// return util.ArrayUtil.ListToTree(
|
||||
// util.ConvertUtil.StructsToMaps(menuResps), "id", "pid", "children"), nil
|
||||
}
|
||||
|
||||
// Detail 菜单详情
|
||||
@@ -112,7 +110,7 @@ func (menuSrv systemAuthMenuService) Edit(editReq SystemAuthMenuEditReq) (e erro
|
||||
return
|
||||
}
|
||||
util.ConvertUtil.Copy(&menu, editReq)
|
||||
// info := structs.Map(menu)
|
||||
|
||||
err = menuSrv.db.Model(&menu).Select("*").Updates(menu).Error
|
||||
if e = response.CheckErr(err, "编辑失败"); e != nil {
|
||||
return
|
||||
@@ -128,18 +126,18 @@ func (menuSrv systemAuthMenuService) Del(id uint) (e error) {
|
||||
if e = response.CheckErrDBNotRecord(err, "菜单已不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "Delete First err"); e != nil {
|
||||
if e = response.CheckErr(err, "查找失败"); e != nil {
|
||||
return
|
||||
}
|
||||
r := menuSrv.db.Where("pid = ?", id).Limit(1).Find(&system_model.SystemAuthMenu{})
|
||||
err = r.Error
|
||||
if e = response.CheckErr(err, "Delete Find by pid err"); e != nil {
|
||||
if e = response.CheckErr(err, "查找子菜单失败"); e != nil {
|
||||
return
|
||||
}
|
||||
if r.RowsAffected > 0 {
|
||||
return response.AssertArgumentError.SetMessage("请先删除子菜单再操作!")
|
||||
}
|
||||
err = menuSrv.db.Delete(&menu).Error
|
||||
e = response.CheckErr(err, "Delete Delete err")
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
return
|
||||
}
|
||||
|
@@ -1,211 +0,0 @@
|
||||
package system_log_sms
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/util"
|
||||
"x_admin/util/excel2"
|
||||
"golang.org/x/sync/singleflight"
|
||||
)
|
||||
|
||||
|
||||
type SystemLogSmsHandler struct {
|
||||
requestGroup singleflight.Group
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志列表
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param Scene query number false "场景编号"
|
||||
// @Param Mobile query string false "手机号码"
|
||||
// @Param Content query string false "发送内容"
|
||||
// @Param Status query number false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param Results query string false "短信结果"
|
||||
// @Param SendTimeStart query string false "发送时间"
|
||||
// @Param SendTimeEnd query string false "发送时间"
|
||||
// @Param CreateTimeStart query string false "创建时间"
|
||||
// @Param CreateTimeEnd query string false "创建时间"
|
||||
// @Param UpdateTimeStart query string false "更新时间"
|
||||
// @Param UpdateTimeEnd query string false "更新时间"
|
||||
//@Success 200 {object} response.Response{ data=response.PageResp{ lists=[]SystemLogSmsResp}} "成功"
|
||||
//@Router /api/admin/system_log_sms/list [get]
|
||||
func (hd *SystemLogSmsHandler) List(c *gin.Context) {
|
||||
var page request.PageReq
|
||||
var listReq SystemLogSmsListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
|
||||
return
|
||||
}
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := SystemLogSmsService.List(page, listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志列表-所有
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Scene query number false "场景编号"
|
||||
// @Param Mobile query string false "手机号码"
|
||||
// @Param Content query string false "发送内容"
|
||||
// @Param Status query number false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param Results query string false "短信结果"
|
||||
// @Param SendTimeStart query string false "发送时间"
|
||||
// @Param SendTimeEnd query string false "发送时间"
|
||||
// @Param CreateTimeStart query string false "创建时间"
|
||||
// @Param CreateTimeEnd query string false "创建时间"
|
||||
// @Param UpdateTimeStart query string false "更新时间"
|
||||
// @Param UpdateTimeEnd query string false "更新时间"
|
||||
// @Success 200 {object} response.Response{ data=[]SystemLogSmsResp} "成功"
|
||||
// @Router /api/admin/system_log_sms/listAll [get]
|
||||
func (hd *SystemLogSmsHandler) ListAll(c *gin.Context) {
|
||||
var listReq SystemLogSmsListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := SystemLogSmsService.ListAll(listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志详情
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Id query number false "id"
|
||||
// @Success 200 {object} response.Response{ data=SystemLogSmsResp} "成功"
|
||||
// @Router /api/admin/system_log_sms/detail [get]
|
||||
func (hd *SystemLogSmsHandler) Detail(c *gin.Context) {
|
||||
var detailReq SystemLogSmsDetailReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||
return
|
||||
}
|
||||
res, err, _ := hd.requestGroup.Do("SystemLogSms:Detail:"+strconv.Itoa(detailReq.Id), func() (any, error) {
|
||||
v, err := SystemLogSmsService.Detail(detailReq.Id)
|
||||
return v, err
|
||||
})
|
||||
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
|
||||
// @Summary 系统短信日志新增
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Scene body number false "场景编号"
|
||||
// @Param Mobile body string false "手机号码"
|
||||
// @Param Content body string false "发送内容"
|
||||
// @Param Status body number false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param Results body string false "短信结果"
|
||||
// @Param SendTime body string false "发送时间"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/system_log_sms/add [post]
|
||||
func (hd *SystemLogSmsHandler) Add(c *gin.Context) {
|
||||
var addReq SystemLogSmsAddReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &addReq)) {
|
||||
return
|
||||
}
|
||||
createId, e := SystemLogSmsService.Add(addReq)
|
||||
response.CheckAndRespWithData(c,createId, e)
|
||||
}
|
||||
// @Summary 系统短信日志编辑
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Id body number false "id"
|
||||
// @Param Scene body number false "场景编号"
|
||||
// @Param Mobile body string false "手机号码"
|
||||
// @Param Content body string false "发送内容"
|
||||
// @Param Status body number false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param Results body string false "短信结果"
|
||||
// @Param SendTime body string false "发送时间"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/system_log_sms/edit [post]
|
||||
func (hd *SystemLogSmsHandler) Edit(c *gin.Context) {
|
||||
var editReq SystemLogSmsEditReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &editReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndRespWithData(c,editReq.Id, SystemLogSmsService.Edit(editReq))
|
||||
}
|
||||
// @Summary 系统短信日志删除
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Id body number false "id"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/system_log_sms/del [post]
|
||||
func (hd *SystemLogSmsHandler) Del(c *gin.Context) {
|
||||
var delReq SystemLogSmsDelReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &delReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, SystemLogSmsService.Del(delReq.Id))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @Summary 系统短信日志导出
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Scene query number false "场景编号"
|
||||
// @Param Mobile query string false "手机号码"
|
||||
// @Param Content query string false "发送内容"
|
||||
// @Param Status query number false "发送状态:[0=发送中, 1=发送成功, 2=发送失败]"
|
||||
// @Param Results query string false "短信结果"
|
||||
// @Param SendTimeStart query string false "发送时间"
|
||||
// @Param SendTimeEnd query string false "发送时间"
|
||||
// @Param CreateTimeStart query string false "创建时间"
|
||||
// @Param CreateTimeEnd query string false "创建时间"
|
||||
// @Param UpdateTimeStart query string false "更新时间"
|
||||
// @Param UpdateTimeEnd query string false "更新时间"
|
||||
// @Router /api/admin/system_log_sms/ExportFile [get]
|
||||
func (hd *SystemLogSmsHandler) ExportFile(c *gin.Context) {
|
||||
var listReq SystemLogSmsListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := SystemLogSmsService.ExportFile(listReq)
|
||||
if err != nil {
|
||||
response.FailWithMsg(c, response.SystemError, "查询信息失败")
|
||||
return
|
||||
}
|
||||
f, err := excel2.Export(res,SystemLogSmsService.GetExcelCol(), "Sheet1", "系统短信日志")
|
||||
if err != nil {
|
||||
response.FailWithMsg(c, response.SystemError, "导出失败")
|
||||
return
|
||||
}
|
||||
excel2.DownLoadExcel("系统短信日志" + time.Now().Format("20060102-150405"), c.Writer, f)
|
||||
}
|
||||
|
||||
// @Summary 系统短信日志导入
|
||||
// @Tags system_log_sms-系统短信日志
|
||||
// @Produce json
|
||||
// @Router /api/admin/system_log_sms/ImportFile [post]
|
||||
func (hd *SystemLogSmsHandler) ImportFile(c *gin.Context) {
|
||||
file, _, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "文件不存在")
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
importList := []SystemLogSmsResp{}
|
||||
err = excel2.GetExcelData(file, &importList,SystemLogSmsService.GetExcelCol())
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = SystemLogSmsService.ImportFile(importList)
|
||||
response.CheckAndResp(c, err)
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
package system_log_sms
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
)
|
||||
|
||||
// SystemLogSmsListReq 系统短信日志列表参数
|
||||
type SystemLogSmsListReq struct {
|
||||
Scene *int `` // 场景编号
|
||||
Mobile *string `` // 手机号码
|
||||
Content *string `` // 发送内容
|
||||
Status *int `` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results *string `` // 短信结果
|
||||
SendTimeStart *string `` // 开始发送时间
|
||||
SendTimeEnd *string `` // 结束发送时间
|
||||
CreateTimeStart *string `` // 开始创建时间
|
||||
CreateTimeEnd *string `` // 结束创建时间
|
||||
UpdateTimeStart *string `` // 开始更新时间
|
||||
UpdateTimeEnd *string `` // 结束更新时间
|
||||
}
|
||||
|
||||
// SystemLogSmsAddReq 系统短信日志新增参数
|
||||
type SystemLogSmsAddReq struct {
|
||||
Scene core.NullInt `` // 场景编号
|
||||
Mobile *string `` // 手机号码
|
||||
Content *string `` // 发送内容
|
||||
Status core.NullInt `` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results *string `` // 短信结果
|
||||
SendTime core.NullTime `` // 发送时间
|
||||
}
|
||||
|
||||
// SystemLogSmsEditReq 系统短信日志编辑参数
|
||||
type SystemLogSmsEditReq struct {
|
||||
Id int `` // id
|
||||
Scene core.NullInt `` // 场景编号
|
||||
Mobile *string `` // 手机号码
|
||||
Content *string `` // 发送内容
|
||||
Status core.NullInt `` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results *string `` // 短信结果
|
||||
SendTime core.NullTime `` // 发送时间
|
||||
}
|
||||
|
||||
// SystemLogSmsDetailReq 系统短信日志详情参数
|
||||
type SystemLogSmsDetailReq struct {
|
||||
Id int `` // id
|
||||
}
|
||||
|
||||
// SystemLogSmsDelReq 系统短信日志删除参数
|
||||
type SystemLogSmsDelReq struct {
|
||||
Id int `` // id
|
||||
}
|
||||
|
||||
// SystemLogSmsResp 系统短信日志返回信息
|
||||
type SystemLogSmsResp struct {
|
||||
Id int `` // id
|
||||
Scene core.NullInt `` // 场景编号
|
||||
Mobile string `` // 手机号码
|
||||
Content string `` // 发送内容
|
||||
Status core.NullInt `` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results string `` // 短信结果
|
||||
SendTime core.NullTime `` // 发送时间
|
||||
CreateTime core.NullTime `` // 创建时间
|
||||
UpdateTime core.NullTime `` // 更新时间
|
||||
}
|
@@ -1,227 +0,0 @@
|
||||
package system_log_sms
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
"x_admin/util"
|
||||
"x_admin/util/excel2"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var SystemLogSmsService = NewSystemLogSmsService()
|
||||
var cacheUtil = util.CacheUtil{
|
||||
Name: SystemLogSmsService.Name,
|
||||
}
|
||||
|
||||
// NewSystemLogSmsService 初始化
|
||||
func NewSystemLogSmsService() *systemLogSmsService {
|
||||
return &systemLogSmsService{
|
||||
db: core.GetDB(),
|
||||
Name: "systemLogSms",
|
||||
}
|
||||
}
|
||||
|
||||
// systemLogSmsService 系统短信日志服务实现类
|
||||
type systemLogSmsService struct {
|
||||
db *gorm.DB
|
||||
Name string
|
||||
}
|
||||
|
||||
// List 系统短信日志列表
|
||||
func (service systemLogSmsService) GetModel(listReq SystemLogSmsListReq) *gorm.DB {
|
||||
// 查询
|
||||
dbModel := service.db.Model(&model.SystemLogSms{})
|
||||
if listReq.Scene != nil {
|
||||
dbModel = dbModel.Where("scene = ?", *listReq.Scene)
|
||||
}
|
||||
if listReq.Mobile != nil {
|
||||
dbModel = dbModel.Where("mobile like ?", "%"+*listReq.Mobile+"%")
|
||||
}
|
||||
if listReq.Content != nil {
|
||||
dbModel = dbModel.Where("content = ?", *listReq.Content)
|
||||
}
|
||||
if listReq.Status != nil {
|
||||
dbModel = dbModel.Where("status = ?", *listReq.Status)
|
||||
}
|
||||
if listReq.Results != nil {
|
||||
dbModel = dbModel.Where("results = ?", *listReq.Results)
|
||||
}
|
||||
if listReq.SendTimeStart != nil {
|
||||
dbModel = dbModel.Where("send_time >= ?", *listReq.SendTimeStart)
|
||||
}
|
||||
if listReq.SendTimeEnd != nil {
|
||||
dbModel = dbModel.Where("send_time <= ?", *listReq.SendTimeEnd)
|
||||
}
|
||||
if listReq.CreateTimeStart != nil {
|
||||
dbModel = dbModel.Where("create_time >= ?", *listReq.CreateTimeStart)
|
||||
}
|
||||
if listReq.CreateTimeEnd != nil {
|
||||
dbModel = dbModel.Where("create_time <= ?", *listReq.CreateTimeEnd)
|
||||
}
|
||||
if listReq.UpdateTimeStart != nil {
|
||||
dbModel = dbModel.Where("update_time >= ?", *listReq.UpdateTimeStart)
|
||||
}
|
||||
if listReq.UpdateTimeEnd != nil {
|
||||
dbModel = dbModel.Where("update_time <= ?", *listReq.UpdateTimeEnd)
|
||||
}
|
||||
return dbModel
|
||||
}
|
||||
|
||||
// List 系统短信日志列表
|
||||
func (service systemLogSmsService) List(page request.PageReq, listReq SystemLogSmsListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
dbModel := service.GetModel(listReq)
|
||||
// 总数
|
||||
var count int64
|
||||
err := dbModel.Count(&count).Error
|
||||
if e = response.CheckErr(err, "失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 数据
|
||||
var modelList []model.SystemLogSms
|
||||
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []SystemLogSmsResp{}
|
||||
util.ConvertUtil.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
PageSize: page.PageSize,
|
||||
Count: count,
|
||||
Lists: result,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListAll 系统短信日志列表
|
||||
func (service systemLogSmsService) ListAll(listReq SystemLogSmsListReq) (res []SystemLogSmsResp, e error) {
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
var modelList []model.SystemLogSms
|
||||
|
||||
err := dbModel.Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询全部失败"); e != nil {
|
||||
return
|
||||
}
|
||||
util.ConvertUtil.Copy(&res, modelList)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Detail 系统短信日志详情
|
||||
func (service systemLogSmsService) Detail(Id int) (res SystemLogSmsResp, e error) {
|
||||
var obj = model.SystemLogSms{}
|
||||
err := cacheUtil.GetCache(Id, &obj)
|
||||
if err != nil {
|
||||
err := service.db.Where("id = ?", Id).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "获取详情失败"); e != nil {
|
||||
return
|
||||
}
|
||||
cacheUtil.SetCache(obj.Id, obj)
|
||||
}
|
||||
|
||||
util.ConvertUtil.Copy(&res, obj)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 系统短信日志新增
|
||||
func (service systemLogSmsService) Add(addReq SystemLogSmsAddReq) (createId int, e error) {
|
||||
var obj model.SystemLogSms
|
||||
util.ConvertUtil.StructToStruct(addReq, &obj)
|
||||
err := service.db.Create(&obj).Error
|
||||
e = response.CheckMysqlErr(err)
|
||||
if e != nil {
|
||||
return 0, e
|
||||
}
|
||||
cacheUtil.SetCache(obj.Id, obj)
|
||||
createId = obj.Id
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 系统短信日志编辑
|
||||
func (service systemLogSmsService) Edit(editReq SystemLogSmsEditReq) (e error) {
|
||||
var obj model.SystemLogSms
|
||||
err := service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
util.ConvertUtil.Copy(&obj, editReq)
|
||||
|
||||
err = service.db.Model(&obj).Select("*").Updates(obj).Error
|
||||
if e = response.CheckErr(err, "编辑失败"); e != nil {
|
||||
return
|
||||
}
|
||||
cacheUtil.RemoveCache(obj.Id)
|
||||
service.Detail(obj.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Del 系统短信日志删除
|
||||
func (service systemLogSmsService) Del(Id int) (e error) {
|
||||
var obj model.SystemLogSms
|
||||
err := service.db.Where("id = ?", Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "查询数据失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 删除
|
||||
err = service.db.Delete(&obj).Error
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
cacheUtil.RemoveCache(obj.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取Excel的列
|
||||
func (service systemLogSmsService) GetExcelCol() []excel2.Col {
|
||||
var cols = []excel2.Col{
|
||||
{Name: "场景编号", Key: "Scene", Width: 15, Encode: core.EncodeInt, Decode: core.DecodeInt},
|
||||
{Name: "手机号码", Key: "Mobile", Width: 15},
|
||||
{Name: "发送内容", Key: "Content", Width: 15},
|
||||
{Name: "发送状态:[0=发送中, 1=发送成功, 2=发送失败]", Key: "Status", Width: 15, Encode: core.EncodeInt, Decode: core.DecodeInt},
|
||||
{Name: "短信结果", Key: "Results", Width: 15},
|
||||
{Name: "发送时间", Key: "SendTime", Width: 15, Encode: util.NullTimeUtil.EncodeTime, Decode: util.NullTimeUtil.DecodeTime},
|
||||
{Name: "创建时间", Key: "CreateTime", Width: 15, Encode: util.NullTimeUtil.EncodeTime, Decode: util.NullTimeUtil.DecodeTime},
|
||||
{Name: "更新时间", Key: "UpdateTime", Width: 15, Encode: util.NullTimeUtil.EncodeTime, Decode: util.NullTimeUtil.DecodeTime},
|
||||
}
|
||||
// 还可以考虑字典,请求下来加上 Replace 实现替换导出
|
||||
return cols
|
||||
}
|
||||
|
||||
// ExportFile 系统短信日志导出
|
||||
func (service systemLogSmsService) ExportFile(listReq SystemLogSmsListReq) (res []SystemLogSmsResp, e error) {
|
||||
// 查询
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
// 数据
|
||||
var modelList []model.SystemLogSms
|
||||
err := dbModel.Order("id asc").Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []SystemLogSmsResp{}
|
||||
util.ConvertUtil.Copy(&result, modelList)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 导入
|
||||
func (service systemLogSmsService) ImportFile(importReq []SystemLogSmsResp) (e error) {
|
||||
var importData []model.SystemLogSms
|
||||
util.ConvertUtil.Copy(&importData, importReq)
|
||||
err := service.db.Create(&importData).Error
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return e
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/middleware"
|
||||
"x_admin/admin/system_log_sms"
|
||||
)
|
||||
|
||||
/**
|
||||
集成
|
||||
1. 导入
|
||||
- 请先提交git避免文件覆盖!!!
|
||||
- 下载并解压压缩包后,直接复制server、admin文件夹到项目根目录即可
|
||||
|
||||
2. 注册路由
|
||||
请在 admin/entry.go 文件引入SystemLogSmsRoute注册路由
|
||||
|
||||
3. 后台手动添加菜单和按钮
|
||||
admin:system_log_sms:add
|
||||
admin:system_log_sms:edit
|
||||
admin:system_log_sms:del
|
||||
admin:system_log_sms:list
|
||||
admin:system_log_sms:listAll
|
||||
admin:system_log_sms:detail
|
||||
admin:system_log_sms:ExportFile
|
||||
admin:system_log_sms:ImportFile
|
||||
|
||||
// 列表-先添加菜单获取菜单id
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '系统短信日志', 'system/log/sms/index', 'system_log_sms/index', 0, 1, 0, now(), now());
|
||||
按钮-替换pid参数为菜单id
|
||||
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志添加','admin:system_log_sms:add', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志编辑','admin:system_log_sms:edit', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志删除','admin:system_log_sms:del', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志列表','admin:system_log_sms:list', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志全部列表','admin:system_log_sms:listAll', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志详情','admin:system_log_sms:detail', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志导出excel','admin:system_log_sms:ExportFile', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '系统短信日志导入excel','admin:system_log_sms:ImportFile', 0, 1, 0, now(), now());
|
||||
*/
|
||||
|
||||
|
||||
// SystemLogSmsRoute(rg)
|
||||
func SystemLogSmsRoute(rg *gin.RouterGroup) {
|
||||
handle := system_log_sms.SystemLogSmsHandler{}
|
||||
|
||||
r := rg.Group("/", middleware.TokenAuth())
|
||||
r.GET("/system_log_sms/list", handle.List)
|
||||
r.GET("/system_log_sms/listAll", handle.ListAll)
|
||||
r.GET("/system_log_sms/detail", handle.Detail)
|
||||
r.POST("/system_log_sms/add",middleware.RecordLog("系统短信日志新增"), handle.Add)
|
||||
r.POST("/system_log_sms/edit",middleware.RecordLog("系统短信日志编辑"), handle.Edit)
|
||||
r.POST("/system_log_sms/del", middleware.RecordLog("系统短信日志删除"), handle.Del)
|
||||
r.GET("/system_log_sms/ExportFile", middleware.RecordLog("系统短信日志导出"), handle.ExportFile)
|
||||
r.POST("/system_log_sms/ImportFile", handle.ImportFile)
|
||||
}
|
193
server/admin/user_protocol/user_protocol_ctl.go
Normal file
193
server/admin/user_protocol/user_protocol_ctl.go
Normal file
@@ -0,0 +1,193 @@
|
||||
package user_protocol
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/util"
|
||||
"x_admin/util/excel2"
|
||||
"golang.org/x/sync/singleflight"
|
||||
)
|
||||
|
||||
|
||||
type UserProtocolHandler struct {
|
||||
requestGroup singleflight.Group
|
||||
}
|
||||
|
||||
// @Summary 用户协议列表
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param Title query string false "标题"
|
||||
// @Param Content query string false "协议内容"
|
||||
// @Param Sort query number false "排序"
|
||||
// @Param CreateTimeStart query string false "创建时间"
|
||||
// @Param CreateTimeEnd query string false "创建时间"
|
||||
// @Param UpdateTimeStart query string false "更新时间"
|
||||
// @Param UpdateTimeEnd query string false "更新时间"
|
||||
//@Success 200 {object} response.Response{ data=response.PageResp{ lists=[]UserProtocolResp}} "成功"
|
||||
//@Router /api/admin/user_protocol/list [get]
|
||||
func (hd *UserProtocolHandler) List(c *gin.Context) {
|
||||
var page request.PageReq
|
||||
var listReq UserProtocolListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &page)) {
|
||||
return
|
||||
}
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := UserProtocolService.List(page, listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 用户协议列表-所有
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Param Title query string false "标题"
|
||||
// @Param Content query string false "协议内容"
|
||||
// @Param Sort query number false "排序"
|
||||
// @Param CreateTimeStart query string false "创建时间"
|
||||
// @Param CreateTimeEnd query string false "创建时间"
|
||||
// @Param UpdateTimeStart query string false "更新时间"
|
||||
// @Param UpdateTimeEnd query string false "更新时间"
|
||||
// @Success 200 {object} response.Response{ data=[]UserProtocolResp} "成功"
|
||||
// @Router /api/admin/user_protocol/listAll [get]
|
||||
func (hd *UserProtocolHandler) ListAll(c *gin.Context) {
|
||||
var listReq UserProtocolListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := UserProtocolService.ListAll(listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 用户协议详情
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Id query number false ""
|
||||
// @Success 200 {object} response.Response{ data=UserProtocolResp} "成功"
|
||||
// @Router /api/admin/user_protocol/detail [get]
|
||||
func (hd *UserProtocolHandler) Detail(c *gin.Context) {
|
||||
var detailReq UserProtocolDetailReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||
return
|
||||
}
|
||||
res, err, _ := hd.requestGroup.Do("UserProtocol:Detail:"+strconv.Itoa(detailReq.Id), func() (any, error) {
|
||||
v, err := UserProtocolService.Detail(detailReq.Id)
|
||||
return v, err
|
||||
})
|
||||
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
|
||||
// @Summary 用户协议新增
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Title body string false "标题"
|
||||
// @Param Content body string false "协议内容"
|
||||
// @Param Sort body number false "排序"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/user_protocol/add [post]
|
||||
func (hd *UserProtocolHandler) Add(c *gin.Context) {
|
||||
var addReq UserProtocolAddReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &addReq)) {
|
||||
return
|
||||
}
|
||||
createId, e := UserProtocolService.Add(addReq)
|
||||
response.CheckAndRespWithData(c,createId, e)
|
||||
}
|
||||
// @Summary 用户协议编辑
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Id body number false ""
|
||||
// @Param Title body string false "标题"
|
||||
// @Param Content body string false "协议内容"
|
||||
// @Param Sort body number false "排序"
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/user_protocol/edit [post]
|
||||
func (hd *UserProtocolHandler) Edit(c *gin.Context) {
|
||||
var editReq UserProtocolEditReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &editReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndRespWithData(c,editReq.Id, UserProtocolService.Edit(editReq))
|
||||
}
|
||||
// @Summary 用户协议删除
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Id body number false ""
|
||||
// @Success 200 {object} response.Response "成功"
|
||||
// @Router /api/admin/user_protocol/del [post]
|
||||
func (hd *UserProtocolHandler) Del(c *gin.Context) {
|
||||
var delReq UserProtocolDelReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &delReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, UserProtocolService.Del(delReq.Id))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @Summary 用户协议导出
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Title query string false "标题"
|
||||
// @Param Content query string false "协议内容"
|
||||
// @Param Sort query number false "排序"
|
||||
// @Param CreateTimeStart query string false "创建时间"
|
||||
// @Param CreateTimeEnd query string false "创建时间"
|
||||
// @Param UpdateTimeStart query string false "更新时间"
|
||||
// @Param UpdateTimeEnd query string false "更新时间"
|
||||
// @Router /api/admin/user_protocol/ExportFile [get]
|
||||
func (hd *UserProtocolHandler) ExportFile(c *gin.Context) {
|
||||
var listReq UserProtocolListReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := UserProtocolService.ExportFile(listReq)
|
||||
if err != nil {
|
||||
response.FailWithMsg(c, response.SystemError, "查询信息失败")
|
||||
return
|
||||
}
|
||||
f, err := excel2.Export(res,UserProtocolService.GetExcelCol(), "Sheet1", "用户协议")
|
||||
if err != nil {
|
||||
response.FailWithMsg(c, response.SystemError, "导出失败")
|
||||
return
|
||||
}
|
||||
excel2.DownLoadExcel("用户协议" + time.Now().Format("20060102-150405"), c.Writer, f)
|
||||
}
|
||||
|
||||
// @Summary 用户协议导入
|
||||
// @Tags user_protocol-用户协议
|
||||
// @Produce json
|
||||
// @Router /api/admin/user_protocol/ImportFile [post]
|
||||
func (hd *UserProtocolHandler) ImportFile(c *gin.Context) {
|
||||
file, _, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "文件不存在")
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
importList := []UserProtocolResp{}
|
||||
err = excel2.GetExcelData(file, &importList,UserProtocolService.GetExcelCol())
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = UserProtocolService.ImportFile(importList)
|
||||
response.CheckAndResp(c, err)
|
||||
}
|
53
server/admin/user_protocol/user_protocol_schema.go
Normal file
53
server/admin/user_protocol/user_protocol_schema.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package user_protocol
|
||||
import (
|
||||
"x_admin/core"
|
||||
|
||||
)
|
||||
|
||||
//UserProtocolListReq 用户协议列表参数
|
||||
type UserProtocolListReq struct {
|
||||
Title *string `` // 标题
|
||||
Content *string `` // 协议内容
|
||||
Sort *float64 `` // 排序
|
||||
CreateTimeStart *string `` // 开始创建时间
|
||||
CreateTimeEnd *string `` // 结束创建时间
|
||||
UpdateTimeStart *string `` // 开始更新时间
|
||||
UpdateTimeEnd *string `` // 结束更新时间
|
||||
}
|
||||
|
||||
|
||||
|
||||
//UserProtocolAddReq 用户协议新增参数
|
||||
type UserProtocolAddReq struct {
|
||||
Title *string `` // 标题
|
||||
Content *string `` // 协议内容
|
||||
Sort core.NullFloat `` // 排序
|
||||
}
|
||||
|
||||
//UserProtocolEditReq 用户协议编辑参数
|
||||
type UserProtocolEditReq struct {
|
||||
Id int `` //
|
||||
Title *string `` // 标题
|
||||
Content *string `` // 协议内容
|
||||
Sort core.NullFloat `` // 排序
|
||||
}
|
||||
|
||||
//UserProtocolDetailReq 用户协议详情参数
|
||||
type UserProtocolDetailReq struct {
|
||||
Id int `` //
|
||||
}
|
||||
|
||||
//UserProtocolDelReq 用户协议删除参数
|
||||
type UserProtocolDelReq struct {
|
||||
Id int `` //
|
||||
}
|
||||
|
||||
//UserProtocolResp 用户协议返回信息
|
||||
type UserProtocolResp struct {
|
||||
Id int `` //
|
||||
Title string `` // 标题
|
||||
Content string `` // 协议内容
|
||||
Sort core.NullFloat `` // 排序
|
||||
CreateTime core.NullTime `` // 创建时间
|
||||
UpdateTime core.NullTime `` // 更新时间
|
||||
}
|
214
server/admin/user_protocol/user_protocol_service.go
Normal file
214
server/admin/user_protocol/user_protocol_service.go
Normal file
@@ -0,0 +1,214 @@
|
||||
package user_protocol
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
"gorm.io/gorm"
|
||||
"x_admin/util"
|
||||
"x_admin/util/excel2"
|
||||
)
|
||||
|
||||
var UserProtocolService=NewUserProtocolService()
|
||||
var cacheUtil = util.CacheUtil{
|
||||
Name: UserProtocolService.Name,
|
||||
}
|
||||
|
||||
// NewUserProtocolService 初始化
|
||||
func NewUserProtocolService() *userProtocolService {
|
||||
return &userProtocolService{
|
||||
db: core.GetDB(),
|
||||
Name: "userProtocol",
|
||||
}
|
||||
}
|
||||
|
||||
//userProtocolService 用户协议服务实现类
|
||||
type userProtocolService struct {
|
||||
db *gorm.DB
|
||||
Name string
|
||||
}
|
||||
|
||||
|
||||
|
||||
// List 用户协议列表
|
||||
func (service userProtocolService) GetModel(listReq UserProtocolListReq) *gorm.DB {
|
||||
// 查询
|
||||
dbModel := service.db.Model(&model.UserProtocol{})
|
||||
if listReq.Title!= nil {
|
||||
dbModel = dbModel.Where("title like ?", "%"+*listReq.Title+"%")
|
||||
}
|
||||
if listReq.Content!= nil {
|
||||
dbModel = dbModel.Where("content = ?", *listReq.Content)
|
||||
}
|
||||
if listReq.Sort!= nil {
|
||||
dbModel = dbModel.Where("sort = ?", *listReq.Sort)
|
||||
}
|
||||
if listReq.CreateTimeStart!= nil {
|
||||
dbModel = dbModel.Where("create_time >= ?", *listReq.CreateTimeStart)
|
||||
}
|
||||
if listReq.CreateTimeEnd!= nil {
|
||||
dbModel = dbModel.Where("create_time <= ?", *listReq.CreateTimeEnd)
|
||||
}
|
||||
if listReq.UpdateTimeStart!= nil {
|
||||
dbModel = dbModel.Where("update_time >= ?", *listReq.UpdateTimeStart)
|
||||
}
|
||||
if listReq.UpdateTimeEnd!= nil {
|
||||
dbModel = dbModel.Where("update_time <= ?", *listReq.UpdateTimeEnd)
|
||||
}
|
||||
dbModel = dbModel.Where("is_delete = ?", 0)
|
||||
return dbModel
|
||||
}
|
||||
// List 用户协议列表
|
||||
func (service userProtocolService) List(page request.PageReq, listReq UserProtocolListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
dbModel := service.GetModel(listReq)
|
||||
// 总数
|
||||
var count int64
|
||||
err := dbModel.Count(&count).Error
|
||||
if e = response.CheckErr(err, "失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 数据
|
||||
var modelList []model.UserProtocol
|
||||
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []UserProtocolResp{}
|
||||
util.ConvertUtil.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
PageSize: page.PageSize,
|
||||
Count: count,
|
||||
Lists: result,
|
||||
}, nil
|
||||
}
|
||||
// ListAll 用户协议列表
|
||||
func (service userProtocolService) ListAll(listReq UserProtocolListReq) (res []UserProtocolResp, e error) {
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
var modelList []model.UserProtocol
|
||||
|
||||
err := dbModel.Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询全部失败"); e != nil {
|
||||
return
|
||||
}
|
||||
util.ConvertUtil.Copy(&res, modelList)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Detail 用户协议详情
|
||||
func (service userProtocolService) Detail(Id int) (res UserProtocolResp, e error) {
|
||||
var obj = model.UserProtocol{}
|
||||
err := cacheUtil.GetCache(Id, &obj)
|
||||
if err != nil {
|
||||
err := service.db.Where("id = ? AND is_delete = ?", Id, 0).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "获取详情失败"); e != nil {
|
||||
return
|
||||
}
|
||||
cacheUtil.SetCache(obj.Id, obj)
|
||||
}
|
||||
|
||||
util.ConvertUtil.Copy(&res, obj)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 用户协议新增
|
||||
func (service userProtocolService) Add(addReq UserProtocolAddReq) (createId int,e error) {
|
||||
var obj model.UserProtocol
|
||||
util.ConvertUtil.StructToStruct(addReq,&obj)
|
||||
err := service.db.Create(&obj).Error
|
||||
e = response.CheckMysqlErr(err)
|
||||
if e != nil {
|
||||
return 0,e
|
||||
}
|
||||
cacheUtil.SetCache(obj.Id, obj)
|
||||
createId = obj.Id
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 用户协议编辑
|
||||
func (service userProtocolService) Edit(editReq UserProtocolEditReq) (e error) {
|
||||
var obj model.UserProtocol
|
||||
err := service.db.Where("id = ? AND is_delete = ?", editReq.Id, 0).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
util.ConvertUtil.Copy(&obj, editReq)
|
||||
|
||||
err = service.db.Model(&obj).Select("*").Updates(obj).Error
|
||||
if e = response.CheckErr(err, "编辑失败"); e != nil {
|
||||
return
|
||||
}
|
||||
cacheUtil.RemoveCache(obj.Id)
|
||||
service.Detail(obj.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Del 用户协议删除
|
||||
func (service userProtocolService) Del(Id int) (e error) {
|
||||
var obj model.UserProtocol
|
||||
err := service.db.Where("id = ? AND is_delete = ?", Id, 0).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "查询数据失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 删除
|
||||
obj.IsDelete = 1
|
||||
obj.DeleteTime = util.NullTimeUtil.Now()
|
||||
err = service.db.Save(&obj).Error
|
||||
e = response.CheckErr(err, "删除失败")
|
||||
cacheUtil.RemoveCache(obj.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取Excel的列
|
||||
func (service userProtocolService) GetExcelCol() []excel2.Col {
|
||||
var cols = []excel2.Col{
|
||||
{Name: "标题", Key: "Title", Width: 15},
|
||||
{Name: "协议内容", Key: "Content", Width: 15},
|
||||
{Name: "排序", Key: "Sort", Width: 15},
|
||||
{Name: "创建时间", Key: "CreateTime", Width: 15, Decode: util.NullTimeUtil.DecodeTime },
|
||||
{Name: "更新时间", Key: "UpdateTime", Width: 15, Decode: util.NullTimeUtil.DecodeTime },
|
||||
}
|
||||
// 还可以考虑字典,请求下来加上 Replace 实现替换导出
|
||||
return cols
|
||||
}
|
||||
|
||||
// ExportFile 用户协议导出
|
||||
func (service userProtocolService) ExportFile(listReq UserProtocolListReq) (res []UserProtocolResp, e error) {
|
||||
// 查询
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
// 数据
|
||||
var modelList []model.UserProtocol
|
||||
err := dbModel.Order("id asc").Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []UserProtocolResp{}
|
||||
util.ConvertUtil.Copy(&result, modelList)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 导入
|
||||
func (service userProtocolService) ImportFile(importReq []UserProtocolResp) (e error) {
|
||||
var importData []model.UserProtocol
|
||||
util.ConvertUtil.Copy(&importData, importReq)
|
||||
err := service.db.Create(&importData).Error
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return e
|
||||
}
|
@@ -13,29 +13,29 @@ type NullFloat struct {
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func EncodeFloat(value any) any {
|
||||
switch v := value.(type) {
|
||||
case map[string]any:
|
||||
if v["Float"] != nil {
|
||||
val := v["Float"]
|
||||
switch f := val.(type) {
|
||||
case *float32:
|
||||
return float64(*f)
|
||||
case *float64:
|
||||
return *f
|
||||
case *int:
|
||||
return float64(*f)
|
||||
case *int64:
|
||||
return float64(*f)
|
||||
case *string:
|
||||
return *f
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// func EncodeFloat(value any) any {
|
||||
// switch v := value.(type) {
|
||||
// case map[string]any:
|
||||
// if v["Float"] != nil {
|
||||
// val := v["Float"]
|
||||
// switch f := val.(type) {
|
||||
// case *float32:
|
||||
// return float64(*f)
|
||||
// case *float64:
|
||||
// return *f
|
||||
// case *int:
|
||||
// return float64(*f)
|
||||
// case *int64:
|
||||
// return float64(*f)
|
||||
// case *string:
|
||||
// return *f
|
||||
// default:
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func DecodeFloat(value any) (any, error) {
|
||||
switch v := value.(type) {
|
||||
|
@@ -13,26 +13,32 @@ type NullInt struct {
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func EncodeInt(value any) any {
|
||||
switch v := value.(type) {
|
||||
case map[string]any:
|
||||
if v["Int"] != nil {
|
||||
val := v["Int"]
|
||||
switch i := val.(type) {
|
||||
case *int:
|
||||
return *i
|
||||
case *int64:
|
||||
return *i
|
||||
case *string:
|
||||
return *i
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
// return val
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// func EncodeInt(value any) any {
|
||||
// switch v := value.(type) {
|
||||
// case NullInt:
|
||||
// if v.Valid {
|
||||
// return *v.Int
|
||||
// } else {
|
||||
// return nil
|
||||
// }
|
||||
// case map[string]any:
|
||||
// if v["Int"] != nil {
|
||||
// val := v["Int"]
|
||||
// switch i := val.(type) {
|
||||
// case *int:
|
||||
// return *i
|
||||
// case *int64:
|
||||
// return *i
|
||||
// case *string:
|
||||
// return *i
|
||||
// default:
|
||||
// return nil
|
||||
// }
|
||||
// // return val
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
func DecodeInt(value any) (any, error) {
|
||||
switch v := value.(type) {
|
||||
case int:
|
||||
|
@@ -17,11 +17,12 @@ const TimeFormat = "2006-01-02 15:04:05"
|
||||
type NullTime struct {
|
||||
Time *time.Time
|
||||
Valid bool
|
||||
Format string
|
||||
}
|
||||
|
||||
func (t *NullTime) IsZero() bool {
|
||||
return t.Valid
|
||||
}
|
||||
// func (t *NullTime) IsZero() bool {
|
||||
// return t.Valid
|
||||
// }
|
||||
func (t *NullTime) UnmarshalJSON(bs []byte) error {
|
||||
var date string
|
||||
err := json.Unmarshal(bs, &date)
|
||||
|
@@ -11,7 +11,7 @@ import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
"x_admin/middleware"
|
||||
"x_admin/routers"
|
||||
"x_admin/router"
|
||||
|
||||
_ "x_admin/docs"
|
||||
|
||||
@@ -28,23 +28,23 @@ var staticFs embed.FS
|
||||
func initRouter() *gin.Engine {
|
||||
// 初始化gin
|
||||
gin.SetMode(config.Config.GinMode)
|
||||
router := gin.New()
|
||||
router.MaxMultipartMemory = 8 << 20 // 8 MiB
|
||||
r := gin.New()
|
||||
r.MaxMultipartMemory = 8 << 20 // 8 MiB
|
||||
// 设置静态路径
|
||||
router.Static(config.Config.PublicPrefix, config.Config.UploadDirectory)
|
||||
r.Static(config.Config.PublicPrefix, config.Config.UploadDirectory)
|
||||
|
||||
staticHttpFs := http.FS(staticFs)
|
||||
router.GET("/api/static/*filepath", func(c *gin.Context) {
|
||||
r.GET("/api/static/*filepath", func(c *gin.Context) {
|
||||
filepath := c.Param("filepath")
|
||||
fmt.Println(filepath)
|
||||
|
||||
c.FileFromFS("static"+filepath, staticHttpFs)
|
||||
})
|
||||
// 设置中间件
|
||||
router.Use(gin.Logger(), middleware.Cors(), middleware.ErrorRecover())
|
||||
router.GET("/api/admin/apiList", middleware.TokenAuth(), func(ctx *gin.Context) {
|
||||
r.Use(gin.Logger(), middleware.Cors(), middleware.ErrorRecover())
|
||||
r.GET("/api/admin/apiList", middleware.TokenAuth(), func(ctx *gin.Context) {
|
||||
var path = []string{}
|
||||
for _, route := range router.Routes() {
|
||||
for _, route := range r.Routes() {
|
||||
// fmt.Printf("%s 127.0.0.1:%v%s\n", route.Method, config.Config.ServerPort, route.Path)
|
||||
path = append(path, route.Path)
|
||||
}
|
||||
@@ -53,17 +53,17 @@ func initRouter() *gin.Engine {
|
||||
|
||||
// 演示模式
|
||||
if config.Config.DisallowModify {
|
||||
router.Use(middleware.ShowMode())
|
||||
r.Use(middleware.ShowMode())
|
||||
}
|
||||
// 特殊异常处理
|
||||
router.NoMethod(response.NoMethod)
|
||||
// router.NoRoute(response.NoRoute)
|
||||
r.NoMethod(response.NoMethod)
|
||||
// r.NoRoute(response.NoRoute)
|
||||
// 注册路由
|
||||
apiGroup := router.Group("/api")
|
||||
apiGroup := r.Group("/api")
|
||||
|
||||
routers.RegisterGroup(apiGroup)
|
||||
router.RegisterGroup(apiGroup)
|
||||
|
||||
return router
|
||||
return r
|
||||
}
|
||||
|
||||
// initServer 初始化server
|
||||
|
@@ -1,18 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
)
|
||||
|
||||
// SystemLogSms 系统短信日志实体
|
||||
type SystemLogSms struct {
|
||||
Id int `gorm:"primarykey;comment:'id'"` // id
|
||||
Scene core.NullInt `gorm:"comment:'场景编号'"` // 场景编号
|
||||
Mobile string `gorm:"comment:'手机号码'"` // 手机号码
|
||||
Content string `gorm:"comment:'发送内容'"` // 发送内容
|
||||
Status core.NullInt `gorm:"comment:'发送状态:[0=发送中, 1=发送成功, 2=发送失败]'"` // 发送状态:[0=发送中, 1=发送成功, 2=发送失败]
|
||||
Results string `gorm:"comment:'短信结果'"` // 短信结果
|
||||
SendTime core.NullTime `gorm:"comment:'发送时间'"` // 发送时间
|
||||
CreateTime core.NullTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
UpdateTime core.NullTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
}
|
@@ -52,7 +52,7 @@ type SystemAuthMenu struct {
|
||||
Params string `gorm:"not null;default:'';comment:'路由参数'"`
|
||||
IsCache uint8 `gorm:"not null;default:0;comment:'是否缓存: 0=否, 1=是''"`
|
||||
IsShow uint8 `gorm:"not null;default:1;comment:'是否显示: 0=否, 1=是'"`
|
||||
IsDisable soft_delete.DeletedAt `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
|
||||
IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
|
||||
CreateTime core.NullTime `gorm:"autoCreateTime;not null;comment:'创建时间'"`
|
||||
UpdateTime core.NullTime `gorm:"autoUpdateTime;not null;comment:'更新时间'"`
|
||||
}
|
||||
|
17
server/model/user_protocol.go
Normal file
17
server/model/user_protocol.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package model
|
||||
import (
|
||||
"x_admin/core"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
)
|
||||
|
||||
//UserProtocol 用户协议实体
|
||||
type UserProtocol struct {
|
||||
Id int `gorm:"primarykey;comment:''"` //
|
||||
Title string `gorm:"comment:'标题'"` // 标题
|
||||
Content string `gorm:"comment:'协议内容'"` // 协议内容
|
||||
Sort core.NullFloat `gorm:"comment:'排序'"` // 排序
|
||||
IsDelete soft_delete.DeletedAt `gorm:"not null;default:0;softDelete:flag,DeletedAtField:DeleteTime;comment:'是否删除: 0=否, 1=是'"`
|
||||
CreateTime core.NullTime `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
UpdateTime core.NullTime `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
DeleteTime core.NullTime `gorm:"comment:'删除时间'"` // 删除时间
|
||||
}
|
@@ -60,5 +60,6 @@ func RegisterGroup(rg *gin.RouterGroup) {
|
||||
MonitorProjectRoute(rg)
|
||||
MonitorClientRoute(rg)
|
||||
MonitorWebRoute(rg)
|
||||
SystemLogSmsRoute(rg)
|
||||
|
||||
UserProtocolRoute(rg)
|
||||
}
|
56
server/router/admin/user_protocol_route.go
Normal file
56
server/router/admin/user_protocol_route.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/middleware"
|
||||
"x_admin/admin/user_protocol"
|
||||
)
|
||||
|
||||
/**
|
||||
集成
|
||||
1. 导入
|
||||
- 请先提交git避免文件覆盖!!!
|
||||
- 下载并解压压缩包后,直接复制server、admin文件夹到项目根目录即可
|
||||
|
||||
2. 注册路由
|
||||
请在 admin/entry.go 文件引入UserProtocolRoute注册路由
|
||||
|
||||
3. 后台手动添加菜单和按钮
|
||||
admin:user_protocol:add
|
||||
admin:user_protocol:edit
|
||||
admin:user_protocol:del
|
||||
admin:user_protocol:list
|
||||
admin:user_protocol:listAll
|
||||
admin:user_protocol:detail
|
||||
admin:user_protocol:ExportFile
|
||||
admin:user_protocol:ImportFile
|
||||
|
||||
// 列表-先添加菜单获取菜单id
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, paths, component, is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'C', '用户协议', 'user/protocol/index', 'user/protocol/index', 0, 1, 0, now(), now());
|
||||
按钮-替换pid参数为菜单id
|
||||
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议添加','admin:user_protocol:add', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议编辑','admin:user_protocol:edit', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议删除','admin:user_protocol:del', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议列表','admin:user_protocol:list', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议全部列表','admin:user_protocol:listAll', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议详情','admin:user_protocol:detail', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议导出excel','admin:user_protocol:ExportFile', 0, 1, 0, now(), now());
|
||||
INSERT INTO x_system_auth_menu (pid, menu_type, menu_name, perms,is_cache, is_show, is_disable, create_time, update_time) VALUES (0, 'A', '用户协议导入excel','admin:user_protocol:ImportFile', 0, 1, 0, now(), now());
|
||||
*/
|
||||
|
||||
|
||||
// UserProtocolRoute(rg)
|
||||
func UserProtocolRoute(rg *gin.RouterGroup) {
|
||||
handle := user_protocol.UserProtocolHandler{}
|
||||
|
||||
r := rg.Group("/", middleware.TokenAuth())
|
||||
r.GET("/user_protocol/list", handle.List)
|
||||
r.GET("/user_protocol/listAll", handle.ListAll)
|
||||
r.GET("/user_protocol/detail", handle.Detail)
|
||||
r.POST("/user_protocol/add",middleware.RecordLog("用户协议新增"), handle.Add)
|
||||
r.POST("/user_protocol/edit",middleware.RecordLog("用户协议编辑"), handle.Edit)
|
||||
r.POST("/user_protocol/del", middleware.RecordLog("用户协议删除"), handle.Del)
|
||||
r.GET("/user_protocol/ExportFile", middleware.RecordLog("用户协议导出"), handle.ExportFile)
|
||||
r.POST("/user_protocol/ImportFile", handle.ImportFile)
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
package routers
|
||||
package router
|
||||
|
||||
import (
|
||||
"x_admin/admin"
|
||||
"x_admin/admin/common/captcha"
|
||||
"x_admin/router/admin"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"x_admin/core"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
@@ -13,13 +14,12 @@ var ConvertUtil = convertUtil{}
|
||||
// convertUtil 转换工具
|
||||
type convertUtil struct{}
|
||||
|
||||
// StructToMap 结构体转换成map
|
||||
// StructToMap 结构体转换成map,深度转换
|
||||
func (c convertUtil) StructToMap(from interface{}) map[string]interface{} {
|
||||
// var m = map[string]interface{}{}
|
||||
// mapstructure.Decode(from, &m) //mapstructure
|
||||
// mapstructure.Decode(from, &m) //深度转换所有结构体
|
||||
|
||||
// m, _ := convertor.StructToMap(from) // 需要tag:json
|
||||
m := structs.Map(from) // 需要tag:structs
|
||||
m := structs.Map(from) // 需要tag:structs,深度转换
|
||||
return m
|
||||
}
|
||||
|
||||
@@ -37,6 +37,35 @@ func (c convertUtil) StructsToMaps(from interface{}) (data []map[string]interfac
|
||||
return data
|
||||
}
|
||||
|
||||
// ShallowStructToMap 将结构体转换成map,浅转换
|
||||
func (c convertUtil) ShallowStructToMap(from interface{}) map[string]interface{} {
|
||||
m := make(map[string]interface{})
|
||||
v := reflect.ValueOf(from)
|
||||
t := v.Type()
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
value := v.Field(i).Interface()
|
||||
m[field.Name] = value
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// ShallowStructsToMaps 将结构体列表转换成Map列表,浅转换
|
||||
func (c convertUtil) ShallowStructsToMaps(from interface{}) (data []map[string]interface{}) {
|
||||
var objList []interface{}
|
||||
err := copier.Copy(&objList, from)
|
||||
if err != nil {
|
||||
core.Logger.Errorf("convertUtil.StructsToMaps err: err=[%+v]", err)
|
||||
return nil
|
||||
}
|
||||
for _, v := range objList {
|
||||
data = append(data, c.ShallowStructToMap(v))
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// MapToStruct 将map弱类型转换成结构体
|
||||
func (c convertUtil) MapToStruct(from interface{}, to interface{}) (err error) {
|
||||
err = mapstructure.WeakDecode(from, to) // 需要tag:mapstructure
|
||||
|
@@ -22,6 +22,16 @@ type Col struct {
|
||||
Decode func(value any) (any, error) //实现类型、值的替换
|
||||
}
|
||||
|
||||
// 定义编码接口
|
||||
type Encode interface {
|
||||
String() string
|
||||
}
|
||||
|
||||
// // 定义解码接口
|
||||
// type Decode interface {
|
||||
// MarshalJSON() ([]byte, error)
|
||||
// }
|
||||
|
||||
// 下载
|
||||
func DownLoadExcel(fileName string, res http.ResponseWriter, file *excelize.File) {
|
||||
// 设置响应头
|
||||
|
@@ -26,7 +26,7 @@ func GetExcelColumnName(columnNumber int) string {
|
||||
func Export(lists any, cols []Col, sheet string, title string) (file *excelize.File, err error) {
|
||||
e := ExcelInit()
|
||||
|
||||
data := util.ConvertUtil.StructsToMaps(lists)
|
||||
data := util.ConvertUtil.ShallowStructsToMaps(lists)
|
||||
|
||||
err = ExportExcel(sheet, title, data, cols, e)
|
||||
if err != nil {
|
||||
@@ -87,7 +87,7 @@ func buildTitle(e *Excel, sheet, title string, cols []Col) (endColName string, s
|
||||
}
|
||||
|
||||
// 构造数据行
|
||||
func buildDataRow(e *Excel, sheet, endColName string, startDataRow int, lists []map[string]interface{}, cols []Col) (err error) {
|
||||
func buildDataRow(e *Excel, sheet, endColName string, startDataRow int, lists []map[string]any, cols []Col) (err error) {
|
||||
//实时写入数据
|
||||
for i := 0; i < len(lists); i++ {
|
||||
startCol := fmt.Sprintf("A%d", startDataRow)
|
||||
@@ -105,7 +105,10 @@ func buildDataRow(e *Excel, sheet, endColName string, startDataRow int, lists []
|
||||
// 先编码
|
||||
if col.Encode != nil {
|
||||
val = col.Encode(val)
|
||||
} else if v, ok := val.(Encode); ok {
|
||||
val = v.String()
|
||||
}
|
||||
|
||||
// 再替换
|
||||
for replaceKey, v := range replace {
|
||||
|
||||
@@ -132,4 +135,5 @@ func buildDataRow(e *Excel, sheet, endColName string, startDataRow int, lists []
|
||||
startDataRow++
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
10
x_admin_app/.vscode/settings.json
vendored
10
x_admin_app/.vscode/settings.json
vendored
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"bignumber",
|
||||
"dcloudio",
|
||||
"fota",
|
||||
"IMEI",
|
||||
@@ -7,5 +8,14 @@
|
||||
"nomore",
|
||||
"pinia",
|
||||
"realname"
|
||||
],
|
||||
"cSpell.ignorePaths":[
|
||||
"package-lock.json",
|
||||
"node_modules",
|
||||
"vscode-extension",
|
||||
".git/objects",
|
||||
".vscode",
|
||||
".vscode-insiders",
|
||||
"uni_modules"
|
||||
]
|
||||
}
|
@@ -1,95 +0,0 @@
|
||||
import { request } from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
import { clearObjEmpty } from "@/utils/utils";
|
||||
|
||||
export type type_system_log_sms = {
|
||||
Id?: number;
|
||||
Scene?: number;
|
||||
Mobile?: string;
|
||||
Content?: string;
|
||||
Status?: number;
|
||||
Results?: string;
|
||||
SendTime?: string;
|
||||
CreateTime?: string;
|
||||
UpdateTime?: string;
|
||||
}
|
||||
// 查询
|
||||
export type type_system_log_sms_query = {
|
||||
Scene?: number;
|
||||
Mobile?: string;
|
||||
Content?: string;
|
||||
Status?: number;
|
||||
Results?: string;
|
||||
SendTimeStart?: string;
|
||||
SendTimeEnd?: string;
|
||||
CreateTimeStart?: string;
|
||||
CreateTimeEnd?: string;
|
||||
UpdateTimeStart?: string;
|
||||
UpdateTimeEnd?: string;
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_system_log_sms_edit = {
|
||||
Id?: number;
|
||||
Scene?: number;
|
||||
Mobile?: string;
|
||||
Content?: string;
|
||||
Status?: number;
|
||||
Results?: string;
|
||||
SendTime?: string;
|
||||
}
|
||||
|
||||
|
||||
// 系统短信日志列表
|
||||
export function system_log_sms_list(params?: type_system_log_sms_query) {
|
||||
return request<Pages<type_system_log_sms>>({
|
||||
url: '/system_log_sms/list',
|
||||
method: 'GET',
|
||||
data: clearObjEmpty(params)
|
||||
})
|
||||
}
|
||||
// 系统短信日志列表-所有
|
||||
export function system_log_sms_list_all(params?: type_system_log_sms_query) {
|
||||
return request<type_system_log_sms[]>({
|
||||
url: '/system_log_sms/listAll',
|
||||
method: 'GET',
|
||||
data: clearObjEmpty(params)
|
||||
})
|
||||
}
|
||||
|
||||
// 系统短信日志详情
|
||||
export function system_log_sms_detail(Id: number | string) {
|
||||
return request<type_system_log_sms>({
|
||||
url: '/system_log_sms/detail',
|
||||
method: 'GET',
|
||||
data: { Id }
|
||||
})
|
||||
}
|
||||
|
||||
// 系统短信日志新增
|
||||
export function system_log_sms_add(data: type_system_log_sms_edit) {
|
||||
return request<null>({
|
||||
url: '/system_log_sms/add',
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 系统短信日志编辑
|
||||
export function system_log_sms_edit(data: type_system_log_sms_edit) {
|
||||
return request<null>({
|
||||
url: '/system_log_sms/edit',
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 系统短信日志删除
|
||||
export function system_log_sms_delete(Id: number | string) {
|
||||
return request<null>({
|
||||
url: '/system_log_sms/del',
|
||||
method: "POST",
|
||||
data:{
|
||||
Id
|
||||
},
|
||||
});
|
||||
}
|
87
x_admin_app/api/user/protocol.ts
Normal file
87
x_admin_app/api/user/protocol.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import { request } from '@/utils/request'
|
||||
import type { Pages } from '@/utils/request'
|
||||
import { clearObjEmpty } from "@/utils/utils";
|
||||
|
||||
export type type_user_protocol = {
|
||||
Id?: number;
|
||||
Title?: string;
|
||||
Content?: string;
|
||||
Sort?: number;
|
||||
IsDelete?: number;
|
||||
CreateTime?: string;
|
||||
UpdateTime?: string;
|
||||
DeleteTime?: string;
|
||||
}
|
||||
// 查询
|
||||
export type type_user_protocol_query = {
|
||||
Title?: string;
|
||||
Content?: string;
|
||||
Sort?: number;
|
||||
CreateTimeStart?: string;
|
||||
CreateTimeEnd?: string;
|
||||
UpdateTimeStart?: string;
|
||||
UpdateTimeEnd?: string;
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_user_protocol_edit = {
|
||||
Id?: number;
|
||||
Title?: string;
|
||||
Content?: string;
|
||||
Sort?: number;
|
||||
}
|
||||
|
||||
|
||||
// 用户协议列表
|
||||
export function user_protocol_list(params?: type_user_protocol_query) {
|
||||
return request<Pages<type_user_protocol>>({
|
||||
url: '/user_protocol/list',
|
||||
method: 'GET',
|
||||
data: clearObjEmpty(params)
|
||||
})
|
||||
}
|
||||
// 用户协议列表-所有
|
||||
export function user_protocol_list_all(params?: type_user_protocol_query) {
|
||||
return request<type_user_protocol[]>({
|
||||
url: '/user_protocol/listAll',
|
||||
method: 'GET',
|
||||
data: clearObjEmpty(params)
|
||||
})
|
||||
}
|
||||
|
||||
// 用户协议详情
|
||||
export function user_protocol_detail(Id: number | string) {
|
||||
return request<type_user_protocol>({
|
||||
url: '/user_protocol/detail',
|
||||
method: 'GET',
|
||||
data: { Id }
|
||||
})
|
||||
}
|
||||
|
||||
// 用户协议新增
|
||||
export function user_protocol_add(data: type_user_protocol_edit) {
|
||||
return request<null>({
|
||||
url: '/user_protocol/add',
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 用户协议编辑
|
||||
export function user_protocol_edit(data: type_user_protocol_edit) {
|
||||
return request<null>({
|
||||
url: '/user_protocol/edit',
|
||||
method: "POST",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 用户协议删除
|
||||
export function user_protocol_delete(Id: number | string) {
|
||||
return request<null>({
|
||||
url: '/user_protocol/del',
|
||||
method: "POST",
|
||||
data:{
|
||||
Id
|
||||
},
|
||||
});
|
||||
}
|
@@ -2,8 +2,8 @@
|
||||
"name": "x_admin_app",
|
||||
"appid": "__UNI__FB29F21",
|
||||
"description": "",
|
||||
"versionName": "1.0.3",
|
||||
"versionCode": 103,
|
||||
"versionName": "2024.08.170956",
|
||||
"versionCode": 104,
|
||||
"transformPx": false,
|
||||
"app-plus": {
|
||||
"compatible": {
|
||||
|
@@ -73,34 +73,6 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索监控-客户端信息"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/system/log/sms/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/details",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志详情",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑系统短信日志"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索系统短信日志"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,32 +0,0 @@
|
||||
// 请将pages里的数据手动合并到根目录下pages.json中
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/system/log/sms/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/details",
|
||||
"style": {
|
||||
"navigationBarTitleText": "系统短信日志详情",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑系统短信日志"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/system/log/sms/search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索系统短信日志"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@@ -1,23 +1,14 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-form labelPosition="left" :model="form">
|
||||
<uv-form-item label="场景编号" prop="Scene" borderBottom>
|
||||
{{form.Scene}}
|
||||
<uv-form-item label="标题" prop="Title" borderBottom>
|
||||
{{form.Title}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="手机号码" prop="Mobile" borderBottom>
|
||||
{{form.Mobile}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送内容" prop="Content" borderBottom>
|
||||
<uv-form-item label="协议内容" prop="Content" borderBottom>
|
||||
{{form.Content}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="Status" borderBottom>
|
||||
{{form.Status}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="短信结果" prop="Results" borderBottom>
|
||||
{{form.Results}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送时间" prop="SendTime" borderBottom>
|
||||
{{form.SendTime}}
|
||||
<uv-form-item label="排序" prop="Sort" borderBottom>
|
||||
{{form.Sort}}
|
||||
</uv-form-item>
|
||||
<uv-form-item label="创建时间" prop="CreateTime" borderBottom>
|
||||
{{form.CreateTime}}
|
||||
@@ -27,7 +18,7 @@
|
||||
</uv-form-item>
|
||||
</uv-form>
|
||||
<uv-button
|
||||
v-if="$perms('admin:system_log_sms:edit')"
|
||||
v-if="$perms('admin:user_protocol:edit')"
|
||||
type="primary"
|
||||
text="编辑"
|
||||
customStyle="margin: 40rpx 0"
|
||||
@@ -41,7 +32,7 @@
|
||||
import {ref} from "vue";
|
||||
import { onLoad,onShow } from "@dcloudio/uni-app";
|
||||
import { useDictData,useListAllData } from "@/hooks/useDictOptions";
|
||||
import { system_log_sms_detail } from "@/api/system_log_sms";
|
||||
import { user_protocol_detail } from "@/api/user/protocol";
|
||||
|
||||
|
||||
import {
|
||||
@@ -52,12 +43,9 @@
|
||||
|
||||
let form = ref({
|
||||
Id: "",
|
||||
Scene: "",
|
||||
Mobile: "",
|
||||
Title: "",
|
||||
Content: "",
|
||||
Status: "",
|
||||
Results: "",
|
||||
SendTime: "",
|
||||
Sort: "",
|
||||
CreateTime: "",
|
||||
UpdateTime: "",
|
||||
});
|
||||
@@ -75,7 +63,7 @@
|
||||
getDetails(form.value.id);
|
||||
});
|
||||
function getDetails(id: number | string) {
|
||||
system_log_sms_detail(id).then((res) => {
|
||||
user_protocol_detail(id).then((res) => {
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.code == 200) {
|
||||
if (res?.data) {
|
||||
@@ -92,7 +80,7 @@
|
||||
}
|
||||
|
||||
function edit() {
|
||||
toPath("/pages/system/log/sms/edit", { id: form.value.id });
|
||||
toPath("/pages/user/protocol/edit", { id: form.value.id });
|
||||
}
|
||||
</script>
|
||||
|
@@ -1,25 +1,16 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-form labelPosition="left" :model="form" :rules="formRules" ref="formRef">
|
||||
<uv-form-item label="id" prop="Id" borderBottom>
|
||||
<uv-form-item label="" prop="Id" borderBottom>
|
||||
<uv-number-box v-model="form.Id" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="场景编号" prop="Scene" borderBottom>
|
||||
<uv-number-box v-model="form.Scene" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
<uv-form-item label="标题" prop="Title" borderBottom>
|
||||
<uv-input v-model="form.Title" border="surround"></uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="手机号码" prop="Mobile" borderBottom>
|
||||
<uv-input v-model="form.Mobile" border="surround"></uv-input>
|
||||
<uv-form-item label="协议内容" prop="Content" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送内容" prop="Content" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="Status" borderBottom>
|
||||
请选择字典生成代码
|
||||
</uv-form-item>
|
||||
<uv-form-item label="短信结果" prop="Results" borderBottom>
|
||||
<uv-textarea v-model="form.Results" border="surround"></uv-textarea>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送时间" prop="SendTime" borderBottom>
|
||||
<x-date v-model:time="form.SendTime"></x-date>
|
||||
<uv-form-item label="排序" prop="Sort" borderBottom>
|
||||
<uv-number-box v-model="form.Sort" :min="-99999999" :max="99999999" :integer="true"></uv-number-box>
|
||||
</uv-form-item>
|
||||
|
||||
<uv-button type="primary" text="提交" customStyle="margin: 40rpx 0"
|
||||
@@ -34,11 +25,11 @@
|
||||
onLoad
|
||||
} from "@dcloudio/uni-app";
|
||||
import {
|
||||
system_log_sms_detail,
|
||||
system_log_sms_edit,
|
||||
system_log_sms_add
|
||||
} from "@/api/system_log_sms";
|
||||
import type { type_system_log_sms_edit } from "@/api/system_log_sms";
|
||||
user_protocol_detail,
|
||||
user_protocol_edit,
|
||||
user_protocol_add
|
||||
} from "@/api/user_protocol";
|
||||
import type { type_user_protocol_edit } from "@/api/user/protocol";
|
||||
|
||||
import {
|
||||
toast,
|
||||
@@ -50,62 +41,38 @@
|
||||
import type { type_dict } from '@/hooks/useDictOptions'
|
||||
|
||||
let formRef = ref();
|
||||
let form = ref<type_system_log_sms_edit>({
|
||||
let form = ref<type_user_protocol_edit>({
|
||||
Id: 0,
|
||||
Scene: 0,
|
||||
Mobile: '',
|
||||
Title: '',
|
||||
Content: '',
|
||||
Status: '',
|
||||
Results: '',
|
||||
SendTime: '',
|
||||
Sort: 0,
|
||||
});
|
||||
const formRules = {
|
||||
Id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入id',
|
||||
message: '请输入',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Scene: [
|
||||
Title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入场景编号',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入手机号码',
|
||||
message: '请输入标题',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Content: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入发送内容',
|
||||
message: '请输入协议内容',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Status: [
|
||||
Sort: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择发送状态:[0=发送中, 1=发送成功, 2=发送失败]',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
Results: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入短信结果',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
SendTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择发送时间',
|
||||
message: '请输入排序',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
@@ -118,7 +85,7 @@
|
||||
});
|
||||
|
||||
function getDetails(Id) {
|
||||
system_log_sms_detail(Id).then((res) => {
|
||||
user_protocol_detail(Id).then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (res?.data) {
|
||||
form.value = res?.data
|
||||
@@ -136,7 +103,7 @@
|
||||
console.log("submit", form.value);
|
||||
formRef.value.validate().then(() => {
|
||||
if (form.value.Id) {
|
||||
system_log_sms_edit(form.value).then((res) => {
|
||||
user_protocol_edit(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("编辑成功");
|
||||
getDetails(form.value?.Id);
|
||||
@@ -145,7 +112,7 @@
|
||||
}
|
||||
});
|
||||
}else{
|
||||
system_log_sms_add(form.value).then((res) => {
|
||||
user_protocol_add(form.value).then((res) => {
|
||||
if (res.code == 200) {
|
||||
toast("添加成功");
|
||||
uni.navigateBack();
|
@@ -7,7 +7,7 @@
|
||||
leftText=""
|
||||
:safeAreaInsetTop="false"
|
||||
:fixed="false"
|
||||
title="系统短信日志"
|
||||
title="用户协议"
|
||||
autoBack
|
||||
>
|
||||
<template v-slot:right>
|
||||
@@ -32,7 +32,7 @@
|
||||
<wd-button v-if="!fromSearch" custom-class="fab-button" type="primary" round @click="moreSearch" >
|
||||
<wd-icon name="search" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
<wd-button v-if="$perms('admin:system_log_sms:add')" custom-class="fab-button" type="primary" round @click="add">
|
||||
<wd-button v-if="$perms('admin:user_protocol:add')" custom-class="fab-button" type="primary" round @click="add">
|
||||
<wd-icon name="add" size="20px"></wd-icon>
|
||||
</wd-button>
|
||||
</wd-fab>
|
||||
@@ -63,19 +63,15 @@ import {
|
||||
onReachBottom,
|
||||
onPageScroll,
|
||||
} from "@dcloudio/uni-app";
|
||||
import { system_log_sms_list } from "@/api/system_log_sms";
|
||||
import type { type_system_log_sms,type_system_log_sms_query } from "@/api/system_log_sms";
|
||||
import { user_protocol_list } from "@/api/user/protocol";
|
||||
import type { type_user_protocol,type_user_protocol_query } from "@/api/user/protocol";
|
||||
|
||||
import { usePaging } from "@/hooks/usePaging";
|
||||
import { toPath } from "@/utils/utils";
|
||||
const queryParams = reactive<type_system_log_sms_query>({
|
||||
Scene: '',
|
||||
Mobile: '',
|
||||
const queryParams = reactive<type_user_protocol_query>({
|
||||
Title: '',
|
||||
Content: '',
|
||||
Status: '',
|
||||
Results: '',
|
||||
SendTimeStart: '',
|
||||
SendTimeEnd: '',
|
||||
Sort: '',
|
||||
CreateTimeStart: '',
|
||||
CreateTimeEnd: '',
|
||||
UpdateTimeStart: '',
|
||||
@@ -84,7 +80,7 @@ const queryParams = reactive<type_system_log_sms_query>({
|
||||
let activeFab = ref(false);
|
||||
let fromSearch=ref(false);
|
||||
onLoad((e) => {
|
||||
console.log("system_log_sms onLoad", e);
|
||||
console.log("user_protocol onLoad", e);
|
||||
if (e) {
|
||||
for (const key in e) {
|
||||
if (Object.hasOwnProperty.call(e, key)) {
|
||||
@@ -95,8 +91,8 @@ onLoad((e) => {
|
||||
}
|
||||
getLists();
|
||||
});
|
||||
const { pager, getLists, NextPage, resetPage, resetParams } = usePaging<type_system_log_sms>({
|
||||
fetchFun: system_log_sms_list,
|
||||
const { pager, getLists, NextPage, resetPage, resetParams } = usePaging<type_user_protocol>({
|
||||
fetchFun: user_protocol_list,
|
||||
params: queryParams,
|
||||
});
|
||||
let scrollTop = ref(0);
|
||||
@@ -111,13 +107,13 @@ onReachBottom(() => {
|
||||
});
|
||||
|
||||
function toDetails(item) {
|
||||
toPath("/pages/system/log/sms/details", { Id: item.Id });
|
||||
toPath("/pages/user/protocol/details", { Id: item.Id });
|
||||
}
|
||||
function moreSearch() {
|
||||
toPath("/pages/system/log/sms/search");
|
||||
toPath("/pages/user/protocol/search");
|
||||
}
|
||||
function add() {
|
||||
toPath("/pages/system/log/sms/edit");
|
||||
toPath("/pages/user/protocol/edit");
|
||||
}
|
||||
</script>
|
||||
|
32
x_admin_app/pages/user/protocol/pages.json
Normal file
32
x_admin_app/pages/user/protocol/pages.json
Normal file
@@ -0,0 +1,32 @@
|
||||
// 请将pages里的数据手动合并到根目录下pages.json中
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/user/protocol/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议",
|
||||
"enablePullDownRefresh": true,
|
||||
"onReachBottomDistance": 100
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/protocol/details",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议详情",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/protocol/edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑用户协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/protocol/search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索用户协议"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@@ -1,20 +1,12 @@
|
||||
<template>
|
||||
<view class="page-content">
|
||||
<uv-form labelPosition="left" labelWidth="80" :model="form">
|
||||
<uv-form-item label="场景编号" prop="Scene" borderBottom>
|
||||
<uv-form-item label="标题" prop="Title" borderBottom>
|
||||
<uv-input v-model="form.Title"> </uv-input>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="手机号码" prop="Mobile" borderBottom>
|
||||
<uv-input v-model="form.Mobile"> </uv-input>
|
||||
<uv-form-item label="协议内容" prop="Content" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送内容" prop="Content" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送状态:[0=发送中, 1=发送成功, 2=发送失败]" prop="Status" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="短信结果" prop="Results" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="发送时间" prop="SendTime" borderBottom>
|
||||
<x-date-range v-model:startTime="form.SendTimeStart"
|
||||
v-model:endTime="form.SendTimeEnd"></x-date-range>
|
||||
<uv-form-item label="排序" prop="Sort" borderBottom>
|
||||
</uv-form-item>
|
||||
<uv-form-item label="创建时间" prop="CreateTime" borderBottom>
|
||||
<x-date-range v-model:startTime="form.CreateTimeStart"
|
||||
@@ -49,16 +41,12 @@
|
||||
useDictData,useListAllData
|
||||
} from "@/hooks/useDictOptions";
|
||||
import xDateRange from "@/components/x-date-range/x-date-range.vue";
|
||||
import type {type_system_log_sms_query} from "@/api/system_log_sms";
|
||||
import type {type_user_protocol_query} from "@/api/user/protocol";
|
||||
|
||||
let form = ref<type_system_log_sms_query>({
|
||||
Scene: null,
|
||||
Mobile: null,
|
||||
let form = ref<type_user_protocol_query>({
|
||||
Title: null,
|
||||
Content: null,
|
||||
Status: null,
|
||||
Results: null,
|
||||
SendTimeStart: null,
|
||||
SendTimeEnd: null,
|
||||
Sort: null,
|
||||
CreateTimeStart: null,
|
||||
CreateTimeEnd: null,
|
||||
UpdateTimeStart: null,
|
||||
@@ -74,7 +62,7 @@
|
||||
return toast("请输入查询条件");
|
||||
}
|
||||
|
||||
toPath("/pages/system/log/sms/index", search);
|
||||
toPath("/pages/user/protocol/index", search);
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user