diff --git a/README.md b/README.md index 81ac3c3..039d65f 100644 --- a/README.md +++ b/README.md @@ -782,13 +782,17 @@ gin-vue-admin提供代码自动生成功能,选择数据库表结构,可直 { "id":100, "header":"周报", + "userName":"xiaoming", + "sendTo": ["xiao1", "xiao2"], "contents":[ - {"title":"", "content":""}, - {"title":"", "content":""} + {"title":"本周工作", "content":"本周工作这里"}, + {"title":"下周计划", "content":"

下周计划在这

这里"} ], + "pics":[ + { "key":"fe01ce2a7fbac8fafaed7c982a04e229_20211102170427.png", "name":"demo.png"} + ] "attachments":[ - {"pic":"fe01ce2a7fbac8fafaed7c982a04e229_20211102170427.png"}, - {"file":"2db0df442ea6d92d75657712a29e5604_20211102201017.txt"} + { "key":"fe01ce2a7fbac8fafaed7c982a04e220_20211102170428.c", "name":"demo.c"} ] } diff --git a/api/enter.go b/api/enter.go index 5fa1143..f5b33be 100644 --- a/api/enter.go +++ b/api/enter.go @@ -2,10 +2,12 @@ package api import ( "goweb-gin-demo/api/web" + "goweb-gin-demo/api/wt" ) type ApiGroup struct { ApiGroup web.ApiGroup + WtServiceGroup wt.ApiWtGroup } var ApiGroupApp = new(ApiGroup) diff --git a/api/web/user.go b/api/web/user.go index 4dd116c..ae264da 100644 --- a/api/web/user.go +++ b/api/web/user.go @@ -4,6 +4,7 @@ import ( "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" "github.com/go-redis/redis/v8" + "go.uber.org/zap" "goweb-gin-demo/global" "goweb-gin-demo/model/common/request" "goweb-gin-demo/model/common/response" @@ -11,7 +12,6 @@ import ( systemReq "goweb-gin-demo/model/web/request" webRes "goweb-gin-demo/model/web/response" "goweb-gin-demo/utils" - "go.uber.org/zap" "strconv" "time" ) @@ -275,7 +275,7 @@ func (b *BaseApi) DeleteUser(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body web.SysSimpleUser true "ID, 用户名, 昵称, 密码" +// @Param data body request.SetUserInfo true "ID, 用户名, 昵称, 密码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" // @Router /user/setUserInfo [put] func (b *BaseApi) SetUserInfo(c *gin.Context) { diff --git a/api/wt/enter.go b/api/wt/enter.go new file mode 100644 index 0000000..9bcf54e --- /dev/null +++ b/api/wt/enter.go @@ -0,0 +1,10 @@ +package wt + +import "goweb-gin-demo/service" + +type ApiWtGroup struct { + WtReportsApi +} + +var wtReportsService = service.ServiceGroupApp.WtReportsService + diff --git a/api/wt/reports.go b/api/wt/reports.go new file mode 100644 index 0000000..0877e64 --- /dev/null +++ b/api/wt/reports.go @@ -0,0 +1,121 @@ +package wt + +import ( + "github.com/gin-gonic/gin" + "go.uber.org/zap" + "goweb-gin-demo/global" + "goweb-gin-demo/model/common/request" + "goweb-gin-demo/model/common/response" + wtReq "goweb-gin-demo/model/wt/request" + "strconv" +) + +type WtReportsApi struct { +} + +// CreateWtReports 创建周报 +// @Tags WtReports +// @Summary 创建周报 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body wtReq.WtReportsVO true "创建周报" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /wtReports/createWtReports [post] +func (wtReportsApi *WtReportsApi) CreateWtReports(c *gin.Context) { + var reportsVO wtReq.WtReportsVO + _ = c.ShouldBindJSON(&reportsVO) + + if err := wtReportsService.CreateWtReports(reportsVO); err != nil { + global.GLOBAL_LOG.Error("创建失败!", zap.Any("err", err)) + response.FailWithMessage("创建失败", c) + } else { + response.OkWithMessage("创建成功", c) + } +} + +// DeleteWtReportsByIds 批量删除周报 +// @Tags WtReports +// @Summary 批量删除周报 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.IdsReq true "批量删除周报" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}" +// @Router /wtReports/deleteWtReportsByIds [delete] +func (wtReportsApi *WtReportsApi) DeleteWtReportsByIds(c *gin.Context) { + var IDS request.IdsReq + _ = c.ShouldBindJSON(&IDS) + if err := wtReportsService.DeleteWtReportsByIds(IDS); err != nil { + global.GLOBAL_LOG.Error("批量删除失败!", zap.Any("err", err)) + response.FailWithMessage("批量删除失败", c) + } else { + response.OkWithMessage("批量删除成功", c) + } +} + +// UpdateWtReports 更新周报 +// @Tags WtReports +// @Summary 更新周报 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body wtReq.WtReportsVO true "更新周报" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}" +// @Router /wtReports/updateWtReports [put] +func (wtReportsApi *WtReportsApi) UpdateWtReports(c *gin.Context) { + var reportsVO wtReq.WtReportsVO + _ = c.ShouldBindJSON(&reportsVO) + if err := wtReportsService.UpdateWtReports(reportsVO); err != nil { + global.GLOBAL_LOG.Error("更新失败!", zap.Any("err", err)) + response.FailWithMessage("更新失败", c) + } else { + response.OkWithMessage("更新成功", c) + } +} + +// FindWtReports 用id查询WtReports +// @Tags WtReports +// @Summary 用id查询WtReports +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query request.GetById true "用id查询WtReports" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" +// @Router /wtReports/findWtReports [get] +func (wtReportsApi *WtReportsApi) FindWtReports(c *gin.Context) { + idStr := c.Query("id") + id, _ := strconv.Atoi(idStr) + + if err, rewtReports := wtReportsService.GetWtReports(uint(id)); err != nil { + global.GLOBAL_LOG.Error("查询失败,id不存在!", zap.Any("err", err)) + response.FailWithMessage("查询失败,id不存在!", c) + } else { + response.OkWithData(gin.H{"rewtReports": rewtReports}, c) + } +} + +// GetWtReportsList 分页获取WtReports列表 +// @Tags WtReports +// @Summary 分页获取WtReports列表 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query wtReq.WtReportsSearch true "分页获取WtReports列表" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /wtReports/getWtReportsList [get] +func (wtReportsApi *WtReportsApi) GetWtReportsList(c *gin.Context) { + var pageInfo wtReq.WtReportsSearch + _ = c.ShouldBindQuery(&pageInfo) + if err, list, total := wtReportsService.GetWtReportsInfoList(pageInfo); err != nil { + global.GLOBAL_LOG.Error("获取失败!", zap.Any("err", err)) + response.FailWithMessage("获取失败", c) + } else { + response.OkWithDetailed(response.PageResult{ + List: list, + Total: total, + Page: pageInfo.Page, + PageSize: pageInfo.PageSize, + }, "获取成功", c) + } +} diff --git a/config.yaml b/config.yaml index 1527cca..764ae19 100644 --- a/config.yaml +++ b/config.yaml @@ -30,7 +30,7 @@ casbin: # system configuration system: env: 'develop' # Change to "develop" to skip authentication for development mode # public - addr: 8888 + addr: 8889 db-type: 'mysql' oss-type: 'local' # 控制oss选择走本期还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置 use-multipoint: false @@ -43,7 +43,7 @@ captcha: # mysql connect configuration mysql: - path: '10.25.17.236:3306' + path: '127.0.0.1:3306' config: 'parseTime=true' db-name: 'weekly_report' username: 'root' diff --git a/docs/docs.go b/docs/docs.go index 9a1f29b..1939cc8 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1335,7 +1335,7 @@ var doc = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/web.SysSimpleUser" + "$ref": "#/definitions/request.SetUserInfo" } } ], @@ -1348,6 +1348,234 @@ var doc = `{ } } } + }, + "/wtReports/createWtReports": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "创建周报", + "parameters": [ + { + "description": "创建周报", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.WtReportsVO" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/deleteWtReportsByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "批量删除周报", + "parameters": [ + { + "description": "批量删除周报", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.IdsReq" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"批量删除成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/findWtReports": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "用id查询WtReports", + "parameters": [ + { + "type": "number", + "description": "主键ID", + "name": "id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/getWtReportsList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "分页获取WtReports列表", + "parameters": [ + { + "type": "string", + "name": "attachments", + "in": "query" + }, + { + "type": "string", + "name": "contents", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "name": "header", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "sendTo", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/updateWtReports": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "更新周报", + "parameters": [ + { + "description": "更新周报", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.WtReportsVO" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}", + "schema": { + "type": "string" + } + } + } + } } }, "definitions": { @@ -1785,6 +2013,17 @@ var doc = `{ } } }, + "request.IdsReq": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "request.Login": { "type": "object", "properties": { @@ -1869,6 +2108,62 @@ var doc = `{ } } }, + "request.SetUserInfo": { + "type": "object", + "properties": { + "authorityId": { + "description": "用户角色ID", + "type": "string" + }, + "id": { + "type": "integer" + }, + "nickName": { + "description": "用户昵称", + "type": "string" + }, + "password": { + "description": "用户登录密码", + "type": "string" + }, + "userName": { + "description": "用户登录名", + "type": "string" + } + } + }, + "request.WtReportsVO": { + "type": "object", + "properties": { + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/wt.Attachments" + } + }, + "contents": { + "type": "array", + "items": { + "$ref": "#/definitions/wt.Contents" + } + }, + "header": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "sendTo": { + "type": "array", + "items": { + "type": "string" + } + }, + "userId": { + "type": "string" + } + } + }, "response.SysAuthorityCopyResponse": { "type": "object", "properties": { @@ -2075,39 +2370,6 @@ var doc = `{ } } }, - "web.SysSimpleUser": { - "type": "object", - "properties": { - "authorityId": { - "description": "用户角色ID", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "nickName": { - "description": "用户昵称", - "type": "string" - }, - "password": { - "description": "用户登录密码", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "userName": { - "description": "用户登录名", - "type": "string" - } - } - }, "web.System": { "type": "object", "properties": { @@ -2115,6 +2377,28 @@ var doc = `{ "$ref": "#/definitions/config.Server" } } + }, + "wt.Attachments": { + "type": "object", + "properties": { + "attachmentName": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "wt.Contents": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "title": { + "type": "string" + } + } } } }` diff --git a/docs/swagger.json b/docs/swagger.json index 30d0819..de59bc7 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1316,7 +1316,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/web.SysSimpleUser" + "$ref": "#/definitions/request.SetUserInfo" } } ], @@ -1329,6 +1329,234 @@ } } } + }, + "/wtReports/createWtReports": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "创建周报", + "parameters": [ + { + "description": "创建周报", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.WtReportsVO" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/deleteWtReportsByIds": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "批量删除周报", + "parameters": [ + { + "description": "批量删除周报", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.IdsReq" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"批量删除成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/findWtReports": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "用id查询WtReports", + "parameters": [ + { + "type": "number", + "description": "主键ID", + "name": "id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/getWtReportsList": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "分页获取WtReports列表", + "parameters": [ + { + "type": "string", + "name": "attachments", + "in": "query" + }, + { + "type": "string", + "name": "contents", + "in": "query" + }, + { + "type": "string", + "description": "创建时间", + "name": "createdAt", + "in": "query" + }, + { + "type": "string", + "name": "header", + "in": "query" + }, + { + "type": "integer", + "description": "主键ID", + "name": "id", + "in": "query" + }, + { + "type": "integer", + "description": "页码", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "每页大小", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "sendTo", + "in": "query" + }, + { + "type": "string", + "description": "更新时间", + "name": "updatedAt", + "in": "query" + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"获取成功\"}", + "schema": { + "type": "string" + } + } + } + } + }, + "/wtReports/updateWtReports": { + "put": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "WtReports" + ], + "summary": "更新周报", + "parameters": [ + { + "description": "更新周报", + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.WtReportsVO" + } + } + ], + "responses": { + "200": { + "description": "{\"success\":true,\"data\":{},\"msg\":\"更新成功\"}", + "schema": { + "type": "string" + } + } + } + } } }, "definitions": { @@ -1766,6 +1994,17 @@ } } }, + "request.IdsReq": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, "request.Login": { "type": "object", "properties": { @@ -1850,6 +2089,62 @@ } } }, + "request.SetUserInfo": { + "type": "object", + "properties": { + "authorityId": { + "description": "用户角色ID", + "type": "string" + }, + "id": { + "type": "integer" + }, + "nickName": { + "description": "用户昵称", + "type": "string" + }, + "password": { + "description": "用户登录密码", + "type": "string" + }, + "userName": { + "description": "用户登录名", + "type": "string" + } + } + }, + "request.WtReportsVO": { + "type": "object", + "properties": { + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/wt.Attachments" + } + }, + "contents": { + "type": "array", + "items": { + "$ref": "#/definitions/wt.Contents" + } + }, + "header": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "sendTo": { + "type": "array", + "items": { + "type": "string" + } + }, + "userId": { + "type": "string" + } + } + }, "response.SysAuthorityCopyResponse": { "type": "object", "properties": { @@ -2056,39 +2351,6 @@ } } }, - "web.SysSimpleUser": { - "type": "object", - "properties": { - "authorityId": { - "description": "用户角色ID", - "type": "string" - }, - "createdAt": { - "description": "创建时间", - "type": "string" - }, - "id": { - "description": "主键ID", - "type": "integer" - }, - "nickName": { - "description": "用户昵称", - "type": "string" - }, - "password": { - "description": "用户登录密码", - "type": "string" - }, - "updatedAt": { - "description": "更新时间", - "type": "string" - }, - "userName": { - "description": "用户登录名", - "type": "string" - } - } - }, "web.System": { "type": "object", "properties": { @@ -2096,6 +2358,28 @@ "$ref": "#/definitions/config.Server" } } + }, + "wt.Attachments": { + "type": "object", + "properties": { + "attachmentName": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "wt.Contents": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "title": { + "type": "string" + } + } } } } \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 95ec83a..47ca787 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -302,6 +302,13 @@ definitions: description: 主键ID type: number type: object + request.IdsReq: + properties: + ids: + items: + type: integer + type: array + type: object request.Login: properties: captcha: @@ -359,6 +366,44 @@ definitions: id: type: integer type: object + request.SetUserInfo: + properties: + authorityId: + description: 用户角色ID + type: string + id: + type: integer + nickName: + description: 用户昵称 + type: string + password: + description: 用户登录密码 + type: string + userName: + description: 用户登录名 + type: string + type: object + request.WtReportsVO: + properties: + attachments: + items: + $ref: '#/definitions/wt.Attachments' + type: array + contents: + items: + $ref: '#/definitions/wt.Contents' + type: array + header: + type: string + id: + type: integer + sendTo: + items: + type: string + type: array + userId: + type: string + type: object response.SysAuthorityCopyResponse: properties: authority: @@ -506,35 +551,25 @@ definitions: description: 地址栏携带参数的值 type: string type: object - web.SysSimpleUser: - properties: - authorityId: - description: 用户角色ID - type: string - createdAt: - description: 创建时间 - type: string - id: - description: 主键ID - type: integer - nickName: - description: 用户昵称 - type: string - password: - description: 用户登录密码 - type: string - updatedAt: - description: 更新时间 - type: string - userName: - description: 用户登录名 - type: string - type: object web.System: properties: config: $ref: '#/definitions/config.Server' type: object + wt.Attachments: + properties: + attachmentName: + type: string + type: + type: string + type: object + wt.Contents: + properties: + content: + type: string + title: + type: string + type: object info: contact: {} paths: @@ -1327,7 +1362,7 @@ paths: name: data required: true schema: - $ref: '#/definitions/web.SysSimpleUser' + $ref: '#/definitions/request.SetUserInfo' produces: - application/json responses: @@ -1340,4 +1375,143 @@ paths: summary: 设置用户信息 tags: - SysUser + /wtReports/createWtReports: + post: + consumes: + - application/json + parameters: + - description: 创建周报 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.WtReportsVO' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"获取成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 创建周报 + tags: + - WtReports + /wtReports/deleteWtReportsByIds: + delete: + consumes: + - application/json + parameters: + - description: 批量删除周报 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.IdsReq' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"批量删除成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 批量删除周报 + tags: + - WtReports + /wtReports/findWtReports: + get: + consumes: + - application/json + parameters: + - description: 主键ID + in: query + name: id + type: number + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"查询成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 用id查询WtReports + tags: + - WtReports + /wtReports/getWtReportsList: + get: + consumes: + - application/json + parameters: + - in: query + name: attachments + type: string + - in: query + name: contents + type: string + - description: 创建时间 + in: query + name: createdAt + type: string + - in: query + name: header + type: string + - description: 主键ID + in: query + name: id + type: integer + - description: 页码 + in: query + name: page + type: integer + - description: 每页大小 + in: query + name: pageSize + type: integer + - in: query + name: sendTo + type: string + - description: 更新时间 + in: query + name: updatedAt + type: string + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"获取成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 分页获取WtReports列表 + tags: + - WtReports + /wtReports/updateWtReports: + put: + consumes: + - application/json + parameters: + - description: 更新周报 + in: body + name: data + required: true + schema: + $ref: '#/definitions/request.WtReportsVO' + produces: + - application/json + responses: + "200": + description: '{"success":true,"data":{},"msg":"更新成功"}' + schema: + type: string + security: + - ApiKeyAuth: [] + summary: 更新周报 + tags: + - WtReports swagger: "2.0" diff --git a/goweb-gin-demo b/goweb-gin-demo index 24ad21d..809fed8 100755 Binary files a/goweb-gin-demo and b/goweb-gin-demo differ diff --git a/initialize/router.go b/initialize/router.go index c6da0ff..1731f36 100644 --- a/initialize/router.go +++ b/initialize/router.go @@ -41,6 +41,7 @@ func Routers() *gin.Engine { RouterGroup.InitSystemRouter(PrivateGroup) RouterGroup.InitFileUploadAndDownloadRouter(PrivateGroup) RouterGroup.InitAuthorityRouter(PrivateGroup) + RouterGroup.InitWtReportsRouter(PrivateGroup) } global.GLOBAL_LOG.Info("router register success") diff --git a/latest_log b/latest_log index b17af21..2cdb3b6 120000 --- a/latest_log +++ b/latest_log @@ -1 +1 @@ -log/2021-11-03.log \ No newline at end of file +log/2021-11-04.log \ No newline at end of file diff --git a/log/2021-10-28.log b/log/2021-10-28.log deleted file mode 100644 index 4e9e9db..0000000 --- a/log/2021-10-28.log +++ /dev/null @@ -1,18 +0,0 @@ -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:16:39.843 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:41 router register success -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:16:39.845 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"} -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:46:41.209 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:46:50.466 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:41 router register success -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:46:50.467 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"} -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:54:51.771 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:54:56.370 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:41 router register success -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 15:54:56.371 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"} -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 16:06:32.084 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 16:06:38.104 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:41 router register success -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 16:06:38.106 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"} -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 17:59:22.081 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 18:00:16.251 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:42 router register success -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 18:00:16.253 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"} -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 18:01:02.383 error /Users/zero/work/mygithub/goweb-gin-demo/api/web/user.go:36 登陆失败! 用户名不存在或者密码错误! {"err": "sql: Scan error on column index 1, name \"created_at\": unsupported Scan, storing driver.Value type []uint8 into type *time.Time"} -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 18:07:16.567 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 18:10:08.680 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:42 router register success -[github.com/flipped-aurora/gin-vue-admin/server]2021/10/28 - 18:10:08.682 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"} diff --git a/log/2021-11-03.log b/log/2021-11-03.log index 5dc1220..ee1efa3 100644 --- a/log/2021-11-03.log +++ b/log/2021-11-03.log @@ -47,3 +47,20 @@ [goweb-demo]2021/11/03 - 16:37:11.018 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:46 router register success [goweb-demo]2021/11/03 - 16:37:11.021 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8888"} [goweb-demo]2021/11/03 - 16:37:22.986 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8888: use of closed network connection +[goweb-demo]2021/11/03 - 16:55:11.514 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:46 router register success +[goweb-demo]2021/11/03 - 16:55:11.518 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/03 - 16:55:36.361 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/03 - 16:55:42.742 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:46 router register success +[goweb-demo]2021/11/03 - 16:55:42.745 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/03 - 17:00:50.486 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/03 - 17:42:09.727 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:46 router register success +[goweb-demo]2021/11/03 - 17:42:09.729 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/03 - 17:42:58.675 error /Users/zero/work/mygithub/goweb-gin-demo/middleware/operation.go:72 create operation record error: {"err": "Error 1146: Table 'weekly_report.sys_operation_records' doesn't exist"} +[goweb-demo]2021/11/03 - 17:44:04.303 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/03 - 17:44:13.322 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/03 - 17:44:13.323 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/03 - 17:46:46.917 error /Users/zero/work/mygithub/goweb-gin-demo/middleware/operation.go:72 create operation record error: {"err": "Error 1146: Table 'weekly_report.sys_operation_records' doesn't exist"} +[goweb-demo]2021/11/03 - 18:11:31.697 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/03 - 18:11:42.617 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/03 - 18:11:42.619 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/03 - 18:13:41.672 error /Users/zero/work/mygithub/goweb-gin-demo/middleware/operation.go:72 create operation record error: {"err": "Error 1146: Table 'weekly_report.sys_operation_records' doesn't exist"} diff --git a/log/2021-11-04.log b/log/2021-11-04.log new file mode 100644 index 0000000..df365d4 --- /dev/null +++ b/log/2021-11-04.log @@ -0,0 +1,59 @@ +[goweb-demo]2021/11/04 - 09:09:00.258 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 09:09:00.259 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 09:55:58.252 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 11:10:53.616 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 11:10:53.618 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 11:51:41.571 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 11:51:41.572 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 12:08:30.100 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 12:08:38.533 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 12:08:38.534 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 13:09:04.755 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 13:09:14.861 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 13:09:14.863 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 13:09:22.503 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 13:09:22.505 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 13:09:22.506 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 net.Listen error: listen tcp :8889: bind: address already in use +[goweb-demo]2021/11/04 - 13:09:58.761 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 13:10:06.971 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 13:10:06.973 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 14:17:23.495 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 14:17:23.500 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 14:20:01.880 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 14:20:01.882 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 14:21:18.585 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 14:21:18.586 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 14:23:51.950 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 14:23:51.950 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 14:25:02.885 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 14:25:02.886 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 15:34:47.410 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 15:34:54.837 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 15:34:54.839 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 15:40:31.044 error /Users/zero/work/mygithub/goweb-gin-demo/api/web/file_upload_download.go:30 接收文件失败! {"err": "http: no such file"} +[goweb-demo]2021/11/04 - 15:50:41.996 error /Users/zero/work/mygithub/goweb-gin-demo/api/web/file_upload_download.go:30 接收文件失败! {"err": "request Content-Type isn't multipart/form-data"} +[goweb-demo]2021/11/04 - 16:12:37.547 error /Users/zero/work/mygithub/goweb-gin-demo/api/web/file_upload_download.go:83 删除失败! {"err": "record not found"} +[goweb-demo]2021/11/04 - 18:38:20.445 error /Users/zero/work/mygithub/goweb-gin-demo/api/wt/reports.go:30 创建失败! {"err": "Error 1062: Duplicate entry '100' for key 'PRIMARY'"} +[goweb-demo]2021/11/04 - 18:39:34.456 error /Users/zero/work/mygithub/goweb-gin-demo/api/wt/reports.go:70 更新失败! {"err": "Error 1292: Incorrect datetime value: '0000-00-00' for column 'created_at' at row 1"} +[goweb-demo]2021/11/04 - 18:46:01.001 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 18:46:01.003 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 18:48:13.914 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 18:48:21.666 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 18:48:21.668 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 18:55:31.198 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 18:55:39.242 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 18:55:39.244 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 18:58:49.191 error /Users/zero/work/mygithub/goweb-gin-demo/api/wt/reports.go:90 查询失败! {"err": "record not found"} +[goweb-demo]2021/11/04 - 19:08:20.085 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 19:08:29.460 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 19:08:29.462 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 19:09:01.818 error /Users/zero/work/mygithub/goweb-gin-demo/api/wt/reports.go:91 查询失败! {"err": "record not found"} +[goweb-demo]2021/11/04 - 19:19:56.154 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 19:20:05.235 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 19:20:05.240 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 19:24:25.980 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 19:24:34.139 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 19:24:34.141 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} +[goweb-demo]2021/11/04 - 19:33:31.774 error /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:38 accept tcp [::]:8889: use of closed network connection +[goweb-demo]2021/11/04 - 19:33:38.881 info /Users/zero/work/mygithub/goweb-gin-demo/initialize/router.go:47 router register success +[goweb-demo]2021/11/04 - 19:33:38.883 info /Users/zero/work/mygithub/goweb-gin-demo/core/server.go:31 server run success on {"address": ":8889"} diff --git a/model/web/request/user.go b/model/web/request/user.go index c03807e..67fd076 100644 --- a/model/web/request/user.go +++ b/model/web/request/user.go @@ -35,3 +35,11 @@ type SetUserAuthorities struct { ID uint AuthorityIds []string `json:"authorityIds"` // 角色ID } + +type SetUserInfo struct { + ID uint + Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名 + Password string `json:"password" gorm:"comment:用户登录密码"` // 用户登录密码 + NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称 + AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID +} diff --git a/model/web/user.go b/model/web/user.go index 0a080ff..901d09a 100644 --- a/model/web/user.go +++ b/model/web/user.go @@ -18,12 +18,4 @@ type SysUser struct { AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID Authority SysAuthority `json:"authority" gorm:"foreignKey:AuthorityId;references:AuthorityId;comment:用户角色"` Authorities []SysAuthority `json:"authorities" gorm:"many2many:sys_user_authority;"` -} - -type SysSimpleUser struct { - global.GLOBAL_MODEL - Username string `json:"userName" gorm:"comment:用户登录名"` // 用户登录名 - Password string `json:"password" gorm:"comment:用户登录密码"` // 用户登录密码 - NickName string `json:"nickName" gorm:"default:系统用户;comment:用户昵称"` // 用户昵称 - AuthorityId string `json:"authorityId" gorm:"default:888;comment:用户角色ID"` // 用户角色ID -} +} \ No newline at end of file diff --git a/model/wt/request/wt_reports.go b/model/wt/request/wt_reports.go new file mode 100644 index 0000000..57d85cc --- /dev/null +++ b/model/wt/request/wt_reports.go @@ -0,0 +1,23 @@ +package request + +import ( + "goweb-gin-demo/model/common/request" + "goweb-gin-demo/model/wt" +) + +type WtReportsSearch struct{ + wt.WtReports + request.PageInfo +} + +// +type WtReportsVO struct{ + ID uint + UserName string `json:"userName"` + SendTo []wt.UserInfo `json:"sendTo"` + Header string `json:"header"` + Contents []wt.Contents `json:"contents"` + Pictures []wt.UploadFileJson `json:"pictures"` + Attachments []wt.UploadFileJson `json:"attachments"` +} + diff --git a/model/wt/wt_reports.go b/model/wt/wt_reports.go new file mode 100644 index 0000000..483e48f --- /dev/null +++ b/model/wt/wt_reports.go @@ -0,0 +1,37 @@ +package wt + +import "goweb-gin-demo/global" + +// WtReports 结构体 +type WtReports struct { + global.GLOBAL_MODEL + UserName string `json:"userName" form:"userName" gorm:"column:user_name;comment:用户名;type:varchar(100);"` + SendTo string `json:"sendTo" form:"sendTo" gorm:"column:send_to;comment:发送给谁;type:varchar(100);"` + Header string `json:"header" form:"header" gorm:"column:header;comment:报告标题名;type:varchar(100);"` + Contents string `json:"contents" form:"contents" gorm:"column:contents;comment:报告内容;type:mediumtext;"` + Pictures string `json:"pictures" form:"pictures" gorm:"column:pictures;comment:图片;type:text;"` + Attachments string `json:"attachments" form:"attachments" gorm:"column:attachments;comment:附件;type:text;"` +} + + +// TableName WtReports 表名 +func (WtReports) TableName() string { + return "wt_reports" +} + +// 报告内容 +type Contents struct { + Title string `json:"title"` + Content string `json:"content"` +} + +// 上传文件 +type UploadFileJson struct { + Key string `json:"key"` + Name string `json:"name"` +} + +type UserInfo struct { + ID uint + Name string `json:"name"` +} diff --git a/router/group.go b/router/group.go index 56f774e..c0c586d 100644 --- a/router/group.go +++ b/router/group.go @@ -1,6 +1,9 @@ package router -import "goweb-gin-demo/router/web" +import ( + "goweb-gin-demo/router/web" + "goweb-gin-demo/router/wt" +) type RouterGroup struct { web.BaseRouter @@ -10,6 +13,8 @@ type RouterGroup struct { web.SysRouter web.FileUploadAndDownloadRouter web.AuthorityRouter + + wt.WtReportsRouter } var RouterGroupApp = new(RouterGroup) diff --git a/router/wt/reports.go b/router/wt/reports.go new file mode 100644 index 0000000..5d09ae7 --- /dev/null +++ b/router/wt/reports.go @@ -0,0 +1,27 @@ +package wt + +import ( + "github.com/gin-gonic/gin" + "goweb-gin-demo/api" + "goweb-gin-demo/middleware" +) + +type WtReportsRouter struct { +} + + +// InitWtReportsRouter 初始化 WtReports 路由信息 +func (s *WtReportsRouter) InitWtReportsRouter(Router *gin.RouterGroup) { + wtReportsRouter := Router.Group("wtReports").Use(middleware.OperationRecord()) + wtReportsRouterWithoutRecord := Router.Group("wtReports") + var wtReportsApi = api.ApiGroupApp.WtServiceGroup.WtReportsApi + { + wtReportsRouter.POST("createWtReports", wtReportsApi.CreateWtReports) // 新建WtReports + wtReportsRouter.DELETE("deleteWtReportsByIds", wtReportsApi.DeleteWtReportsByIds) // 批量删除WtReports + wtReportsRouter.PUT("updateWtReports", wtReportsApi.UpdateWtReports) // 更新WtReports + } + { + wtReportsRouterWithoutRecord.GET("findWtReports", wtReportsApi.FindWtReports) // 根据ID获取WtReports + wtReportsRouterWithoutRecord.GET("getWtReportsList", wtReportsApi.GetWtReportsList) // 获取WtReports列表 + } +} \ No newline at end of file diff --git a/service/enter.go b/service/enter.go index f437ba4..c3c85df 100644 --- a/service/enter.go +++ b/service/enter.go @@ -1,5 +1,7 @@ package service +import "goweb-gin-demo/service/wt" + type ServiceGroup struct { UserService JwtService @@ -10,6 +12,8 @@ type ServiceGroup struct { SystemConfigService FileUploadAndDownloadService AuthorityService + + wt.WtReportsService } var ServiceGroupApp = new(ServiceGroup) diff --git a/service/wt/enter.go b/service/wt/enter.go new file mode 100644 index 0000000..4fbb35d --- /dev/null +++ b/service/wt/enter.go @@ -0,0 +1 @@ +package wt diff --git a/service/wt/wt_report.go b/service/wt/wt_report.go new file mode 100644 index 0000000..96f0e71 --- /dev/null +++ b/service/wt/wt_report.go @@ -0,0 +1,102 @@ +package wt + +import ( + "encoding/json" + "goweb-gin-demo/global" + "goweb-gin-demo/model/common/request" + "goweb-gin-demo/model/wt" + wtReq "goweb-gin-demo/model/wt/request" +) + +type WtReportsService struct { +} + +// CreateWtReports 创建周报 +func (wtReportsService *WtReportsService) CreateWtReports(reportsVO wtReq.WtReportsVO) (err error) { + wtReports := voToRrports(reportsVO) + err = global.GLOBAL_DB.Create(&wtReports).Error + return err +} + +// DeleteWtReportsByIds 批量删除周报 +func (wtReportsService *WtReportsService) DeleteWtReportsByIds(ids request.IdsReq) (err error) { + err = global.GLOBAL_DB.Delete(&[]wt.WtReports{}, "id in ?", ids.Ids).Error + return err +} + +// UpdateWtReports 更新周报 +func (wtReportsService *WtReportsService) UpdateWtReports(reportsVO wtReq.WtReportsVO) (err error) { + wtReports := voToRrports(reportsVO) + err = global.GLOBAL_DB.Updates(&wtReports).Error + return err +} + +// GetWtReports 根据id获取周报 +func (wtReportsService *WtReportsService) GetWtReports(id uint) (err error, reportsVO wtReq.WtReportsVO) { + report := wt.WtReports{} + err = global.GLOBAL_DB.Where("id = ?", id).First(&report).Error + reportVO := reportToVO(report) + + return err, reportVO +} + +// GetWtReportsInfoList 分页获取周报 +func (wtReportsService *WtReportsService) GetWtReportsInfoList(info wtReq.WtReportsSearch) (err error, list interface{}, total int64) { + limit := info.PageSize + offset := info.PageSize * (info.Page - 1) + // 创建db + db := global.GLOBAL_DB.Model(&wt.WtReports{}) + var wtReportsList []wt.WtReports + // 如果有条件搜索 下方会自动创建搜索语句 + err = db.Count(&total).Error + if err != nil { + return + } + err = db.Limit(limit).Offset(offset).Find(&wtReportsList).Error + + reportsVOList := reportsToVOs(wtReportsList) + + return err, reportsVOList, total +} + +//数据转换一下, 需要把json数据转换为字符串 +func voToRrports(reportsVO wtReq.WtReportsVO) wt.WtReports { + sendToJson, _ := json.Marshal(reportsVO.SendTo) + contentJson, _ := json.Marshal(reportsVO.Contents) + picturesJson, _ := json.Marshal(reportsVO.Pictures) + attachmentsJson, _ := json.Marshal(reportsVO.Attachments) + + wtReports := wt.WtReports{ + GLOBAL_MODEL: global.GLOBAL_MODEL{ID: reportsVO.ID}, + UserName: reportsVO.UserName, + SendTo: string(sendToJson), + Header: reportsVO.Header, + Contents: string(contentJson), + Pictures: string(picturesJson), + Attachments: string(attachmentsJson), + } + return wtReports +} + +// 批量转换 数据转换, 把字符串转换为json +func reportsToVOs(wtReportsList []wt.WtReports) []wtReq.WtReportsVO { + var reportsVOList []wtReq.WtReportsVO + for _, report := range wtReportsList { + reportVO := reportToVO(report) + reportsVOList = append(reportsVOList, reportVO) + } + return reportsVOList +} + +//单个转换 +func reportToVO(report wt.WtReports) wtReq.WtReportsVO { + reportVO := wtReq.WtReportsVO{} + reportVO.ID = report.ID + reportVO.UserName = report.UserName + reportVO.Header = report.Header + json.Unmarshal([]byte(report.SendTo), &reportVO.SendTo) + json.Unmarshal([]byte(report.Contents), &reportVO.Contents) + json.Unmarshal([]byte(report.Pictures), &reportVO.Pictures) + json.Unmarshal([]byte(report.Attachments), &reportVO.Attachments) + return reportVO +}