广告平台(站长使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_set_center.go 23 KiB

3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. package hdl
  2. import (
  3. "applet/app/cfg"
  4. implement2 "applet/app/db/implement"
  5. "applet/app/e"
  6. "applet/app/enum"
  7. "applet/app/lib/validate"
  8. "applet/app/lib/wechat"
  9. "applet/app/md"
  10. "applet/app/svc"
  11. "applet/app/utils"
  12. db "code.fnuoos.com/zhimeng/model.git/src"
  13. "code.fnuoos.com/zhimeng/model.git/src/super/implement"
  14. "code.fnuoos.com/zhimeng/model.git/src/super/model"
  15. "github.com/gin-gonic/gin"
  16. "time"
  17. )
  18. // SetOss
  19. // @Summary oss设置
  20. // @Tags 设置中心-基础设置
  21. // @Description 基础设置-oss设置
  22. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  23. // @Accept json
  24. // @Produce json
  25. // @Param args body md.SetOssReq true "请求参数"
  26. // @Success 200 {string} "success"
  27. // @Failure 400 {object} md.Response "具体错误"
  28. // @Router /api/setCenter/basic/setOss [POST]
  29. func SetOss(c *gin.Context) {
  30. var req md.SetOssReq
  31. err := c.ShouldBindJSON(&req)
  32. if err != nil {
  33. err = validate.HandleValidateErr(err)
  34. err1 := err.(e.E)
  35. e.OutErr(c, err1.Code, err1.Error())
  36. return
  37. }
  38. masterId := svc.GetMasterId(c)
  39. engine := db.DBs[masterId]
  40. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  41. sysCfgDb.SysCfgUpdate(enum.FileAccessKey, req.FileAccessKey)
  42. sysCfgDb.SysCfgUpdate(enum.FileSecretKey, req.FileSecretKey)
  43. sysCfgDb.SysCfgUpdate(enum.FileBucketHost, req.FileBucketHost)
  44. sysCfgDb.SysCfgUpdate(enum.FileBucketRegion, req.FileBucketRegion)
  45. sysCfgDb.SysCfgUpdate(enum.FileBucket, req.FileBucket)
  46. svc.ClearRedis(c, masterId, enum.FileAccessKey)
  47. svc.ClearRedis(c, masterId, enum.FileSecretKey)
  48. svc.ClearRedis(c, masterId, enum.FileBucketHost)
  49. svc.ClearRedis(c, masterId, enum.FileBucketRegion)
  50. svc.ClearRedis(c, masterId, enum.FileBucket)
  51. svc.ClearAllRedis(c, masterId)
  52. e.OutSuc(c, "success", nil)
  53. return
  54. }
  55. // GetOss
  56. // @Summary oss获取
  57. // @Tags 设置中心-基础设置
  58. // @Description 基础设置-oss获取
  59. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  60. // @Accept json
  61. // @Produce json
  62. // @Success 200 {object} md.SetOssResp
  63. // @Failure 400 {object} md.Response "具体错误"
  64. // @Router /api/setCenter/basic/getOss [GET]
  65. func GetOss(c *gin.Context) {
  66. masterId := svc.GetMasterId(c)
  67. engine := db.DBs[masterId]
  68. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  69. res := sysCfgDb.SysCfgFindWithDb(enum.FileAccessKey, enum.FileSecretKey, enum.FileBucketHost, enum.FileBucketRegion, enum.FileBucket)
  70. e.OutSuc(c, md.SetOssResp{
  71. Data: md.SetOssReq{
  72. FileAccessKey: res[enum.FileAccessKey],
  73. FileSecretKey: res[enum.FileSecretKey],
  74. FileBucketHost: res[enum.FileBucketHost],
  75. FileBucketRegion: res[enum.FileBucketRegion],
  76. FileBucket: res[enum.FileBucket],
  77. },
  78. QiNiuBucketRegionList: md.QiNiuBucketRegionList,
  79. }, nil)
  80. return
  81. }
  82. // WxOpenSet
  83. // @Summary 微信三方应用设置
  84. // @Tags 设置中心-基础设置
  85. // @Description 基础设置-微信三方应用设置
  86. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  87. // @Accept json
  88. // @Produce json
  89. // @Param args body md.WxOpenSetReq true "请求参数"
  90. // @Success 200 {string} "success"
  91. // @Failure 400 {object} md.Response "具体错误"
  92. // @Router /api/setCenter/basic/wxOpenSet [POST]
  93. func WxOpenSet(c *gin.Context) {
  94. var req md.WxOpenSetReq
  95. err := c.ShouldBindJSON(&req)
  96. if err != nil {
  97. err = validate.HandleValidateErr(err)
  98. err1 := err.(e.E)
  99. e.OutErr(c, err1.Code, err1.Error())
  100. return
  101. }
  102. masterId := svc.GetMasterId(c)
  103. //1、查找对应 wx_open_third_party_app_list 记录
  104. wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db)
  105. UserWxAppletList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId))
  106. if err != nil {
  107. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  108. return
  109. }
  110. if UserWxAppletList == nil {
  111. UserWxAppletList = &model.WxOpenThirdPartyAppList{
  112. Uuid: utils.StrToInt(masterId),
  113. Token: req.Token,
  114. AesKey: req.AesKey,
  115. Appid: req.Appid,
  116. AppSecret: req.AppSecret,
  117. ComponentVerifyTicket: "",
  118. ComponentAccessToken: "",
  119. CreateAt: time.Now().Format("2006-01-02 15:04:05"),
  120. UpdateAt: time.Now().Format("2006-01-02 15:04:05"),
  121. }
  122. _, err = wxOpenThirdPartyAppListDb.WxOpenThirdPartyAppListInsert(UserWxAppletList)
  123. if err != nil {
  124. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  125. return
  126. }
  127. } else {
  128. UserWxAppletList.Token = req.Token
  129. UserWxAppletList.AesKey = req.AesKey
  130. UserWxAppletList.Appid = req.Appid
  131. UserWxAppletList.AppSecret = req.AppSecret
  132. _, err = wxOpenThirdPartyAppListDb.UpdateWxOpenThirdPartyAppList(UserWxAppletList,
  133. "token", "aes_key", "appid", "app_secret")
  134. if err != nil {
  135. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  136. return
  137. }
  138. }
  139. e.OutSuc(c, "success", nil)
  140. return
  141. }
  142. // WxOpenGet
  143. // @Summary 微信三方应用获取
  144. // @Tags 设置中心-基础设置
  145. // @Description 基础设置-微信三方应用获取
  146. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  147. // @Accept json
  148. // @Produce json
  149. // @Success 200 {object} md.WxOpenGetResp
  150. // @Failure 400 {object} md.Response "具体错误"
  151. // @Router /api/setCenter/basic/wxOpenGet [GET]
  152. func WxOpenGet(c *gin.Context) {
  153. masterId := svc.GetMasterId(c)
  154. //1、查找对应 wx_open_third_party_app_list 记录
  155. wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db)
  156. UserWxAppletList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId))
  157. if err != nil {
  158. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  159. return
  160. }
  161. if UserWxAppletList == nil {
  162. UserWxAppletList = &model.WxOpenThirdPartyAppList{
  163. Uuid: utils.StrToInt(masterId),
  164. Token: "",
  165. AesKey: "",
  166. Appid: "",
  167. AppSecret: "",
  168. ComponentVerifyTicket: "",
  169. ComponentAccessToken: "",
  170. CreateAt: time.Now().Format("2006-01-02 15:04:05"),
  171. UpdateAt: time.Now().Format("2006-01-02 15:04:05"),
  172. }
  173. _, err = wxOpenThirdPartyAppListDb.WxOpenThirdPartyAppListInsert(UserWxAppletList)
  174. if err != nil {
  175. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  176. return
  177. }
  178. }
  179. sysCfgDb := implement2.NewSysCfgDb(db.Db, "")
  180. res := sysCfgDb.SysCfgFindWithDb(enum.WxOpenAppletServerDomain, enum.WxOpenAuthorizationEventReceivingConfiguration,
  181. enum.WxOpenDomainOfTheInitiatingPageForLoginAuthorization, enum.WxOpenMessageAndEventReceptionConfiguration, enum.WxOpenWhiteListIp)
  182. e.OutSuc(c, md.WxOpenGetResp{
  183. Token: UserWxAppletList.Token,
  184. AesKey: UserWxAppletList.AesKey,
  185. Appid: UserWxAppletList.Appid,
  186. AppSecret: UserWxAppletList.AppSecret,
  187. WxOpenAppletServerDomain: res[enum.WxOpenAppletServerDomain],
  188. WxOpenAuthorizationEventReceivingConfiguration: res[enum.WxOpenAuthorizationEventReceivingConfiguration],
  189. WxOpenDomainOfTheInitiatingPageForLoginAuthorization: res[enum.WxOpenDomainOfTheInitiatingPageForLoginAuthorization],
  190. WxOpenMessageAndEventReceptionConfiguration: res[enum.WxOpenMessageAndEventReceptionConfiguration],
  191. WxOpenWhiteListIp: res[enum.WxOpenWhiteListIp],
  192. }, nil)
  193. return
  194. }
  195. type WxOpenThirdPartyAppList struct {
  196. Id int `json:"id" xorm:"not null pk autoincr unique(IDX_UUID_TYPE) INT(11)"`
  197. Uuid int `json:"uuid" xorm:"not null comment('站长id') index unique(IDX_UUID_TYPE) INT(10)"`
  198. Token string `json:"token" xorm:"not null default '' comment('消息校验Token') VARCHAR(255)"`
  199. AesKey string `json:"aes_key" xorm:"not null default '' comment('消息加解密Key') VARCHAR(255)"`
  200. Appid string `json:"appid" xorm:"not null default '' comment('appid') CHAR(50)"`
  201. AppSecret string `json:"app_secret" xorm:"not null default '' comment('appSecret') VARCHAR(255)"`
  202. ComponentVerifyTicket string `json:"component_verify_ticket" xorm:"not null default '' comment('验证票据') VARCHAR(255)"`
  203. ComponentAccessToken string `json:"component_access_token" xorm:"not null default '' comment('接口令牌') VARCHAR(255)"`
  204. CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
  205. UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
  206. }
  207. // AppletList
  208. // @Summary 列表
  209. // @Tags 设置中心-小程序设置
  210. // @Description 小程序设置-列表
  211. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  212. // @Accept json
  213. // @Produce json
  214. // @Success 200 {object} WxOpenThirdPartyAppList
  215. // @Failure 400 {object} md.Response "具体错误"
  216. // @Router /api/setCenter/applet/list [GET]
  217. func AppletList(c *gin.Context) {
  218. masterId := svc.GetMasterId(c)
  219. //1、查找对应 user_wx_applet_list 记录
  220. userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db)
  221. UserWxAppletList, err := userWxAppletListDb.GetUserWxAppletList(masterId)
  222. if err != nil {
  223. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  224. return
  225. }
  226. e.OutSuc(c, UserWxAppletList, nil)
  227. return
  228. }
  229. // AppletAdd
  230. // @Summary 新增
  231. // @Tags 设置中心-小程序设置
  232. // @Description 小程序设置-新增
  233. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  234. // @Accept json
  235. // @Produce json
  236. // @Param args body md.AppletAddReq true "请求参数"
  237. // @Success 200 {string} "success"
  238. // @Failure 400 {object} md.Response "具体错误"
  239. // @Router /api/setCenter/applet/add [POST]
  240. func AppletAdd(c *gin.Context) {
  241. var req md.AppletAddReq
  242. err := c.ShouldBindJSON(&req)
  243. if err != nil {
  244. err = validate.HandleValidateErr(err)
  245. err1 := err.(e.E)
  246. e.OutErr(c, err1.Code, err1.Error())
  247. return
  248. }
  249. masterId := svc.GetMasterId(c)
  250. //1、查找对应 user_wx_applet_list 记录
  251. userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db)
  252. UserWxAppletList, err := userWxAppletListDb.GetUserWxAppletList(masterId)
  253. if err != nil {
  254. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  255. return
  256. }
  257. if UserWxAppletList != nil {
  258. e.OutErr(c, e.ERR, "当前仅支持单个小程序")
  259. return
  260. }
  261. _, err = userWxAppletListDb.UserWxAppletListInsert(&model.UserWxAppletList{
  262. Name: req.Name,
  263. Logo: req.Logo,
  264. Appid: req.Appid,
  265. OriginalId: req.OriginalId,
  266. AuthorizerRefreshToken: "",
  267. IsAuth: 0,
  268. Uuid: masterId,
  269. CreateAt: time.Now().Format("2006-01-02 15:04:05"),
  270. UpdateAt: time.Now().Format("2006-01-02 15:04:05"),
  271. })
  272. if err != nil {
  273. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  274. return
  275. }
  276. e.OutSuc(c, "success", nil)
  277. return
  278. }
  279. // AppletUpdate
  280. // @Summary 更新
  281. // @Tags 设置中心-小程序设置
  282. // @Description 小程序设置-更新
  283. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  284. // @Accept json
  285. // @Produce json
  286. // @Param args body md.AppletUpdateReq true "请求参数"
  287. // @Success 200 {string} "success"
  288. // @Failure 400 {object} md.Response "具体错误"
  289. // @Router /api/setCenter/applet/update [POST]
  290. func AppletUpdate(c *gin.Context) {
  291. var req md.AppletUpdateReq
  292. err := c.ShouldBindJSON(&req)
  293. if err != nil {
  294. err = validate.HandleValidateErr(err)
  295. err1 := err.(e.E)
  296. e.OutErr(c, err1.Code, err1.Error())
  297. return
  298. }
  299. masterId := svc.GetMasterId(c)
  300. //1、查找对应 user_wx_applet_list 记录
  301. userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db)
  302. UserWxAppletList, err := userWxAppletListDb.GetUserWxAppletList(masterId)
  303. if err != nil {
  304. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  305. return
  306. }
  307. if UserWxAppletList == nil {
  308. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  309. return
  310. }
  311. UserWxAppletList.Logo = req.Logo
  312. UserWxAppletList.Name = req.Name
  313. _, err = userWxAppletListDb.UpdateUserWxAppletList(UserWxAppletList, "logo", "name")
  314. if err != nil {
  315. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  316. return
  317. }
  318. e.OutSuc(c, "success", nil)
  319. return
  320. }
  321. // AppletDelete
  322. // @Summary 删除
  323. // @Tags 设置中心-小程序设置
  324. // @Description 小程序设置-删除
  325. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  326. // @Accept json
  327. // @Produce json
  328. // @Success 200 {string} "success"
  329. // @Failure 400 {object} md.Response "具体错误"
  330. // @Router /v1/banner/delete/{$id} [DELETE]
  331. func AppletDelete(c *gin.Context) {
  332. id := c.Param("id")
  333. masterId := svc.GetMasterId(c)
  334. //1、查找对应 user_wx_applet_list 记录
  335. userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db)
  336. UserWxAppletList, err := userWxAppletListDb.GetUserWxAppletList(masterId)
  337. if err != nil {
  338. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  339. return
  340. }
  341. if UserWxAppletList == nil {
  342. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  343. return
  344. }
  345. _, err = userWxAppletListDb.UserWxAppletListDelete(id)
  346. if err != nil {
  347. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  348. return
  349. }
  350. e.OutSuc(c, "success", nil)
  351. return
  352. }
  353. // AppletAuthorize
  354. // @Summary 设置中心-基础设置-微信三方应用获取
  355. // @Tags 设置中心
  356. // @Description 设置中心-基础设置
  357. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  358. // @Accept json
  359. // @Produce json
  360. // @Success 200 {string} "微信授权界面url"
  361. // @Failure 400 {object} md.Response "具体错误"
  362. // @Router /api/setCenter/applet/authorize [GET]
  363. func AppletAuthorize(c *gin.Context) {
  364. masterId := svc.GetMasterId(c)
  365. url := "http://super.advertisement.dengbiao.top/api/wxOpen/getPreAuthCode?master_id=" + masterId
  366. if cfg.Prd {
  367. url = "http://super.advertisement.dengbiao.top/api/wxOpen/getPreAuthCode?master_id=" + masterId
  368. }
  369. e.OutSuc(c, map[string]string{
  370. "url": url,
  371. }, nil)
  372. return
  373. }
  374. // AppletUnauthorized
  375. // @Summary 设置中心-基础设置-微信三方应用获取
  376. // @Tags 设置中心
  377. // @Description 设置中心-基础设置
  378. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  379. // @Accept json
  380. // @Produce json
  381. // @Success 200 {string} "success"
  382. // @Failure 400 {object} md.Response "具体错误"
  383. // @Router /api/setCenter/applet/unauthorized [GET]
  384. func AppletUnauthorized(c *gin.Context) {
  385. appId := c.DefaultQuery("app_id", "")
  386. masterId := svc.GetMasterId(c)
  387. //1、查找对应 user_wx_applet_list 记录
  388. userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db)
  389. UserWxAppletList, err := userWxAppletListDb.GetUserWxAppletList(masterId)
  390. if err != nil {
  391. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  392. return
  393. }
  394. if UserWxAppletList == nil {
  395. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  396. return
  397. }
  398. wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db)
  399. wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId))
  400. if err != nil {
  401. e.OutErr(c, e.ERR, err.Error())
  402. return
  403. }
  404. if wxOpenThirdPartyAppList == nil {
  405. e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录")
  406. return
  407. }
  408. wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret)
  409. if err != nil {
  410. e.OutErr(c, e.ERR, err.Error())
  411. return
  412. }
  413. err = wxApiService.DelAuthorize(appId)
  414. if err != nil {
  415. e.OutErr(c, e.ERR, err.Error())
  416. return
  417. }
  418. e.OutSuc(c, "success", nil)
  419. return
  420. }
  421. // ShareIndex
  422. // @Summary 邀请链接
  423. // @Tags 设置中心-邀请链接
  424. // @Description 邀请链接界面接口
  425. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  426. // @Accept json
  427. // @Produce json
  428. // @Success 200 {object} md.ShareIndexResp
  429. // @Failure 400 {object} md.Response "具体错误"
  430. // @Router /api/setCenter/share/index [GET]
  431. func ShareIndex(c *gin.Context) {
  432. masterId := svc.GetMasterId(c)
  433. agent := new(model.UserAppDomain)
  434. _, err := db.Db.Where("type =?", "agent").And("uuid =?", masterId).And("is_ssl =1").Get(agent)
  435. if err != nil {
  436. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  437. return
  438. }
  439. medium := new(model.UserAppDomain)
  440. _, err = db.Db.Where("type =?", "medium").And("uuid =?", masterId).And("is_ssl =1").Get(medium)
  441. if err != nil {
  442. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  443. return
  444. }
  445. agentDomain := ""
  446. if agent != nil {
  447. agentDomain = agent.Domain
  448. }
  449. mediumDomain := ""
  450. if medium != nil {
  451. mediumDomain = medium.Domain
  452. }
  453. e.OutSuc(c, md.ShareIndexResp{
  454. MasterId: masterId,
  455. AgentDomain: agentDomain,
  456. MediumDomain: mediumDomain,
  457. }, nil)
  458. return
  459. }
  460. // SetMob
  461. // @Summary mob设置
  462. // @Tags 设置中心-基础设置
  463. // @Description 基础设置-mob设置
  464. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  465. // @Accept json
  466. // @Produce json
  467. // @Param args body md.SetMobReq true "请求参数"
  468. // @Success 200 {string} "success"
  469. // @Failure 400 {object} md.Response "具体错误"
  470. // @Router /api/setCenter/basic/setMob [POST]
  471. func SetMob(c *gin.Context) {
  472. var req md.SetMobReq
  473. err := c.ShouldBindJSON(&req)
  474. if err != nil {
  475. err = validate.HandleValidateErr(err)
  476. err1 := err.(e.E)
  477. e.OutErr(c, err1.Code, err1.Error())
  478. return
  479. }
  480. masterId := svc.GetMasterId(c)
  481. engine := db.DBs[masterId]
  482. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  483. sysCfgDb.SysCfgUpdate("mob_app_key", req.MobAppKey)
  484. sysCfgDb.SysCfgUpdate("mob_app_secret", req.MobAppSecret)
  485. svc.ClearRedis(c, masterId, "mob_app_key")
  486. svc.ClearRedis(c, masterId, "mob_app_secret")
  487. svc.ClearAllRedis(c, masterId)
  488. e.OutSuc(c, "success", nil)
  489. return
  490. }
  491. // GetMob
  492. // @Summary mob获取
  493. // @Tags 设置中心-基础设置
  494. // @Description 基础设置-mob获取
  495. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  496. // @Accept json
  497. // @Produce json
  498. // @Success 200 {object} md.SetOssResp
  499. // @Failure 400 {object} md.Response "具体错误"
  500. // @Router /api/setCenter/basic/getMob [GET]
  501. func GetMob(c *gin.Context) {
  502. masterId := svc.GetMasterId(c)
  503. engine := db.DBs[masterId]
  504. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  505. res := sysCfgDb.SysCfgFindWithDb("mob_app_key", "mob_app_secret")
  506. e.OutSuc(c, md.SetMobResp{
  507. Data: md.SetMobReq{
  508. MobAppSecret: res["mob_app_secret"],
  509. MobAppKey: res["mob_app_key"],
  510. },
  511. }, nil)
  512. return
  513. }
  514. // SetLogo
  515. // @Summary logo设置
  516. // @Tags 设置中心-基础设置
  517. // @Description 基础设置-logo设置
  518. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  519. // @Accept json
  520. // @Produce json
  521. // @Param args body md.SetLogoReq true "请求参数"
  522. // @Success 200 {string} "success"
  523. // @Failure 400 {object} md.Response "具体错误"
  524. // @Router /api/setCenter/basic/setLogo [POST]
  525. func SetLogo(c *gin.Context) {
  526. var req md.SetLogoReq
  527. err := c.ShouldBindJSON(&req)
  528. if err != nil {
  529. err = validate.HandleValidateErr(err)
  530. err1 := err.(e.E)
  531. e.OutErr(c, err1.Code, err1.Error())
  532. return
  533. }
  534. masterId := svc.GetMasterId(c)
  535. engine := db.DBs[masterId]
  536. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  537. sysCfgDb.SysCfgUpdate("medium_logo", req.MediumLogo)
  538. sysCfgDb.SysCfgUpdate("agent_logo", req.AgentLogo)
  539. svc.ClearRedis(c, masterId, "medium_logo")
  540. svc.ClearRedis(c, masterId, "agent_logo")
  541. svc.ClearAllRedis(c, masterId)
  542. e.OutSuc(c, "success", nil)
  543. return
  544. }
  545. // GetLogo
  546. // @Summary logo获取
  547. // @Tags 设置中心-基础设置
  548. // @Description 基础设置-logo获取
  549. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  550. // @Accept json
  551. // @Produce json
  552. // @Success 200 {object} md.SetLogoResp
  553. // @Failure 400 {object} md.Response "具体错误"
  554. // @Router /api/setCenter/basic/getLogo [GET]
  555. func GetLogo(c *gin.Context) {
  556. masterId := svc.GetMasterId(c)
  557. engine := db.DBs[masterId]
  558. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  559. res := sysCfgDb.SysCfgFindWithDb("medium_logo", "agent_logo")
  560. e.OutSuc(c, md.SetLogoResp{
  561. Data: md.SetLogoReq{
  562. MediumLogo: res["medium_logo"],
  563. AgentLogo: res["agent_logo"],
  564. },
  565. }, nil)
  566. return
  567. }
  568. // SetSeo
  569. // @Summary Seo设置
  570. // @Tags 设置中心-基础设置
  571. // @Description 基础设置-logo设置
  572. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  573. // @Accept json
  574. // @Produce json
  575. // @Param args body md.SetSeoReq true "请求参数"
  576. // @Success 200 {string} "success"
  577. // @Failure 400 {object} md.Response "具体错误"
  578. // @Router /api/setCenter/basic/setSeo [POST]
  579. func SetSeo(c *gin.Context) {
  580. var req md.SetSeoReq
  581. err := c.ShouldBindJSON(&req)
  582. if err != nil {
  583. err = validate.HandleValidateErr(err)
  584. err1 := err.(e.E)
  585. e.OutErr(c, err1.Code, err1.Error())
  586. return
  587. }
  588. masterId := svc.GetMasterId(c)
  589. engine := db.DBs[masterId]
  590. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  591. sysCfgDb.SysCfgUpdate("seo_medium_title", req.SeoMediumTitle)
  592. sysCfgDb.SysCfgUpdate("seo_agent_title", req.SeoAgentTitle)
  593. sysCfgDb.SysCfgUpdate("seo_platform_title", req.SeoPlatformTitle)
  594. svc.ClearRedis(c, masterId, "seo_medium_title")
  595. svc.ClearRedis(c, masterId, "seo_agent_title")
  596. svc.ClearRedis(c, masterId, "seo_platform_title")
  597. sysCfgDb.SysCfgUpdate("seo_medium_logo", req.SeoMediumLogo)
  598. sysCfgDb.SysCfgUpdate("seo_agent_logo", req.SeoAgentLogo)
  599. sysCfgDb.SysCfgUpdate("seo_platform_logo", req.SeoPlatformLogo)
  600. svc.ClearRedis(c, masterId, "seo_medium_logo")
  601. svc.ClearRedis(c, masterId, "seo_agent_logo")
  602. svc.ClearRedis(c, masterId, "seo_platform_logo")
  603. svc.ClearAllRedis(c, masterId)
  604. e.OutSuc(c, "success", nil)
  605. return
  606. }
  607. // GetSeo
  608. // @Summary Seo获取
  609. // @Tags 设置中心-基础设置
  610. // @Description 基础设置-logo获取
  611. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  612. // @Accept json
  613. // @Produce json
  614. // @Success 200 {object} md.SetSeoResp
  615. // @Failure 400 {object} md.Response "具体错误"
  616. // @Router /api/setCenter/basic/getSeo [GET]
  617. func GetSeo(c *gin.Context) {
  618. masterId := svc.GetMasterId(c)
  619. engine := db.DBs[masterId]
  620. sysCfgDb := implement2.NewSysCfgDb(engine, masterId)
  621. res := sysCfgDb.SysCfgFindWithDb("seo_medium_logo", "seo_agent_logo", "seo_platform_logo", "seo_medium_title", "seo_agent_title", "seo_platform_title")
  622. e.OutSuc(c, md.SetSeoResp{
  623. Data: md.SetSeoReq{
  624. SeoMediumTitle: res["seo_medium_title"],
  625. SeoAgentTitle: res["seo_agent_title"],
  626. SeoPlatformTitle: res["seo_platform_title"],
  627. SeoMediumLogo: res["seo_medium_logo"],
  628. SeoAgentLogo: res["seo_agent_logo"],
  629. SeoPlatformLogo: res["seo_platform_logo"],
  630. },
  631. }, nil)
  632. return
  633. }