代码规范化

master
18650180552 2019-03-12 14:01:25 +08:00
parent f12f001664
commit 0a2783b4a2
5 changed files with 38 additions and 70 deletions

View File

@ -1,39 +1,9 @@
# background
#### 介绍
开源的后台管理前后端
后端采用go+gin+ redis
开源的后台管理前后端
后端采用go+gin+ redis
前端采用vue+iview框架
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -9,7 +9,6 @@ import (
)
type FileController struct {
}
func (this *FileController) OnUpload(c *gin.Context) {
@ -27,7 +26,7 @@ func (this *FileController) OnUpload(c *gin.Context) {
}
}
func (this *FileController) OnDownLoad(c *gin.Context) {
func (this *FileController) OnDownLoad(c *gin.Context) {
file, header, err := c.Request.FormFile("upload")
filename := header.Filename
fmt.Println(header.Filename)

View File

@ -17,8 +17,8 @@ import (
"user/config"
"user/db"
)
type MailController struct {
type MailController struct {
}
type RespJson struct {
Msg string `json:"msg"`
@ -236,7 +236,7 @@ func OnSendEmailTpl(c *gin.Context) {
//content :网页模板的参数 key-value结构
//temp_data 模板内具体要替换的变量名字 Key-value结构
//generate 是否生成静态html
func (this *MailController)OnSendEmailCode(c *gin.Context) {
func (this *MailController) OnSendEmailCode(c *gin.Context) {
var req ReqSendEmail
var resp RespJson
defer func() {

View File

@ -1,32 +1,32 @@
package controller
import (
"bytes"
"crypto/md5"
"encoding/json"
"errors"
"fmt"
"github.com/fatih/structs"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/tommy351/gin-sessions"
"io"
"log"
"math/rand"
"net/http"
"net/smtp"
"regexp"
"strconv"
"strings"
"time"
"user/config"
"user/db"
"user/logs"
"user/model"
"user/redis"
"bytes"
"crypto/md5"
"encoding/json"
"errors"
"fmt"
"github.com/fatih/structs"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/tommy351/gin-sessions"
"io"
"log"
"math/rand"
"net/http"
"net/smtp"
"regexp"
"strconv"
"strings"
"time"
"user/config"
"user/db"
"user/logs"
"user/model"
"user/redis"
)
type UserController struct{
type UserController struct {
}
type ReqSendEmailCode struct {
@ -45,7 +45,7 @@ type RespBase struct {
Data interface{}
}
func (this *UserController)Auth(c *gin.Context) {
func (this *UserController) Auth(c *gin.Context) {
var resp RespBase
var statuscode int
@ -124,7 +124,7 @@ func (this *UserController) GetUser(c *gin.Context) {
// @Param department_id query string false "name search by q"
// @Param permission_type query string false "name search by q"
// @Router /api/users [get]
func (this *UserController) Users(c *gin.Context) {
func (this *UserController) Users(c *gin.Context) {
var statuscode int
var resp RespBase
@ -197,7 +197,7 @@ func (this *UserController) SerarchUsers(c *gin.Context) {
resp.Msg = "OK"
resp.Data = dat
}
func CreateVerify(length int32) string {
func CreateVerify(length int32) string {
strAry := []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
result := string("")
for i := int32(0); i < length; i++ {
@ -212,7 +212,7 @@ func CreateVerify(length int32) string {
* @param {Number} length Token
* @return {string} Token
*/
func createToken(length int32) string {
func createToken(length int32) string {
strAry := []byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_'}
result := string("")
for i := int32(0); i < length; i++ {
@ -434,7 +434,7 @@ func Reader2Json(r io.ReadCloser) string {
return ret
}
func SendExternalEmail(msg interface{}) error {
func SendExternalEmail(msg interface{}) error {
req := make(map[string]interface{}, 1)
req["type"] = "text"
req["action"] = "smtp-sys"
@ -510,7 +510,7 @@ func (this *UserController) SendEmailCode(c *gin.Context) {
//判断邮箱是否存在
var users []model.Users
e = db.GetMysqlClient().Query2("select * from users where email_adress = ?", &users, req.EmailAdress)
if nil != e{
if nil != e {
log.Print(e.Error())
resp.Msg = "email address error"
return

View File

@ -16,7 +16,7 @@ var (
mailContoller = controller.MailController{}
)
func InitConfig() {
func InitConfig() {
e := config.Init("user.yaml")
if nil != e {
log.Println(e.Error())
@ -30,14 +30,14 @@ func InitMysql() {
db.Init()
}
}
func InitRedis() {
func InitRedis() {
e := config.InitRedis()
if nil != e {
logs.Error(e.Error())
return
}
}
func InitLogs() {
func InitLogs() {
logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile)
}
func CORSMiddleware(c *gin.Context) {
@ -57,7 +57,6 @@ func CORSMiddleware(c *gin.Context) {
}
}
func main() {
InitConfig()
InitLogs()