Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b4fa679c2 | ||
|
|
c2ae95c4cc | ||
|
|
b2b7f60fd5 | ||
|
|
a465888b31 |
@@ -3569,7 +3569,7 @@ const docTemplateadmin = `{
|
|||||||
"token": []
|
"token": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "登录凭证删除",
|
"description": "登录凭证批量删除",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -3579,7 +3579,7 @@ const docTemplateadmin = `{
|
|||||||
"tags": [
|
"tags": [
|
||||||
"登录凭证"
|
"登录凭证"
|
||||||
],
|
],
|
||||||
"summary": "登录凭证删除",
|
"summary": "登录凭证批量删除",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "登录凭证信息",
|
"description": "登录凭证信息",
|
||||||
@@ -3587,7 +3587,7 @@ const docTemplateadmin = `{
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/model.UserToken"
|
"$ref": "#/definitions/admin.UserTokenBatchDeleteForm"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -3798,12 +3798,12 @@ const docTemplateadmin = `{
|
|||||||
"properties": {
|
"properties": {
|
||||||
"new_password": {
|
"new_password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
},
|
},
|
||||||
"old_password": {
|
"old_password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4038,7 +4038,7 @@ const docTemplateadmin = `{
|
|||||||
},
|
},
|
||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 32,
|
||||||
"minLength": 2
|
"minLength": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4066,11 +4066,25 @@ const docTemplateadmin = `{
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"admin.UserTokenBatchDeleteForm": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"ids"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"model.AddressBook": {
|
"model.AddressBook": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -3562,7 +3562,7 @@
|
|||||||
"token": []
|
"token": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "登录凭证删除",
|
"description": "登录凭证批量删除",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -3572,7 +3572,7 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"登录凭证"
|
"登录凭证"
|
||||||
],
|
],
|
||||||
"summary": "登录凭证删除",
|
"summary": "登录凭证批量删除",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "登录凭证信息",
|
"description": "登录凭证信息",
|
||||||
@@ -3580,7 +3580,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/model.UserToken"
|
"$ref": "#/definitions/admin.UserTokenBatchDeleteForm"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -3791,12 +3791,12 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"new_password": {
|
"new_password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
},
|
},
|
||||||
"old_password": {
|
"old_password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4031,7 +4031,7 @@
|
|||||||
},
|
},
|
||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 32,
|
||||||
"minLength": 2
|
"minLength": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4059,11 +4059,25 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"admin.UserTokenBatchDeleteForm": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"ids"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"ids": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"model.AddressBook": {
|
"model.AddressBook": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ definitions:
|
|||||||
admin.ChangeCurPasswordForm:
|
admin.ChangeCurPasswordForm:
|
||||||
properties:
|
properties:
|
||||||
new_password:
|
new_password:
|
||||||
maxLength: 20
|
maxLength: 32
|
||||||
minLength: 4
|
minLength: 4
|
||||||
type: string
|
type: string
|
||||||
old_password:
|
old_password:
|
||||||
maxLength: 20
|
maxLength: 32
|
||||||
minLength: 4
|
minLength: 4
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
@@ -238,7 +238,7 @@ definitions:
|
|||||||
- $ref: '#/definitions/model.StatusCode'
|
- $ref: '#/definitions/model.StatusCode'
|
||||||
minimum: 0
|
minimum: 0
|
||||||
username:
|
username:
|
||||||
maxLength: 10
|
maxLength: 32
|
||||||
minLength: 2
|
minLength: 2
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
@@ -258,13 +258,22 @@ definitions:
|
|||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
password:
|
password:
|
||||||
maxLength: 20
|
maxLength: 32
|
||||||
minLength: 4
|
minLength: 4
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
- password
|
- password
|
||||||
type: object
|
type: object
|
||||||
|
admin.UserTokenBatchDeleteForm:
|
||||||
|
properties:
|
||||||
|
ids:
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
|
type: array
|
||||||
|
required:
|
||||||
|
- ids
|
||||||
|
type: object
|
||||||
model.AddressBook:
|
model.AddressBook:
|
||||||
properties:
|
properties:
|
||||||
alias:
|
alias:
|
||||||
@@ -2871,14 +2880,14 @@ paths:
|
|||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: 登录凭证删除
|
description: 登录凭证批量删除
|
||||||
parameters:
|
parameters:
|
||||||
- description: 登录凭证信息
|
- description: 登录凭证信息
|
||||||
in: body
|
in: body
|
||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/model.UserToken'
|
$ref: '#/definitions/admin.UserTokenBatchDeleteForm'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@@ -2892,7 +2901,7 @@ paths:
|
|||||||
$ref: '#/definitions/response.Response'
|
$ref: '#/definitions/response.Response'
|
||||||
security:
|
security:
|
||||||
- token: []
|
- token: []
|
||||||
summary: 登录凭证删除
|
summary: 登录凭证批量删除
|
||||||
tags:
|
tags:
|
||||||
- 登录凭证
|
- 登录凭证
|
||||||
/admin/user_token/list:
|
/admin/user_token/list:
|
||||||
|
|||||||
@@ -1356,7 +1356,7 @@ const docTemplateapi = `{
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
@@ -1364,7 +1364,7 @@ const docTemplateapi = `{
|
|||||||
},
|
},
|
||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 32,
|
||||||
"minLength": 2
|
"minLength": 2
|
||||||
},
|
},
|
||||||
"uuid": {
|
"uuid": {
|
||||||
|
|||||||
@@ -1349,7 +1349,7 @@
|
|||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 20,
|
"maxLength": 32,
|
||||||
"minLength": 4
|
"minLength": 4
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
@@ -1357,7 +1357,7 @@
|
|||||||
},
|
},
|
||||||
"username": {
|
"username": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": 10,
|
"maxLength": 32,
|
||||||
"minLength": 2
|
"minLength": 2
|
||||||
},
|
},
|
||||||
"uuid": {
|
"uuid": {
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ definitions:
|
|||||||
id:
|
id:
|
||||||
type: string
|
type: string
|
||||||
password:
|
password:
|
||||||
maxLength: 20
|
maxLength: 32
|
||||||
minLength: 4
|
minLength: 4
|
||||||
type: string
|
type: string
|
||||||
type:
|
type:
|
||||||
type: string
|
type: string
|
||||||
username:
|
username:
|
||||||
maxLength: 10
|
maxLength: 32
|
||||||
minLength: 2
|
minLength: 2
|
||||||
type: string
|
type: string
|
||||||
uuid:
|
uuid:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"Gwen/http/response"
|
"Gwen/http/response"
|
||||||
"Gwen/model"
|
"Gwen/model"
|
||||||
"Gwen/service"
|
"Gwen/service"
|
||||||
|
"encoding/json"
|
||||||
_ "encoding/json"
|
_ "encoding/json"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@@ -327,3 +328,70 @@ func (ct *AddressBook) ShareByWebClient(c *gin.Context) {
|
|||||||
"share_token": m.ShareToken,
|
"share_token": m.ShareToken,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ct *AddressBook) BatchCreateFromPeers(c *gin.Context) {
|
||||||
|
f := &admin.BatchCreateFromPeersForm{}
|
||||||
|
if err := c.ShouldBindJSON(f); err != nil {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
u := service.AllService.UserService.CurUser(c)
|
||||||
|
|
||||||
|
if f.CollectionId != 0 {
|
||||||
|
collection := service.AllService.AddressBookService.CollectionInfoById(f.CollectionId)
|
||||||
|
if collection.Id == 0 {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if collection.UserId != u.Id {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "NoAccess"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
peers := service.AllService.PeerService.List(1, 999, func(tx *gorm.DB) {
|
||||||
|
tx.Where("row_id in ?", f.PeerIds)
|
||||||
|
tx.Where("user_id = ?", u.Id)
|
||||||
|
})
|
||||||
|
if peers.Total == 0 {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tags, _ := json.Marshal(f.Tags)
|
||||||
|
for _, peer := range peers.Peers {
|
||||||
|
ab := service.AllService.AddressBookService.FromPeer(peer)
|
||||||
|
ab.Tags = tags
|
||||||
|
ab.CollectionId = f.CollectionId
|
||||||
|
ex := service.AllService.AddressBookService.InfoByUserIdAndIdAndCid(u.Id, ab.Id, ab.CollectionId)
|
||||||
|
if ex.RowId != 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
service.AllService.AddressBookService.Create(ab)
|
||||||
|
}
|
||||||
|
response.Success(c, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ct *AddressBook) BatchUpdateTags(c *gin.Context) {
|
||||||
|
f := &admin.BatchUpdateTagsForm{}
|
||||||
|
if err := c.ShouldBindJSON(f); err != nil {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
u := service.AllService.UserService.CurUser(c)
|
||||||
|
|
||||||
|
abs := service.AllService.AddressBookService.List(1, 999, func(tx *gorm.DB) {
|
||||||
|
tx.Where("row_id in ?", f.RowIds)
|
||||||
|
tx.Where("user_id = ?", u.Id)
|
||||||
|
})
|
||||||
|
if abs.Total == 0 {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := service.AllService.AddressBookService.BatchUpdateTags(abs.AddressBooks, f.Tags)
|
||||||
|
if err != nil {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "OperationFailed")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.Success(c, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -81,3 +81,33 @@ func (ct *UserToken) Delete(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
response.Fail(c, 101, response.TranslateMsg(c, "ItemNotFound"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BatchDelete 批量删除
|
||||||
|
// @Tags 登录凭证
|
||||||
|
// @Summary 登录凭证批量删除
|
||||||
|
// @Description 登录凭证批量删除
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param body body admin.UserTokenBatchDeleteForm true "登录凭证信息"
|
||||||
|
// @Success 200 {object} response.Response
|
||||||
|
// @Failure 500 {object} response.Response
|
||||||
|
// @Router /admin/user_token/delete [post]
|
||||||
|
// @Security token
|
||||||
|
func (ct *UserToken) BatchDelete(c *gin.Context) {
|
||||||
|
f := &admin.UserTokenBatchDeleteForm{}
|
||||||
|
if err := c.ShouldBindJSON(f); err != nil {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ids := f.Ids
|
||||||
|
if len(ids) == 0 {
|
||||||
|
response.Fail(c, 101, response.TranslateMsg(c, "ParamsError"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := service.AllService.UserService.BatchDeleteUserToken(ids)
|
||||||
|
if err == nil {
|
||||||
|
response.Success(c, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.Fail(c, 101, err.Error())
|
||||||
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func (i *WebClient) SharedPeer(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {object} response.Response
|
// @Success 200 {object} response.Response
|
||||||
// @Failure 500 {object} response.Response
|
// @Failure 500 {object} response.Response
|
||||||
// @Router /server-config [get]
|
// @Router /server-config-v2 [get]
|
||||||
// @Security token
|
// @Security token
|
||||||
func (i *WebClient) ServerConfigV2(c *gin.Context) {
|
func (i *WebClient) ServerConfigV2(c *gin.Context) {
|
||||||
response.Success(
|
response.Success(
|
||||||
|
|||||||
@@ -122,3 +122,13 @@ type AddressBookCollectionRuleQuery struct {
|
|||||||
IsMy int `form:"is_my"`
|
IsMy int `form:"is_my"`
|
||||||
PageQuery
|
PageQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BatchCreateFromPeersForm struct {
|
||||||
|
CollectionId uint `json:"collection_id"`
|
||||||
|
PeerIds []uint `json:"peer_ids"`
|
||||||
|
Tags []string `json:"tags"`
|
||||||
|
}
|
||||||
|
type BatchUpdateTagsForm struct {
|
||||||
|
RowIds []uint `json:"row_ids"`
|
||||||
|
Tags []string `json:"tags"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
type UserForm struct {
|
type UserForm struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
Username string `json:"username" validate:"required,gte=2,lte=10"`
|
Username string `json:"username" validate:"required,gte=2,lte=32"`
|
||||||
Email string `json:"email"` //validate:"required,email" email不强制
|
Email string `json:"email"` //validate:"required,email" email不强制
|
||||||
//Password string `json:"password" validate:"required,gte=4,lte=20"`
|
//Password string `json:"password" validate:"required,gte=4,lte=20"`
|
||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
@@ -51,12 +51,12 @@ type UserQuery struct {
|
|||||||
}
|
}
|
||||||
type UserPasswordForm struct {
|
type UserPasswordForm struct {
|
||||||
Id uint `json:"id" validate:"required"`
|
Id uint `json:"id" validate:"required"`
|
||||||
Password string `json:"password" validate:"required,gte=4,lte=20"`
|
Password string `json:"password" validate:"required,gte=4,lte=32"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChangeCurPasswordForm struct {
|
type ChangeCurPasswordForm struct {
|
||||||
OldPassword string `json:"old_password" validate:"required,gte=4,lte=20"`
|
OldPassword string `json:"old_password" validate:"required,gte=4,lte=32"`
|
||||||
NewPassword string `json:"new_password" validate:"required,gte=4,lte=20"`
|
NewPassword string `json:"new_password" validate:"required,gte=4,lte=32"`
|
||||||
}
|
}
|
||||||
type GroupUsersQuery struct {
|
type GroupUsersQuery struct {
|
||||||
IsMy int `json:"is_my"`
|
IsMy int `json:"is_my"`
|
||||||
@@ -64,8 +64,12 @@ type GroupUsersQuery struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RegisterForm struct {
|
type RegisterForm struct {
|
||||||
Username string `json:"username" validate:"required,gte=2,lte=10"`
|
Username string `json:"username" validate:"required,gte=2,lte=32"`
|
||||||
Email string `json:"email"` // validate:"required,email"
|
Email string `json:"email"` // validate:"required,email"
|
||||||
Password string `json:"password" validate:"required,gte=4,lte=20"`
|
Password string `json:"password" validate:"required,gte=4,lte=32"`
|
||||||
ConfirmPassword string `json:"confirm_password" validate:"required,gte=4,lte=20"`
|
ConfirmPassword string `json:"confirm_password" validate:"required,gte=4,lte=32"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserTokenBatchDeleteForm struct {
|
||||||
|
Ids []uint `json:"ids" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ type LoginForm struct {
|
|||||||
Id string `json:"id" label:"id"`
|
Id string `json:"id" label:"id"`
|
||||||
Type string `json:"type" label:"type"`
|
Type string `json:"type" label:"type"`
|
||||||
Uuid string `json:"uuid" label:"uuid"`
|
Uuid string `json:"uuid" label:"uuid"`
|
||||||
Username string `json:"username" validate:"required,gte=2,lte=10" label:"用户名"`
|
Username string `json:"username" validate:"required,gte=2,lte=32" label:"用户名"`
|
||||||
Password string `json:"password,omitempty" validate:"gte=4,lte=20" label:"密码"`
|
Password string `json:"password,omitempty" validate:"gte=4,lte=32" label:"密码"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserListQuery struct {
|
type UserListQuery struct {
|
||||||
|
|||||||
@@ -107,9 +107,12 @@ func AddressBookBind(rg *gin.RouterGroup) {
|
|||||||
aR.POST("/update", cont.Update)
|
aR.POST("/update", cont.Update)
|
||||||
aR.POST("/delete", cont.Delete)
|
aR.POST("/delete", cont.Delete)
|
||||||
aR.POST("/shareByWebClient", cont.ShareByWebClient)
|
aR.POST("/shareByWebClient", cont.ShareByWebClient)
|
||||||
|
aR.POST("/batchCreateFromPeers", cont.BatchCreateFromPeers)
|
||||||
|
aR.POST("/batchUpdateTags", cont.BatchUpdateTags)
|
||||||
|
|
||||||
arp := aR.Use(middleware.AdminPrivilege())
|
arp := aR.Use(middleware.AdminPrivilege())
|
||||||
arp.POST("/batchCreate", cont.BatchCreate)
|
arp.POST("/batchCreate", cont.BatchCreate)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func PeerBind(rg *gin.RouterGroup) {
|
func PeerBind(rg *gin.RouterGroup) {
|
||||||
@@ -195,6 +198,7 @@ func UserTokenBind(rg *gin.RouterGroup) {
|
|||||||
cont := &admin.UserToken{}
|
cont := &admin.UserToken{}
|
||||||
aR.GET("/list", cont.List)
|
aR.GET("/list", cont.List)
|
||||||
aR.POST("/delete", cont.Delete)
|
aR.POST("/delete", cont.Delete)
|
||||||
|
aR.POST("/batchDelete", cont.BatchDelete)
|
||||||
}
|
}
|
||||||
func ConfigBind(rg *gin.RouterGroup) {
|
func ConfigBind(rg *gin.RouterGroup) {
|
||||||
aR := rg.Group("/config")
|
aR := rg.Group("/config")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"Gwen/global"
|
"Gwen/global"
|
||||||
"Gwen/model"
|
"Gwen/model"
|
||||||
|
"encoding/json"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -116,6 +117,16 @@ func (s *AddressBookService) List(page, pageSize uint, where func(tx *gorm.DB))
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *AddressBookService) FromPeer(peer *model.Peer) (a *model.AddressBook) {
|
||||||
|
a = &model.AddressBook{}
|
||||||
|
a.Id = peer.Id
|
||||||
|
a.Username = peer.Username
|
||||||
|
a.Hostname = peer.Hostname
|
||||||
|
a.UserId = peer.UserId
|
||||||
|
a.Platform = s.PlatformFromOs(peer.Os)
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
// Create 创建
|
// Create 创建
|
||||||
func (s *AddressBookService) Create(u *model.AddressBook) error {
|
func (s *AddressBookService) Create(u *model.AddressBook) error {
|
||||||
res := global.DB.Create(u).Error
|
res := global.DB.Create(u).Error
|
||||||
@@ -318,3 +329,12 @@ func (s *AddressBookService) CheckCollectionOwner(uid uint, cid uint) bool {
|
|||||||
p := s.CollectionInfoById(cid)
|
p := s.CollectionInfoById(cid)
|
||||||
return p.UserId == uid
|
return p.UserId == uid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *AddressBookService) BatchUpdateTags(abs []*model.AddressBook, tags []string) error {
|
||||||
|
ids := make([]uint, 0)
|
||||||
|
for _, ab := range abs {
|
||||||
|
ids = append(ids, ab.RowId)
|
||||||
|
}
|
||||||
|
tagsv, _ := json.Marshal(tags)
|
||||||
|
return global.DB.Model(&model.AddressBook{}).Where("row_id in ?", ids).Update("tags", tagsv).Error
|
||||||
|
}
|
||||||
|
|||||||
@@ -458,3 +458,7 @@ func (us *UserService) AutoRefreshAccessToken(ut *model.UserToken) {
|
|||||||
us.RefreshAccessToken(ut)
|
us.RefreshAccessToken(ut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (us *UserService) BatchDeleteUserToken(ids []uint) error {
|
||||||
|
return global.DB.Where("id in ?", ids).Delete(&model.UserToken{}).Error
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user