| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package logs
- import (
- . "dashoo.cn/backend/api/controllers"
- "dashoo.cn/backend/api/business/authcode"
- "dashoo.cn/utils"
- )
- // 授权码管理接口说明
- type AuthCodeController struct {
- BaseController
- }
- // @Title 授权信息
- // @Description 授权信息
- // @Success 200 {object} business.device.DeviceChannels
- // @router /getauthcode [get]
- func (this *AuthCodeController) Getauthcode() {
- svc := authcode.GetAuthCodeService(utils.DBE)
- where := " AccCode='" + this.User.AccCode + "'"
- var list []authcode.AuthCode
- list = svc.GetList("", where)
- this.Data["AuthCodelist"] = list
- if len(list) > 0 {
- this.Data["authcode"] = list[0].AuthCode
- this.Data["json"] = list[0].AuthCode
- } else {
- this.Data["json"] = authcode.AuthCode{}
- }
- this.ServeJSON()
- }
- // @Title 保存授权信息
- // @Description 保存授权信息
- // @Success 200 {object} business.device.DeviceChannels
- // @router /saveauthcode [put]
- func (this *AuthCodeController) SaveAuthCode() {
- code := this.GetString("AuthCode")
- svc := authcode.GetAuthCodeService(utils.DBE)
- //删除原来的授权码
- delwhere := " where AccCode='" + this.User.AccCode + "'"
- svc.DeleteAuth(delwhere)
- var acentity authcode.AuthCode
- acentity.AccCode = this.User.AccCode
- acentity.AuthCode = code
- acentity.AccCode = this.User.AccCode
- acentity.CreateBy = this.User.Realname
- acentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
- svc.InsertEntity(&acentity)
- var errinfo ErrorInfo
- errinfo.Message = "授权码保存成功!"
- errinfo.Code = 0
- this.Data["json"] = &errinfo
- this.ServeJSON()
- }
|