From fd3414f7c712435171e5d886264e411d704fdd02 Mon Sep 17 00:00:00 2001 From: chenlin Date: Wed, 23 Apr 2025 18:00:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E7=9F=AD=E4=BF=A1=E6=A8=A1?= =?UTF-8?q?=E7=89=88=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/apis/bus_apis/a_sms_manage.go | 1081 +++++++++- app/admin/models/bus_models/m_sms_manage.go | 325 ++- app/admin/router/bus_sms_manage.go | 42 +- app/admin/service/bus_service/s_sms_manage.go | 854 +++++++- docs/admin/admin_docs.go | 1880 ++++++++++++++++- docs/admin/admin_swagger.json | 1880 ++++++++++++++++- docs/admin/admin_swagger.yaml | 1204 ++++++++++- tools/utils/utils.go | 9 + 8 files changed, 7221 insertions(+), 54 deletions(-) create mode 100644 tools/utils/utils.go diff --git a/app/admin/apis/bus_apis/a_sms_manage.go b/app/admin/apis/bus_apis/a_sms_manage.go index deca469..61bcda8 100644 --- a/app/admin/apis/bus_apis/a_sms_manage.go +++ b/app/admin/apis/bus_apis/a_sms_manage.go @@ -13,8 +13,11 @@ import ( "go-admin/app/admin/service/bus_service" "go-admin/tools/app" "go-admin/tools/crypto" + "go-admin/tools/utils" "io" + "strconv" "strings" + "time" ) type SmsApi struct { @@ -807,6 +810,132 @@ func (e SmsApi) ListSignatureRealname(c *gin.Context) { app.OK(c, resp, "查询成功") } +// AddContactsCategory 新增通讯录分类节点 +// @Summary 新增通讯录分类节点 +// @Tags 短信管理-通讯录 +// @Accept json +// @Produce json +// @Param request body bus_models.AddContactCategoryReq true "分类信息" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/contacts_category/add [post] +func (e SmsApi) AddContactsCategory(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.AddContactCategoryReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + err = smsService.AddContactsCategory(req, e.Orm) + if err != nil { + e.Error(500, err, "添加失败") + return + } + + app.OK(c, nil, "添加成功") +} + +// EditContactsCategory 编辑通讯录分类节点 +// @Summary 编辑通讯录分类节点 +// @Tags 短信管理-通讯录 +// @Accept json +// @Produce json +// @Param request body bus_models.EditContactCategoryReq true "编辑信息" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/contacts_category/edit [post] +func (e SmsApi) EditContactsCategory(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.EditContactCategoryReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + err = smsService.EditContactsCategory(req, e.Orm) + if err != nil { + e.Error(500, err, "编辑失败") + return + } + + app.OK(c, nil, "编辑成功") +} + +// ListContactsCategories 查询通讯录分类列表(树形结构) +// @Summary 查询通讯录分类树 +// @Tags 短信管理-通讯录 +// @Accept json +// @Produce json +// @Param request body bus_models.ListContactCategoryRequest true "要删除的分类ID列表" +// @Success 200 {object} bus_models.SmsContactCategoryTree +// @Router /api/v1/sms/contacts_category/list [post] +func (e SmsApi) ListContactsCategories(c *gin.Context) { + var req bus_models.ListContactCategoryRequest + + smsService := bus_service.SmsService{} + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + data, err := smsService.GetContactsCategoryTree(e.Orm, req.CategoryID) + if err != nil { + e.Error(500, err, "查询失败") + return + } + + app.OK(c, data, "查询成功") +} + +// DeleteContactsCategories 删除通讯录分类 +// @Summary 删除通讯录分类 +// @Tags 短信管理-通讯录 +// @Accept json +// @Produce json +// @Param request body bus_models.DeleteContactCategoryRequest true "要删除的分类ID列表" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/contacts_category/delete [post] +func (e SmsApi) DeleteContactsCategories(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.DeleteContactCategoryRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(400, err, "参数绑定失败") + return + } + + err = smsService.DeleteContactsCategories(req.IDs, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + app.OK(c, nil, "删除成功") +} + // ListContacts 查询通讯录列表 // @Summary 查询通讯录列表 // @Tags 短信管理-通讯录 @@ -821,7 +950,7 @@ func (e SmsApi) ListContacts(c *gin.Context) { err := e.MakeContext(c). MakeOrm(). - Bind(&req, binding.Query). + Bind(&req, binding.JSON). MakeService(&smsService.Service). Errors if err != nil { @@ -845,12 +974,12 @@ func (e SmsApi) ListContacts(c *gin.Context) { // @Tags 短信管理-通讯录 // @Accept json // @Produce json -// @Param request body bus_models.SmsContact true "联系人信息" +// @Param request body bus_models.ContactInput true "联系人信息" // @Success 200 {object} app.Response // @Router /api/v1/sms/contacts/add [post] func (e SmsApi) AddContact(c *gin.Context) { smsService := bus_service.SmsService{} - var req bus_models.SmsContact + var req bus_models.ContactInput err := e.MakeContext(c). MakeOrm(). @@ -863,13 +992,55 @@ func (e SmsApi) AddContact(c *gin.Context) { return } - err = smsService.AddContact(req, e.Orm) - if err != nil { - e.Logger.Error(err) - e.Error(500, err, "新增联系人失败") + // 验证手机号格式(只做基础校验) + if !utils.IsValidPhone(req.PhoneNumber) { + e.Error(400, nil, "手机号格式不正确") return } + var birthday *time.Time + if req.BirthdayStr != "" { + t, err := time.Parse("2006-01-02", req.BirthdayStr) + if err != nil { + e.Error(400, nil, "生日格式应为 YYYY-MM-DD") + return + } + birthday = &t + } + + userName := user.GetUserName(c) + fmt.Println("userName is:", userName) + + // 查询合作商的编号和名称 + coopNum, coopName, err := bus_models.GetCooperativeInfoByAccount(e.Orm, userName) + if err != nil { + err = fmt.Errorf("GetCooperativeInfoByAccount error, %s", err.Error()) + return + } + + // 遍历分类ID列表,为每个分类添加联系人 + for _, categoryId := range req.CategoryID { + contact := bus_models.SmsContact{ + CategoryID: categoryId, + Name: req.Name, + PhoneNumber: req.PhoneNumber, + Gender: req.Gender, + Birthday: birthday, + Company: req.Company, + Address: req.Address, + Remark: req.Remark, + CooperativeName: coopName, + CooperativeNumber: coopNum, + } + + err = smsService.AddContact(contact, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, "新增联系人失败") + return + } + } + app.OK(c, nil, "新增联系人成功") } @@ -878,14 +1049,12 @@ func (e SmsApi) AddContact(c *gin.Context) { // @Tags 短信管理-通讯录 // @Accept json // @Produce json -// @Param id path int true "联系人ID" -// @Param request body bus_models.SmsContact true "联系人信息" +// @Param request body bus_models.EditContactInput true "联系人信息" // @Success 200 {object} app.Response // @Router /api/v1/sms/contacts/edit [post] func (e SmsApi) EditContact(c *gin.Context) { smsService := bus_service.SmsService{} - var req bus_models.SmsContact - id := c.Param("id") + var req bus_models.EditContactInput err := e.MakeContext(c). MakeOrm(). @@ -898,7 +1067,50 @@ func (e SmsApi) EditContact(c *gin.Context) { return } - err = smsService.EditContact(id, req, e.Orm) + if req.CategoryID == 0 { + e.Error(400, nil, "分类ID不能为空") + return + } + + // 手机号验证 + if !utils.IsValidPhone(req.PhoneNumber) { + e.Error(400, nil, "手机号格式不正确") + return + } + + // 生日格式处理 + var birthday *time.Time + if req.BirthdayStr != "" { + t, err := time.Parse("2006-01-02", req.BirthdayStr) + if err != nil { + e.Error(400, nil, "生日格式应为 YYYY-MM-DD") + return + } + birthday = &t + } + + userName := user.GetUserName(c) + coopNum, coopName, err := bus_models.GetCooperativeInfoByAccount(e.Orm, userName) + if err != nil { + e.Error(500, err, "获取合作商信息失败") + return + } + + // 构造用于更新的结构体 + contact := bus_models.SmsContact{ + CategoryID: req.CategoryID, + Name: req.Name, + PhoneNumber: req.PhoneNumber, + Gender: req.Gender, + Birthday: birthday, + Company: req.Company, + Address: req.Address, + Remark: req.Remark, + CooperativeName: coopName, + CooperativeNumber: coopNum, + } + + err = smsService.EditContact(req.ID, contact, e.Orm) if err != nil { e.Logger.Error(err) e.Error(500, err, "编辑联系人失败") @@ -940,3 +1152,848 @@ func (e SmsApi) BulkDeleteContacts(c *gin.Context) { app.OK(c, nil, "批量删除联系人成功") } + +// BulkImportContacts 批量导入通讯录 +// @Summary 批量导入通讯录 +// @Tags 短信管理-通讯录 +// @Accept multipart/form-data +// @Produce json +// @Param category_id formData file true "分类ID" +// @Param file formData file true "上传Excel文件" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/contacts/import [post] +func (e SmsApi) BulkImportContacts(c *gin.Context) { + smsService := bus_service.SmsService{} + + err := e.MakeContext(c). + MakeOrm(). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + categoryIdStr := c.PostForm("category_id") + if categoryIdStr == "" { + e.Error(400, nil, "分类ID不能为空") + return + } + + nCategoryId, err := strconv.ParseUint(categoryIdStr, 10, 64) + if err != nil { + e.Error(400, err, "分类ID格式错误") + return + } + + file, err := c.FormFile("file") + if err != nil { + e.Error(400, err, "上传文件失败") + return + } + openFile, err := file.Open() + if err != nil { + e.Error(500, err, "文件打开失败") + return + } + defer openFile.Close() + + userName := user.GetUserName(c) + coopNum, coopName, err := bus_models.GetCooperativeInfoByAccount(e.Orm, userName) + if err != nil { + e.Error(500, err, "获取合作商信息失败") + return + } + + err = smsService.ImportContactsFromExcel(openFile, e.Orm, coopNum, coopName, nCategoryId) + if err != nil { + e.Error(400, err, err.Error()) + return + } + + app.OK(c, nil, "导入成功") +} + +// BulkExportContacts 批量导出通讯录 +// @Summary 批量导出通讯录 +// @Tags 短信管理-通讯录 +// @Accept json +// @Produce json +// @Param data body bus_models.ExportContactsRequest true "请求参数" +// @Success 200 {object} bus_models.ExportContactsResp "下载链接" +// @Router /api/v1/sms/contacts/export [post] +func (e SmsApi) BulkExportContacts(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.ExportContactsRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + url, err := smsService.ExportContactsToExcel(e.Orm, req) + if err != nil { + e.Error(500, err, "导出失败") + return + } + + resp := bus_models.ExportContactsResp{ + ExportUrl: url, + } + + app.OK(c, resp, "导出成功") +} + +// AddPhraseCategory 新增短语分类节点 +// @Summary 新增短语分类节点 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param request body bus_models.AddPhraseCategoryReq true "分类信息" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/phrase_category/add [post] +func (e SmsApi) AddPhraseCategory(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.AddPhraseCategoryReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + err = smsService.AddPhraseCategory(req, e.Orm) + if err != nil { + e.Error(500, err, "添加失败") + return + } + + app.OK(c, nil, "添加成功") +} + +// EditPhraseCategory 编辑短语分类节点 +// @Summary 编辑短语分类节点 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param request body bus_models.EditPhraseCategoryReq true "编辑信息" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/phrase_category/edit [post] +func (e SmsApi) EditPhraseCategory(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.EditPhraseCategoryReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + err = smsService.EditPhraseCategory(req, e.Orm) + if err != nil { + e.Error(500, err, "编辑失败") + return + } + + app.OK(c, nil, "编辑成功") +} + +// ListPhraseCategories 查询常用短语分类列表(树形结构) +// @Summary 查询常用短语分类树 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param request body bus_models.ListPhraseCategoryRequest true "要删除的分类ID列表" +// @Success 200 {object} bus_models.SmsPhraseCategoryTree +// @Router /api/v1/sms/phrase_category/list [post] +func (e SmsApi) ListPhraseCategories(c *gin.Context) { + var req bus_models.ListPhraseCategoryRequest + + smsService := bus_service.SmsService{} + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + data, err := smsService.GetPhraseCategoryTree(e.Orm, req.CategoryID) + if err != nil { + e.Error(500, err, "查询失败") + return + } + + app.OK(c, data, "查询成功") +} + +// DeletePhraseCategories 删除常用短语分类 +// @Summary 删除常用短语分类 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param request body bus_models.DeletePhraseCategoryRequest true "要删除的分类ID列表" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/phrase_category/delete [post] +func (e SmsApi) DeletePhraseCategories(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.DeletePhraseCategoryRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(400, err, "参数绑定失败") + return + } + + err = smsService.DeletePhraseCategories(req.IDs, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + app.OK(c, nil, "删除成功") +} + +// ListPhrases 查询常用短语列表 +// @Summary 查询常用短语列表 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsPhraseQuery true "短语数据" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/phrase/list [post] +func (e SmsApi) ListPhrases(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsPhraseQuery + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + resp, err := smsService.ListPhrases(req, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, "查询失败") + return + } + + app.OK(c, resp, "查询成功") +} + +// AddPhrase 新增常用短语 +// @Summary 新增常用短语 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsPhraseAddOrEdit true "短语数据" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/phrase/add [post] +func (e SmsApi) AddPhrase(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsPhraseAddOrEdit + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + err = smsService.AddPhrase(req, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, "新增失败") + return + } + + app.OK(c, nil, "新增成功") +} + +// EditPhrase 编辑常用短语 +// @Summary 编辑常用短语 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsPhraseAddOrEdit true "短语数据" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/phrase/edit [post] +func (e SmsApi) EditPhrase(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsPhraseAddOrEdit + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + err = smsService.EditPhrase(req, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, "编辑失败") + return + } + + app.OK(c, nil, "编辑成功") +} + +// DeletePhrases 批量删除短语 +// @Summary 批量删除短语 +// @Tags 短信管理-通讯录-常用短语 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsPhraseBatchDeleteReq true "短语ID数组" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/phrase/delete [post] +func (e SmsApi) DeletePhrases(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsPhraseBatchDeleteReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + err = smsService.DeletePhrases(req.IDs, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, "删除失败") + return + } + + app.OK(c, nil, "删除成功") +} + +// ListCommonNumbers 常用号码列表 +// @Summary 常用号码列表 +// @Tags 短信管理-通讯录-常用号码 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsCommonNumberQuery true "查询参数" +// @Success 200 {object} bus_models.SmsCommonNumberListResp +// @Router /api/v1/sms/common_number/list [post] +func (e SmsApi) ListCommonNumbers(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsCommonNumberQuery + + if err := e.MakeContext(c).MakeOrm().Bind(&req, binding.JSON).MakeService(&smsService.Service).Errors; err != nil { + e.Error(500, err, err.Error()) + return + } + + resp, err := smsService.ListCommonNumbers(req, e.Orm) + if err != nil { + e.Error(500, err, "查询失败") + return + } + + app.OK(c, resp, "查询成功") +} + +// AddCommonNumber 添加常用号码 +// @Summary 添加常用号码 +// @Tags 短信管理-通讯录-常用号码 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsCommonNumberAddReq true "添加参数" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/common_number/add [post] +func (e SmsApi) AddCommonNumber(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsCommonNumberAddReq + + if err := e.MakeContext(c).MakeOrm().Bind(&req, binding.JSON).MakeService(&smsService.Service).Errors; err != nil { + e.Error(500, err, err.Error()) + return + } + + err := smsService.AddCommonNumber(req, e.Orm) + if err != nil { + e.Error(500, err, "添加失败") + return + } + + app.OK(c, nil, "添加成功") +} + +// AppendCommonNumber 追加号码 +// @Summary 追加号码 +// @Tags 短信管理-通讯录-常用号码 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsCommonNumberAppendReq true "追加参数" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/common_number/append [post] +func (e SmsApi) AppendCommonNumber(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsCommonNumberAppendReq + + if err := e.MakeContext(c).MakeOrm().Bind(&req, binding.JSON).MakeService(&smsService.Service).Errors; err != nil { + e.Error(500, err, err.Error()) + return + } + + err := smsService.AppendCommonNumber(req, e.Orm) + if err != nil { + e.Error(500, err, "追加失败") + return + } + + app.OK(c, nil, "追加成功") +} + +// CommonNumberDetail 常用号码详情 +// @Summary 常用号码详情 +// @Tags 短信管理-通讯录-常用号码 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsCommonNumberDetailReq true "常用号码详情模型" +// @Success 200 {object} bus_models.SmsCommonNumber +// @Router /api/v1/sms/common_number/detail [post] +func (e SmsApi) CommonNumberDetail(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsCommonNumberDetailReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + data, err := smsService.GetCommonNumberDetail(req.ID, e.Orm) + if err != nil { + e.Error(500, err, "获取详情失败") + return + } + + app.OK(c, data, "获取成功") +} + +// DeleteCommonNumbers 批量删除常用号码 +// @Summary 批量删除常用号码 +// @Tags 短信管理-通讯录-常用号码 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsCommonNumberDeleteReq true "ID列表" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/common_number/delete [post] +func (e SmsApi) DeleteCommonNumbers(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsCommonNumberDeleteReq + + if err := e.MakeContext(c).MakeOrm().Bind(&req, binding.JSON).MakeService(&smsService.Service).Errors; err != nil { + e.Error(500, err, err.Error()) + return + } + + err := smsService.DeleteCommonNumbers(req.Ids, e.Orm) + if err != nil { + e.Error(500, err, "删除失败") + return + } + + app.OK(c, nil, "删除成功") +} + +// ExportCommonNumber 导出常用号码 +// @Summary 导出常用号码 +// @Tags 短信管理-通讯录-常用号码 +// @Accept json +// @Produce application/octet-stream +// @Param data body bus_models.SmsCommonNumberExportReq true "ID列表" +// @Success 200 {file} bus_models.SmsCommonNumberExportResp +// @Router /api/v1/sms/common_number/export [get] +func (e SmsApi) ExportCommonNumber(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsCommonNumberExportReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + fileUrl, err := smsService.ExportCommonNumbers(req, e.Orm) + if err != nil { + e.Error(500, err, "导出失败") + return + } + + resp := bus_models.ExportContactsResp{ + ExportUrl: fileUrl, + } + + app.OK(c, resp, "导出成功") +} + +// AddBlacklistNumber 添加黑名单 +// @Summary 添加黑名单 +// @Tags 短信管理-通讯录-黑名单 +// @Accept json +// @Produce json +// @Param data body bus_models.BlacklistAddReq true "黑名单添加参数" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/black_list/add [post] +func (e SmsApi) AddBlacklistNumber(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.BlacklistAddReq + + if err := e.MakeContext(c).MakeOrm().Bind(&req, binding.JSON).MakeService(&smsService.Service).Errors; err != nil { + e.Error(500, err, err.Error()) + return + } + + if err := smsService.AddBlacklistNumber(req, e.Orm); err != nil { + e.Error(500, err, "添加失败") + return + } + + app.OK(c, nil, "添加成功") +} + +// ListBlacklist 黑名单列表 +// @Summary 黑名单列表 +// @Tags 短信管理-通讯录-黑名单 +// @Accept json +// @Produce json +// @Param data body bus_models.BlacklistQuery true "查询参数" +// @Success 200 {object} bus_models.BlacklistListResp +// @Router /api/v1/sms/black_list/list [post] +func (e SmsApi) ListBlacklist(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.BlacklistQuery + + if err := e.MakeContext(c).MakeOrm().Bind(&req, binding.JSON).MakeService(&smsService.Service).Errors; err != nil { + e.Error(500, err, err.Error()) + return + } + + resp, err := smsService.ListBlacklist(req, e.Orm) + if err != nil { + e.Error(500, err, "查询失败") + return + } + + app.OK(c, resp, "查询成功") +} + +// ExportBlacklist 批量导出黑名单 +// @Summary 批量导出黑名单 +// @Tags 短信管理-通讯录-黑名单 +// @Accept json +// @Produce json +// @Param data body bus_models.ExportBlacklistRequest true "请求参数" +// @Success 200 {object} bus_models.ExportContactsResp "下载链接" +// @Router /api/v1/sms/black_list/export [post] +func (e SmsApi) ExportBlacklist(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.ExportBlacklistRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + url, err := smsService.ExportBlacklistToExcel(e.Orm, req) + if err != nil { + e.Error(500, err, "导出失败") + return + } + + resp := bus_models.ExportContactsResp{ + ExportUrl: url, + } + app.OK(c, resp, "导出成功") +} + +// DeleteBlacklist 批量删除黑名单 +// @Summary 批量删除黑名单 +// @Tags 短信管理-通讯录-黑名单 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsBlacklistBatchDeleteReq true "黑名单ID数组" +// @Success 200 {object} app.Response +// @Router /api/v1/sms/black_list/delete [post] +func (e SmsApi) DeleteBlacklist(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsBlacklistBatchDeleteReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + err = smsService.DeleteBlacklist(req.IDs, e.Orm) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, "删除失败") + return + } + + app.OK(c, nil, "删除成功") +} + +// CreateSmsTemplate 新增短信模版 +// @Summary 新增短信模版 +// @Description 创建一条新的短信模版,默认为待审核状态 +// @Tags 短信管理-短信模版 +// @Accept json +// @Produce json +// @Param request body bus_models.SmsTemplateCreateRequest true "短信模版信息" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/template/create [post] +func (e SmsApi) CreateSmsTemplate(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsTemplateCreateRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + userName := user.GetUserName(c) + coopNum, coopName, err := bus_models.GetCooperativeInfoByAccount(e.Orm, userName) + if err != nil { + e.Logger.Error(err) + e.Error(500, err, "获取合作商信息失败") + return + } + + var smsTemplate bus_models.SmsTemplate + + smsTemplate.CooperativeName = coopName + smsTemplate.CooperativeNumber = coopNum + smsTemplate.Content = req.Content + smsTemplate.Status = 0 // 默认待审核 + smsTemplate.Remark = req.Remark + smsTemplate.ExpireAt = req.ExpireAt + + if err := smsService.CreateSmsTemplate(&smsTemplate, e.Orm); err != nil { + e.Logger.Error(err) + e.Error(500, err, "创建失败") + return + } + + app.OK(c, nil, "创建成功") +} + +// DeleteSmsTemplates 批量删除短信模版 +// @Summary 批量删除短信模版 +// @Tags 短信管理-短信模版 +// @Accept json +// @Produce json +// @Param request body bus_models.DeleteIdsRequest true "ID数组" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/template/delete [post] +func (e SmsApi) DeleteSmsTemplates(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.DeleteIdsRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + if err := smsService.DeleteSmsTemplates(req.IDs, e.Orm); err != nil { + e.Error(500, err, "删除失败") + return + } + + app.OK(c, nil, "删除成功") +} + +// UpdateSmsTemplate 修改短信模版 +// @Summary 修改短信模版 +// @Tags 短信管理-短信模版 +// @Accept json +// @Produce json +// @Param request body bus_models.SmsTemplateUpdateRequest true "短信模版更新信息" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/template/update [post] +func (e SmsApi) UpdateSmsTemplate(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsTemplateUpdateRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + if err := smsService.UpdateSmsTemplate(&req, e.Orm); err != nil { + e.Error(500, err, "更新失败") + return + } + + app.OK(c, nil, "更新成功") +} + +// ApproveSmsTemplate 审核短信模版 +// @Summary 审核短信模版 +// @Tags 短信管理-短信模版 +// @Accept json +// @Produce json +// @Param request body bus_models.ApproveTemplateRequest true "模版审核信息" +// @Success 200 {object} app.Response{msg=string} +// @Router /api/v1/sms/template/approve [post] +func (e SmsApi) ApproveSmsTemplate(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.ApproveTemplateRequest + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Error(500, err, err.Error()) + return + } + + if err := smsService.ApproveSmsTemplate(req.ID, req.Status, e.Orm); err != nil { + e.Error(500, err, "审核失败") + return + } + + app.OK(c, nil, "审核成功") +} + +// ListSmsTemplates 获取短信模版列表 +// @Summary 获取短信模版列表 +// @Tags 短信管理-短信模版 +// @Accept json +// @Produce json +// @Param data body bus_models.SmsTemplateQuery true "查询参数" +// @Success 200 {object} bus_models.SmsTemplateListResp +// @Router /api/v1/sms/template/list [post] +func (e SmsApi) ListSmsTemplates(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsTemplateQuery + + if err := e.MakeContext(c).MakeOrm().Bind(&req, binding.JSON).MakeService(&smsService.Service).Errors; err != nil { + e.Error(500, err, err.Error()) + return + } + + resp, err := smsService.ListSmsTemplates(req, e.Orm) + if err != nil { + e.Error(500, err, "查询失败") + return + } + + app.OK(c, resp, "查询成功") +} + +// ExportSmsTemplate 导出短信模版 +// @Summary 导出短信模版 +// @Tags 短信管理-短信模版 +// @Accept json +// @Produce application/json +// @Param data body bus_models.SmsTemplateExportReq true "导出参数" +// @Success 200 {object} bus_models.ExportTemplateResp +// @Router /api/v1/sms/template/export [post] +func (e SmsApi) ExportSmsTemplate(c *gin.Context) { + smsService := bus_service.SmsService{} + var req bus_models.SmsTemplateExportReq + + err := e.MakeContext(c). + MakeOrm(). + Bind(&req, binding.JSON). + MakeService(&smsService.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return + } + + fileUrl, err := smsService.ExportSmsTemplates(req, e.Orm) + if err != nil { + e.Error(500, err, "导出失败") + return + } + + app.OK(c, bus_models.ExportTemplateResp{ExportUrl: fileUrl}, "导出成功") +} diff --git a/app/admin/models/bus_models/m_sms_manage.go b/app/admin/models/bus_models/m_sms_manage.go index 19bbbb3..0dce89e 100644 --- a/app/admin/models/bus_models/m_sms_manage.go +++ b/app/admin/models/bus_models/m_sms_manage.go @@ -10,6 +10,7 @@ const ( ShowCount = 100 // 前端展示手机号数量 ) +// SmsTask 短信下行记录 type SmsTask struct { models.Model @@ -27,6 +28,7 @@ type SmsTask struct { ScheduleTime *time.Time `gorm:"schedule_time"` // 计划发送时间(定时时间) } +// SmsTaskBatch 短信批量任务记录 type SmsTaskBatch struct { models.Model @@ -45,6 +47,7 @@ type SmsTaskBatch struct { ScheduleTime *time.Time `gorm:"schedule_time"` // 计划发送时间(定时时间) } +// SmsSendRecord 短信发送明细 type SmsSendRecord struct { models.Model @@ -70,6 +73,7 @@ type SensitiveWord struct { IsEnabled bool `json:"is_enabled" gorm:"default:1;column:is_enabled;comment:是否启用"` } +// SmsUplinkLog 短信上行记录 type SmsUplinkLog struct { models.Model @@ -78,6 +82,7 @@ type SmsUplinkLog struct { BatchID string `gorm:"column:batch_id;type:varchar(64);not null" json:"batch_id"` // 下行短信批次 ID } +// SmsSignatureRealname 签名实名制 type SmsSignatureRealname struct { models.Model @@ -100,12 +105,21 @@ type SmsSignatureRealname struct { IsActive int `json:"is_active"` // 是否有效(0 无效;1 有效) } +// SmsContactCategory 通讯录分类 +type SmsContactCategory struct { + models.Model + Name string `json:"name" gorm:"type:varchar(100);not null"` + ParentID uint64 `json:"parent_id" gorm:"default:0"` + Children []SmsContactCategory `json:"children,omitempty" gorm:"-"` +} + // SmsContact 通讯录 type SmsContact struct { models.Model - CooperativeNumber string `gorm:"column:cooperative_number"` // 合作商编号 - CooperativeName string `gorm:"column:cooperative_name"` // 合作商名称 + CategoryID uint64 `json:"category_id" gorm:"default:0"` + CooperativeNumber string `json:"cooperative_number"` // 合作商编号 + CooperativeName string `json:"cooperative_name"` // 合作商名称 Name string `json:"name"` PhoneNumber string `json:"phone_number"` Gender string `json:"gender"` @@ -115,6 +129,75 @@ type SmsContact struct { Remark string `json:"remark"` } +// SmsPhraseCategory 短语分类 +type SmsPhraseCategory struct { + models.Model + Name string `json:"name" gorm:"type:varchar(100);not null"` + ParentID uint64 `json:"parent_id" gorm:"default:0"` + Children []SmsPhraseCategory `json:"children,omitempty" gorm:"-"` +} + +// SmsPhrase 通讯录-常用短语 +type SmsPhrase struct { + models.Model + + Content string `json:"content" gorm:"type:varchar(255);not null"` + CategoryID uint `json:"category_id" gorm:"default:0"` +} + +// SmsCommonNumber 常用号码列表 +type SmsCommonNumber struct { + models.Model + + Name string `json:"name"` + PhoneNumbers string `json:"phone_numbers"` // 如:"12345678901,13322223333" + PhoneCount int `json:"phone_count" gorm:"-"` // 号码数量(从 phone_numbers 计算) +} + +// SmsBlackList 黑名单列表 +type SmsBlackList struct { + models.Model + + PhoneNumber string `json:"phone_number"` + Remark string `json:"remark"` +} + +// SmsTemplate 短信模版表 +type SmsTemplate struct { + models.Model + + CooperativeNumber string `gorm:"column:cooperative_number"` // 合作商编号 + CooperativeName string `gorm:"column:cooperative_name"` // 合作商名称 + Content string `json:"content"` // 模版内容(必填) + ExpireAt *time.Time `json:"expire_at"` // 到期时间(有效期) + Remark string `json:"remark"` // 备注 + Status int `json:"status"` // 状态:0=审核中 1=正常 2=拒绝 3=过期 +} + +type ContactInput struct { + CategoryID []uint64 `json:"category_id" binding:"required"` + ID uint64 `json:"id"` // 联系人ID + Name string `json:"name"` + PhoneNumber string `json:"phone_number"` + Gender string `json:"gender"` + BirthdayStr string `json:"birthday"` // 先用 string 接收 + Company string `json:"company"` + Address string `json:"address"` + Remark string `json:"remark"` +} + +type EditContactInput struct { + CategoryID uint64 `json:"category_id" binding:"required"` + ID uint64 `json:"id"` // 联系人ID + Name string `json:"name"` + PhoneNumber string `json:"phone_number"` + Gender string `json:"gender"` + BirthdayStr string `json:"birthday"` // 先用 string 接收 + Company string `json:"company"` + Address string `json:"address"` + Remark string `json:"remark"` +} + type MassImportPhoneResp struct { List []string `json:"list"` // 加密后的数据 ImportSerialNumber string `json:"import_serial_number"` // 导入excel返回的编号 @@ -272,12 +355,40 @@ type SignatureRealnameQueryResp struct { TotalPage int64 `json:"total_page"` } +type AddContactCategoryReq struct { + Name string `json:"name" binding:"required"` + ParentID uint `json:"parent_id"` // 默认 0 表示顶级 +} + +type EditContactCategoryReq struct { + ID uint `json:"id" binding:"required"` + Name string `json:"name" binding:"required"` +} + +// DeleteContactCategoryRequest 删除通讯录分类请求 +type DeleteContactCategoryRequest struct { + IDs []uint `json:"ids" binding:"required"` // 要删除的分类ID列表 +} + +// ListContactCategoryRequest 查询通讯录分类树的请求 +type ListContactCategoryRequest struct { + CategoryID uint64 `json:"category_id"` // 为空表示查询整个树 +} + +type SmsContactCategoryTree struct { + ID uint64 `json:"id"` + Name string `json:"name"` + ParentID uint64 `json:"parent_id"` + Children []SmsContactCategoryTree `json:"children,omitempty"` +} + // ContactQuery 请求结构体 type ContactQuery struct { - Name string `form:"name"` // 模糊搜索 - PhoneNumber string `form:"phone_number"` // 模糊搜索 - Page int `form:"page"` - PageSize int `form:"page_size"` + CategoryID []uint64 `json:"category_id" binding:"required"` + Name string `form:"name"` // 模糊搜索 + PhoneNumber string `form:"phone_number"` // 模糊搜索 + Page int `form:"page"` + PageSize int `form:"page_size"` } // ContactQueryResp 响应结构体 @@ -292,3 +403,205 @@ type ContactQueryResp struct { type ContactDeleteRequest struct { ContactIDs []uint `json:"contact_ids" binding:"required"` // 要删除的记录ID列表 } + +// ExportContactsRequest 导出联系人请求参数 +type ExportContactsRequest struct { + IDs []uint `json:"ids"` // 联系人ID列表(优先) + All bool `json:"all"` // 是否导出全部 +} + +type ExportContactsResp struct { + ExportUrl string `json:"export_url"` // 下载链接 +} + +type AddPhraseCategoryReq struct { + Name string `json:"name" binding:"required"` + ParentID uint `json:"parent_id"` // 默认 0 表示顶级 +} + +type EditPhraseCategoryReq struct { + ID uint `json:"id" binding:"required"` + Name string `json:"name" binding:"required"` +} + +// DeletePhraseCategoryRequest 删除短语分类请求 +type DeletePhraseCategoryRequest struct { + IDs []uint `json:"ids" binding:"required"` // 要删除的分类ID列表 +} + +// SmsPhraseQuery 查询参数 +type SmsPhraseQuery struct { + Content string `form:"content" binding:"required"` // 模糊搜索内容 + CategoryID uint `form:"category_id"` // 所属分类ID + Page int `form:"page"` + PageSize int `form:"page_size"` +} + +type SmsPhraseListResp struct { + List []SmsPhrase `json:"list"` // 短语列表 + Total int64 `json:"total"` // 总条数 + Page int `json:"page"` // 当前页 + PageSize int `json:"page_size"` // 每页大小 + TotalPage int64 `json:"total_page"` // 总页数 +} + +// SmsPhraseAddOrEdit 新增或编辑参数 +type SmsPhraseAddOrEdit struct { + ID uint `json:"id"` // 编辑时用 + Content string `json:"content" binding:"required"` + CategoryID uint `json:"category_id" binding:"required"` +} + +// SmsPhraseBatchDeleteReq 批量删除 +type SmsPhraseBatchDeleteReq struct { + IDs []uint `json:"ids" binding:"required"` +} + +// ListPhraseCategoryRequest 查询短语分类树的请求 +type ListPhraseCategoryRequest struct { + CategoryID uint64 `json:"category_id"` // 为空表示查询整个树 +} + +type SmsPhraseCategoryTree struct { + ID uint64 `json:"id"` + Name string `json:"name"` + ParentID uint64 `json:"parent_id"` + Children []SmsPhraseCategoryTree `json:"children,omitempty"` +} + +// SmsCommonNumberQuery 查询 +type SmsCommonNumberQuery struct { + Name string `json:"name"` + Page int `json:"page"` + PageSize int `json:"pageSize"` +} + +// SmsCommonNumberAddReq 添加常用号码请求结构体 +type SmsCommonNumberAddReq struct { + Name string `json:"name" binding:"required"` // 名称 + PhoneList []string `json:"phone_list" binding:"required"` // 号码列表 +} + +// SmsCommonNumberAppendReq 追加常用号码请求结构体 +type SmsCommonNumberAppendReq struct { + ID int64 `json:"id" binding:"required"` // 记录ID + PhoneList []string `json:"phone_list" binding:"required"` // 需要追加的号码列表 +} + +// SmsCommonNumberDetailReq 常用号码详情 +type SmsCommonNumberDetailReq struct { + ID int64 `json:"id" binding:"required"` // 记录ID +} + +// SmsCommonNumberDeleteReq 删除 +type SmsCommonNumberDeleteReq struct { + Ids []uint64 `json:"ids"` +} + +// SmsCommonNumberExportReq 导出 +type SmsCommonNumberExportReq struct { + All bool `json:"all"` // 是否导出全部 + Ids []uint64 `json:"ids"` +} + +type SmsCommonNumberExportResp struct { + ExportUrl string `json:"export_url"` // 下载链接 +} + +type SmsCommonNumberListResp struct { + List []SmsCommonNumber `json:"list"` + Total int64 `json:"total"` + Page int `json:"page"` + PageSize int `json:"pageSize"` + TotalPage int64 `json:"totalPage"` +} + +type BlacklistAddReq struct { + PhoneList []string `json:"phone_list" binding:"required"` + Remark string `json:"remark"` +} + +// ExportBlacklistRequest 导出黑名单请求 +type ExportBlacklistRequest struct { + All bool `json:"all"` // 是否导出全部 + Ids []string `json:"ids"` // 指定导出的手机号ID +} + +// ExportBlacklistResp 导出响应 +type ExportBlacklistResp struct { + ExportUrl string `json:"export_url"` +} + +type BlacklistQuery struct { + PhoneNumber string `json:"phone_number"` + Page int `json:"page"` + PageSize int `json:"page_size"` +} + +type BlacklistListResp struct { + List []SmsBlackList `json:"list"` + Total int64 `json:"total"` + Page int `json:"page"` + PageSize int `json:"page_size"` + TotalPage int64 `json:"total_page"` +} + +// SmsBlacklistBatchDeleteReq 批量删除黑名单请求 +type SmsBlacklistBatchDeleteReq struct { + IDs []uint `json:"ids"` // 黑名单记录ID +} + +// SmsTemplateQuery 短信模版查询参数 +type SmsTemplateQuery struct { + Content string `json:"content"` // 模版内容模糊查询 + Status int `json:"status"` // 模版状态(0=待审核,1=正常,2=审核拒绝,3=已过期) + CreateStart time.Time `json:"create_start"` // 创建时间起 + CreateEnd time.Time `json:"create_end"` // 创建时间止 + Page int `json:"page"` + PageSize int `json:"page_size"` +} + +// SmsTemplateListResp 返回模版列表结构 +type SmsTemplateListResp struct { + List []SmsTemplate `json:"list"` + Total int64 `json:"total"` + Page int `json:"page"` + PageSize int `json:"page_size"` + TotalPage int64 `json:"total_page"` +} + +// SmsTemplateExportReq 短信模版导出请求 +type SmsTemplateExportReq struct { + Ids []uint `json:"ids"` // 选择的模版 ID 列表 + All bool `json:"all"` // 是否导出全部 +} + +// ExportTemplateResp 导出结果 +type ExportTemplateResp struct { + ExportUrl string `json:"export_url"` // 下载地址 +} + +type ApproveTemplateRequest struct { + ID uint `json:"id"` + Status int `json:"status"` // 1 正常, 2 审核不通过 +} + +// SmsTemplateUpdateRequest 修改短信模版请求 +type SmsTemplateUpdateRequest struct { + ID uint `json:"id" binding:"required"` + Content string `json:"content" binding:"required"` + ExpireAt *time.Time `json:"expire_at"` + Remark string `json:"remark"` +} + +// DeleteIdsRequest 批量删除模版时使用 +type DeleteIdsRequest struct { + IDs []uint `json:"ids" binding:"required"` +} + +// SmsTemplateCreateRequest 创建短信模版请求 +type SmsTemplateCreateRequest struct { + Content string `json:"content" binding:"required"` // 模版内容 + ExpireAt *time.Time `json:"expire_at"` // 到期时间 + Remark string `json:"remark"` // 备注 +} diff --git a/app/admin/router/bus_sms_manage.go b/app/admin/router/bus_sms_manage.go index d801663..e9caa95 100644 --- a/app/admin/router/bus_sms_manage.go +++ b/app/admin/router/bus_sms_manage.go @@ -39,9 +39,43 @@ func registerSmsManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd sms.POST("/signature_realname/update", api.UpdateSignatureRealname) // 编辑实名签名 sms.POST("/signature_realname/delete", api.DeleteSignatureRealname) // 批量删除签名实名记录 - sms.POST("/contacts/list", api.ListContacts) // 查询通讯录列表 - sms.POST("/contacts/add", api.AddContact) // 新增联系人 - sms.POST("/contacts/edit", api.EditContact) // 编辑联系人 - sms.POST("/contacts/batch_delete", api.BulkDeleteContacts) // 批量删除联系人 + sms.POST("/contacts_category/add", api.AddContactsCategory) // 新增通讯录分类节点 + sms.POST("/contacts_category/edit", api.EditContactsCategory) // 编辑通讯录分类节点 + sms.POST("/contacts_category/delete", api.DeleteContactsCategories) // 删除通讯录分类 + sms.POST("/contacts_category/list", api.ListContactsCategories) // 查询通讯录分类列表(树形结构) + sms.POST("/contacts/list", api.ListContacts) // 查询通讯录列表 + sms.POST("/contacts/add", api.AddContact) // 新增联系人 + sms.POST("/contacts/edit", api.EditContact) // 编辑联系人 + sms.POST("/contacts/batch_delete", api.BulkDeleteContacts) // 批量删除联系人 + sms.POST("/contacts/import", api.BulkImportContacts) // 批量导入通讯录 + sms.POST("/contacts/export", api.BulkExportContacts) // 批量导出通讯录 + + sms.POST("/phrase_category/add", api.AddPhraseCategory) // 新增短语分类节点 + sms.POST("/phrase_category/edit", api.EditPhraseCategory) // 编辑短语分类节点 + sms.POST("/phrase_category/delete", api.DeletePhraseCategories) // 删除常用短语分类 + sms.POST("/phrase_category/list", api.ListPhraseCategories) // 查询常用短语分类列表(树形结构) + sms.POST("/phrase/add", api.AddPhrase) // 新增常用短语 + sms.POST("/phrase/edit", api.EditPhrase) // 编辑常用短语 + sms.POST("/phrase/delete", api.DeletePhrases) // 批量删除短语 + sms.POST("/phrase/list", api.ListPhrases) // 查询常用短语列表 + + sms.POST("/common_number/list", api.ListCommonNumbers) // 常用号码列表 + sms.POST("/common_number/add", api.AddCommonNumber) // 添加常用号码 + sms.POST("/common_number/append", api.AppendCommonNumber) // 追加号码 + sms.POST("/common_number/detail", api.CommonNumberDetail) // 常用号码详情 + sms.POST("/common_number/delete", api.DeleteCommonNumbers) // 批量删除常用号码 + sms.POST("/common_number/export", api.ExportCommonNumber) // 导出常用号码 + + sms.POST("/black_list/add", api.AddBlacklistNumber) // 添加黑名单 + sms.POST("/black_list/list", api.ListBlacklist) // 黑名单列表 + sms.POST("/black_list/export", api.ExportBlacklist) // 导出黑名单号码 + sms.POST("/black_list/delete", api.DeleteBlacklist) // 批量删除黑名单 + + sms.POST("/template/create", api.CreateSmsTemplate) // 新增短信模版 + sms.POST("/template/delete", api.DeleteSmsTemplates) // 批量删除短信模版 + sms.POST("/template/update", api.UpdateSmsTemplate) // 修改短信模版 + sms.POST("/template/approve", api.ApproveSmsTemplate) // 审核短信模版 + sms.POST("/template/list", api.ListSmsTemplates) // 获取短信模版列表 + sms.POST("/template/export", api.ExportSmsTemplate) // 导出短信模版 } } diff --git a/app/admin/service/bus_service/s_sms_manage.go b/app/admin/service/bus_service/s_sms_manage.go index 1e09320..eebc916 100644 --- a/app/admin/service/bus_service/s_sms_manage.go +++ b/app/admin/service/bus_service/s_sms_manage.go @@ -2,6 +2,7 @@ package bus_service import ( "bytes" + "encoding/csv" "errors" "fmt" "github.com/go-admin-team/go-admin-core/logger" @@ -11,7 +12,11 @@ import ( "go-admin/common/redisx" "golang.org/x/net/context" "gorm.io/gorm" + "io" "math/rand" + "os" + "regexp" + "sort" "strconv" "strings" "time" @@ -811,6 +816,9 @@ func (s *SmsService) ListContacts(req bus_models.ContactQuery, db *gorm.DB) (bus query := db.Model(&bus_models.SmsContact{}) + if len(req.CategoryID) != 0 { + query = query.Where("category_id IN ?", req.CategoryID) + } if req.Name != "" { query = query.Where("name LIKE ?", "%"+req.Name+"%") } @@ -862,7 +870,7 @@ func (s *SmsService) AddContact(contact bus_models.SmsContact, db *gorm.DB) erro } // EditContact 编辑联系人 -func (s *SmsService) EditContact(id string, contact bus_models.SmsContact, db *gorm.DB) error { +func (s *SmsService) EditContact(id uint64, contact bus_models.SmsContact, db *gorm.DB) error { var existingContact bus_models.SmsContact if err := db.Where("id = ?", id).First(&existingContact).Error; err != nil { return err @@ -886,3 +894,847 @@ func (s *SmsService) EditContact(id string, contact bus_models.SmsContact, db *g func (s *SmsService) BulkDeleteContacts(req bus_models.ContactDeleteRequest, db *gorm.DB) error { return db.Where("id IN (?)", req.ContactIDs).Delete(&bus_models.SmsContact{}).Error } + +// ImportContactsFromExcel 从Excel导入联系人(含格式校验) +func (s *SmsService) ImportContactsFromExcel(r io.Reader, db *gorm.DB, coopNum, coopName string, categoryId uint64) error { + excelFile, err := excelize.OpenReader(r) + if err != nil { + return errors.New("解析Excel失败") + } + + rows, err := excelFile.GetRows("Sheet1") + if err != nil || len(rows) < 2 { + return errors.New("excel格式错误或无有效数据") + } + + var contacts []bus_models.SmsContact + for i, row := range rows { + if i == 0 { + continue + } + + if len(row) < 7 { + // 如果一行少于7个字段,补充缺失字段为空字符串或默认值 + for len(row) < 7 { + row = append(row, "") + } + } + + phone := strings.TrimSpace(row[3]) + if !isValidPhoneNumber(phone) { + return fmt.Errorf("第 %d 行手机号码格式不正确: %s", i+1, phone) + } + + birthday, err := parseExcelDate(row[4]) + if err != nil { + return fmt.Errorf("第 %d 行生日格式不正确,应为YYYY-MM-DD: %s", i+1, row[4]) + } + + contacts = append(contacts, bus_models.SmsContact{ + CategoryID: categoryId, + CooperativeNumber: coopNum, + CooperativeName: coopName, + Name: strings.TrimSpace(row[0]), + Company: strings.TrimSpace(row[1]), + Gender: strings.TrimSpace(row[2]), + PhoneNumber: phone, + Birthday: birthday, + Address: strings.TrimSpace(row[5]), + Remark: strings.TrimSpace(row[6]), + }) + } + + if len(contacts) == 0 { + return errors.New("无有效联系人记录") + } + + err = db.Create(&contacts).Error + if err != nil { + return errors.New("导入失败:" + err.Error()) + } + + return nil +} + +func isValidPhoneNumber(phone string) bool { + match, _ := regexp.MatchString(`^1\d{10}$`, phone) + return match +} + +func parseExcelDate(dateStr string) (*time.Time, error) { + if dateStr == "" { + return nil, nil + } + layouts := []string{"2006-01-02", "2006/01/02"} + for _, layout := range layouts { + if t, err := time.Parse(layout, dateStr); err == nil { + return &t, nil + } + } + return nil, fmt.Errorf("日期格式不正确") +} + +func (s *SmsService) ExportContactsToExcel(db *gorm.DB, req bus_models.ExportContactsRequest) (string, error) { + var contacts []bus_models.SmsContact + query := db.Order("id desc") + + if !req.All { + if len(req.IDs) == 0 { + return "", fmt.Errorf("未传入ID且未选择导出全部") + } + query = query.Where("id IN ?", req.IDs) + } + + if err := query.Find(&contacts).Error; err != nil { + return "", err + } + + if len(contacts) == 0 { + return "", fmt.Errorf("没有可导出的联系人") + } + + file := excelize.NewFile() + sheet := "Sheet1" + headers := []string{"姓名", "公司", "性别", "手机号码", "生日", "地址", "备注"} + + // 表头 + for i, h := range headers { + col := string('A' + i) + file.SetCellValue(sheet, col+"1", h) + } + + // 内容 + for i, c := range contacts { + row := i + 2 + file.SetCellValue(sheet, "A"+strconv.Itoa(row), c.Name) + file.SetCellValue(sheet, "B"+strconv.Itoa(row), c.Company) + file.SetCellValue(sheet, "C"+strconv.Itoa(row), c.Gender) + file.SetCellValue(sheet, "D"+strconv.Itoa(row), c.PhoneNumber) + if c.Birthday != nil { + file.SetCellValue(sheet, "E"+strconv.Itoa(row), c.Birthday.Format("2006-01-02")) + } + file.SetCellValue(sheet, "F"+strconv.Itoa(row), c.Address) + file.SetCellValue(sheet, "G"+strconv.Itoa(row), c.Remark) + } + + style, _ := file.NewStyle(&excelize.Style{ + Alignment: &excelize.Alignment{ + Horizontal: "center", + Vertical: "center", + }, + }) + file.SetColWidth(sheet, "A", "G", 20) + file.SetCellStyle(sheet, "A1", fmt.Sprintf("G%d", len(contacts)+1), style) + + // 保存文件 + fileName := time.Now().Format("20060102150405") + "_导出通讯录.xlsx" + filePath := ExportFile + fileName + fileUrl := MiGuExportUrl + fileName + + if err := file.SaveAs(filePath); err != nil { + logger.Errorf("导出通讯录失败: %v", err) + return "", err + } + + return fileUrl, nil +} + +func (s *SmsService) AddPhraseCategory(req bus_models.AddPhraseCategoryReq, db *gorm.DB) error { + return db.Create(&bus_models.SmsPhraseCategory{ + Name: req.Name, + ParentID: uint64(req.ParentID), + }).Error +} + +func (s *SmsService) EditPhraseCategory(req bus_models.EditPhraseCategoryReq, db *gorm.DB) error { + return db.Model(&bus_models.SmsPhraseCategory{}). + Where("id = ?", req.ID). + Update("name", req.Name). + Error +} + +func (s *SmsService) DeletePhraseCategories(ids []uint, db *gorm.DB) error { + if len(ids) == 0 { + return errors.New("未指定需要删除的分类") + } + + var total int64 + if err := db.Model(&bus_models.SmsPhraseCategory{}).Count(&total).Error; err != nil { + return err + } + + // 递归找出所有要删除的 ID(含子分类) + var allIDs []uint + var walk func(uint) + walk = func(parentID uint) { + var children []bus_models.SmsPhraseCategory + db.Where("parent_id = ?", parentID).Find(&children) + for _, child := range children { + allIDs = append(allIDs, uint(child.ID)) + walk(uint(child.ID)) + } + } + + for _, id := range ids { + allIDs = append(allIDs, id) + walk(id) + } + + // 保证删除后至少保留一个分类节点 + if len(allIDs) >= int(total) { + return errors.New("无法删除所有分类节点,至少保留一个") + } + + // 删除短语 + if err := db.Where("category_id IN ?", allIDs).Delete(&bus_models.SmsPhrase{}).Error; err != nil { + return err + } + + // 删除分类 + return db.Where("id IN ?", allIDs).Delete(&bus_models.SmsPhraseCategory{}).Error +} + +func (s *SmsService) ListPhrases(req bus_models.SmsPhraseQuery, db *gorm.DB) (bus_models.SmsPhraseListResp, error) { + var list []bus_models.SmsPhrase + var total int64 + + query := db.Model(&bus_models.SmsPhrase{}) + + if req.Content != "" { + query = query.Where("content LIKE ?", "%"+req.Content+"%") + } + if req.CategoryID != 0 { + query = query.Where("category_id = ?", req.CategoryID) + } + + err := query.Count(&total).Error + if err != nil { + return bus_models.SmsPhraseListResp{}, err + } + + // 处理分页 + page := req.Page + if page < 1 { + page = 1 + } + pageSize := req.PageSize + if pageSize <= 0 { + pageSize = 10 + } + + err = query.Order("id desc"). + Offset((page - 1) * pageSize). + Limit(pageSize). + Find(&list).Error + if err != nil { + return bus_models.SmsPhraseListResp{}, err + } + + return bus_models.SmsPhraseListResp{ + List: list, + Total: total, + Page: page, + PageSize: pageSize, + TotalPage: (total + int64(pageSize) - 1) / int64(pageSize), + }, nil +} + +// AddPhrase 新增 +func (s *SmsService) AddPhrase(req bus_models.SmsPhraseAddOrEdit, db *gorm.DB) error { + phrase := bus_models.SmsPhrase{ + Content: req.Content, + CategoryID: req.CategoryID, + } + return db.Create(&phrase).Error +} + +// EditPhrase 编辑 +func (s *SmsService) EditPhrase(req bus_models.SmsPhraseAddOrEdit, db *gorm.DB) error { + return db.Model(&bus_models.SmsPhrase{}). + Where("id = ?", req.ID). + Updates(map[string]interface{}{ + "content": req.Content, + "category_id": req.CategoryID, + }).Error +} + +// DeletePhrases 批量删除 +func (s *SmsService) DeletePhrases(ids []uint, db *gorm.DB) error { + return db.Where("id IN (?)", ids).Delete(&bus_models.SmsPhrase{}).Error +} + +func (s *SmsService) GetPhraseCategoryTree(db *gorm.DB, parentID uint64) ([]bus_models.SmsPhraseCategoryTree, error) { + var categories []bus_models.SmsPhraseCategory + if err := db.Find(&categories).Error; err != nil { + return nil, err + } + + // 构建 map[id]category + idMap := make(map[uint64]*bus_models.SmsPhraseCategoryTree) + for _, cat := range categories { + node := &bus_models.SmsPhraseCategoryTree{ + ID: cat.ID, + Name: cat.Name, + ParentID: cat.ParentID, + } + idMap[cat.ID] = node + } + + // 构建树结构 + for _, node := range idMap { + if parent, ok := idMap[node.ParentID]; ok { + parent.Children = append(parent.Children, *node) + } + } + + // 返回指定节点下的树 + if parentID != 0 { + if root, ok := idMap[parentID]; ok { + return []bus_models.SmsPhraseCategoryTree{*root}, nil + } + return []bus_models.SmsPhraseCategoryTree{}, nil // 指定节点不存在 + } + + // 否则返回整棵树 + var roots []bus_models.SmsPhraseCategoryTree + for _, node := range idMap { + if node.ParentID == 0 { + roots = append(roots, *node) + } + } + + return roots, nil +} + +func (s *SmsService) AddContactsCategory(req bus_models.AddContactCategoryReq, db *gorm.DB) error { + return db.Create(&bus_models.SmsContactCategory{ + Name: req.Name, + ParentID: uint64(req.ParentID), + }).Error +} + +func (s *SmsService) EditContactsCategory(req bus_models.EditContactCategoryReq, db *gorm.DB) error { + return db.Model(&bus_models.SmsContactCategory{}). + Where("id = ?", req.ID). + Update("name", req.Name). + Error +} + +func (s *SmsService) DeleteContactsCategories(ids []uint, db *gorm.DB) error { + if len(ids) == 0 { + return errors.New("未指定需要删除的分类") + } + + var total int64 + if err := db.Model(&bus_models.SmsContactCategory{}).Count(&total).Error; err != nil { + return err + } + + // 递归找出所有要删除的 ID(含子分类) + var allIDs []uint + var walk func(uint) + walk = func(parentID uint) { + var children []bus_models.SmsContactCategory + db.Where("parent_id = ?", parentID).Find(&children) + for _, child := range children { + allIDs = append(allIDs, uint(child.ID)) + walk(uint(child.ID)) + } + } + + for _, id := range ids { + allIDs = append(allIDs, id) + walk(id) + } + + // 保证删除后至少保留一个分类节点 + if len(allIDs) >= int(total) { + return errors.New("无法删除所有分类节点,至少保留一个") + } + + // 删除短语 + if err := db.Where("category_id IN ?", allIDs).Delete(&bus_models.SmsContact{}).Error; err != nil { + return err + } + + // 删除分类 + return db.Where("id IN ?", allIDs).Delete(&bus_models.SmsContactCategory{}).Error +} + +func (s *SmsService) GetContactsCategoryTree(db *gorm.DB, parentID uint64) ([]bus_models.SmsContactCategoryTree, error) { + var categories []bus_models.SmsContactCategory + if err := db.Find(&categories).Error; err != nil { + return nil, err + } + + // 构建 map[id]category + idMap := make(map[uint64]*bus_models.SmsContactCategoryTree) + for _, cat := range categories { + node := &bus_models.SmsContactCategoryTree{ + ID: cat.ID, + Name: cat.Name, + ParentID: cat.ParentID, + } + idMap[cat.ID] = node + } + + // 构建树结构 + for _, node := range idMap { + if parent, ok := idMap[node.ParentID]; ok { + parent.Children = append(parent.Children, *node) + } + } + + // 返回指定节点下的树 + if parentID != 0 { + if root, ok := idMap[parentID]; ok { + return []bus_models.SmsContactCategoryTree{*root}, nil + } + return []bus_models.SmsContactCategoryTree{}, nil // 指定节点不存在 + } + + // 否则返回整棵树 + var roots []bus_models.SmsContactCategoryTree + for _, node := range idMap { + if node.ParentID == 0 { + roots = append(roots, *node) + } + } + + return roots, nil +} + +func (s *SmsService) ListCommonNumbers(req bus_models.SmsCommonNumberQuery, db *gorm.DB) (bus_models.SmsCommonNumberListResp, error) { + var dbList []bus_models.SmsCommonNumber + var total int64 + + query := db.Model(&bus_models.SmsCommonNumber{}) + if req.Name != "" { + query = query.Where("name LIKE ?", "%"+req.Name+"%") + } + err := query.Count(&total).Error + if err != nil { + return bus_models.SmsCommonNumberListResp{}, err + } + + // 处理分页 + page := req.Page + if page < 1 { + page = 1 + } + pageSize := req.PageSize + if pageSize <= 0 { + pageSize = 10 + } + + err = query.Order("id desc"). + Offset((page - 1) * pageSize). + Limit(pageSize). + Find(&dbList).Error + if err != nil { + return bus_models.SmsCommonNumberListResp{}, err + } + + // 转换为返回结构体 + var respList []bus_models.SmsCommonNumber + for _, item := range dbList { + respList = append(respList, bus_models.SmsCommonNumber{ + Name: item.Name, + PhoneNumbers: item.PhoneNumbers, + PhoneCount: len(strings.Split(item.PhoneNumbers, ",")), + }) + } + + totalPage := (total + int64(page) - 1) / int64(pageSize) + if totalPage < 1 { + totalPage = 1 + } + + return bus_models.SmsCommonNumberListResp{ + List: respList, + Total: total, + Page: page, + PageSize: pageSize, + TotalPage: totalPage, + }, nil +} + +func (s *SmsService) AddCommonNumber(req bus_models.SmsCommonNumberAddReq, db *gorm.DB) error { + if req.Name == "" { + return errors.New("名称不能为空") + } + return db.Create(&bus_models.SmsCommonNumber{ + Name: req.Name, + PhoneNumbers: strings.Join(req.PhoneList, ","), + }).Error +} + +// AppendCommonNumber 向已有常用号码记录中追加号码(自动去重) +// 逻辑:获取原始号码列表 + 新号码列表 => 合并去重 => 更新保存 +func (s *SmsService) AppendCommonNumber(req bus_models.SmsCommonNumberAppendReq, db *gorm.DB) error { + var record bus_models.SmsCommonNumber + err := db.Where("id = ?", req.ID).First(&record).Error + if err != nil { + return err + } + + // 拆分原始号码 + originalNumbers := strings.Split(record.PhoneNumbers, ",") + numberSet := make(map[string]struct{}) + + // 原号码去重填入 map + for _, num := range originalNumbers { + num = strings.TrimSpace(num) + if num != "" { + numberSet[num] = struct{}{} + } + } + // 新号码去重合并 + for _, num := range req.PhoneList { + num = strings.TrimSpace(num) + if num != "" { + numberSet[num] = struct{}{} + } + } + + var deduplicated []string + for num := range numberSet { + deduplicated = append(deduplicated, num) + } + sort.Strings(deduplicated) // 方便前端对比、稳定输出顺序 + + record.PhoneNumbers = strings.Join(deduplicated, ",") + return db.Save(&record).Error +} + +func (s *SmsService) GetCommonNumberDetail(id int64, db *gorm.DB) (bus_models.SmsCommonNumber, error) { + var record bus_models.SmsCommonNumber + err := db.First(&record, id).Error + return record, err +} + +func (s *SmsService) DeleteCommonNumbers(ids []uint64, db *gorm.DB) error { + return db.Where("id IN (?)", ids).Delete(&bus_models.SmsCommonNumber{}).Error +} + +// ExportCommonNumbers 导出多个常用号码名称下的所有号码到一个文件 +func (s *SmsService) ExportCommonNumbers(req bus_models.SmsCommonNumberExportReq, db *gorm.DB) (string, error) { + var records []bus_models.SmsCommonNumber + + query := db.Model(&bus_models.SmsCommonNumber{}).Order("id desc") + if !req.All { + if len(req.Ids) == 0 { + return "", fmt.Errorf("未传入号码且未选择导出全部") + } + query = query.Where("id IN ?", req.Ids) + } + + err := query.Find(&records).Error + if err != nil { + return "", err + } + + if len(records) == 0 { + return "", errors.New("未找到对应的常用号码数据") + } + + // 创建文件 + fileName := time.Now().Format("20060102150405") + "_常用号码.xlsx" + filePath := ExportFile + fileName + fileUrl := MiGuExportUrl + fileName + + file, err := os.Create(filePath) + if err != nil { + return "", err + } + defer file.Close() + + writer := csv.NewWriter(file) + defer writer.Flush() + + // 写数据 + for _, record := range records { + numbers := strings.Split(record.PhoneNumbers, ",") + for _, number := range numbers { + trimmed := strings.TrimSpace(number) + if trimmed != "" { + writer.Write([]string{trimmed}) + } + } + } + + return fileUrl, nil +} + +func (s *SmsService) AddBlacklistNumber(req bus_models.BlacklistAddReq, db *gorm.DB) error { + if len(req.PhoneList) == 0 { + return fmt.Errorf("手机号列表不能为空") + } + + var records []bus_models.SmsBlackList + for _, phone := range req.PhoneList { + records = append(records, bus_models.SmsBlackList{ + PhoneNumber: phone, + Remark: req.Remark, + }) + } + + return db.Create(&records).Error +} + +func (s *SmsService) ListBlacklist(req bus_models.BlacklistQuery, db *gorm.DB) (bus_models.BlacklistListResp, error) { + var list []bus_models.SmsBlackList + var total int64 + + query := db.Model(&bus_models.SmsBlackList{}) + if req.PhoneNumber != "" { + query = query.Where("phone_number LIKE ?", "%"+req.PhoneNumber+"%") + } + + err := query.Count(&total).Error + if err != nil { + return bus_models.BlacklistListResp{}, err + } + + page := req.Page + if page < 1 { + page = 1 + } + pageSize := req.PageSize + if pageSize <= 0 { + pageSize = 10 + } + + err = query.Order("id desc"). + Offset((page - 1) * pageSize). + Limit(pageSize). + Find(&list).Error + if err != nil { + return bus_models.BlacklistListResp{}, err + } + + totalPage := (total + int64(pageSize) - 1) / int64(pageSize) + if totalPage < 1 { + totalPage = 1 + } + + return bus_models.BlacklistListResp{ + List: list, + Total: total, + Page: page, + PageSize: pageSize, + TotalPage: totalPage, + }, nil +} + +func (s *SmsService) ExportBlacklistToExcel(db *gorm.DB, req bus_models.ExportBlacklistRequest) (string, error) { + var blacklists []bus_models.SmsBlackList + query := db.Model(&bus_models.SmsBlackList{}).Order("id desc") + + if !req.All { + if len(req.Ids) == 0 { + return "", fmt.Errorf("未传入号码且未选择导出全部") + } + query = query.Where("id IN ?", req.Ids) + } + + if err := query.Find(&blacklists).Error; err != nil { + return "", err + } + + if len(blacklists) == 0 { + return "", fmt.Errorf("没有可导出的黑名单记录") + } + + file := excelize.NewFile() + sheet := "Sheet1" + headers := []string{"手机号", "备注", "创建时间"} + + for i, h := range headers { + col := string('A' + i) + file.SetCellValue(sheet, col+"1", h) + } + + for i, b := range blacklists { + row := strconv.Itoa(i + 2) + file.SetCellValue(sheet, "A"+row, b.PhoneNumber) + file.SetCellValue(sheet, "B"+row, b.Remark) + file.SetCellValue(sheet, "C"+row, b.CreatedAt.Format("2006-01-02 15:04:05")) + } + + style, _ := file.NewStyle(&excelize.Style{ + Alignment: &excelize.Alignment{ + Horizontal: "center", + Vertical: "center", + }, + }) + file.SetColWidth(sheet, "A", "C", 20) + file.SetCellStyle(sheet, "A1", fmt.Sprintf("C%d", len(blacklists)+1), style) + + fileName := time.Now().Format("20060102150405") + "_导出黑名单.xlsx" + filePath := ExportFile + fileName + fileUrl := MiGuExportUrl + fileName + + if err := file.SaveAs(filePath); err != nil { + logger.Errorf("导出黑名单失败: %v", err) + return "", err + } + + return fileUrl, nil +} + +// DeleteBlacklist 批量删除黑名单记录 +func (s *SmsService) DeleteBlacklist(ids []uint, db *gorm.DB) error { + return db.Where("id IN ?", ids).Delete(&bus_models.SmsBlackList{}).Error +} + +// CreateSmsTemplate 创建短信模版 +func (s *SmsService) CreateSmsTemplate(data *bus_models.SmsTemplate, db *gorm.DB) error { + return db.Create(data).Error +} + +// DeleteSmsTemplates 批量删除短信模版 +func (s *SmsService) DeleteSmsTemplates(ids []uint, db *gorm.DB) error { + return db.Delete(&bus_models.SmsTemplate{}, ids).Error +} + +// UpdateSmsTemplate 更新短信模版 +func (s *SmsService) UpdateSmsTemplate(req *bus_models.SmsTemplateUpdateRequest, db *gorm.DB) error { + var tmpl bus_models.SmsTemplate + + // 查找原始数据 + if err := db.First(&tmpl, req.ID).Error; err != nil { + return fmt.Errorf("未找到指定的短信模版") + } + + // 更新模版内容 + tmpl.Content = req.Content + + // 更新到期时间(如果传入了新的时间) + if !req.ExpireAt.IsZero() { + tmpl.ExpireAt = req.ExpireAt + } + + // 更新更新时间 + tmpl.UpdatedAt = time.Now() + + // 保存更新后的模版 + return db.Save(&tmpl).Error +} + +// ApproveSmsTemplate 审核短信模版 +func (s *SmsService) ApproveSmsTemplate(id uint, status int, db *gorm.DB) error { + return db.Model(&bus_models.SmsTemplate{}). + Where("id = ?", id). + Update("status", status).Error +} + +func (s *SmsService) ListSmsTemplates(req bus_models.SmsTemplateQuery, db *gorm.DB) (bus_models.SmsTemplateListResp, error) { + var list []bus_models.SmsTemplate + var total int64 + + query := db.Model(&bus_models.SmsTemplate{}) + + if req.Content != "" { + query = query.Where("content LIKE ?", "%"+req.Content+"%") + } + if req.Status != 0 { + query = query.Where("status = ?", req.Status) + } + if !req.CreateStart.IsZero() && !req.CreateEnd.IsZero() { + query = query.Where("created_at BETWEEN ? AND ?", req.CreateStart, req.CreateEnd) + } + + err := query.Count(&total).Error + if err != nil { + return bus_models.SmsTemplateListResp{}, err + } + + page := req.Page + if page < 1 { + page = 1 + } + pageSize := req.PageSize + if pageSize <= 0 { + pageSize = 10 + } + + err = query.Order("id desc"). + Offset((page - 1) * pageSize). + Limit(pageSize). + Find(&list).Error + if err != nil { + return bus_models.SmsTemplateListResp{}, err + } + + totalPage := (total + int64(pageSize) - 1) / int64(pageSize) + if totalPage < 1 { + totalPage = 1 + } + + return bus_models.SmsTemplateListResp{ + List: list, + Total: total, + Page: page, + PageSize: pageSize, + TotalPage: totalPage, + }, nil +} + +func (s *SmsService) ExportSmsTemplates(req bus_models.SmsTemplateExportReq, db *gorm.DB) (string, error) { + var templates []bus_models.SmsTemplate + + query := db.Model(&bus_models.SmsTemplate{}).Order("id desc") + if !req.All { + if len(req.Ids) == 0 { + return "", fmt.Errorf("未传入模版且未选择导出全部") + } + query = query.Where("id IN ?", req.Ids) + } + + err := query.Find(&templates).Error + if err != nil { + return "", err + } + + if len(templates) == 0 { + return "", errors.New("未找到对应的短信模版数据") + } + + // 生成文件 + fileName := time.Now().Format("20060102150405") + "_短信模版导出.csv" + filePath := ExportFile + fileName + fileUrl := MiGuExportUrl + fileName + + file, err := os.Create(filePath) + if err != nil { + return "", err + } + defer file.Close() + + writer := csv.NewWriter(file) + defer writer.Flush() + + // 写表头 + writer.Write([]string{"模版ID", "模版内容", "备注", "状态", "创建时间"}) + + // 写内容 + for _, tmpl := range templates { + status := map[int]string{ + 0: "待审核", + 1: "正常", + 2: "审核拒绝", + 3: "已过期", + }[tmpl.Status] + + writer.Write([]string{ + strconv.Itoa(int(tmpl.ID)), + tmpl.Content, + tmpl.Remark, + status, + tmpl.CreatedAt.Format("2006-01-02 15:04:05"), + }) + } + + return fileUrl, nil +} diff --git a/docs/admin/admin_docs.go b/docs/admin/admin_docs.go index e299d1e..e49dc66 100644 --- a/docs/admin/admin_docs.go +++ b/docs/admin/admin_docs.go @@ -2485,6 +2485,138 @@ const docTemplateadmin = `{ } } }, + "/api/v1/sms/black_list/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "添加黑名单", + "parameters": [ + { + "description": "黑名单添加参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.BlacklistAddReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/black_list/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "批量删除黑名单", + "parameters": [ + { + "description": "黑名单ID数组", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsBlacklistBatchDeleteReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/black_list/export": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "批量导出黑名单", + "parameters": [ + { + "description": "请求参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ExportBlacklistRequest" + } + } + ], + "responses": { + "200": { + "description": "下载链接", + "schema": { + "$ref": "#/definitions/bus_models.ExportContactsResp" + } + } + } + } + }, + "/api/v1/sms/black_list/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "黑名单列表", + "parameters": [ + { + "description": "查询参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.BlacklistQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.BlacklistListResp" + } + } + } + } + }, "/api/v1/sms/check_sensitive_words": { "post": { "consumes": [ @@ -2518,6 +2650,204 @@ const docTemplateadmin = `{ } } }, + "/api/v1/sms/common_number/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "添加常用号码", + "parameters": [ + { + "description": "添加参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberAddReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/common_number/append": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "追加号码", + "parameters": [ + { + "description": "追加参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberAppendReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/common_number/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "批量删除常用号码", + "parameters": [ + { + "description": "ID列表", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberDeleteReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/common_number/detail": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "常用号码详情", + "parameters": [ + { + "description": "常用号码详情模型", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberDetailReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumber" + } + } + } + } + }, + "/api/v1/sms/common_number/export": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "导出常用号码", + "parameters": [ + { + "description": "ID列表", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberExportReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "file" + } + } + } + } + }, + "/api/v1/sms/common_number/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "常用号码列表", + "parameters": [ + { + "description": "查询参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberListResp" + } + } + } + } + }, "/api/v1/sms/contacts/add": { "post": { "consumes": [ @@ -2537,7 +2867,7 @@ const docTemplateadmin = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/bus_models.SmsContact" + "$ref": "#/definitions/bus_models.ContactInput" } } ], @@ -2597,20 +2927,13 @@ const docTemplateadmin = `{ ], "summary": "编辑联系人", "parameters": [ - { - "type": "integer", - "description": "联系人ID", - "name": "id", - "in": "path", - "required": true - }, { "description": "联系人信息", "name": "request", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/bus_models.SmsContact" + "$ref": "#/definitions/bus_models.EditContactInput" } } ], @@ -2624,6 +2947,77 @@ const docTemplateadmin = `{ } } }, + "/api/v1/sms/contacts/export": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "批量导出通讯录", + "parameters": [ + { + "description": "请求参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ExportContactsRequest" + } + } + ], + "responses": { + "200": { + "description": "下载链接", + "schema": { + "$ref": "#/definitions/bus_models.ExportContactsResp" + } + } + } + } + }, + "/api/v1/sms/contacts/import": { + "post": { + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "批量导入通讯录", + "parameters": [ + { + "type": "file", + "description": "分类ID", + "name": "category_id", + "in": "formData", + "required": true + }, + { + "type": "file", + "description": "上传Excel文件", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, "/api/v1/sms/contacts/list": { "get": { "consumes": [ @@ -2637,6 +3031,16 @@ const docTemplateadmin = `{ ], "summary": "查询通讯录列表", "parameters": [ + { + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "csv", + "name": "category_id", + "in": "query", + "required": true + }, { "type": "string", "description": "模糊搜索", @@ -2670,6 +3074,174 @@ const docTemplateadmin = `{ } } }, + "/api/v1/sms/contacts_category/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "新增通讯录分类节点", + "parameters": [ + { + "description": "分类信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.AddContactCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/contacts_category/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "删除通讯录分类", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.DeleteContactCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/contacts_category/edit": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "编辑通讯录分类节点", + "parameters": [ + { + "description": "编辑信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.EditContactCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/contacts_category/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "查询通讯录分类树", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ListContactCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsContactCategoryTree" + } + } + } + } + }, "/api/v1/sms/export_mess_phone": { "post": { "consumes": [ @@ -2766,6 +3338,306 @@ const docTemplateadmin = `{ } } }, + "/api/v1/sms/phrase/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "新增常用短语", + "parameters": [ + { + "description": "短语数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseAddOrEdit" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "批量删除短语", + "parameters": [ + { + "description": "短语ID数组", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseBatchDeleteReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase/edit": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "编辑常用短语", + "parameters": [ + { + "description": "短语数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseAddOrEdit" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "查询常用短语列表", + "parameters": [ + { + "description": "短语数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase_category/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "新增短语分类节点", + "parameters": [ + { + "description": "分类信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.AddPhraseCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/phrase_category/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "删除常用短语分类", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.DeletePhraseCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/phrase_category/edit": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "编辑短语分类节点", + "parameters": [ + { + "description": "编辑信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.EditPhraseCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/phrase_category/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "查询常用短语分类树", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ListPhraseCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseCategoryTree" + } + } + } + } + }, "/api/v1/sms/send_sms": { "post": { "consumes": [ @@ -3078,6 +3950,253 @@ const docTemplateadmin = `{ } } }, + "/api/v1/sms/template/approve": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "审核短信模版", + "parameters": [ + { + "description": "模版审核信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ApproveTemplateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/template/create": { + "post": { + "description": "创建一条新的短信模版,默认为待审核状态", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "新增短信模版", + "parameters": [ + { + "description": "短信模版信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/template/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "批量删除短信模版", + "parameters": [ + { + "description": "ID数组", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.DeleteIdsRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/template/export": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "导出短信模版", + "parameters": [ + { + "description": "导出参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateExportReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.ExportTemplateResp" + } + } + } + } + }, + "/api/v1/sms/template/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "获取短信模版列表", + "parameters": [ + { + "description": "查询参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateListResp" + } + } + } + } + }, + "/api/v1/sms/template/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "修改短信模版", + "parameters": [ + { + "description": "短信模版更新信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateUpdateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/api/v1/sms/uplink_log": { "post": { "consumes": [ @@ -4352,6 +5471,36 @@ const docTemplateadmin = `{ } } }, + "bus_models.AddContactCategoryReq": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "parent_id": { + "description": "默认 0 表示顶级", + "type": "integer" + } + } + }, + "bus_models.AddPhraseCategoryReq": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "parent_id": { + "description": "默认 0 表示顶级", + "type": "integer" + } + } + }, "bus_models.AdjustAccountReq": { "type": "object", "required": [ @@ -4385,6 +5534,18 @@ const docTemplateadmin = `{ } } }, + "bus_models.ApproveTemplateRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "status": { + "description": "1 正常, 2 审核不通过", + "type": "integer" + } + } + }, "bus_models.BatchResetScheduleTimeRequest": { "type": "object", "properties": { @@ -4429,6 +5590,60 @@ const docTemplateadmin = `{ } } }, + "bus_models.BlacklistAddReq": { + "type": "object", + "required": [ + "phone_list" + ], + "properties": { + "phone_list": { + "type": "array", + "items": { + "type": "string" + } + }, + "remark": { + "type": "string" + } + } + }, + "bus_models.BlacklistListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsBlackList" + } + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_page": { + "type": "integer" + } + } + }, + "bus_models.BlacklistQuery": { + "type": "object", + "properties": { + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "phone_number": { + "type": "string" + } + } + }, "bus_models.BusContract": { "type": "object", "properties": { @@ -4674,6 +5889,46 @@ const docTemplateadmin = `{ } } }, + "bus_models.ContactInput": { + "type": "object", + "required": [ + "category_id" + ], + "properties": { + "address": { + "type": "string" + }, + "birthday": { + "description": "先用 string 接收", + "type": "string" + }, + "category_id": { + "type": "array", + "items": { + "type": "integer" + } + }, + "company": { + "type": "string" + }, + "gender": { + "type": "string" + }, + "id": { + "description": "联系人ID", + "type": "integer" + }, + "name": { + "type": "string" + }, + "phone_number": { + "type": "string" + }, + "remark": { + "type": "string" + } + } + }, "bus_models.ContactQueryResp": { "type": "object", "properties": { @@ -5073,6 +6328,21 @@ const docTemplateadmin = `{ } } }, + "bus_models.DeleteContactCategoryRequest": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "要删除的分类ID列表", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "bus_models.DeleteContractReq": { "type": "object", "required": [ @@ -5094,6 +6364,35 @@ const docTemplateadmin = `{ } } }, + "bus_models.DeleteIdsRequest": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.DeletePhraseCategoryRequest": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "要删除的分类ID列表", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "bus_models.DeleteProductReq": { "type": "object", "required": [ @@ -5121,6 +6420,58 @@ const docTemplateadmin = `{ } } }, + "bus_models.EditContactCategoryReq": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "bus_models.EditContactInput": { + "type": "object", + "required": [ + "category_id" + ], + "properties": { + "address": { + "type": "string" + }, + "birthday": { + "description": "先用 string 接收", + "type": "string" + }, + "category_id": { + "type": "integer" + }, + "company": { + "type": "string" + }, + "gender": { + "type": "string" + }, + "id": { + "description": "联系人ID", + "type": "integer" + }, + "name": { + "type": "string" + }, + "phone_number": { + "type": "string" + }, + "remark": { + "type": "string" + } + } + }, "bus_models.EditContractRemarkReq": { "type": "object", "required": [ @@ -5232,6 +6583,21 @@ const docTemplateadmin = `{ } } }, + "bus_models.EditPhraseCategoryReq": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, "bus_models.EditProductReq": { "type": "object", "required": [ @@ -5302,6 +6668,47 @@ const docTemplateadmin = `{ } } }, + "bus_models.ExportBlacklistRequest": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "description": "指定导出的手机号ID", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "bus_models.ExportContactsRequest": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "description": "联系人ID列表(优先)", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.ExportContactsResp": { + "type": "object", + "properties": { + "export_url": { + "description": "下载链接", + "type": "string" + } + } + }, "bus_models.ExportMessPhoneReq": { "type": "object", "properties": { @@ -5331,6 +6738,15 @@ const docTemplateadmin = `{ } } }, + "bus_models.ExportTemplateResp": { + "type": "object", + "properties": { + "export_url": { + "description": "下载地址", + "type": "string" + } + } + }, "bus_models.GetContractDownloadLinkReq": { "type": "object", "required": [ @@ -5391,6 +6807,15 @@ const docTemplateadmin = `{ } } }, + "bus_models.ListContactCategoryRequest": { + "type": "object", + "properties": { + "category_id": { + "description": "为空表示查询整个树", + "type": "integer" + } + } + }, "bus_models.ListContractReq": { "type": "object", "properties": { @@ -5443,6 +6868,15 @@ const docTemplateadmin = `{ } } }, + "bus_models.ListPhraseCategoryRequest": { + "type": "object", + "properties": { + "category_id": { + "description": "为空表示查询整个树", + "type": "integer" + } + } + }, "bus_models.MassImportPhoneResp": { "type": "object", "properties": { @@ -5748,6 +7182,184 @@ const docTemplateadmin = `{ } } }, + "bus_models.SmsBlackList": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "数据库记录编号", + "type": "integer" + }, + "phone_number": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "bus_models.SmsBlacklistBatchDeleteReq": { + "type": "object", + "properties": { + "ids": { + "description": "黑名单记录ID", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsCommonNumber": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "数据库记录编号", + "type": "integer" + }, + "name": { + "type": "string" + }, + "phone_count": { + "description": "号码数量(从 phone_numbers 计算)", + "type": "integer" + }, + "phone_numbers": { + "description": "如:\"12345678901,13322223333\"", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "bus_models.SmsCommonNumberAddReq": { + "type": "object", + "required": [ + "name", + "phone_list" + ], + "properties": { + "name": { + "description": "名称", + "type": "string" + }, + "phone_list": { + "description": "号码列表", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "bus_models.SmsCommonNumberAppendReq": { + "type": "object", + "required": [ + "id", + "phone_list" + ], + "properties": { + "id": { + "description": "记录ID", + "type": "integer" + }, + "phone_list": { + "description": "需要追加的号码列表", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "bus_models.SmsCommonNumberDeleteReq": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsCommonNumberDetailReq": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "记录ID", + "type": "integer" + } + } + }, + "bus_models.SmsCommonNumberExportReq": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsCommonNumberListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsCommonNumber" + } + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + }, + "bus_models.SmsCommonNumberQuery": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, "bus_models.SmsContact": { "type": "object", "properties": { @@ -5757,14 +7369,17 @@ const docTemplateadmin = `{ "birthday": { "type": "string" }, + "category_id": { + "type": "integer" + }, "company": { "type": "string" }, - "cooperativeName": { + "cooperative_name": { "description": "合作商名称", "type": "string" }, - "cooperativeNumber": { + "cooperative_number": { "description": "合作商编号", "type": "string" }, @@ -5794,6 +7409,101 @@ const docTemplateadmin = `{ } } }, + "bus_models.SmsContactCategoryTree": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsContactCategoryTree" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "parent_id": { + "type": "integer" + } + } + }, + "bus_models.SmsPhraseAddOrEdit": { + "type": "object", + "required": [ + "category_id", + "content" + ], + "properties": { + "category_id": { + "type": "integer" + }, + "content": { + "type": "string" + }, + "id": { + "description": "编辑时用", + "type": "integer" + } + } + }, + "bus_models.SmsPhraseBatchDeleteReq": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsPhraseCategoryTree": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsPhraseCategoryTree" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "parent_id": { + "type": "integer" + } + } + }, + "bus_models.SmsPhraseQuery": { + "type": "object", + "required": [ + "content" + ], + "properties": { + "category_id": { + "description": "所属分类ID", + "type": "integer" + }, + "content": { + "description": "模糊搜索内容", + "type": "string" + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + } + } + }, "bus_models.SmsSignatureRealname": { "type": "object", "properties": { @@ -6028,6 +7738,154 @@ const docTemplateadmin = `{ } } }, + "bus_models.SmsTemplate": { + "type": "object", + "properties": { + "content": { + "description": "模版内容(必填)", + "type": "string" + }, + "cooperativeName": { + "description": "合作商名称", + "type": "string" + }, + "cooperativeNumber": { + "description": "合作商编号", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "expire_at": { + "description": "到期时间(有效期)", + "type": "string" + }, + "id": { + "description": "数据库记录编号", + "type": "integer" + }, + "remark": { + "description": "备注", + "type": "string" + }, + "status": { + "description": "状态:0=审核中 1=正常 2=拒绝 3=过期", + "type": "integer" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "bus_models.SmsTemplateCreateRequest": { + "type": "object", + "required": [ + "content" + ], + "properties": { + "content": { + "description": "模版内容", + "type": "string" + }, + "expire_at": { + "description": "到期时间", + "type": "string" + }, + "remark": { + "description": "备注", + "type": "string" + } + } + }, + "bus_models.SmsTemplateExportReq": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "description": "选择的模版 ID 列表", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsTemplateListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsTemplate" + } + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_page": { + "type": "integer" + } + } + }, + "bus_models.SmsTemplateQuery": { + "type": "object", + "properties": { + "content": { + "description": "模版内容模糊查询", + "type": "string" + }, + "create_end": { + "description": "创建时间止", + "type": "string" + }, + "create_start": { + "description": "创建时间起", + "type": "string" + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "status": { + "description": "模版状态(0=待审核,1=正常,2=审核拒绝,3=已过期)", + "type": "integer" + } + } + }, + "bus_models.SmsTemplateUpdateRequest": { + "type": "object", + "required": [ + "content", + "id" + ], + "properties": { + "content": { + "type": "string" + }, + "expire_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "remark": { + "type": "string" + } + } + }, "bus_models.SmsUplinkQueryRequest": { "type": "object", "properties": { diff --git a/docs/admin/admin_swagger.json b/docs/admin/admin_swagger.json index 5a9a382..c80f676 100644 --- a/docs/admin/admin_swagger.json +++ b/docs/admin/admin_swagger.json @@ -2477,6 +2477,138 @@ } } }, + "/api/v1/sms/black_list/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "添加黑名单", + "parameters": [ + { + "description": "黑名单添加参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.BlacklistAddReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/black_list/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "批量删除黑名单", + "parameters": [ + { + "description": "黑名单ID数组", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsBlacklistBatchDeleteReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/black_list/export": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "批量导出黑名单", + "parameters": [ + { + "description": "请求参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ExportBlacklistRequest" + } + } + ], + "responses": { + "200": { + "description": "下载链接", + "schema": { + "$ref": "#/definitions/bus_models.ExportContactsResp" + } + } + } + } + }, + "/api/v1/sms/black_list/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-黑名单" + ], + "summary": "黑名单列表", + "parameters": [ + { + "description": "查询参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.BlacklistQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.BlacklistListResp" + } + } + } + } + }, "/api/v1/sms/check_sensitive_words": { "post": { "consumes": [ @@ -2510,6 +2642,204 @@ } } }, + "/api/v1/sms/common_number/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "添加常用号码", + "parameters": [ + { + "description": "添加参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberAddReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/common_number/append": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "追加号码", + "parameters": [ + { + "description": "追加参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberAppendReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/common_number/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "批量删除常用号码", + "parameters": [ + { + "description": "ID列表", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberDeleteReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/common_number/detail": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "常用号码详情", + "parameters": [ + { + "description": "常用号码详情模型", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberDetailReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumber" + } + } + } + } + }, + "/api/v1/sms/common_number/export": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/octet-stream" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "导出常用号码", + "parameters": [ + { + "description": "ID列表", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberExportReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "file" + } + } + } + } + }, + "/api/v1/sms/common_number/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用号码" + ], + "summary": "常用号码列表", + "parameters": [ + { + "description": "查询参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsCommonNumberListResp" + } + } + } + } + }, "/api/v1/sms/contacts/add": { "post": { "consumes": [ @@ -2529,7 +2859,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/bus_models.SmsContact" + "$ref": "#/definitions/bus_models.ContactInput" } } ], @@ -2589,20 +2919,13 @@ ], "summary": "编辑联系人", "parameters": [ - { - "type": "integer", - "description": "联系人ID", - "name": "id", - "in": "path", - "required": true - }, { "description": "联系人信息", "name": "request", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/bus_models.SmsContact" + "$ref": "#/definitions/bus_models.EditContactInput" } } ], @@ -2616,6 +2939,77 @@ } } }, + "/api/v1/sms/contacts/export": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "批量导出通讯录", + "parameters": [ + { + "description": "请求参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ExportContactsRequest" + } + } + ], + "responses": { + "200": { + "description": "下载链接", + "schema": { + "$ref": "#/definitions/bus_models.ExportContactsResp" + } + } + } + } + }, + "/api/v1/sms/contacts/import": { + "post": { + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "批量导入通讯录", + "parameters": [ + { + "type": "file", + "description": "分类ID", + "name": "category_id", + "in": "formData", + "required": true + }, + { + "type": "file", + "description": "上传Excel文件", + "name": "file", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, "/api/v1/sms/contacts/list": { "get": { "consumes": [ @@ -2629,6 +3023,16 @@ ], "summary": "查询通讯录列表", "parameters": [ + { + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "csv", + "name": "category_id", + "in": "query", + "required": true + }, { "type": "string", "description": "模糊搜索", @@ -2662,6 +3066,174 @@ } } }, + "/api/v1/sms/contacts_category/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "新增通讯录分类节点", + "parameters": [ + { + "description": "分类信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.AddContactCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/contacts_category/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "删除通讯录分类", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.DeleteContactCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/contacts_category/edit": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "编辑通讯录分类节点", + "parameters": [ + { + "description": "编辑信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.EditContactCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/contacts_category/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录" + ], + "summary": "查询通讯录分类树", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ListContactCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsContactCategoryTree" + } + } + } + } + }, "/api/v1/sms/export_mess_phone": { "post": { "consumes": [ @@ -2758,6 +3330,306 @@ } } }, + "/api/v1/sms/phrase/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "新增常用短语", + "parameters": [ + { + "description": "短语数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseAddOrEdit" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "批量删除短语", + "parameters": [ + { + "description": "短语ID数组", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseBatchDeleteReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase/edit": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "编辑常用短语", + "parameters": [ + { + "description": "短语数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseAddOrEdit" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "查询常用短语列表", + "parameters": [ + { + "description": "短语数据", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/sms/phrase_category/add": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "新增短语分类节点", + "parameters": [ + { + "description": "分类信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.AddPhraseCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/phrase_category/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "删除常用短语分类", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.DeletePhraseCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/phrase_category/edit": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "编辑短语分类节点", + "parameters": [ + { + "description": "编辑信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.EditPhraseCategoryReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/phrase_category/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-通讯录-常用短语" + ], + "summary": "查询常用短语分类树", + "parameters": [ + { + "description": "要删除的分类ID列表", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ListPhraseCategoryRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsPhraseCategoryTree" + } + } + } + } + }, "/api/v1/sms/send_sms": { "post": { "consumes": [ @@ -3070,6 +3942,253 @@ } } }, + "/api/v1/sms/template/approve": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "审核短信模版", + "parameters": [ + { + "description": "模版审核信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.ApproveTemplateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/template/create": { + "post": { + "description": "创建一条新的短信模版,默认为待审核状态", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "新增短信模版", + "parameters": [ + { + "description": "短信模版信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/template/delete": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "批量删除短信模版", + "parameters": [ + { + "description": "ID数组", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.DeleteIdsRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/v1/sms/template/export": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "导出短信模版", + "parameters": [ + { + "description": "导出参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateExportReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.ExportTemplateResp" + } + } + } + } + }, + "/api/v1/sms/template/list": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "获取短信模版列表", + "parameters": [ + { + "description": "查询参数", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateQuery" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateListResp" + } + } + } + } + }, + "/api/v1/sms/template/update": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "短信管理-短信模版" + ], + "summary": "修改短信模版", + "parameters": [ + { + "description": "短信模版更新信息", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/bus_models.SmsTemplateUpdateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/app.Response" + }, + { + "type": "object", + "properties": { + "msg": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/api/v1/sms/uplink_log": { "post": { "consumes": [ @@ -4344,6 +5463,36 @@ } } }, + "bus_models.AddContactCategoryReq": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "parent_id": { + "description": "默认 0 表示顶级", + "type": "integer" + } + } + }, + "bus_models.AddPhraseCategoryReq": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string" + }, + "parent_id": { + "description": "默认 0 表示顶级", + "type": "integer" + } + } + }, "bus_models.AdjustAccountReq": { "type": "object", "required": [ @@ -4377,6 +5526,18 @@ } } }, + "bus_models.ApproveTemplateRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "status": { + "description": "1 正常, 2 审核不通过", + "type": "integer" + } + } + }, "bus_models.BatchResetScheduleTimeRequest": { "type": "object", "properties": { @@ -4421,6 +5582,60 @@ } } }, + "bus_models.BlacklistAddReq": { + "type": "object", + "required": [ + "phone_list" + ], + "properties": { + "phone_list": { + "type": "array", + "items": { + "type": "string" + } + }, + "remark": { + "type": "string" + } + } + }, + "bus_models.BlacklistListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsBlackList" + } + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_page": { + "type": "integer" + } + } + }, + "bus_models.BlacklistQuery": { + "type": "object", + "properties": { + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "phone_number": { + "type": "string" + } + } + }, "bus_models.BusContract": { "type": "object", "properties": { @@ -4666,6 +5881,46 @@ } } }, + "bus_models.ContactInput": { + "type": "object", + "required": [ + "category_id" + ], + "properties": { + "address": { + "type": "string" + }, + "birthday": { + "description": "先用 string 接收", + "type": "string" + }, + "category_id": { + "type": "array", + "items": { + "type": "integer" + } + }, + "company": { + "type": "string" + }, + "gender": { + "type": "string" + }, + "id": { + "description": "联系人ID", + "type": "integer" + }, + "name": { + "type": "string" + }, + "phone_number": { + "type": "string" + }, + "remark": { + "type": "string" + } + } + }, "bus_models.ContactQueryResp": { "type": "object", "properties": { @@ -5065,6 +6320,21 @@ } } }, + "bus_models.DeleteContactCategoryRequest": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "要删除的分类ID列表", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "bus_models.DeleteContractReq": { "type": "object", "required": [ @@ -5086,6 +6356,35 @@ } } }, + "bus_models.DeleteIdsRequest": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.DeletePhraseCategoryRequest": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "要删除的分类ID列表", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "bus_models.DeleteProductReq": { "type": "object", "required": [ @@ -5113,6 +6412,58 @@ } } }, + "bus_models.EditContactCategoryReq": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "bus_models.EditContactInput": { + "type": "object", + "required": [ + "category_id" + ], + "properties": { + "address": { + "type": "string" + }, + "birthday": { + "description": "先用 string 接收", + "type": "string" + }, + "category_id": { + "type": "integer" + }, + "company": { + "type": "string" + }, + "gender": { + "type": "string" + }, + "id": { + "description": "联系人ID", + "type": "integer" + }, + "name": { + "type": "string" + }, + "phone_number": { + "type": "string" + }, + "remark": { + "type": "string" + } + } + }, "bus_models.EditContractRemarkReq": { "type": "object", "required": [ @@ -5224,6 +6575,21 @@ } } }, + "bus_models.EditPhraseCategoryReq": { + "type": "object", + "required": [ + "id", + "name" + ], + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, "bus_models.EditProductReq": { "type": "object", "required": [ @@ -5294,6 +6660,47 @@ } } }, + "bus_models.ExportBlacklistRequest": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "description": "指定导出的手机号ID", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "bus_models.ExportContactsRequest": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "description": "联系人ID列表(优先)", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.ExportContactsResp": { + "type": "object", + "properties": { + "export_url": { + "description": "下载链接", + "type": "string" + } + } + }, "bus_models.ExportMessPhoneReq": { "type": "object", "properties": { @@ -5323,6 +6730,15 @@ } } }, + "bus_models.ExportTemplateResp": { + "type": "object", + "properties": { + "export_url": { + "description": "下载地址", + "type": "string" + } + } + }, "bus_models.GetContractDownloadLinkReq": { "type": "object", "required": [ @@ -5383,6 +6799,15 @@ } } }, + "bus_models.ListContactCategoryRequest": { + "type": "object", + "properties": { + "category_id": { + "description": "为空表示查询整个树", + "type": "integer" + } + } + }, "bus_models.ListContractReq": { "type": "object", "properties": { @@ -5435,6 +6860,15 @@ } } }, + "bus_models.ListPhraseCategoryRequest": { + "type": "object", + "properties": { + "category_id": { + "description": "为空表示查询整个树", + "type": "integer" + } + } + }, "bus_models.MassImportPhoneResp": { "type": "object", "properties": { @@ -5740,6 +7174,184 @@ } } }, + "bus_models.SmsBlackList": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "数据库记录编号", + "type": "integer" + }, + "phone_number": { + "type": "string" + }, + "remark": { + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "bus_models.SmsBlacklistBatchDeleteReq": { + "type": "object", + "properties": { + "ids": { + "description": "黑名单记录ID", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsCommonNumber": { + "type": "object", + "properties": { + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "id": { + "description": "数据库记录编号", + "type": "integer" + }, + "name": { + "type": "string" + }, + "phone_count": { + "description": "号码数量(从 phone_numbers 计算)", + "type": "integer" + }, + "phone_numbers": { + "description": "如:\"12345678901,13322223333\"", + "type": "string" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "bus_models.SmsCommonNumberAddReq": { + "type": "object", + "required": [ + "name", + "phone_list" + ], + "properties": { + "name": { + "description": "名称", + "type": "string" + }, + "phone_list": { + "description": "号码列表", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "bus_models.SmsCommonNumberAppendReq": { + "type": "object", + "required": [ + "id", + "phone_list" + ], + "properties": { + "id": { + "description": "记录ID", + "type": "integer" + }, + "phone_list": { + "description": "需要追加的号码列表", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "bus_models.SmsCommonNumberDeleteReq": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsCommonNumberDetailReq": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "description": "记录ID", + "type": "integer" + } + } + }, + "bus_models.SmsCommonNumberExportReq": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsCommonNumberListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsCommonNumber" + } + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + }, + "bus_models.SmsCommonNumberQuery": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + } + } + }, "bus_models.SmsContact": { "type": "object", "properties": { @@ -5749,14 +7361,17 @@ "birthday": { "type": "string" }, + "category_id": { + "type": "integer" + }, "company": { "type": "string" }, - "cooperativeName": { + "cooperative_name": { "description": "合作商名称", "type": "string" }, - "cooperativeNumber": { + "cooperative_number": { "description": "合作商编号", "type": "string" }, @@ -5786,6 +7401,101 @@ } } }, + "bus_models.SmsContactCategoryTree": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsContactCategoryTree" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "parent_id": { + "type": "integer" + } + } + }, + "bus_models.SmsPhraseAddOrEdit": { + "type": "object", + "required": [ + "category_id", + "content" + ], + "properties": { + "category_id": { + "type": "integer" + }, + "content": { + "type": "string" + }, + "id": { + "description": "编辑时用", + "type": "integer" + } + } + }, + "bus_models.SmsPhraseBatchDeleteReq": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsPhraseCategoryTree": { + "type": "object", + "properties": { + "children": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsPhraseCategoryTree" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "parent_id": { + "type": "integer" + } + } + }, + "bus_models.SmsPhraseQuery": { + "type": "object", + "required": [ + "content" + ], + "properties": { + "category_id": { + "description": "所属分类ID", + "type": "integer" + }, + "content": { + "description": "模糊搜索内容", + "type": "string" + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + } + } + }, "bus_models.SmsSignatureRealname": { "type": "object", "properties": { @@ -6020,6 +7730,154 @@ } } }, + "bus_models.SmsTemplate": { + "type": "object", + "properties": { + "content": { + "description": "模版内容(必填)", + "type": "string" + }, + "cooperativeName": { + "description": "合作商名称", + "type": "string" + }, + "cooperativeNumber": { + "description": "合作商编号", + "type": "string" + }, + "createdAt": { + "description": "创建时间", + "type": "string" + }, + "expire_at": { + "description": "到期时间(有效期)", + "type": "string" + }, + "id": { + "description": "数据库记录编号", + "type": "integer" + }, + "remark": { + "description": "备注", + "type": "string" + }, + "status": { + "description": "状态:0=审核中 1=正常 2=拒绝 3=过期", + "type": "integer" + }, + "updatedAt": { + "description": "更新时间", + "type": "string" + } + } + }, + "bus_models.SmsTemplateCreateRequest": { + "type": "object", + "required": [ + "content" + ], + "properties": { + "content": { + "description": "模版内容", + "type": "string" + }, + "expire_at": { + "description": "到期时间", + "type": "string" + }, + "remark": { + "description": "备注", + "type": "string" + } + } + }, + "bus_models.SmsTemplateExportReq": { + "type": "object", + "properties": { + "all": { + "description": "是否导出全部", + "type": "boolean" + }, + "ids": { + "description": "选择的模版 ID 列表", + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "bus_models.SmsTemplateListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/bus_models.SmsTemplate" + } + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_page": { + "type": "integer" + } + } + }, + "bus_models.SmsTemplateQuery": { + "type": "object", + "properties": { + "content": { + "description": "模版内容模糊查询", + "type": "string" + }, + "create_end": { + "description": "创建时间止", + "type": "string" + }, + "create_start": { + "description": "创建时间起", + "type": "string" + }, + "page": { + "type": "integer" + }, + "page_size": { + "type": "integer" + }, + "status": { + "description": "模版状态(0=待审核,1=正常,2=审核拒绝,3=已过期)", + "type": "integer" + } + } + }, + "bus_models.SmsTemplateUpdateRequest": { + "type": "object", + "required": [ + "content", + "id" + ], + "properties": { + "content": { + "type": "string" + }, + "expire_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "remark": { + "type": "string" + } + } + }, "bus_models.SmsUplinkQueryRequest": { "type": "object", "properties": { diff --git a/docs/admin/admin_swagger.yaml b/docs/admin/admin_swagger.yaml index 859e507..948cd08 100644 --- a/docs/admin/admin_swagger.yaml +++ b/docs/admin/admin_swagger.yaml @@ -14,6 +14,26 @@ definitions: description: 请求id type: string type: object + bus_models.AddContactCategoryReq: + properties: + name: + type: string + parent_id: + description: 默认 0 表示顶级 + type: integer + required: + - name + type: object + bus_models.AddPhraseCategoryReq: + properties: + name: + type: string + parent_id: + description: 默认 0 表示顶级 + type: integer + required: + - name + type: object bus_models.AdjustAccountReq: properties: amount: @@ -38,6 +58,14 @@ definitions: - cooperative_number - transaction_type type: object + bus_models.ApproveTemplateRequest: + properties: + id: + type: integer + status: + description: 1 正常, 2 审核不通过 + type: integer + type: object bus_models.BatchResetScheduleTimeRequest: properties: schedule_time: @@ -68,6 +96,41 @@ definitions: type: integer type: array type: object + bus_models.BlacklistAddReq: + properties: + phone_list: + items: + type: string + type: array + remark: + type: string + required: + - phone_list + type: object + bus_models.BlacklistListResp: + properties: + list: + items: + $ref: '#/definitions/bus_models.SmsBlackList' + type: array + page: + type: integer + page_size: + type: integer + total: + type: integer + total_page: + type: integer + type: object + bus_models.BlacklistQuery: + properties: + page: + type: integer + page_size: + type: integer + phone_number: + type: string + type: object bus_models.BusContract: properties: contract_number: @@ -246,6 +309,33 @@ definitions: required: - contact_ids type: object + bus_models.ContactInput: + properties: + address: + type: string + birthday: + description: 先用 string 接收 + type: string + category_id: + items: + type: integer + type: array + company: + type: string + gender: + type: string + id: + description: 联系人ID + type: integer + name: + type: string + phone_number: + type: string + remark: + type: string + required: + - category_id + type: object bus_models.ContactQueryResp: properties: list: @@ -534,6 +624,16 @@ definitions: description: 新创建的产品ID type: integer type: object + bus_models.DeleteContactCategoryRequest: + properties: + ids: + description: 要删除的分类ID列表 + items: + type: integer + type: array + required: + - ids + type: object bus_models.DeleteContractReq: properties: contract_number: @@ -548,6 +648,25 @@ definitions: description: 合作商编号 type: string type: object + bus_models.DeleteIdsRequest: + properties: + ids: + items: + type: integer + type: array + required: + - ids + type: object + bus_models.DeletePhraseCategoryRequest: + properties: + ids: + description: 要删除的分类ID列表 + items: + type: integer + type: array + required: + - ids + type: object bus_models.DeleteProductReq: properties: id: @@ -566,6 +685,41 @@ definitions: required: - ids type: object + bus_models.EditContactCategoryReq: + properties: + id: + type: integer + name: + type: string + required: + - id + - name + type: object + bus_models.EditContactInput: + properties: + address: + type: string + birthday: + description: 先用 string 接收 + type: string + category_id: + type: integer + company: + type: string + gender: + type: string + id: + description: 联系人ID + type: integer + name: + type: string + phone_number: + type: string + remark: + type: string + required: + - category_id + type: object bus_models.EditContractRemarkReq: properties: contract_number: @@ -646,6 +800,16 @@ definitions: description: 手机号(可选) type: string type: object + bus_models.EditPhraseCategoryReq: + properties: + id: + type: integer + name: + type: string + required: + - id + - name + type: object bus_models.EditProductReq: properties: city: @@ -698,6 +862,34 @@ definitions: - product_code - product_name type: object + bus_models.ExportBlacklistRequest: + properties: + all: + description: 是否导出全部 + type: boolean + ids: + description: 指定导出的手机号ID + items: + type: string + type: array + type: object + bus_models.ExportContactsRequest: + properties: + all: + description: 是否导出全部 + type: boolean + ids: + description: 联系人ID列表(优先) + items: + type: integer + type: array + type: object + bus_models.ExportContactsResp: + properties: + export_url: + description: 下载链接 + type: string + type: object bus_models.ExportMessPhoneReq: properties: data: @@ -718,6 +910,12 @@ definitions: description: 下载链接 type: string type: object + bus_models.ExportTemplateResp: + properties: + export_url: + description: 下载地址 + type: string + type: object bus_models.GetContractDownloadLinkReq: properties: contract_number: @@ -758,6 +956,12 @@ definitions: required: - contract_number type: object + bus_models.ListContactCategoryRequest: + properties: + category_id: + description: 为空表示查询整个树 + type: integer + type: object bus_models.ListContractReq: properties: contract_number: @@ -795,6 +999,12 @@ definitions: description: 总记录数 type: integer type: object + bus_models.ListPhraseCategoryRequest: + properties: + category_id: + description: 为空表示查询整个树 + type: integer + type: object bus_models.MassImportPhoneResp: properties: import_serial_number: @@ -1007,18 +1217,141 @@ definitions: usage_category: type: integer type: object + bus_models.SmsBlackList: + properties: + createdAt: + description: 创建时间 + type: string + id: + description: 数据库记录编号 + type: integer + phone_number: + type: string + remark: + type: string + updatedAt: + description: 更新时间 + type: string + type: object + bus_models.SmsBlacklistBatchDeleteReq: + properties: + ids: + description: 黑名单记录ID + items: + type: integer + type: array + type: object + bus_models.SmsCommonNumber: + properties: + createdAt: + description: 创建时间 + type: string + id: + description: 数据库记录编号 + type: integer + name: + type: string + phone_count: + description: 号码数量(从 phone_numbers 计算) + type: integer + phone_numbers: + description: 如:"12345678901,13322223333" + type: string + updatedAt: + description: 更新时间 + type: string + type: object + bus_models.SmsCommonNumberAddReq: + properties: + name: + description: 名称 + type: string + phone_list: + description: 号码列表 + items: + type: string + type: array + required: + - name + - phone_list + type: object + bus_models.SmsCommonNumberAppendReq: + properties: + id: + description: 记录ID + type: integer + phone_list: + description: 需要追加的号码列表 + items: + type: string + type: array + required: + - id + - phone_list + type: object + bus_models.SmsCommonNumberDeleteReq: + properties: + ids: + items: + type: integer + type: array + type: object + bus_models.SmsCommonNumberDetailReq: + properties: + id: + description: 记录ID + type: integer + required: + - id + type: object + bus_models.SmsCommonNumberExportReq: + properties: + all: + description: 是否导出全部 + type: boolean + ids: + items: + type: integer + type: array + type: object + bus_models.SmsCommonNumberListResp: + properties: + list: + items: + $ref: '#/definitions/bus_models.SmsCommonNumber' + type: array + page: + type: integer + pageSize: + type: integer + total: + type: integer + totalPage: + type: integer + type: object + bus_models.SmsCommonNumberQuery: + properties: + name: + type: string + page: + type: integer + pageSize: + type: integer + type: object bus_models.SmsContact: properties: address: type: string birthday: type: string + category_id: + type: integer company: type: string - cooperativeName: + cooperative_name: description: 合作商名称 type: string - cooperativeNumber: + cooperative_number: description: 合作商编号 type: string createdAt: @@ -1039,6 +1372,69 @@ definitions: description: 更新时间 type: string type: object + bus_models.SmsContactCategoryTree: + properties: + children: + items: + $ref: '#/definitions/bus_models.SmsContactCategoryTree' + type: array + id: + type: integer + name: + type: string + parent_id: + type: integer + type: object + bus_models.SmsPhraseAddOrEdit: + properties: + category_id: + type: integer + content: + type: string + id: + description: 编辑时用 + type: integer + required: + - category_id + - content + type: object + bus_models.SmsPhraseBatchDeleteReq: + properties: + ids: + items: + type: integer + type: array + required: + - ids + type: object + bus_models.SmsPhraseCategoryTree: + properties: + children: + items: + $ref: '#/definitions/bus_models.SmsPhraseCategoryTree' + type: array + id: + type: integer + name: + type: string + parent_id: + type: integer + type: object + bus_models.SmsPhraseQuery: + properties: + category_id: + description: 所属分类ID + type: integer + content: + description: 模糊搜索内容 + type: string + page: + type: integer + page_size: + type: integer + required: + - content + type: object bus_models.SmsSignatureRealname: properties: agent_id_number: @@ -1210,6 +1606,109 @@ definitions: description: 查询开始时间(schedule_time) type: string type: object + bus_models.SmsTemplate: + properties: + content: + description: 模版内容(必填) + type: string + cooperativeName: + description: 合作商名称 + type: string + cooperativeNumber: + description: 合作商编号 + type: string + createdAt: + description: 创建时间 + type: string + expire_at: + description: 到期时间(有效期) + type: string + id: + description: 数据库记录编号 + type: integer + remark: + description: 备注 + type: string + status: + description: 状态:0=审核中 1=正常 2=拒绝 3=过期 + type: integer + updatedAt: + description: 更新时间 + type: string + type: object + bus_models.SmsTemplateCreateRequest: + properties: + content: + description: 模版内容 + type: string + expire_at: + description: 到期时间 + type: string + remark: + description: 备注 + type: string + required: + - content + type: object + bus_models.SmsTemplateExportReq: + properties: + all: + description: 是否导出全部 + type: boolean + ids: + description: 选择的模版 ID 列表 + items: + type: integer + type: array + type: object + bus_models.SmsTemplateListResp: + properties: + list: + items: + $ref: '#/definitions/bus_models.SmsTemplate' + type: array + page: + type: integer + page_size: + type: integer + total: + type: integer + total_page: + type: integer + type: object + bus_models.SmsTemplateQuery: + properties: + content: + description: 模版内容模糊查询 + type: string + create_end: + description: 创建时间止 + type: string + create_start: + description: 创建时间起 + type: string + page: + type: integer + page_size: + type: integer + status: + description: 模版状态(0=待审核,1=正常,2=审核拒绝,3=已过期) + type: integer + type: object + bus_models.SmsTemplateUpdateRequest: + properties: + content: + type: string + expire_at: + type: string + id: + type: integer + remark: + type: string + required: + - content + - id + type: object bus_models.SmsUplinkQueryRequest: properties: end_time: @@ -3905,6 +4404,90 @@ paths: summary: 批量修改定时短信内容 tags: - 短信管理-V1.0.0 + /api/v1/sms/black_list/add: + post: + consumes: + - application/json + parameters: + - description: 黑名单添加参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.BlacklistAddReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 添加黑名单 + tags: + - 短信管理-通讯录-黑名单 + /api/v1/sms/black_list/delete: + post: + consumes: + - application/json + parameters: + - description: 黑名单ID数组 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsBlacklistBatchDeleteReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 批量删除黑名单 + tags: + - 短信管理-通讯录-黑名单 + /api/v1/sms/black_list/export: + post: + consumes: + - application/json + parameters: + - description: 请求参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.ExportBlacklistRequest' + produces: + - application/json + responses: + "200": + description: 下载链接 + schema: + $ref: '#/definitions/bus_models.ExportContactsResp' + summary: 批量导出黑名单 + tags: + - 短信管理-通讯录-黑名单 + /api/v1/sms/black_list/list: + post: + consumes: + - application/json + parameters: + - description: 查询参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.BlacklistQuery' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/bus_models.BlacklistListResp' + summary: 黑名单列表 + tags: + - 短信管理-通讯录-黑名单 /api/v1/sms/check_sensitive_words: post: consumes: @@ -3926,6 +4509,132 @@ paths: summary: 敏感词检测 tags: - 短信管理-V1.0.0 + /api/v1/sms/common_number/add: + post: + consumes: + - application/json + parameters: + - description: 添加参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsCommonNumberAddReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 添加常用号码 + tags: + - 短信管理-通讯录-常用号码 + /api/v1/sms/common_number/append: + post: + consumes: + - application/json + parameters: + - description: 追加参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsCommonNumberAppendReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 追加号码 + tags: + - 短信管理-通讯录-常用号码 + /api/v1/sms/common_number/delete: + post: + consumes: + - application/json + parameters: + - description: ID列表 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsCommonNumberDeleteReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 批量删除常用号码 + tags: + - 短信管理-通讯录-常用号码 + /api/v1/sms/common_number/detail: + post: + consumes: + - application/json + parameters: + - description: 常用号码详情模型 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsCommonNumberDetailReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/bus_models.SmsCommonNumber' + summary: 常用号码详情 + tags: + - 短信管理-通讯录-常用号码 + /api/v1/sms/common_number/export: + get: + consumes: + - application/json + parameters: + - description: ID列表 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsCommonNumberExportReq' + produces: + - application/octet-stream + responses: + "200": + description: OK + schema: + type: file + summary: 导出常用号码 + tags: + - 短信管理-通讯录-常用号码 + /api/v1/sms/common_number/list: + post: + consumes: + - application/json + parameters: + - description: 查询参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsCommonNumberQuery' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/bus_models.SmsCommonNumberListResp' + summary: 常用号码列表 + tags: + - 短信管理-通讯录-常用号码 /api/v1/sms/contacts/add: post: consumes: @@ -3936,7 +4645,7 @@ paths: name: request required: true schema: - $ref: '#/definitions/bus_models.SmsContact' + $ref: '#/definitions/bus_models.ContactInput' produces: - application/json responses: @@ -3973,17 +4682,12 @@ paths: consumes: - application/json parameters: - - description: 联系人ID - in: path - name: id - required: true - type: integer - description: 联系人信息 in: body name: request required: true schema: - $ref: '#/definitions/bus_models.SmsContact' + $ref: '#/definitions/bus_models.EditContactInput' produces: - application/json responses: @@ -3994,11 +4698,64 @@ paths: summary: 编辑联系人 tags: - 短信管理-通讯录 + /api/v1/sms/contacts/export: + post: + consumes: + - application/json + parameters: + - description: 请求参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.ExportContactsRequest' + produces: + - application/json + responses: + "200": + description: 下载链接 + schema: + $ref: '#/definitions/bus_models.ExportContactsResp' + summary: 批量导出通讯录 + tags: + - 短信管理-通讯录 + /api/v1/sms/contacts/import: + post: + consumes: + - multipart/form-data + parameters: + - description: 分类ID + in: formData + name: category_id + required: true + type: file + - description: 上传Excel文件 + in: formData + name: file + required: true + type: file + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 批量导入通讯录 + tags: + - 短信管理-通讯录 /api/v1/sms/contacts/list: get: consumes: - application/json parameters: + - collectionFormat: csv + in: query + items: + type: integer + name: category_id + required: true + type: array - description: 模糊搜索 in: query name: name @@ -4023,6 +4780,105 @@ paths: summary: 查询通讯录列表 tags: - 短信管理-通讯录 + /api/v1/sms/contacts_category/add: + post: + consumes: + - application/json + parameters: + - description: 分类信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.AddContactCategoryReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 新增通讯录分类节点 + tags: + - 短信管理-通讯录 + /api/v1/sms/contacts_category/delete: + post: + consumes: + - application/json + parameters: + - description: 要删除的分类ID列表 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.DeleteContactCategoryRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 删除通讯录分类 + tags: + - 短信管理-通讯录 + /api/v1/sms/contacts_category/edit: + post: + consumes: + - application/json + parameters: + - description: 编辑信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.EditContactCategoryReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 编辑通讯录分类节点 + tags: + - 短信管理-通讯录 + /api/v1/sms/contacts_category/list: + post: + consumes: + - application/json + parameters: + - description: 要删除的分类ID列表 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.ListContactCategoryRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/bus_models.SmsContactCategoryTree' + summary: 查询通讯录分类树 + tags: + - 短信管理-通讯录 /api/v1/sms/export_mess_phone: post: consumes: @@ -4084,6 +4940,189 @@ paths: summary: 导入号码(群发短信) tags: - 短信管理-V1.0.0 + /api/v1/sms/phrase/add: + post: + consumes: + - application/json + parameters: + - description: 短语数据 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsPhraseAddOrEdit' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 新增常用短语 + tags: + - 短信管理-通讯录-常用短语 + /api/v1/sms/phrase/delete: + post: + consumes: + - application/json + parameters: + - description: 短语ID数组 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsPhraseBatchDeleteReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 批量删除短语 + tags: + - 短信管理-通讯录-常用短语 + /api/v1/sms/phrase/edit: + post: + consumes: + - application/json + parameters: + - description: 短语数据 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsPhraseAddOrEdit' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 编辑常用短语 + tags: + - 短信管理-通讯录-常用短语 + /api/v1/sms/phrase/list: + post: + consumes: + - application/json + parameters: + - description: 短语数据 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsPhraseQuery' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + summary: 查询常用短语列表 + tags: + - 短信管理-通讯录-常用短语 + /api/v1/sms/phrase_category/add: + post: + consumes: + - application/json + parameters: + - description: 分类信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.AddPhraseCategoryReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 新增短语分类节点 + tags: + - 短信管理-通讯录-常用短语 + /api/v1/sms/phrase_category/delete: + post: + consumes: + - application/json + parameters: + - description: 要删除的分类ID列表 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.DeletePhraseCategoryRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 删除常用短语分类 + tags: + - 短信管理-通讯录-常用短语 + /api/v1/sms/phrase_category/edit: + post: + consumes: + - application/json + parameters: + - description: 编辑信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.EditPhraseCategoryReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 编辑短语分类节点 + tags: + - 短信管理-通讯录-常用短语 + /api/v1/sms/phrase_category/list: + post: + consumes: + - application/json + parameters: + - description: 要删除的分类ID列表 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.ListPhraseCategoryRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/bus_models.SmsPhraseCategoryTree' + summary: 查询常用短语分类树 + tags: + - 短信管理-通讯录-常用短语 /api/v1/sms/send_sms: post: consumes: @@ -4272,6 +5311,153 @@ paths: summary: 查询定时短信任务列表 tags: - 短信管理-V1.0.0 + /api/v1/sms/template/approve: + post: + consumes: + - application/json + parameters: + - description: 模版审核信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.ApproveTemplateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 审核短信模版 + tags: + - 短信管理-短信模版 + /api/v1/sms/template/create: + post: + consumes: + - application/json + description: 创建一条新的短信模版,默认为待审核状态 + parameters: + - description: 短信模版信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.SmsTemplateCreateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 新增短信模版 + tags: + - 短信管理-短信模版 + /api/v1/sms/template/delete: + post: + consumes: + - application/json + parameters: + - description: ID数组 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.DeleteIdsRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 批量删除短信模版 + tags: + - 短信管理-短信模版 + /api/v1/sms/template/export: + post: + consumes: + - application/json + parameters: + - description: 导出参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsTemplateExportReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/bus_models.ExportTemplateResp' + summary: 导出短信模版 + tags: + - 短信管理-短信模版 + /api/v1/sms/template/list: + post: + consumes: + - application/json + parameters: + - description: 查询参数 + in: body + name: data + required: true + schema: + $ref: '#/definitions/bus_models.SmsTemplateQuery' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/bus_models.SmsTemplateListResp' + summary: 获取短信模版列表 + tags: + - 短信管理-短信模版 + /api/v1/sms/template/update: + post: + consumes: + - application/json + parameters: + - description: 短信模版更新信息 + in: body + name: request + required: true + schema: + $ref: '#/definitions/bus_models.SmsTemplateUpdateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/app.Response' + - properties: + msg: + type: string + type: object + summary: 修改短信模版 + tags: + - 短信管理-短信模版 /api/v1/sms/uplink_log: post: consumes: diff --git a/tools/utils/utils.go b/tools/utils/utils.go new file mode 100644 index 0000000..c606956 --- /dev/null +++ b/tools/utils/utils.go @@ -0,0 +1,9 @@ +package utils + +import "regexp" + +func IsValidPhone(phone string) bool { + // 简单验证:以1开头,后面10位数字 + reg := regexp.MustCompile(`^1[0-9]{10}$`) + return reg.MatchString(phone) +}