前言:
项目中公用的一些方法,配置,常量等
正文:
文件:common/inc.go
package common const TimeTem = "2006-01-02 15:04:05" const AdminSecret = "jO4s4QcGs4B8brP2" //随机秘钥 // 定义一个统一的返回对象 type ReData struct { Status bool Msg string Data interface{} }
文件:common/functions.go
package common import ( "crypto/md5" "encoding/hex" "strconv" "strings" ) //生成加密的密码 func MyMd5(str string) string { str = AdminSecret+str has := md5.New() has.Write([]byte(str)) b := has.Sum(nil) return hex.EncodeToString(b) } //管理后台权限判断 func HasPower(pids string ,pid int) bool{ id := strconv.Itoa(pid) ids := ","+id+"," return strings.Contains(pids,ids) }
完结
标签:string,admin,pid,ids,common,str,公共,go,解析 From: https://www.cnblogs.com/ypeih/p/17334574.html