80 changed files with 4944 additions and 26 deletions
@ -0,0 +1,9 @@ |
|||
package base |
|||
|
|||
import "key_performance_indicators/api/base/loginVerify" |
|||
|
|||
type ApiEntry struct { |
|||
LoginVerify loginVerify.ApiMethod |
|||
} |
|||
|
|||
var AppApiEntry = new(ApiEntry) |
|||
@ -0,0 +1,187 @@ |
|||
package loginVerify |
|||
|
|||
import ( |
|||
"fmt" |
|||
"key_performance_indicators/middleware/grocerystore" |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
func (a *ApiMethod) ScanCodeLogin(c *gin.Context) { |
|||
var requestData Login |
|||
c.ShouldBindJSON(&requestData) |
|||
|
|||
if requestData.Username == "" { |
|||
publicmethod.Result(1, requestData, c, "请输入用户名!") |
|||
return |
|||
} |
|||
if requestData.Password == "" { |
|||
publicmethod.Result(1, requestData, c, "请输入密码!") |
|||
return |
|||
} |
|||
if requestData.Captcha == "" { |
|||
publicmethod.Result(1, requestData, c, "请输入验证码!") |
|||
return |
|||
} |
|||
|
|||
// if store.Verify(requestData.CaptchaId, requestData.Captcha, true) != true {
|
|||
// publicmethod.Result(1, requestData, c, "验证码不正确!")
|
|||
// return
|
|||
// }
|
|||
|
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
// userAgent = "250"
|
|||
|
|||
var md5JiaMiPwd publicmethod.Md5Encryption |
|||
md5JiaMiPwd.Md5EncryptionInit(requestData.Password) |
|||
md5TokenPwd := md5JiaMiPwd.Md5EncryptionAlgorithm() |
|||
// var oldAdmin OldSchollAdmin
|
|||
// oldErr := overall.CONSTANT_DB_Master.Model(&models.SystemUser{}).Select("system_user.*,system_user_attribute.*").Joins("left join system_user_attribute on system_user.u_key = system_user_attribute.ua_id").Where("`u_name` = ? AND `u_password` = ?", requestData.Username, md5TokenPwd).First(&oldAdmin).Error
|
|||
// if oldErr == nil {
|
|||
// //原知行学院管理员账号登录
|
|||
// }
|
|||
//新的登录认证方式
|
|||
var userCont models.ManCont |
|||
userErr := userCont.GetCont(map[string]interface{}{"number": requestData.Username, "password": md5TokenPwd}) |
|||
if userErr != nil { |
|||
publicmethod.Result(2000, userErr, c) |
|||
return |
|||
} |
|||
if requestData.OpenId != "" { |
|||
var userInfo models.PersonArchives |
|||
userInfo.EiteCont(map[string]interface{}{"id": userCont.Id}, map[string]interface{}{"work_wechat": requestData.OpenId}) |
|||
} |
|||
if userCont.State == 2 { |
|||
publicmethod.Result(1, userErr, c, "登陆失败! 该账号已经被禁用!") |
|||
return |
|||
} |
|||
if userCont.State == 3 { |
|||
publicmethod.Result(1, userErr, c, "登陆失败! 该账号不存在!") |
|||
return |
|||
} |
|||
|
|||
var md5JiaMi publicmethod.Md5Encryption |
|||
md5JiaMi.Md5EncryptionInit(userAgent) |
|||
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
|||
|
|||
var md5JiaMiNumber publicmethod.Md5Encryption |
|||
md5JiaMiNumber.Md5EncryptionInit(userCont.Number) |
|||
userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm() |
|||
|
|||
sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token |
|||
sha1Token := publicmethod.Sha1Encryption(sha1Str) |
|||
|
|||
//返回值
|
|||
saveData := publicmethod.MapOut[string]() |
|||
saveData["key"] = userKeyCode |
|||
saveData["token"] = sha1Token |
|||
saveData["userinfo"] = userCont |
|||
menuoper, jurisdiction := getRoleSeat(userCont.Role) |
|||
writeRedisData := map[string]interface{}{ |
|||
"userkey": userKeyCode, |
|||
"key": userCont.Key, |
|||
"usernumber": userCont.Number, |
|||
"userpwd": userCont.Password, |
|||
"usertoken": sha1Token, |
|||
"jurisdiction": jurisdiction, |
|||
"menuOper": menuoper, |
|||
"wand": 118, |
|||
} |
|||
//API Token数据
|
|||
redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKeyCode) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) |
|||
redisClient.SetRedisTime(10800) |
|||
redisClient.HashMsetAdd(redisFileKey, writeRedisData) |
|||
//缓存写入个人信息
|
|||
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userCont.Number) |
|||
myCont := publicmethod.MapOut[string]() |
|||
myCont["id"] = userCont.Id |
|||
myCont["number"] = userCont.Number //员工工号
|
|||
myCont["name"] = userCont.Name //姓名
|
|||
myCont["icon"] = userCont.Icon //头像
|
|||
myCont["hire_class"] = userCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;)
|
|||
myCont["emp_type"] = userCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职)
|
|||
myCont["company"] = userCont.Company //入职公司
|
|||
myCont["maindeparment"] = userCont.MainDeparment //主部门
|
|||
myCont["sun_main_department"] = userCont.SunMainDeparment //二级主部门
|
|||
myCont["deparment"] = userCont.Deparment //部门
|
|||
myCont["admin_org"] = userCont.AdminOrg //所属行政组织
|
|||
myCont["teamid"] = userCont.TeamId //班组
|
|||
myCont["position"] = userCont.Position //职位
|
|||
myCont["job_class"] = userCont.JobClass //职务分类
|
|||
myCont["job_id"] = userCont.JobId //职务
|
|||
myCont["job_leve"] = userCont.JobLeve //职务等级
|
|||
myCont["wechat"] = userCont.Wechat //微信UserId
|
|||
myCont["work_wechat"] = userCont.WorkWechat //企业微信UserId
|
|||
myCont["state"] = userCont.State //状态(1:启用;2:禁用;3:删除)
|
|||
myCont["key"] = userCont.Key //key
|
|||
myCont["is_admin"] = userCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管
|
|||
myCont["password"] = userCont.Password //密码
|
|||
myCont["role"] = userCont.Role //角色
|
|||
myCont["idcardno"] = userCont.Idcardno //身份证号
|
|||
myCont["passportno"] = userCont.Passportno //护照号码
|
|||
myCont["globalroaming"] = userCont.Globalroaming //国际区号
|
|||
myCont["mobilephone"] = userCont.Mobilephone //手机号码
|
|||
myCont["email"] = userCont.Email //电子邮件
|
|||
myCont["gender"] = userCont.Gender //性别(1:男性;2:女性;3:中性)
|
|||
myCont["birthday"] = userCont.Birthday //birthday
|
|||
myCont["myfolk"] = userCont.Myfolk //民族
|
|||
myCont["nativeplace"] = userCont.Nativeplace //籍贯
|
|||
myCont["idcardstartdate"] = userCont.Idcardstartdate //身份证有效期开始
|
|||
myCont["idcardenddate"] = userCont.Idcardenddate //身份证有效期结束
|
|||
myCont["idcardaddress"] = userCont.Idcardaddress //身份证地址
|
|||
myCont["idcardIssued"] = userCont.IdcardIssued //身份证签发机关
|
|||
myCont["health"] = userCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)
|
|||
myCont["maritalstatus"] = userCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
|
|||
myCont["internaltelephone"] = userCont.Internaltelephone //内线电话
|
|||
myCont["currentresidence"] = userCont.Currentresidence //现居住地址
|
|||
myCont["constellationing"] = userCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
|
|||
myCont["isdoubleworker"] = userCont.Isdoubleworker //是否双职工(1:是;2:否)
|
|||
myCont["isveterans"] = userCont.Isveterans //是否为退役军人(1:是;2:否)
|
|||
myCont["veteransnumber"] = userCont.Veteransnumber //退役证编号
|
|||
myCont["jobstartdate"] = userCont.Jobstartdate //参加工作日期
|
|||
myCont["entrydate"] = userCont.Entrydate //入职日期
|
|||
myCont["probationperiod"] = userCont.Probationperiod //试用期
|
|||
myCont["planformaldate"] = userCont.Planformaldate //预计转正日期
|
|||
myCont["political_outlook"] = userCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
|
|||
redisClient.HashMsetAdd(redisMyContKey, myCont) |
|||
publicmethod.Result(0, saveData, c) |
|||
} |
|||
|
|||
//获取权限点位
|
|||
func getRoleSeat(roleId string) (menuStr, buttonStr string) { |
|||
var roleInfo models.SystemRole |
|||
err := roleInfo.GetCont(map[string]interface{}{"r_id": roleId}, "r_menu_oper", "r_jurisdiction") |
|||
if err != nil { |
|||
return |
|||
} |
|||
menuStr = roleInfo.MenuOper |
|||
buttonStr = roleInfo.Jurisdiction |
|||
return |
|||
} |
|||
|
|||
//退出登录
|
|||
func (a *ApiMethod) SignOut(c *gin.Context) { |
|||
userKey := c.Request.Header.Get("user-key") |
|||
redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) |
|||
userToken, isTrue := redisClient.HashGetAll(redisFileKey) |
|||
if isTrue == false { |
|||
publicmethod.Result(0, isTrue, c, "退出成功!") |
|||
return |
|||
} |
|||
// fmt.Printf("userToken----->%v\n", userToken)
|
|||
_, err := publicmethod.GetUserRedisCont(userToken["usernumber"]) |
|||
if err != nil { |
|||
redisClient.DelKey(redisFileKey) |
|||
publicmethod.Result(0, isTrue, c, "退出成功!") |
|||
return |
|||
} |
|||
redisClient.DelKey(redisFileKey) |
|||
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userToken["usernumber"]) |
|||
redisClient.DelKey(redisMyContKey) |
|||
publicmethod.Result(0, isTrue, c, "退出成功!") |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package loginVerify |
|||
|
|||
import ( |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
type ApiMethod struct{} |
|||
|
|||
//系统登录入口
|
|||
func (a *ApiMethod) Index(c *gin.Context) { |
|||
outputCont := publicmethod.MapOut[string]() |
|||
outputCont["index"] = "系统登录入口" |
|||
publicmethod.Result(0, outputCont, c) |
|||
} |
|||
|
|||
//验证码输出
|
|||
type SysCaptchaResponse struct { |
|||
CaptchaId string `json:"captchaid"` |
|||
PicPath string `json:"picPath"` |
|||
} |
|||
|
|||
//登录相关
|
|||
type Login struct { |
|||
Username string `json:"username"` // 用户名
|
|||
Password string `json:"password"` // 密码
|
|||
Captcha string `json:"captcha"` // 验证码
|
|||
CaptchaId string `json:"captchaid"` // 验证码ID
|
|||
OpenId string `json:"openid"` //企业微信ID
|
|||
} |
|||
|
|||
//原知行学院管理员表
|
|||
type OldSchollAdmin struct { |
|||
models.SystemUser |
|||
models.SystemUserAttribute |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package loginVerify |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
"github.com/mojocn/base64Captcha" |
|||
) |
|||
|
|||
var store = base64Captcha.DefaultMemStore |
|||
|
|||
func (a *ApiMethod) Captcha(c *gin.Context) { |
|||
// 字符,公式,验证码配置
|
|||
// 生成默认数字的driver
|
|||
driver := base64Captcha.NewDriverDigit(overall.CONSTANT_CONFIG.Captcha.ImgHeight, overall.CONSTANT_CONFIG.Captcha.ImgWidth, overall.CONSTANT_CONFIG.Captcha.KeyLong, 0.7, 80) |
|||
//coder := base64Captcha.NewCaptcha(driver, store.UseWithCtx(c)) // v8下使用redis
|
|||
coder := base64Captcha.NewCaptcha(driver, store) |
|||
if id, b64s, err := coder.Generate(); err != nil { |
|||
publicmethod.Result(1, err, c, "验证码获取失败") |
|||
} else { |
|||
publicmethod.Result(0, SysCaptchaResponse{ |
|||
CaptchaId: id, |
|||
PicPath: b64s, |
|||
}, c) |
|||
} |
|||
} |
|||
@ -0,0 +1,147 @@ |
|||
package authorize |
|||
|
|||
import ( |
|||
"fmt" |
|||
"key_performance_indicators/overall" |
|||
"strconv" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
|
|||
"key_performance_indicators/middleware/grocerystore" |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
) |
|||
|
|||
//授权
|
|||
func (e *EmpowerApi) GainToken(c *gin.Context) { |
|||
ContentType := c.Request.Header.Get("Content-Type") |
|||
Origin := c.Request.Header.Get("Origin") |
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
|
|||
var requestData gainAuthorize |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
|
|||
if ContentType == "" || userAgent == "" || Origin == "" { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
|
|||
if requestData.UserNumber == "" || requestData.Password == "" { |
|||
publicmethod.Result(101, err, c) |
|||
return |
|||
} |
|||
//密码加密
|
|||
var passwordMd5 publicmethod.Md5Encryption |
|||
passwordMd5.Md5EncryptionInit(requestData.Password) |
|||
passwordMd5Str := passwordMd5.Md5EncryptionAlgorithm() |
|||
var empowerUser models.EmpowerUser |
|||
userErr := empowerUser.GetCont(map[string]interface{}{"userkey": requestData.UserNumber, "password": passwordMd5Str}, "verification_code") |
|||
if userErr != nil { |
|||
publicmethod.Result(2000, passwordMd5Str, c) |
|||
return |
|||
} |
|||
//获取随机数
|
|||
randCode := strconv.FormatInt(publicmethod.TableNumber(), 10) |
|||
// randCode := strconv.FormatInt(16557925694780, 10)
|
|||
//头文件加密
|
|||
//ContentType
|
|||
var ContentTypeMd5 publicmethod.Md5Encryption |
|||
ContentTypeMd5.Md5EncryptionInit(ContentType) |
|||
if empowerUser.VerificationCode != "" { |
|||
ContentTypeMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
|
|||
fmt.Printf("ContentTypeMd5Str ----->%v\n", ContentTypeMd5) |
|||
|
|||
ContentTypeMd5Str := ContentTypeMd5.Md5EncryptionAlgorithm() |
|||
//Origin
|
|||
var OriginMd5 publicmethod.Md5Encryption |
|||
OriginMd5.Md5EncryptionInit(Origin) |
|||
if empowerUser.VerificationCode != "" { |
|||
OriginMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
|
|||
originMd5Str := OriginMd5.Md5EncryptionAlgorithm() |
|||
//userAgent
|
|||
var userAgentMd5 publicmethod.Md5Encryption |
|||
userAgentMd5.Md5EncryptionInit(userAgent) |
|||
if empowerUser.VerificationCode != "" { |
|||
userAgentMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
userAgentMd5Str := userAgentMd5.Md5EncryptionAlgorithm() |
|||
|
|||
//随机数加密
|
|||
var randomNumberMd5 publicmethod.Md5Encryption |
|||
randomNumberMd5.Md5EncryptionInit(randCode) |
|||
if empowerUser.VerificationCode != "" { |
|||
randomNumberMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
numberMd5 := randomNumberMd5.Md5EncryptionAlgorithm() |
|||
|
|||
//用户名加密
|
|||
var userKeyMd5 publicmethod.Md5Encryption |
|||
userKeyMd5.Md5EncryptionInit(requestData.UserNumber) |
|||
if empowerUser.VerificationCode != "" { |
|||
userKeyMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
userKeyMd5Str := userKeyMd5.Md5EncryptionAlgorithm() |
|||
|
|||
clearCodeToken := fmt.Sprintf("%v-%v-%v-%v-%v-%v", ContentTypeMd5Str, originMd5Str, userAgentMd5Str, numberMd5, userKeyMd5Str, passwordMd5Str) |
|||
|
|||
fmt.Printf("redisKey---->ContentTypeMd5Str:%v-originMd5Str:%v-userAgentMd5Str:%v-numberMd5:%v-userKeyMd5Str:%v-passwordMd5Str:%v\n", ContentTypeMd5Str, originMd5Str, userAgentMd5Str, numberMd5, userKeyMd5Str, passwordMd5Str) |
|||
//token 加密
|
|||
var tokenMd5 publicmethod.Md5Encryption |
|||
tokenMd5.Md5EncryptionInit(clearCodeToken) |
|||
if empowerUser.VerificationCode != "" { |
|||
tokenMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
fmt.Printf("tokenMd5Appk ----->%v\n", tokenMd5) |
|||
tokenMd5Str := tokenMd5.Md5EncryptionAlgorithm() |
|||
|
|||
//设定redis Key名称
|
|||
redisKey := fmt.Sprintf("Authentication:ApiAuthent_%v", tokenMd5Str) |
|||
|
|||
saveTokenRedis := publicmethod.MapOut[string]() |
|||
saveTokenRedis["number"] = randCode |
|||
saveTokenRedis["userkey"] = requestData.UserNumber |
|||
saveTokenRedis["password"] = requestData.Password |
|||
//将验证信息写入Redis
|
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) |
|||
redisClient.SetRedisTime(10800) |
|||
redisClient.HashMsetAdd(redisKey, saveTokenRedis) |
|||
//输出验证
|
|||
// clearTokenStr := fmt.Sprintf("%v-%v", tokenMd5Str, numberMd5)
|
|||
// var clearTokenMd5 publicmethod.Md5Encryption
|
|||
// clearTokenMd5.Md5EncryptionInit(clearTokenStr)
|
|||
// clearTokenMd5Str := clearTokenMd5.Md5EncryptionAlgorithm()
|
|||
var sendToken SendToken |
|||
sendToken.Number = randCode |
|||
sendToken.Token = tokenMd5Str |
|||
publicmethod.Result(0, sendToken, c) |
|||
} |
|||
|
|||
//加密验证
|
|||
func (e *EmpowerApi) Encryption(c *gin.Context) { |
|||
var requestData EncryptionData |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
var ContentTypeMd5 publicmethod.Md5Encryption |
|||
ContentTypeMd5.Md5EncryptionInit(requestData.Number) |
|||
ContentTypeMd5.AppKey = requestData.AppKey |
|||
ContentTypeMd5Str, dfg := ContentTypeMd5.Md5EncryptionAlgorithmFj() |
|||
outputCont := publicmethod.MapOut[string]() |
|||
outputCont["index"] = "MD5加密验证" |
|||
// outputCont["userErr"] = userErr
|
|||
outputCont["md5"] = ContentTypeMd5Str |
|||
outputCont["number"] = requestData.Number |
|||
outputCont["appkey"] = requestData.AppKey |
|||
outputCont["step"] = dfg |
|||
publicmethod.Result(0, outputCont, c) |
|||
} |
|||
@ -1,10 +1,41 @@ |
|||
package authorize |
|||
|
|||
import "github.com/gin-gonic/gin" |
|||
import ( |
|||
"github.com/gin-gonic/gin" |
|||
|
|||
"key_performance_indicators/overall/publicmethod" |
|||
) |
|||
|
|||
type EmpowerApi struct{} |
|||
|
|||
//入口
|
|||
func (e *EmpowerApi) Index(c *gin.Context){ |
|||
func (e *EmpowerApi) Index(c *gin.Context) { |
|||
outputCont := publicmethod.MapOut[string]() |
|||
outputCont["entry"] = "授权入口" |
|||
publicmethod.Result(0, outputCont, c) |
|||
} |
|||
|
|||
//授权
|
|||
type gainAuthorize struct { |
|||
UserNumber string `json:"username"` |
|||
Password string `json:"password"` |
|||
} |
|||
|
|||
//输出Token
|
|||
type SendToken struct { |
|||
Token string `json:"token"` |
|||
Number string `json:"number"` |
|||
} |
|||
|
|||
//保存Redis Token
|
|||
type SaveToken struct { |
|||
Number string `json:"number"` //随机数
|
|||
UserKey string `json:"userkey"` //用户名
|
|||
PassWord string `json:"password"` //密码
|
|||
} |
|||
|
|||
//加密参数
|
|||
type EncryptionData struct { |
|||
Number string `json:"number"` |
|||
AppKey string `json:"appkey"` |
|||
} |
|||
@ -1,5 +1,9 @@ |
|||
package empower |
|||
|
|||
type ApiEntry struct{} |
|||
import "key_performance_indicators/api/empower/authorize" |
|||
|
|||
type ApiEntry struct { |
|||
EmpowerApi authorize.EmpowerApi //授权
|
|||
} |
|||
|
|||
var AppApiEntry = new(ApiEntry) |
|||
|
|||
@ -0,0 +1,9 @@ |
|||
package shiyan |
|||
|
|||
import "key_performance_indicators/api/shiyan/maptostruct" |
|||
|
|||
type ApiEntry struct { |
|||
MapToStructApi maptostruct.ApiMethod |
|||
} |
|||
|
|||
var AppApiEntry = new(ApiEntry) |
|||
@ -0,0 +1,28 @@ |
|||
package maptostruct |
|||
|
|||
import ( |
|||
"fmt" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//map 装 struct 实验
|
|||
func (a *ApiMethod) MapToStructShiyan(c *gin.Context) { |
|||
mapShiyan := map[string]string{ |
|||
"name": "秦东", |
|||
"age": "1", |
|||
"time": "456313", |
|||
"time1": "45631321654654", |
|||
"time2": "4.5631321654654", |
|||
"time3": "45.631321654654", |
|||
} |
|||
var shiyanVal shiyanType |
|||
err := publicmethod.MapToStruct(mapShiyan, &shiyanVal, "json") |
|||
if err != nil { |
|||
publicmethod.Result(1, err.Error(), c) |
|||
return |
|||
} |
|||
fmt.Printf("shiyanType---->%v\n", shiyanVal) |
|||
publicmethod.Result(0, shiyanVal, c) |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package maptostruct |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
type ApiMethod struct{} |
|||
|
|||
//实验入口
|
|||
func (a *ApiMethod) Index(c *gin.Context) { |
|||
outputCont := publicmethod.MapOut[string]() |
|||
outputCont["index"] = "实验入口" |
|||
publicmethod.Result(0, outputCont, c) |
|||
} |
|||
|
|||
//实验数据
|
|||
type shiyanType struct { |
|||
Name string `json:"name"` |
|||
Age int `json:"age"` |
|||
Time int32 `json:"time"` |
|||
Time1 int64 `json:"time1"` |
|||
Time2 float32 `json:"time2"` |
|||
Time3 float64 `json:"time3"` |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
package version1 |
|||
|
|||
import "key_performance_indicators/api/version1/honoraryArchives" |
|||
|
|||
type ApiEntry struct { |
|||
HonorsApi honoraryArchives.ApiMethod |
|||
} |
|||
|
|||
var AppApiEntry = new(ApiEntry) |
|||
@ -0,0 +1,158 @@ |
|||
package honoraryArchives |
|||
|
|||
import ( |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
"time" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//档案载体
|
|||
|
|||
//列表
|
|||
func (a *ApiMethod) CarrierList(c *gin.Context) { |
|||
var requestData carrierListKey |
|||
errs := c.ShouldBindJSON(&requestData) |
|||
if errs != nil { |
|||
publicmethod.Result(100, errs, c) |
|||
return |
|||
} |
|||
var carrierList []models.CarrierType |
|||
gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&models.CarrierType{}).Where("`state` BETWEEN ? AND ?", 1, 2) |
|||
if requestData.Name != "" { |
|||
gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%") |
|||
} |
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
|||
err := gormDb.Order("`id` DESC").Find(&carrierList).Error |
|||
if err != nil { |
|||
publicmethod.Result(105, err, c) |
|||
return |
|||
} |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(carrierList)), carrierList, c) |
|||
} |
|||
|
|||
//添加载体类型
|
|||
func (a *ApiMethod) AddCarrier(c *gin.Context) { |
|||
var requestData addCarrierCont |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if requestData.Name == "" { |
|||
publicmethod.Result(101, err, c) |
|||
return |
|||
} |
|||
var carrierCont models.CarrierType |
|||
juadgeErr := carrierCont.GetCont(map[string]interface{}{"`name`": requestData.Name}, "`id`") |
|||
if juadgeErr == nil { |
|||
if carrierCont.Id != 0 { |
|||
publicmethod.Result(103, carrierCont, c) |
|||
} |
|||
} |
|||
carrierCont.Name = requestData.Name |
|||
carrierCont.State = 1 |
|||
carrierCont.Time = time.Now().Unix() |
|||
addErr := overall.CONSTANT_DB_MANAGE_ARCHIVES.Create(&carrierCont).Error |
|||
if addErr != nil { |
|||
publicmethod.Result(104, addErr, c) |
|||
} else { |
|||
publicmethod.Result(0, addErr, c) |
|||
} |
|||
} |
|||
|
|||
//编辑荣誉类型
|
|||
func (a *ApiMethod) EidyCarrier(c *gin.Context) { |
|||
var requestData eidyCarrierCont |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
publicmethod.Result(100, err, c) |
|||
return |
|||
} |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(101, err, c) |
|||
return |
|||
} |
|||
if requestData.Name == "" { |
|||
publicmethod.Result(101, err, c) |
|||
return |
|||
} |
|||
var carrierCont models.CarrierType |
|||
conErr := carrierCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`name`") |
|||
if conErr != nil { |
|||
publicmethod.Result(107, conErr, c) |
|||
return |
|||
} |
|||
if requestData.Name != carrierCont.Name { |
|||
var oldCarrierCont models.CarrierType |
|||
conErrOld := oldCarrierCont.GetCont(map[string]interface{}{"`name`": requestData.Name}, "`id`") |
|||
if conErrOld == nil { |
|||
publicmethod.Result(103, err, c) |
|||
return |
|||
} |
|||
} else { |
|||
publicmethod.Result(0, err, c) |
|||
return |
|||
} |
|||
saveData := publicmethod.MapOut[string]() |
|||
saveData["name"] = requestData.Name |
|||
eidtErr := carrierCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData) |
|||
if eidtErr != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
publicmethod.Result(0, err, c) |
|||
} |
|||
|
|||
//编辑荣誉类型状态
|
|||
func (a *ApiMethod) EidyCarrierState(c *gin.Context) { |
|||
var requestData publicmethod.PublicState |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
if requestData.State == 0 { |
|||
requestData.State = 1 |
|||
} |
|||
if requestData.IsTrue == 0 { |
|||
requestData.IsTrue = 2 |
|||
} |
|||
where := publicmethod.MapOut[string]() |
|||
where["id"] = requestData.Id |
|||
var carrierTypeCont models.CarrierType |
|||
judgeErr := carrierTypeCont.GetCont(where, "`id`") |
|||
if judgeErr != nil { |
|||
publicmethod.Result(107, judgeErr, c) |
|||
return |
|||
} |
|||
if requestData.State != 3 { |
|||
err := carrierTypeCont.EiteCont(where, map[string]interface{}{"`state`": requestData.State}) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
} else { |
|||
if requestData.IsTrue == 1 { |
|||
err := carrierTypeCont.DelCont(where) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
} else { |
|||
err := carrierTypeCont.EiteCont(where, map[string]interface{}{"`state`": requestData.State}) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
} |
|||
} |
|||
publicmethod.Result(0, carrierTypeCont, c) |
|||
} |
|||
@ -0,0 +1,334 @@ |
|||
package honoraryArchives |
|||
|
|||
import ( |
|||
"fmt" |
|||
"key_performance_indicators/middleware/snowflake" |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
"gorm.io/gorm" |
|||
) |
|||
|
|||
//荣誉列表
|
|||
func (a *ApiMethod) HonorList(c *gin.Context) { |
|||
var requestData honorListKey |
|||
c.ShouldBindJSON(&requestData) |
|||
var honorsList []models.HonoraryArchives |
|||
gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&models.HonoraryArchives{}).Where("state BETWEEN ? AND ?", 1, 2) |
|||
if requestData.Name != "" { |
|||
gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%") |
|||
} |
|||
if requestData.IssuingAgency != "" { |
|||
gormDb = gormDb.Where("`issuing_unit` LIKE ?", "%"+requestData.IssuingAgency+"%") |
|||
} |
|||
if requestData.Carrier != 0 { |
|||
gormDb = gormDb.Where("carrier = ?", requestData.Carrier) |
|||
} |
|||
if requestData.AwardTimeBegin != "" && requestData.AwardTimeEnd != "" { |
|||
timeBegin := fmt.Sprintf("%v 00:00:00", requestData.AwardTimeBegin) |
|||
timeEnd := fmt.Sprintf("%v 23:59:59", requestData.AwardTimeEnd) |
|||
gormDb = gormDb.Where("`award_time` BETWEEN ?", timeBegin, timeEnd) |
|||
} else if requestData.AwardTimeBegin != "" && requestData.AwardTimeEnd == "" { |
|||
timeBegin := fmt.Sprintf("%v 00:00:00", requestData.AwardTimeBegin) |
|||
timeEnd := fmt.Sprintf("%v 23:59:59", requestData.AwardTimeBegin) |
|||
gormDb = gormDb.Where("`award_time` BETWEEN ?", timeBegin, timeEnd) |
|||
} else if requestData.AwardTimeBegin == "" && requestData.AwardTimeEnd != "" { |
|||
timeBegin := fmt.Sprintf("%v 00:00:00", requestData.AwardTimeEnd) |
|||
timeEnd := fmt.Sprintf("%v 23:59:59", requestData.AwardTimeEnd) |
|||
gormDb = gormDb.Where("`award_time` BETWEEN ?", timeBegin, timeEnd) |
|||
} |
|||
if requestData.Organize != "" { |
|||
gormDb = gormDb.Where("organization = ?", requestData.Organize) |
|||
} |
|||
if requestData.UserKey != "" { |
|||
gormDb = gormDb.Where("userid = ?", requestData.UserKey) |
|||
} |
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize) |
|||
err := gormDb.Order("`id` DESC").Find(&honorsList).Error |
|||
if err != nil { |
|||
publicmethod.Result(105, err, c) |
|||
return |
|||
} |
|||
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(honorsList)), honorsList, c) |
|||
} |
|||
|
|||
//添加荣誉
|
|||
func (a *ApiMethod) AddHonorCont(c *gin.Context) { |
|||
var requestData addHonorCont |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Name == "" || requestData.IssuingAgency == "" || requestData.AwardTime == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
if requestData.Carrier == 0 { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
var uuId int64 = 0 |
|||
snowflakeId, snowflakeErr := snowflake.NewWorker(1) |
|||
if snowflakeErr != nil { |
|||
uuId = publicmethod.TableNumber() |
|||
} else { |
|||
uuId = snowflakeId.GetId() |
|||
} |
|||
var honorCont models.HonoraryArchives |
|||
honorCont.Id = uuId |
|||
honorCont.Name = requestData.Name //荣誉名称"`
|
|||
honorCont.IssuingUnit = requestData.IssuingAgency //发放单位"`
|
|||
honorCont.Carrier = int64(requestData.Carrier) //载体"`
|
|||
awardTime, _ := publicmethod.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", requestData.AwardTime)) |
|||
honorCont.AwardTime = awardTime //获奖时间"`
|
|||
if requestData.EfficientDate != "" { |
|||
termvalidity, _ := publicmethod.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", requestData.EfficientDate)) |
|||
if termvalidity <= awardTime { |
|||
publicmethod.Result(1, requestData, c, "有效日期必须晚于获奖日期!") |
|||
return |
|||
} |
|||
honorCont.TermOfValidity = termvalidity //有效期限"`
|
|||
} |
|||
|
|||
honorCont.Contet = requestData.Remark //备注"`
|
|||
if requestData.Organize != "" { |
|||
organizationId, _ := strconv.ParseInt(requestData.Organize, 10, 64) |
|||
honorCont.Organization = organizationId //归属行政组织"`
|
|||
} |
|||
if requestData.UserKey != "" { |
|||
userId, _ := strconv.ParseInt(requestData.UserKey, 10, 64) |
|||
honorCont.Userid = userId //归属人员"`
|
|||
} |
|||
honorCont.Time = time.Now().Unix() //创建时间"`
|
|||
honorCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|||
if len(requestData.ImgUrl) > 0 { |
|||
var imgList []models.PhotosGallery |
|||
for _, v := range requestData.ImgUrl { |
|||
var imgCont models.PhotosGallery |
|||
imgCont.Url = v.Url //图片地址"`
|
|||
imgCont.ImgPath = v.Imgpath //物理地址"`
|
|||
imgCont.Name = v.Name //文档名称"`
|
|||
imgCont.FileSize = v.FileSize //文档大小"`
|
|||
imgCont.Time = time.Now().Unix() //创建时间"`
|
|||
imgCont.AscriptionId = uuId //归属"`
|
|||
imgCont.AscriptionDataSheet = "honorary_archives" //归属拿个数据表"`
|
|||
imgCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|||
imgList = append(imgList, imgCont) |
|||
} |
|||
addErr := overall.CONSTANT_DB_MANAGE_ARCHIVES.Transaction(func(tx *gorm.DB) error { |
|||
if err := tx.Create(&honorCont).Error; err != nil { |
|||
// 返回任何错误都会回滚事务
|
|||
return err |
|||
} |
|||
if err := tx.Create(&imgList).Error; err != nil { |
|||
// 返回任何错误都会回滚事务
|
|||
return err |
|||
} |
|||
return nil |
|||
}) |
|||
if addErr != nil { |
|||
publicmethod.Result(104, addErr.Error(), c) |
|||
} else { |
|||
publicmethod.Result(0, addErr, c) |
|||
} |
|||
} else { |
|||
addErr := overall.CONSTANT_DB_MANAGE_ARCHIVES.Create(&honorCont) |
|||
if addErr != nil { |
|||
publicmethod.Result(104, addErr, c) |
|||
} else { |
|||
publicmethod.Result(0, addErr, c) |
|||
} |
|||
} |
|||
} |
|||
|
|||
//编辑荣誉
|
|||
func (a *ApiMethod) EidyHonorCont(c *gin.Context) { |
|||
var requestData eidtHonorCont |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Id == "" || requestData.Name == "" || requestData.IssuingAgency == "" || requestData.AwardTime == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
if requestData.Carrier == 0 { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
where := publicmethod.MapOut[string]() |
|||
where["id"] = requestData.Id |
|||
//原信息
|
|||
var honContOld models.HonoraryArchives |
|||
err := honContOld.GetCont(where) |
|||
if err != nil { |
|||
publicmethod.Result(107, err, c) |
|||
return |
|||
} |
|||
//要修改的内容
|
|||
saveData := publicmethod.MapOut[string]() |
|||
if requestData.Name != "" && requestData.Name != honContOld.Name { |
|||
saveData["name"] = requestData.Name |
|||
} |
|||
if requestData.IssuingAgency != "" && requestData.IssuingAgency != honContOld.IssuingUnit { |
|||
saveData["issuing_unit"] = requestData.IssuingAgency |
|||
} |
|||
if requestData.Carrier != honContOld.Carrier { |
|||
saveData["carrier"] = requestData.Carrier |
|||
} |
|||
var awardTime int64 = 0 |
|||
if requestData.AwardTime != "" { |
|||
awardTime, _ = publicmethod.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", requestData.AwardTime)) |
|||
if awardTime != honContOld.AwardTime { |
|||
saveData["award_time"] = awardTime |
|||
} |
|||
} |
|||
if requestData.EfficientDate != "" { |
|||
efficientDate, _ := publicmethod.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", requestData.EfficientDate)) |
|||
if efficientDate != honContOld.TermOfValidity { |
|||
if awardTime != 0 && awardTime >= efficientDate { |
|||
publicmethod.Result(1, requestData, c, "有效日期必须晚于获奖日期!") |
|||
return |
|||
} else { |
|||
saveData["award_time"] = efficientDate |
|||
} |
|||
|
|||
} |
|||
} |
|||
if requestData.Organize != "" { |
|||
organizationId, _ := strconv.ParseInt(requestData.Organize, 10, 64) |
|||
if organizationId != honContOld.Organization { |
|||
saveData["organization"] = organizationId |
|||
} |
|||
} |
|||
if requestData.UserKey != "" { |
|||
userId, _ := strconv.ParseInt(requestData.UserKey, 10, 64) |
|||
if userId != honContOld.Userid { |
|||
saveData["userid"] = userId |
|||
} |
|||
} |
|||
if requestData.Remark != "" && requestData.Remark != honContOld.Contet { |
|||
saveData["contet"] = requestData.Remark |
|||
} |
|||
var imgUrlListNoId []models.PhotosGallery |
|||
var pldImgId []int64 |
|||
if len(requestData.ImgUrl) > 0 { |
|||
for _, v := range requestData.ImgUrl { |
|||
if v.Id != "" { |
|||
oldIdInt, _ := strconv.ParseInt(v.Id, 10, 64) |
|||
if publicmethod.IsInTrue[int64](oldIdInt, pldImgId) == false { |
|||
pldImgId = append(pldImgId, oldIdInt) |
|||
} |
|||
} else { |
|||
var imgCont models.PhotosGallery |
|||
imgCont.Url = v.Url //图片地址"`
|
|||
imgCont.ImgPath = v.Imgpath //物理地址"`
|
|||
imgCont.Name = v.Name //文档名称"`
|
|||
imgCont.FileSize = v.FileSize //文档大小"`
|
|||
imgCont.Time = time.Now().Unix() //创建时间"`
|
|||
imgCont.AscriptionId = honContOld.Id //归属"`
|
|||
imgCont.AscriptionDataSheet = "honorary_archives" //归属拿个数据表"`
|
|||
imgCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|||
imgUrlListNoId = append(imgUrlListNoId, imgCont) |
|||
} |
|||
} |
|||
} |
|||
|
|||
if len(imgUrlListNoId) > 0 { |
|||
var imgList models.PhotosGallery |
|||
saveErr := overall.CONSTANT_DB_MANAGE_ARCHIVES.Transaction(func(tx *gorm.DB) error { |
|||
if len(pldImgId) > 0 { |
|||
if err := tx.Not(map[string]interface{}{"`id`": pldImgId}).Where(map[string]interface{}{"`ascription_id`": requestData.Id, "`ascription_data_sheet`": "honorary_archives"}).Delete(&imgList).Error; err != nil { |
|||
return err |
|||
} |
|||
} else { |
|||
if err := tx.Where(map[string]interface{}{"`ascription_id`": requestData.Id, "`ascription_data_sheet`": "honorary_archives"}).Delete(&imgList).Error; err != nil { |
|||
return err |
|||
} |
|||
} |
|||
|
|||
saveData["time"] = time.Now().Unix() |
|||
|
|||
if err := tx.Model(&models.HonoraryArchives{}).Where(where).Updates(&saveData).Error; err != nil { |
|||
// 返回任何错误都会回滚事务
|
|||
return err |
|||
} |
|||
|
|||
if err := tx.Create(&imgUrlListNoId).Error; err != nil { |
|||
// 返回任何错误都会回滚事务
|
|||
return err |
|||
} |
|||
|
|||
return nil |
|||
}) |
|||
if saveErr == nil { |
|||
publicmethod.Result(0, err, c) |
|||
} else { |
|||
publicmethod.Result(106, err, c) |
|||
} |
|||
|
|||
} else { |
|||
saveData["time"] = time.Now().Unix() |
|||
saveErr := honContOld.EiteCont(where, saveData) |
|||
if saveErr == nil { |
|||
var imgList models.PhotosGallery |
|||
if len(pldImgId) > 0 { |
|||
overall.CONSTANT_DB_MANAGE_ARCHIVES.Not(map[string]interface{}{"`id`": pldImgId, "`ascription_id`": requestData.Id, "`ascription_data_sheet`": "honorary_archives"}).Delete(&imgList) |
|||
} else { |
|||
imgList.DelCont(map[string]interface{}{"ascription_id": requestData.Id, "ascription_data_sheet": "honorary_archives"}) |
|||
} |
|||
publicmethod.Result(0, err, c) |
|||
} else { |
|||
publicmethod.Result(106, err, c) |
|||
} |
|||
} |
|||
} |
|||
|
|||
//编辑状态
|
|||
func (a *ApiMethod) EidyHonorContState(c *gin.Context) { |
|||
var requestData publicmethod.PublicState |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.Id == "" { |
|||
publicmethod.Result(101, requestData, c) |
|||
return |
|||
} |
|||
if requestData.State == 0 { |
|||
requestData.State = 1 |
|||
} |
|||
if requestData.IsTrue == 0 { |
|||
requestData.IsTrue = 2 |
|||
} |
|||
where := publicmethod.MapOut[string]() |
|||
where["id"] = requestData.Id |
|||
var carrierTypeCont models.HonoraryArchives |
|||
judgeErr := carrierTypeCont.GetCont(where, "`id`") |
|||
if judgeErr != nil { |
|||
publicmethod.Result(107, judgeErr, c) |
|||
return |
|||
} |
|||
if requestData.State != 3 { |
|||
err := carrierTypeCont.EiteCont(where, map[string]interface{}{"`state`": requestData.State}) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
} else { |
|||
if requestData.IsTrue == 1 { |
|||
err := carrierTypeCont.DelCont(where) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
} else { |
|||
err := carrierTypeCont.EiteCont(where, map[string]interface{}{"`state`": requestData.State}) |
|||
if err != nil { |
|||
publicmethod.Result(106, err, c) |
|||
return |
|||
} |
|||
} |
|||
} |
|||
publicmethod.Result(0, carrierTypeCont, c) |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
package honoraryArchives |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
type ApiMethod struct{} |
|||
|
|||
//荣誉档案入口
|
|||
func (a *ApiMethod) Index(c *gin.Context) { |
|||
outputCont := publicmethod.MapOut[string]() |
|||
outputCont["index"] = "荣誉档案入口" |
|||
publicmethod.Result(0, outputCont, c) |
|||
} |
|||
|
|||
//荣誉列表查询字段
|
|||
type honorListKey struct { |
|||
publicmethod.PagesTurn |
|||
Name string `json:"name"` //名称
|
|||
IssuingAgency string `json:"issuingagency"` //发放单位
|
|||
Carrier int `json:"carrier"` //载体
|
|||
AwardTimeBegin string `json:"awardtimebegin"` //获奖时间
|
|||
AwardTimeEnd string `json:"awardtimeend"` //获奖时间
|
|||
Organize string `json:"organize"` //行政组织
|
|||
UserKey string `json:"userkey"` //人员Key
|
|||
} |
|||
|
|||
//添加荣誉
|
|||
type addHonorCont struct { |
|||
addCarrierCont |
|||
IssuingAgency string `json:"issuingagency"` //发放单位
|
|||
Carrier int64 `json:"carrier"` //载体
|
|||
AwardTime string `json:"awardtime"` //获奖时间
|
|||
EfficientDate string `json:"efficientDate"` //有效期限
|
|||
Organize string `json:"organize"` //行政组织
|
|||
UserKey string `json:"userkey"` //人员Key
|
|||
Remark string `json:"remark"` //备注
|
|||
ImgUrl []publicmethod.PubilcImageCont `json:"imgurl"` //图片集
|
|||
} |
|||
|
|||
//编辑荣誉
|
|||
type eidtHonorCont struct { |
|||
publicmethod.PublicId |
|||
addHonorCont |
|||
} |
|||
|
|||
//载体类型查询字段
|
|||
type carrierListKey struct { |
|||
publicmethod.PagesTurn |
|||
addCarrierCont |
|||
} |
|||
|
|||
//添加载体类型
|
|||
type addCarrierCont struct { |
|||
Name string `json:"name"` //名称
|
|||
} |
|||
|
|||
//编辑载体类型
|
|||
type eidyCarrierCont struct { |
|||
publicmethod.PublicId |
|||
addCarrierCont |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package apishiyan |
|||
|
|||
//Api实验
|
|||
|
|||
type ApiRouter struct{} |
|||
@ -0,0 +1,20 @@ |
|||
package apishiyan |
|||
|
|||
import ( |
|||
"key_performance_indicators/api/shiyan" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//实验
|
|||
|
|||
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
|||
apiRouter := router.Group("shiyan") |
|||
|
|||
var methodBinding = shiyan.AppApiEntry.MapToStructApi |
|||
{ |
|||
apiRouter.GET("", methodBinding.Index) //入口
|
|||
apiRouter.POST("", methodBinding.Index) //入口
|
|||
apiRouter.POST("maptostructshiyan", methodBinding.MapToStructShiyan) //map转struct
|
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package empower |
|||
|
|||
import ( |
|||
"key_performance_indicators/api/empower" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//OAuth 2.0 授权
|
|||
|
|||
func (e *EmpowerApiRouter) RouterGroup(router *gin.RouterGroup) { |
|||
apiRouter := router.Group("empower") |
|||
var methodBinding = empower.AppApiEntry.EmpowerApi |
|||
{ |
|||
apiRouter.GET("", methodBinding.Index) //入口
|
|||
apiRouter.POST("", methodBinding.Index) //入口
|
|||
apiRouter.POST("givemetoken", methodBinding.GainToken) //获取令牌
|
|||
apiRouter.POST("encryption", methodBinding.Encryption) //加密验证
|
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package empower |
|||
|
|||
//OAuth 2.0 授权
|
|||
|
|||
type EmpowerApiRouter struct{} |
|||
@ -0,0 +1,19 @@ |
|||
package apirouter |
|||
|
|||
import ( |
|||
"key_performance_indicators/apirouter/apishiyan" |
|||
"key_performance_indicators/apirouter/empower" |
|||
honorsRoute "key_performance_indicators/apirouter/v1/honorsRoute" |
|||
"key_performance_indicators/apirouter/verifyLogin" |
|||
// "key_performance_indicators/v1"
|
|||
) |
|||
|
|||
//路由结构
|
|||
type RouterGroup struct { |
|||
EmpowerRouter empower.EmpowerApiRouter |
|||
VerifyLogin verifyLogin.ApiRouter |
|||
ShiyanApi apishiyan.ApiRouter |
|||
HonorsSouteRouter honorsRoute.ApiRouter |
|||
} |
|||
|
|||
var RouterGroupEntry = new(RouterGroup) |
|||
@ -0,0 +1,28 @@ |
|||
package honorsRoute |
|||
|
|||
import ( |
|||
"key_performance_indicators/api/version1" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//荣誉墙
|
|||
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
|||
apiRouter := router.Group("honors") |
|||
|
|||
var methodBinding = version1.AppApiEntry.HonorsApi |
|||
{ |
|||
apiRouter.GET("", methodBinding.Index) //入口
|
|||
apiRouter.POST("", methodBinding.Index) //入口
|
|||
apiRouter.POST("honorlist", methodBinding.HonorList) //荣誉列表
|
|||
apiRouter.POST("addhonorcont", methodBinding.AddHonorCont) //添加荣誉
|
|||
apiRouter.POST("eidyhonorcont", methodBinding.EidyHonorCont) //编辑荣誉
|
|||
apiRouter.POST("eidyhonorcontstate", methodBinding.EidyHonorContState) //编辑荣誉状态
|
|||
|
|||
//载体类型
|
|||
apiRouter.POST("carrierlist", methodBinding.CarrierList) //载体类型列表
|
|||
apiRouter.POST("addcarrier", methodBinding.AddCarrier) //添加载体类型
|
|||
apiRouter.POST("eidycarrier", methodBinding.EidyCarrier) //编辑载体类型
|
|||
apiRouter.POST("eidycarrierstate", methodBinding.EidyCarrierState) //编辑载体类型状态
|
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
package honorsRoute |
|||
|
|||
//荣誉墙
|
|||
type ApiRouter struct{} |
|||
@ -0,0 +1,21 @@ |
|||
package verifyLogin |
|||
|
|||
import ( |
|||
"key_performance_indicators/api/base" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//OAuth 2.0 授权
|
|||
|
|||
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) { |
|||
apiRouter := router.Group("base") |
|||
var methodBinding = base.AppApiEntry.LoginVerify |
|||
{ |
|||
apiRouter.GET("", methodBinding.Index) //入口
|
|||
apiRouter.POST("", methodBinding.Index) //入口
|
|||
apiRouter.POST("captcha", methodBinding.Captcha) //获取验证码
|
|||
apiRouter.POST("login", methodBinding.ScanCodeLogin) //登录
|
|||
apiRouter.POST("signout", methodBinding.SignOut) //退出登录
|
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package verifyLogin |
|||
|
|||
//登录合验证码
|
|||
|
|||
type ApiRouter struct{} |
|||
@ -0,0 +1,167 @@ |
|||
package interceptor |
|||
|
|||
import ( |
|||
"fmt" |
|||
"key_performance_indicators/middleware/grocerystore" |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
"github.com/mitchellh/mapstructure" |
|||
) |
|||
|
|||
//身份验证器
|
|||
func IdentificationToken() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
userToken := c.Request.Header.Get("token") |
|||
randomNumber := c.Request.Header.Get("number") |
|||
ContentType := c.Request.Header.Get("Content-Type") |
|||
Origin := c.Request.Header.Get("Origin") |
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
|
|||
if ContentType == "" || userToken == "" || userAgent == "" || randomNumber == "" { |
|||
iii := publicmethod.MapOut[string]() |
|||
iii["ContentType"] = ContentType |
|||
iii["userToken"] = userToken |
|||
iii["userAgent"] = userAgent |
|||
iii["Origin"] = Origin |
|||
iii["randomNumber"] = randomNumber |
|||
publicmethod.Result(2001, "请输入关键信息数据!", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
//设定redis Key名称
|
|||
redisKey := fmt.Sprintf("Authentication:ApiAuthent_%v", userToken) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3) |
|||
tokenInfo, isTrue := redisClient.HashGetAll(redisKey) |
|||
if isTrue != true { |
|||
iii := publicmethod.MapOut[string]() |
|||
iii["ContentType"] = ContentType |
|||
iii["userToken"] = userToken |
|||
iii["userAgent"] = userAgent |
|||
iii["Origin"] = Origin |
|||
iii["randomNumber"] = randomNumber |
|||
iii["redisKey"] = redisKey |
|||
iii["isTrue"] = isTrue |
|||
publicmethod.Result(2002, "您的指令不正确!或已经超时!请重新获取指令!", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
var validator ValidatorToken |
|||
identityErr := mapstructure.Decode(tokenInfo, &validator) |
|||
if identityErr != nil { |
|||
publicmethod.Result(2003, "对不起!身份验证失败!", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
|
|||
//密码加密
|
|||
var passWordMd5 publicmethod.Md5Encryption |
|||
passWordMd5.Md5EncryptionInit(validator.PassWord) |
|||
passWordMd5Str := passWordMd5.Md5EncryptionAlgorithm() |
|||
|
|||
var empowerUser models.EmpowerUser |
|||
userErr := empowerUser.GetCont(map[string]interface{}{"userkey": validator.UserKey, "password": passWordMd5Str}, "verification_code") |
|||
if userErr != nil { |
|||
publicmethod.Result(2000, userErr, c) |
|||
return |
|||
} |
|||
|
|||
//头文件加密
|
|||
//ContentType
|
|||
var ContentTypeMd5 publicmethod.Md5Encryption |
|||
ContentTypeMd5.Md5EncryptionInit(ContentType) |
|||
if empowerUser.VerificationCode != "" { |
|||
ContentTypeMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
|
|||
fmt.Printf("ContentTypeMd5Str ----->%v\n", ContentTypeMd5) |
|||
|
|||
ContentTypeMd5Str := ContentTypeMd5.Md5EncryptionAlgorithm() |
|||
//Origin
|
|||
var OriginMd5 publicmethod.Md5Encryption |
|||
OriginMd5.Md5EncryptionInit(Origin) |
|||
if empowerUser.VerificationCode != "" { |
|||
OriginMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
originMd5Str := OriginMd5.Md5EncryptionAlgorithm() |
|||
//userAgent
|
|||
var userAgentMd5 publicmethod.Md5Encryption |
|||
userAgentMd5.Md5EncryptionInit(userAgent) |
|||
if empowerUser.VerificationCode != "" { |
|||
userAgentMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
|
|||
userAgentMd5Str := userAgentMd5.Md5EncryptionAlgorithm() |
|||
|
|||
//随机数加密
|
|||
var randomNumberMd5 publicmethod.Md5Encryption |
|||
randomNumberMd5.Md5EncryptionInit(validator.Number) |
|||
if empowerUser.VerificationCode != "" { |
|||
randomNumberMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
|
|||
numberMd5 := randomNumberMd5.Md5EncryptionAlgorithm() |
|||
|
|||
//用户名加密
|
|||
var userKeyMd5 publicmethod.Md5Encryption |
|||
userKeyMd5.Md5EncryptionInit(validator.UserKey) |
|||
if empowerUser.VerificationCode != "" { |
|||
userKeyMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
|
|||
userKeyMd5Str := userKeyMd5.Md5EncryptionAlgorithm() |
|||
|
|||
clearCodeToken := fmt.Sprintf("%v-%v-%v-%v-%v-%v", ContentTypeMd5Str, originMd5Str, userAgentMd5Str, numberMd5, userKeyMd5Str, passWordMd5Str) |
|||
|
|||
fmt.Printf("redisKey---->ContentTypeMd5Str:%v-originMd5Str:%v-userAgentMd5Str:%v-numberMd5:%v-userKeyMd5Str:%v-passwordMd5Str:%v\n", ContentTypeMd5Str, originMd5Str, userAgentMd5Str, numberMd5, userKeyMd5Str, passWordMd5Str) |
|||
|
|||
//token 加密
|
|||
var tokenMd5 publicmethod.Md5Encryption |
|||
tokenMd5.Md5EncryptionInit(clearCodeToken) |
|||
if empowerUser.VerificationCode != "" { |
|||
tokenMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
fmt.Printf("tokenMd5Appk ----->%v\n", tokenMd5) |
|||
tokenMd5Str := tokenMd5.Md5EncryptionAlgorithm() |
|||
|
|||
clearTokenStr := fmt.Sprintf("%v-%v", tokenMd5Str, numberMd5) |
|||
var clearTokenMd5 publicmethod.Md5Encryption |
|||
clearTokenMd5.Md5EncryptionInit(clearTokenStr) |
|||
if empowerUser.VerificationCode != "" { |
|||
clearTokenMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
clearTokenMd5Str := clearTokenMd5.Md5EncryptionAlgorithm() |
|||
|
|||
//提交Token转化
|
|||
submitTokenStr := fmt.Sprintf("%v-%v", userToken, randomNumber) |
|||
|
|||
var submitTokenMd5 publicmethod.Md5Encryption |
|||
submitTokenMd5.Md5EncryptionInit(submitTokenStr) |
|||
if empowerUser.VerificationCode != "" { |
|||
submitTokenMd5.AppKey = empowerUser.VerificationCode |
|||
} |
|||
submitTokenMd5Str := submitTokenMd5.Md5EncryptionAlgorithm() |
|||
|
|||
if submitTokenMd5Str != clearTokenMd5Str { |
|||
sss := publicmethod.MapOut[string]() |
|||
sss["numberMd5"] = numberMd5 |
|||
sss["submitTokenMd5Str"] = submitTokenMd5Str |
|||
sss["clearTokenMd5Str"] = clearTokenMd5Str |
|||
sss["tokenMd5Str"] = tokenMd5Str |
|||
sss["clearCodeToken"] = clearCodeToken |
|||
sss["submitTokenStr"] = submitTokenStr |
|||
sss["clearTokenStr"] = clearTokenStr |
|||
sss["userToken"] = userToken |
|||
|
|||
// tokenMd5Str, numberMd5
|
|||
// publicmethod.Result(2004, "对不起!非法令牌!不可访问系统", c)
|
|||
publicmethod.Result(2004, sss, c, "对不起!非法令牌!不可访问系统") |
|||
c.Abort() |
|||
return |
|||
} |
|||
c.Set("token", validator) |
|||
c.Next() |
|||
} |
|||
} |
|||
@ -0,0 +1,127 @@ |
|||
package interceptor |
|||
|
|||
import ( |
|||
"fmt" |
|||
"key_performance_indicators/middleware/grocerystore" |
|||
"key_performance_indicators/overall" |
|||
"key_performance_indicators/overall/publicmethod" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//验证用户是否登录
|
|||
func AuthenticateUser() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
userKey := c.Request.Header.Get("user-key") |
|||
userToken := c.Request.Header.Get("user-token") |
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
|
|||
if userKey == "" || userToken == "" || userAgent == "" { |
|||
response.FailWithDetailed(gin.H{"reload": false, "code": 300}, "未登录或非法访问", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
|
|||
redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKey) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) |
|||
userRedisToken, isTrue := redisClient.HashGetAll(redisFileKey) |
|||
if isTrue == false { |
|||
response.FailWithDetailed(gin.H{"reload": false, "code": 301}, "未登录或非法访问", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
if userToken != userRedisToken["usertoken"] { |
|||
response.FailWithDetailed(gin.H{"reload": false, "code": 302}, "令牌不正确!非法访问!", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
myCont, myErr := publicmethod.GetUserRedisCont(userRedisToken["usernumber"]) |
|||
if myErr != nil { |
|||
response.FailWithDetailed(gin.H{"reload": false, "code": 303, "data": myErr}, "登录超时!请重新登录", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
// fmt.Printf("myCont---------------->%v\n", myCont)
|
|||
c.Set(overall.MyContJwt, myCont) |
|||
writeRedisData := publicmethod.MapOut[string]() |
|||
for i, v := range userRedisToken { |
|||
writeRedisData[i] = v |
|||
} |
|||
redisClient.SetRedisTime(10800) |
|||
redisClient.HashMsetAdd(redisFileKey, writeRedisData) |
|||
myContRedis := publicmethod.MapOut[string]() |
|||
myContRedis["id"] = myCont.Id |
|||
myContRedis["number"] = myCont.Number //员工工号
|
|||
myContRedis["name"] = myCont.Name //姓名
|
|||
myContRedis["icon"] = myCont.Icon //头像
|
|||
myContRedis["hire_class"] = myCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;)
|
|||
myContRedis["emp_type"] = myCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职)
|
|||
myContRedis["company"] = myCont.Company //入职公司
|
|||
myContRedis["maindeparment"] = myCont.MainDeparment //主部门
|
|||
myContRedis["sun_main_department"] = myCont.SunMainDeparment //二级主部门
|
|||
myContRedis["deparment"] = myCont.Deparment //部门
|
|||
myContRedis["admin_org"] = myCont.AdminOrg //所属行政组织
|
|||
myContRedis["teamid"] = myCont.TeamId //班组
|
|||
myContRedis["position"] = myCont.Position //职位
|
|||
myContRedis["job_class"] = myCont.JobClass //职务分类
|
|||
myContRedis["job_id"] = myCont.JobId //职务
|
|||
myContRedis["job_leve"] = myCont.JobLeve //职务等级
|
|||
myContRedis["wechat"] = myCont.Wechat //微信UserId
|
|||
myContRedis["work_wechat"] = myCont.WorkWechat //企业微信UserId
|
|||
myContRedis["state"] = myCont.State //状态(1:启用;2:禁用;3:删除)
|
|||
myContRedis["key"] = myCont.Key //key
|
|||
myContRedis["is_admin"] = myCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管
|
|||
myContRedis["password"] = myCont.Password //密码
|
|||
myContRedis["role"] = myCont.Role //角色
|
|||
myContRedis["idcardno"] = myCont.Idcardno //身份证号
|
|||
myContRedis["passportno"] = myCont.Passportno //护照号码
|
|||
myContRedis["globalroaming"] = myCont.Globalroaming //国际区号
|
|||
myContRedis["mobilephone"] = myCont.Mobilephone //手机号码
|
|||
myContRedis["email"] = myCont.Email //电子邮件
|
|||
myContRedis["gender"] = myCont.Gender //性别(1:男性;2:女性;3:中性)
|
|||
myContRedis["birthday"] = myCont.Birthday //birthday
|
|||
myContRedis["myfolk"] = myCont.Myfolk //民族
|
|||
myContRedis["nativeplace"] = myCont.Nativeplace //籍贯
|
|||
myContRedis["idcardstartdate"] = myCont.Idcardstartdate //身份证有效期开始
|
|||
myContRedis["idcardenddate"] = myCont.Idcardenddate //身份证有效期结束
|
|||
myContRedis["idcardaddress"] = myCont.Idcardaddress //身份证地址
|
|||
myContRedis["idcardIssued"] = myCont.IdcardIssued //身份证签发机关
|
|||
myContRedis["health"] = myCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)
|
|||
myContRedis["maritalstatus"] = myCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
|
|||
myContRedis["internaltelephone"] = myCont.Internaltelephone //内线电话
|
|||
myContRedis["currentresidence"] = myCont.Currentresidence //现居住地址
|
|||
myContRedis["constellationing"] = myCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
|
|||
myContRedis["isdoubleworker"] = myCont.Isdoubleworker //是否双职工(1:是;2:否)
|
|||
myContRedis["isveterans"] = myCont.Isveterans //是否为退役军人(1:是;2:否)
|
|||
myContRedis["veteransnumber"] = myCont.Veteransnumber //退役证编号
|
|||
myContRedis["jobstartdate"] = myCont.Jobstartdate //参加工作日期
|
|||
myContRedis["entrydate"] = myCont.Entrydate //入职日期
|
|||
myContRedis["probationperiod"] = myCont.Probationperiod //试用期
|
|||
myContRedis["planformaldate"] = myCont.Planformaldate //预计转正日期
|
|||
myContRedis["political_outlook"] = myCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
|
|||
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, myCont.Number) |
|||
redisClient.HashMsetAdd(redisMyContKey, myContRedis) |
|||
c.Next() |
|||
} |
|||
} |
|||
|
|||
//验证用户是否具备权限
|
|||
func VerifyUrl() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
systemClass := c.Request.Header.Get("system-class") |
|||
context, exi := publicmethod.LoginMyCont(c) |
|||
if exi != nil { |
|||
response.FailWithDetailed(gin.H{"reload": false, "code": 303, "data": exi}, exi.Error(), c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
// 获取请求的PATH
|
|||
obj := c.Request.URL.Path |
|||
// 获取请求方法
|
|||
act := c.Request.Method |
|||
|
|||
fmt.Printf("obj------>%v-----------act------->%v---systemClass------------>%v------------------context-------->%v\n", obj, act, systemClass, context.Role) |
|||
c.Next() |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
package interceptor |
|||
|
|||
//验证器结构Token
|
|||
type ValidatorToken struct { |
|||
Number string `json:"number"` //随机数
|
|||
UserKey string `json:"userkey"` //用户名
|
|||
PassWord string `json:"password"` //密码
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package middleware |
|||
|
|||
import ( |
|||
"net/http" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
// 处理跨域请求,支持options访问
|
|||
func CrossDomainRequest() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
method := c.Request.Method |
|||
origin := c.Request.Header.Get("Origin") |
|||
c.Header("Access-Control-Allow-Origin", origin) |
|||
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id") |
|||
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT") |
|||
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type") |
|||
c.Header("Access-Control-Allow-Credentials", "true") |
|||
// 放行所有OPTIONS方法
|
|||
if method == "OPTIONS" { |
|||
c.AbortWithStatus(http.StatusNoContent) |
|||
} |
|||
// 处理请求
|
|||
c.Next() |
|||
} |
|||
} |
|||
@ -0,0 +1,380 @@ |
|||
package grocerystore |
|||
|
|||
import ( |
|||
"context" |
|||
"fmt" |
|||
"key_performance_indicators/overall" |
|||
"time" |
|||
|
|||
"github.com/go-redis/redis/v8" |
|||
) |
|||
|
|||
//redis 基础设定
|
|||
type RedisStoreType struct { |
|||
Expiration time.Duration |
|||
PreKey string |
|||
Context context.Context |
|||
RedisDb *redis.Client |
|||
} |
|||
|
|||
//启动redis
|
|||
func RunRedis(redisClient *redis.Client) *RedisStoreType { |
|||
var redisStoreType RedisStoreType |
|||
redisStoreType.Expiration = time.Second * 300 |
|||
redisStoreType.PreKey = fmt.Sprintf("%v:", overall.CONSTANT_CONFIG.RedisPrefixStr.PreFix) |
|||
redisStoreType.Context = context.Background() |
|||
redisStoreType.RedisDb = redisClient |
|||
return &redisStoreType |
|||
} |
|||
|
|||
//设置键前缀
|
|||
func (r *RedisStoreType) SetRedisPrefix(prefix string) { |
|||
r.PreKey = prefix |
|||
} |
|||
|
|||
//设置过期时间
|
|||
func (r *RedisStoreType) SetRedisTime(timeDate int64) { |
|||
r.Expiration = time.Second * time.Duration(timeDate) |
|||
} |
|||
|
|||
//设置字符串
|
|||
func (r *RedisStoreType) Set(key string, value string) bool { |
|||
err := r.RedisDb.Set(r.Context, r.PreKey+key, value, r.Expiration).Err() |
|||
if err != nil { |
|||
return false |
|||
} |
|||
return true |
|||
} |
|||
|
|||
//获取字符串
|
|||
func (r *RedisStoreType) Get(key string) (bool, string) { |
|||
err := r.RedisDb.Get(r.Context, r.PreKey+key) |
|||
if err.Err() != nil { |
|||
return false, "" |
|||
} |
|||
return true, err.Val() |
|||
} |
|||
|
|||
//删除键
|
|||
func (r *RedisStoreType) DelKey(key string) bool { |
|||
err := r.RedisDb.Del(r.Context, r.PreKey+key).Err() |
|||
if err != nil { |
|||
return false |
|||
} |
|||
return true |
|||
} |
|||
|
|||
//哈希操作
|
|||
/* |
|||
获取单个哈希键值 |
|||
@hashName 集合名称 |
|||
@hashKey 哈希键 |
|||
callback |
|||
errs 状态 |
|||
hashVal 获得值 |
|||
*/ |
|||
func (r *RedisStoreType) HashGet(hashName, hashKey string) (errs bool, hashVal string) { |
|||
err := r.RedisDb.HGet(r.Context, r.PreKey+hashName, hashKey) |
|||
if err.Err() != nil { |
|||
return false, "" |
|||
} |
|||
return true, err.Val() |
|||
} |
|||
|
|||
/* |
|||
为哈希表中的字段赋值 。 单一设置 |
|||
@hashName 集合名称 |
|||
@hashKey 哈希键 |
|||
@hashVal 要添加的值 |
|||
*/ |
|||
func (r *RedisStoreType) HashSet(hashName, hashKey, hashVal string) bool { |
|||
err := r.RedisDb.HSet(r.Context, r.PreKey+hashName, hashKey, hashVal).Err() |
|||
if err != nil { |
|||
return false |
|||
} |
|||
if r.Expiration == 0 { |
|||
r.RedisDb.Persist(r.Context, r.PreKey+hashName) |
|||
} else { |
|||
r.RedisDb.PExpire(r.Context, r.PreKey+hashName, r.Expiration) |
|||
} |
|||
// global.GVA_REDIS.PExpire(r.Context, r.PreKey+hashName, r.Expiration)
|
|||
return true |
|||
} |
|||
|
|||
/* |
|||
同时将多个 field-value (字段-值)对设置到哈希表中。 |
|||
@hashName 集合名称 |
|||
@hashVal 要添加的键与值 |
|||
*/ |
|||
func (r *RedisStoreType) HashMsetAdd(hashName string, hashVal map[string]interface{}) bool { |
|||
// rdb := RedisInit()
|
|||
err := r.RedisDb.HMSet(r.Context, r.PreKey+hashName, hashVal).Err() |
|||
// fmt.Printf("错误sss=========》%v=====2====》%v\n", err, hashVal)
|
|||
// err := rdb.HMSet(ctx, "userfg", hashVal).Err()
|
|||
if err != nil { |
|||
return false |
|||
} |
|||
if r.Expiration == 0 { |
|||
r.RedisDb.Persist(r.Context, r.PreKey+hashName) |
|||
} else { |
|||
r.RedisDb.PExpire(r.Context, r.PreKey+hashName, r.Expiration) |
|||
} |
|||
|
|||
return true |
|||
} |
|||
func (r *RedisStoreType) HashMsetAddAry(hashName string, hashVal []map[string]interface{}) bool { |
|||
// rdb := RedisInit()
|
|||
err := r.RedisDb.HMSet(r.Context, r.PreKey+hashName, hashVal).Err() |
|||
// err := rdb.HMSet(ctx, "userfg", hashVal).Err()
|
|||
if err != nil { |
|||
return false |
|||
} |
|||
if r.Expiration == 0 { |
|||
r.RedisDb.Persist(r.Context, r.PreKey+hashName) |
|||
} else { |
|||
r.RedisDb.PExpire(r.Context, r.PreKey+hashName, r.Expiration) |
|||
} |
|||
// global.GVA_REDIS.PExpire(r.Context, r.PreKey+hashName, r.Expiration)
|
|||
// fmt.Printf("错误sss=========》%v\n", hashVal)
|
|||
return true |
|||
} |
|||
|
|||
/* |
|||
返回哈希表中,所有的字段和值。 |
|||
@hashName 集合名称 |
|||
@hashKey 哈希键 |
|||
*/ |
|||
func (r *RedisStoreType) HashGetAll(hashName string) (map[string]string, bool) { |
|||
// rdb := RedisInit()
|
|||
// fmt.Printf("strKEy:===>%v\n", r.PreKey+hashName)
|
|||
val, err := r.RedisDb.HGetAll(r.Context, r.PreKey+hashName).Result() |
|||
if err != nil { |
|||
return val, false |
|||
} |
|||
if len(val) == 0 { |
|||
return val, false |
|||
} |
|||
return val, true |
|||
} |
|||
|
|||
//Redis 列表(List)
|
|||
|
|||
/** |
|||
Linsert 命令用于在列表的元素前或者后插入元素。当指定元素不存在于列表中时,不执行任何操作。 |
|||
当列表不存在时,被视为空列表,不执行任何操作。 |
|||
如果 key 不是列表类型,返回一个错误。 |
|||
@key 列表 |
|||
@op 插入状态 (1:在pivot之后;2:在pivot之前) |
|||
@pivot 定位值 |
|||
@value 要插入值 |
|||
*/ |
|||
func (r *RedisStoreType) Linsert(key string, op int, pivot, value interface{}) (int64, bool) { |
|||
BeforeOrAfter := "BEFORE" |
|||
if op != 1 { |
|||
BeforeOrAfter = "AFTER" |
|||
} |
|||
linsert, linsertErr := r.RedisDb.LInsert(r.Context, key, BeforeOrAfter, pivot, value).Result() |
|||
if linsertErr != nil { |
|||
return 0, false |
|||
} |
|||
return linsert, true |
|||
} |
|||
|
|||
/** |
|||
Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 |
|||
@key 列表 |
|||
@index 索引 |
|||
*/ |
|||
func (r *RedisStoreType) Lindex(key string, index int64) (val string, err error) { |
|||
val, err = r.RedisDb.LIndex(r.Context, key, index).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Llen 命令用于返回列表的长度。 如果列表 key 不存在,则 key 被解释为一个空列表,返回 0 。 如果 key 不是列表类型,返回一个错误。 |
|||
@key 列表 |
|||
*/ |
|||
func (r *RedisStoreType) Llen(key string) (val int64, err error) { |
|||
val, err = r.RedisDb.LLen(r.Context, key).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Lpop 命令用于移除并返回列表的第一个元素。 |
|||
@key 列表 |
|||
*/ |
|||
func (r *RedisStoreType) Lpop(key string) (val string, err error) { |
|||
val, err = r.RedisDb.LPop(r.Context, key).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Lpush 命令将一个或多个值插入到列表头部。 如果 key 不存在,一个空列表会被创建并执行 LPUSH 操作。 当 key 存在但不是列表类型时,返回一个错误。 |
|||
@key 列表 |
|||
@value 要插入的字符串 |
|||
*/ |
|||
func (r *RedisStoreType) Lpush(key string, value ...interface{}) (val int64, err error) { |
|||
val, err = r.RedisDb.LPush(r.Context, key, value).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Lpushx 将一个值插入到已存在的列表头部,列表不存在时操作无效。 |
|||
@key 列表 |
|||
@value 要插入的字符串 |
|||
*/ |
|||
func (r *RedisStoreType) Lpushx(key, value string) (val int64, err error) { |
|||
val, err = r.RedisDb.LPushX(r.Context, key, value).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Lrange 返回列表中指定区间内的元素,区间以偏移量 START 和 END 指定。 其中 0 表示列表的第一个元素, 1 表示列表的第二个元素,以此类推。 你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 |
|||
@key 列表 |
|||
@start 起始值 |
|||
@stop 结束值 |
|||
*/ |
|||
func (r *RedisStoreType) Lrange(key string, start, stop int64) (val []string, err error) { |
|||
val, err = r.RedisDb.LRange(r.Context, key, start, stop).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Lrem 根据参数 COUNT 的值,移除列表中与参数 VALUE 相等的元素。 |
|||
COUNT 的值可以是以下几种: |
|||
count > 0 : 从表头开始向表尾搜索,移除与 VALUE 相等的元素,数量为 COUNT 。 |
|||
count < 0 : 从表尾开始向表头搜索,移除与 VALUE 相等的元素,数量为 COUNT 的绝对值。 |
|||
count = 0 : 移除表中所有与 VALUE 相等的值。 |
|||
@start = COUNT |
|||
@key 列表 |
|||
*/ |
|||
func (r *RedisStoreType) Lrem(key string, start int64, value ...interface{}) (val int64, err error) { |
|||
val, err = r.RedisDb.LRem(r.Context, key, start, value).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Redis Lset 通过索引来设置元素的值。 |
|||
|
|||
当索引参数超出范围,或对一个空列表进行 LSET 时,返回一个错误。 |
|||
@key 列表 |
|||
@indexes 索引值 |
|||
*/ |
|||
func (r *RedisStoreType) Lset(key string, indexes int64, value ...interface{}) (val string, err error) { |
|||
val, err = r.RedisDb.LSet(r.Context, key, indexes, value).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Ltrim 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。 |
|||
|
|||
下标 0 表示列表的第一个元素,以 1 表示列表的第二个元素,以此类推。 你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 |
|||
@key 列表 |
|||
@start 起始值 |
|||
@stop 结束值 |
|||
*/ |
|||
func (r *RedisStoreType) Ltrim(key string, start, stop int64) (val string, err error) { |
|||
val, err = r.RedisDb.LTrim(r.Context, key, start, stop).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Rpop 命令用于移除列表的最后一个元素,返回值为移除的元素。 |
|||
@key 列表 |
|||
*/ |
|||
func (r *RedisStoreType) Rpop(key string) (val string, err error) { |
|||
val, err = r.RedisDb.RPop(r.Context, key).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Rpoplpush 命令用于移除列表的最后一个元素,并将该元素添加到另一个列表并返回。 |
|||
@sourceKey 源列表 |
|||
@newKey 目标列表 |
|||
*/ |
|||
func (r *RedisStoreType) Rpoplpush(sourceKey, newKey string) (val string, err error) { |
|||
val, err = r.RedisDb.RPopLPush(r.Context, sourceKey, newKey).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Rpush 命令用于将一个或多个值插入到列表的尾部(最右边)。 |
|||
如果列表不存在,一个空列表会被创建并执行 RPUSH 操作。 当列表存在但不是列表类型时,返回一个错误。 |
|||
@key 列表 |
|||
@value 要插入的字符串 |
|||
*/ |
|||
func (r *RedisStoreType) Rpush(key string, value ...interface{}) (val int64, err error) { |
|||
val, err = r.RedisDb.RPush(r.Context, key, value).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Rpushx 命令用于将一个值插入到已存在的列表尾部(最右边)。如果列表不存在,操作无效。 |
|||
@key 列表 |
|||
@value 要插入的字符串 |
|||
*/ |
|||
func (r *RedisStoreType) Rpushx(key string, value ...interface{}) (val int64, err error) { |
|||
val, err = r.RedisDb.RPushX(r.Context, key, value).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Blpop 命令移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 |
|||
@key 列表 |
|||
*/ |
|||
func (r *RedisStoreType) Blpop(key string) (val []string, err error) { |
|||
val, err = r.RedisDb.BLPop(r.Context, r.Expiration, key).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Brpop 命令移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 |
|||
@key 列表 |
|||
*/ |
|||
func (r *RedisStoreType) Brpop(key string) (val []string, err error) { |
|||
val, err = r.RedisDb.BRPop(r.Context, r.Expiration, key).Result() |
|||
return |
|||
} |
|||
|
|||
/** |
|||
Brpoplpush 命令从列表中取出最后一个元素,并插入到另外一个列表的头部; 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 |
|||
@source 源列表 |
|||
@destination 目标列表 |
|||
*/ |
|||
func (r *RedisStoreType) Brpoplpush(source, destination string) (val string, err error) { |
|||
val, err = r.RedisDb.BRPopLPush(r.Context, source, destination, r.Expiration).Result() |
|||
return |
|||
} |
|||
|
|||
/* |
|||
Redis 键(key) |
|||
Redis 键命令用于管理 redis 的键。 |
|||
*/ |
|||
|
|||
/* |
|||
Redis SCAN 命令 |
|||
Redis Scan 命令用于迭代数据库中的数据库键。 |
|||
|
|||
SCAN 命令是一个基于游标的迭代器,每次被调用之后, 都会向用户返回一个新的游标, 用户在下次迭代时需要使用这个新游标作为 SCAN 命令的游标参数, 以此来延续之前的迭代过程。 |
|||
|
|||
SCAN 返回一个包含两个元素的数组, 第一个元素是用于进行下一次迭代的新游标, 而第二个元素则是一个数组, 这个数组中包含了所有被迭代的元素。如果新游标返回 0 表示迭代已结束。 |
|||
|
|||
相关命令: |
|||
|
|||
SSCAN 命令用于迭代集合键中的元素。 |
|||
HSCAN 命令用于迭代哈希键中的键值对。 |
|||
ZSCAN 命令用于迭代有序集合中的元素(包括元素成员和元素分值)。 |
|||
*/ |
|||
|
|||
func (r *RedisStoreType) Scan(cursor uint64, match string, count int64) (keys []string, cursores uint64, err error) { |
|||
keys, cursores, err = r.RedisDb.Scan(r.Context, cursor, match, count).Result() |
|||
return |
|||
} |
|||
|
|||
/* |
|||
*Keys 命令用于查找所有符合给定模式 pattern 的 key 。。 |
|||
*/ |
|||
func (r *RedisStoreType) Keys(key string) (val []string, err error) { |
|||
val, err = r.RedisDb.Keys(r.Context, key).Result() |
|||
return |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package snowflake |
|||
|
|||
import ( |
|||
"errors" |
|||
"time" |
|||
) |
|||
|
|||
//雪花算法
|
|||
func NewWorker(workerId int64) (*Worker, error) { |
|||
if workerId < 0 || workerId > workerMax { |
|||
return nil, errors.New("工作机器的ID超出范围!") |
|||
} |
|||
// 生成一个新节点
|
|||
return &Worker{ |
|||
timestamp: 0, |
|||
workerId: workerId, |
|||
number: 0, |
|||
}, nil |
|||
} |
|||
|
|||
func (w *Worker) GetId() int64 { |
|||
w.mu.Lock() |
|||
defer w.mu.Unlock() |
|||
now := time.Now().UnixNano() / 1e6 |
|||
if w.timestamp == now { |
|||
w.number++ |
|||
if w.number > numberMax { |
|||
for now <= w.timestamp { |
|||
now = time.Now().UnixNano() / 1e6 |
|||
} |
|||
} |
|||
} else { |
|||
w.number = 0 |
|||
w.timestamp = now |
|||
} |
|||
ID := int64((now-startTime)<<timeShift | (w.workerId << workerShift) | (w.number)) |
|||
return ID |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package snowflake |
|||
|
|||
import "sync" |
|||
|
|||
//雪花算法
|
|||
const ( |
|||
workerBits uint8 = 10 |
|||
numberBits uint8 = 12 |
|||
workerMax int64 = -1 ^ (-1 << workerBits) |
|||
numberMax int64 = -1 ^ (-1 << numberBits) |
|||
timeShift uint8 = workerBits + numberBits |
|||
workerShift uint8 = numberBits |
|||
startTime int64 = 1655827200000 // 如果在程序跑了一段时间修改了epoch这个值 可能会导致生成相同的ID
|
|||
) |
|||
|
|||
type Worker struct { |
|||
mu sync.Mutex |
|||
timestamp int64 |
|||
workerId int64 |
|||
number int64 |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//行政组织
|
|||
type AdministrativeOrganization struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
|||
Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` |
|||
OrganizationType int64 `json:"organizationtype" gorm:"column:organization_type;type:bigint(20) unsigned;default:0;not null;comment:行政组织类型"` |
|||
Abbreviation string `json:"abbreviation" gorm:"column:abbreviation;type:varchar(255) unsigned;default:'';not null;comment:行政组织简称"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
WechatOrganizationId int64 `json:"wechatorganizationid" gorm:"column:wechat_organization_id;type:bigint(20) unsigned;default:0;not null;comment:微信组织架构对照码"` |
|||
SuperiorSun string `json:"superiorsun" gorm:"column:superior_sun;type:mediumtext;comment:级联ID"` |
|||
Schoole int64 `json:"schoole" gorm:"column:schoole;type:bigint(20) unsigned;default:0;not null;comment:原知行学院对照码"` |
|||
KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
|||
IsPower int `json:"ispower" gorm:"column:ispower;type:int(1) unsigned;default:2;not null;comment:是否为实权部门"` |
|||
} |
|||
|
|||
func (AdministrativeOrganization *AdministrativeOrganization) TableName() string { |
|||
return "administrative_organization" |
|||
} |
|||
|
|||
//编辑行政组织内容
|
|||
func (cont *AdministrativeOrganization) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取行政组织内容
|
|||
func (cont *AdministrativeOrganization) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//根据条件获取总数
|
|||
func (cont *AdministrativeOrganization) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
//读取全部信息
|
|||
func (cont *AdministrativeOrganization) ContMap(whereMap interface{}) (countAry []AdministrativeOrganization) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Find(&countAry) |
|||
return |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//行政组织类型
|
|||
type AdministrativeOrganizationType struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:类型名称"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` |
|||
KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
|||
} |
|||
|
|||
func (AdministrativeOrganizationType *AdministrativeOrganizationType) TableName() string { |
|||
return "administrative_organization_type" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (cont *AdministrativeOrganizationType) EiteCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *AdministrativeOrganizationType) GetCont(whereMap map[string]interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//载体类型
|
|||
type CarrierType struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:荣誉名称"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
} |
|||
|
|||
func (CarrierType *CarrierType) TableName() string { |
|||
return "carrier_type" |
|||
} |
|||
|
|||
//编辑载体类型内容
|
|||
func (cont *CarrierType) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取载体类型内容
|
|||
func (cont *CarrierType) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//删除内容
|
|||
func (cont *CarrierType) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//双职工
|
|||
type DoubleWorker struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
|||
Company string `json:"company" gorm:"column:company;type:varchar(255) unsigned;default:'';not null;comment:所在公司"` |
|||
Department string `json:"department" gorm:"column:department;type:varchar(255) unsigned;default:'';not null;comment:所在部门"` |
|||
Position string `json:"position" gorm:"column:position;type:varchar(255) unsigned;default:'';not null;comment:所在岗位"` |
|||
Tel string `json:"tel" gorm:"column:tel;type:varchar(255) unsigned;default:'';not null;comment:联系方式"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
} |
|||
|
|||
func (DoubleWorker *DoubleWorker) TableName() string { |
|||
return "double_worker" |
|||
} |
|||
|
|||
//编辑双职工内容
|
|||
func (DoubleWorker *DoubleWorker) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&DoubleWorker).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取双职工内容
|
|||
func (cont *DoubleWorker) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//职务
|
|||
type Duties struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` |
|||
JobType int64 `json:"jobtype" gorm:"column:job_type;type:bigint(20) unsigned;default:0;not null;comment:归属职务类型"` |
|||
Weight int64 `json:"weight" gorm:"column:weight;type:bigint(20) unsigned;default:1;not null;comment:权重"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:编码"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
|||
KingdeeNum string `json:"kingdeenum" gorm:"column:kingdeenum;type:varchar(255) unsigned;default:'';comment:金蝶对照编码"` |
|||
} |
|||
|
|||
func (Duties *Duties) TableName() string { |
|||
return "duties" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (Duties *Duties) EiteCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&Duties).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *Duties) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//职务信息及类别、等级视图
|
|||
type DutiesClassLeve struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:d_id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Name string `json:"name" gorm:"column:d_name;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` |
|||
Weight int64 `json:"weight" gorm:"column:d_weight;type:bigint(20) unsigned;default:1;not null;comment:权重"` |
|||
Number string `json:"number" gorm:"column:d_num;type:varchar(50) unsigned;default:'';not null;comment:编码"` |
|||
State int `json:"state" gorm:"column:d_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
KingdeeId string `json:"kingdeeid" gorm:"column:d_king;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
|||
ClassId int64 `json:"classid" gorm:"column:c_id;type:bigint(20) unsigned;not null;comment:Id;index"` //职务分类Id
|
|||
ClassName string `json:"classname" gorm:"column:c_name;type:varchar(255) unsigned;default:'';not null;comment:职务分类名称"` |
|||
// LeveId int64 `json:"leveid" gorm:"column:l_id;type:bigint(20) unsigned;not null;comment:Id;index"` //职务等级Id
|
|||
// LeveNumber string `json:"levenumber" gorm:"column:l_num;type:varchar(50) unsigned;default:'';not null;comment:等级编号"`
|
|||
// LeveName string `json:"levename" gorm:"column:l_name;type:varchar(255) unsigned;default:'';not null;comment:等级名称"`
|
|||
} |
|||
|
|||
func (DutiesClassLeve *DutiesClassLeve) TableName() string { |
|||
return "duties_class_leve" |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *DutiesClassLeve) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//紧急联系人
|
|||
type EmergencyContact struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:紧急联系人姓名"` |
|||
Relationship string `json:"relationship" gorm:"column:relationship;type:varchar(255) unsigned;default:'';not null;comment:与紧急联系人关系"` |
|||
Tel string `json:"tel" gorm:"column:tel;type:varchar(255) unsigned;default:'';not null;comment:紧急联系人电话"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
} |
|||
|
|||
func (EmergencyContact *EmergencyContact) TableName() string { |
|||
return "emergency_contact" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (EmergencyContact *EmergencyContact) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&EmergencyContact).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取行政组织内容
|
|||
func (cont *EmergencyContact) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//根据条件获取总数
|
|||
func (cont *EmergencyContact) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//授权账户
|
|||
type EmpowerUser struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
UserKey string `json:"userkey" gorm:"column:userkey;type:varchar(255) unsigned;not null;comment:账户"` |
|||
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:使用人(组织)名称"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)` |
|||
Time int64 `json:"addtime" gorm:"column:addtime;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` |
|||
EiteTime int64 `json:"eitetime" gorm:"column:eitetime;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
|||
VerificationCode string `json:"verificationcode" gorm:"column:verification_code;type:mediumtext unsigned;comment:身份识别码"` |
|||
} |
|||
|
|||
func (Position *EmpowerUser) TableName() string { |
|||
return "empoweruser" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (cont *EmpowerUser) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取行政组织内容
|
|||
func (cont *EmpowerUser) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//根据条件获取总数
|
|||
func (cont *EmpowerUser) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//员工家属
|
|||
type FamilyMembers struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
|||
Relationship string `json:"relationship" gorm:"column:relation;type:varchar(255) unsigned;default:'';not null;comment:亲属关系"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
|||
Company string `json:"company" gorm:"column:company;type:varchar(255) unsigned;default:'';not null;comment:所在公司"` |
|||
Deparment string `json:"deparment" gorm:"column:deparment;type:varchar(255) unsigned;default:'';not null;comment:所在部门"` |
|||
Postnme string `json:"postnme" gorm:"column:postnme;type:varchar(255) unsigned;default:'';not null;comment:所在岗位"` |
|||
Tel string `json:"tel" gorm:"column:tel;type:varchar(255) unsigned;default:'';not null;comment:紧急联系人电话"` |
|||
PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;type:int(3) unsigned;default:1;not null;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
|
|||
PoliticalOutlookCn string `json:"politicaloutlookcn" gorm:"column:political_outlook_cn;type:varchar(30) unsigned;not null;comment:政治面貌汉字说明"` |
|||
} |
|||
|
|||
func (FamilyMembers *FamilyMembers) TableName() string { |
|||
return "family_members" |
|||
} |
|||
|
|||
//编辑员工家属内容
|
|||
func (FamilyMembers *FamilyMembers) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&FamilyMembers).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取员工家属内容
|
|||
func (cont *FamilyMembers) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//荣誉档案
|
|||
type HonoraryArchives struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:荣誉名称"` |
|||
IssuingUnit string `json:"issuingunit" gorm:"column:issuing_unit;type:varchar(255) unsigned;default:'';not null;comment:发放单位"` |
|||
Carrier int64 `json:"carrier" gorm:"column:carrier;type:bigint(20) unsigned;default:0;not null;comment:载体"` |
|||
AwardTime int64 `json:"awardtime" gorm:"column:award_time;type:bigint(20) ;default:0;not null;comment:获奖时间"` |
|||
TermOfValidity int64 `json:"termvalidity" gorm:"column:term_of_validity;type:bigint(20) unsigned;default:0;not null;comment:有效期限"` |
|||
Contet string `json:"contet" gorm:"column:contet;type:mediumtext unsigned;comment:备注"` |
|||
Organization int64 `json:"organization" gorm:"column:organization;type:bigint(20) unsigned;default:0;not null;comment:归属行政组织"` |
|||
Userid int64 `json:"userid" gorm:"column:userid;type:bigint(20) unsigned;default:0;not null;comment:归属人员"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
} |
|||
|
|||
func (HonoraryArchives *HonoraryArchives) TableName() string { |
|||
return "honorary_archives" |
|||
} |
|||
|
|||
//编辑荣誉档案内容
|
|||
func (cont *HonoraryArchives) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取荣誉档案内容
|
|||
func (cont *HonoraryArchives) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//删除内容
|
|||
func (cont *HonoraryArchives) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//集团内部工作经历
|
|||
type InsideWorkHistory struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(20) unsigned;default:0;not null;comment:员工识别符"` |
|||
Group int64 `json:"group" gorm:"column:group;type:bigint(20) unsigned;default:0;not null;comment:集团"` |
|||
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:公司"` |
|||
Department int64 `json:"department" gorm:"column:department;type:bigint(20) unsigned;default:0;not null;comment:部室"` |
|||
WorkShop int64 `json:"workshop" gorm:"column:workshop;type:bigint(20) unsigned;default:0;not null;comment:二级部门或车间"` |
|||
WorkshopSection int64 `json:"workshopsection" gorm:"column:workshop_section;type:bigint(20) unsigned;default:0;not null;comment:工段"` |
|||
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"` |
|||
GradePositions int64 `json:"gradepositions" gorm:"column:grade_positions;type:bigint(20) unsigned;default:0;not null;comment:职等"` |
|||
StartTime int64 `json:"starttime" gorm:"column:start_time;type:bigint(20) unsigned;default:0;not null;comment:开始日期"` |
|||
EndTime int64 `json:"endtime" gorm:"column:end_time;type:bigint(20) unsigned;default:0;not null;comment:结束日期"` |
|||
Team int64 `json:"team" gorm:"column:team;type:int(1) unsigned;default:1;not null;comment:班组(1:长白;2:甲;3:乙;4:丙;5:丁)"` |
|||
ChangeType int `json:"changetype" gorm:"column:change_type;type:int(1) unsigned;default:1;not null;comment:变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;)"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
AssignType int `json:"assigntype" gorm:"column:assign_type;type:int(1) unsigned;default:1;not null;comment:1、主职;2:兼职"` |
|||
} |
|||
|
|||
func (InsideWorkHistory *InsideWorkHistory) TableName() string { |
|||
return "inside_work_history" |
|||
} |
|||
|
|||
//编辑集团内部工作经历内容
|
|||
func (cont *InsideWorkHistory) EditCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *InsideWorkHistory) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
type InsideWorkView struct { |
|||
InsideWorkHistory |
|||
GroupNumber string `json:"groupnumber" gorm:"column:g_number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
|||
GroupName string `json:"groupname" gorm:"column:g_name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
|||
CompanyNumber string `json:"companynumber" gorm:"column:c_number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
|||
CompanyName string `json:"companyname" gorm:"column:c_name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
|||
DepartmentNumber string `json:"departmentnumber" gorm:"column:d_number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
|||
DepartmentName string `json:"departmentname" gorm:"column:d_name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
|||
WorkShopNumber string `json:"workshopnumber" gorm:"column:ws_number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
|||
WorkShopName string `json:"workshopname" gorm:"column:ws_name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
|||
SectionNumber string `json:"sectionnumber" gorm:"column:w_number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
|||
SectionName string `json:"sectionnasectionme" gorm:"column:w_name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
|||
PostJobNumber string `json:"postjobnumber" gorm:"column:p_number;type:varchar(50) unsigned;default:'';not null;comment:职位编码"` |
|||
PostJobName string `json:"postjobname" gorm:"column:p_name;type:varchar(255) unsigned;default:'';not null;comment:职位名称"` |
|||
TeamName string `json:"teamname" gorm:"column:r_name;type:varchar(255) unsigned;default:'';not null;comment:班组名称"` |
|||
} |
|||
|
|||
func (InsideWorkView *InsideWorkView) TableName() string { |
|||
return "inside_work_view" |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *InsideWorkView) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//职务分类
|
|||
type JobClass struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:职务分类名称"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
|||
KingdeeNum string `json:"kingdeenum" gorm:"column:kingdeenum;type:varchar(255) unsigned;default:'';comment:金蝶对照编码"` |
|||
} |
|||
|
|||
func (JobClass *JobClass) TableName() string { |
|||
return "job_class" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (JobClass *JobClass) EiteJobClassCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&JobClass).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *JobClass) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//金蝶对照记录
|
|||
type KingdeeLog struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(255) unsigned;default:'';not null;comment:工号"` |
|||
Cont string `json:"cont" gorm:"column:cont;type:longtext unsigned;default:'';not null;comment:内容"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
} |
|||
|
|||
func (KingdeeLog *KingdeeLog) TableName() string { |
|||
return "kingdee_log" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (KingdeeLog *KingdeeLog) EidtCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&KingdeeLog).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *KingdeeLog) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
type ManCont struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
|||
Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"` |
|||
HireClass int `json:"hireclass" gorm:"column:hire_class;type:tinyint(1) unsigned;default:1;not null;comment:雇佣类型(1:雇佣入职;2:再入职;)"` |
|||
EmpType int `json:"emptype" gorm:"column:emp_type;type:tinyint(1) unsigned;default:1;not null;comment:用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职)"` |
|||
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` |
|||
MainDeparment int64 `json:"maindeparment" gorm:"column:maindeparment;type:bigint(20) unsigned;default:0;not null;comment:主部门"` |
|||
SunMainDeparment int64 `json:"sunmaindeparment" gorm:"column:sun_main_department;type:bigint(20) unsigned;default:0;not null;comment:二级主部门"` |
|||
Deparment string `json:"deparment" gorm:"column:deparment;type:text;comment:部门"` |
|||
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` |
|||
TeamId int64 `json:"teamid" gorm:"column:teamid;type:bigint(20) unsigned;default:0;not null;comment:班组"` |
|||
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"` |
|||
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:2;not null;comment:职务分类"` |
|||
JobId int64 `json:"jobid" gorm:"column:job_id;type:bigint(20) unsigned;default:0;not null;comment:职务"` |
|||
JobLeve int64 `json:"jobleve" gorm:"column:job_leve;type:bigint(20) unsigned;default:0;not null;comment:职务等级"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` |
|||
EiteTime int64 `json:"eitetime" gorm:"column:eite_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
|||
Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255) unsigned;default:'';not null;comment:微信UserId"` |
|||
WorkWechat string `json:"workwechat" gorm:"column:work_wechat;type:varchar(255) unsigned;default:'';not null;comment:企业微信UserId"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
IsAdmin int `json:"isadmin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管` |
|||
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"` |
|||
Role string `json:"role" gorm:"column:role;type:longtext;comment:角色"` |
|||
Idcardno string `json:"idcardno" gorm:"column:idcardno;type:varchar(50) unsigned;default:'';not null;comment:身份证号"` |
|||
Passportno string `json:"passportno" gorm:"column:passportno;type:varchar(50) unsigned;default:'';not null;comment:护照号码"` |
|||
Globalroaming string `json:"globalroaming" gorm:"column:globalroaming;type:varchar(50) unsigned;default:'';not null;comment:国际区号"` |
|||
Mobilephone string `json:"mobilephone" gorm:"column:mobilephone;type:varchar(50) unsigned;default:'';not null;comment:手机号码"` |
|||
Email string `json:"email" gorm:"column:email;type:varchar(255) unsigned;default:'';not null;comment:电子邮件"` |
|||
Gender int `json:"gender" gorm:"column:gender;type:tinyint(1) unsigned;default:1;not null;comment:性别(1:男性;2:女性;3:中性)"` |
|||
Birthday int64 `json:"birthday" gorm:"column:birthday;type:bigint(20) unsigned;default:0;not null;comment:birthday"` |
|||
Myfolk string `json:"myfolk" gorm:"column:myfolk;type:varchar(50) unsigned;default:'';not null;comment:民族"` |
|||
Nativeplace string `json:"nativeplace" gorm:"column:nativeplace;type:varchar(255) unsigned;default:'';not null;comment:籍贯"` |
|||
Idcardstartdate int64 `json:"idcardstartdate" gorm:"column:idcardstartdate;type:bigint(20) unsigned;default:0;not null;comment:身份证有效期开始"` |
|||
Idcardenddate int64 `json:"idcardenddate" gorm:"column:idcardenddate;type:bigint(20) unsigned;default:0;not null;comment:身份证有效期结束"` |
|||
Idcardaddress string `json:"idcardaddress" gorm:"column:idcardaddress;type:varchar(255) unsigned;default:'';not null;comment:身份证地址"` |
|||
IdcardIssued string `json:"idcardIssued" gorm:"column:idcardIssued;type:varchar(255) unsigned;default:'';not null;comment:身份证签发机关"` |
|||
Health int `json:"health" gorm:"column:health;type:tinyint(1) unsigned;default:1;not null;comment:健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)"` |
|||
Maritalstatus int `json:"maritalstatus" gorm:"column:maritalstatus;type:tinyint(1) unsigned;default:1;not null;comment:婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)"` |
|||
Internaltelephone string `json:"internaltelephone" gorm:"column:internaltelephone;type:varchar(255) unsigned;default:'';not null;comment:内线电话"` |
|||
Currentresidence string `json:"currentresidence" gorm:"column:currentresidence;type:varchar(255) unsigned;default:'';not null;comment:现居住地址"` |
|||
Constellation int `json:"constellationing" gorm:"column:constellationing;type:tinyint(3) unsigned;comment:星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)"` |
|||
Isdoubleworker int `json:"isdoubleworker" gorm:"column:isdoubleworker;type:tinyint(1) unsigned;default:1;comment:是否双职工(1:是;2:否)"` |
|||
Isveterans int `json:"isveterans" gorm:"column:isveterans;type:tinyint(1) unsigned;default:1;comment:是否为退役军人(1:是;2:否)"` |
|||
Veteransnumber string `json:"veteransnumber" gorm:"column:veteransnumber;type:varchar(255) unsigned;default:'';comment:退役证编号"` |
|||
Jobstartdate int64 `json:"jobstartdate" gorm:"column:jobstartdate;type:bigint(20) unsigned;default:0;comment:参加工作日期"` |
|||
Entrydate int64 `json:"entrydate" gorm:"column:entrydate;type:bigint(20) unsigned;default:0;comment:入职日期"` |
|||
Probationperiod int `json:"probationperiod" gorm:"column:probationperiod;type:int(5) unsigned;default:0;comment:试用期"` |
|||
Planformaldate int64 `json:"planformaldate" gorm:"column:planformaldate;type:bigint(20) unsigned;default:0;comment:预计转正日期"` |
|||
PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;type:tinyint(3) unsigned;default:1;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"` |
|||
} |
|||
|
|||
func (ManCont *ManCont) TableName() string { |
|||
return "man_cont" |
|||
} |
|||
|
|||
//获取职务分类内容
|
|||
func (cont *ManCont) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package models |
|||
|
|||
//菜单功能
|
|||
type MenuOperation struct { |
|||
OperId int64 `json:"operId" gorm:"primaryKey;column:oper_id;type:bigint(20) unsigned;not null;comment:功能ID"` |
|||
MenuId int64 `json:"menuId" gorm:"column:menu_id;type:bigint(20) unsigned;not null;default:0;comment:菜单id"` |
|||
OperTitle string `json:"operTitle" gorm:"column:oper_title;type:varchar(255);not null;comment:操作名称"` |
|||
} |
|||
|
|||
func (MenuOperation *MenuOperation) TableName() string { |
|||
return "menu_operation" |
|||
} |
|||
@ -0,0 +1,90 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//个人信息主表
|
|||
type WorkMan struct { |
|||
Id int64 `json:"id" gorm:"column:wm_id;type:bigint(20);;primaryKey;unique;not null;autoIncrement;index"` |
|||
Number string `json:"number" gorm:"column:wm_number;type:varchar(10);not null;comment:员工编号"` |
|||
Password string `json:"pwd" gorm:"column:wm_pwd;type:varchar(50);not null;comment:密码"` |
|||
DepartmentId int64 `json:"departmentid" gorm:"column:wm_bf_id;type:bigint(20) unsigned;default:0;not null;comment:分厂"` |
|||
WorkshopId int64 `json:"workshopid" gorm:"column:wm_ws_id;type:bigint(20) unsigned;default:0;not null;comment:工段"` |
|||
PostId int64 `json:"postid" gorm:"column:wm_pt_id;type:bigint(20) unsigned;default:0;not null;comment:职务"` |
|||
Key int64 `json:"key" gorm:"column:wm_key;type:bigint(50) unsigned;default:0;not null;comment:唯一识别码"` |
|||
State int `json:"state" gorm:"column:wm_set;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
HireSet int `json:"hireset" gorm:"column:wm_hire_set;type:tinyint(1) unsigned;default:1;not null;comment:雇佣状态(1:在职;2:离职)"` |
|||
Time int64 `json:"time" gorm:"column:wm_time;type:bigint(20) unsigned;default:0;not null;comment:添加事件"` |
|||
EiteTime int64 `json:"eitetime" gorm:"column:wm_eite_time;type:bigint(20) unsigned;default:0;not null;comment:修改事件"` |
|||
UserId int64 `json:"userid" gorm:"column:wm_user_id;type:bigint(50) unsigned;default:0;not null;comment:录入人"` |
|||
QuitTime int64 `json:"quitime" gorm:"column:wm_quit_time;type:bigint(20) unsigned;default:0;not null"` |
|||
Group int64 `json:"group" gorm:"column:wm_group;type:bigint(20) unsigned;default:0;not null;comment:集团公司"` |
|||
Soptcheck int `json:"soptcheck" gorm:"column:wm_soptcheck;type:tinyint(1) unsigned;default:1;not null"` |
|||
Tema int64 `json:"tema" gorm:"column:wm_tema;type:bigint(20) unsigned;default:0;not null;comment:班组"` |
|||
IsOne int `json:"isone" gorm:"column:wm_one;type:tinyint(1) unsigned;default:1;not null;comment:第一次登陆"` |
|||
WorkWechatId string `json:"workwechatid" gorm:"column:qywx_key;type:varchar(255);not null;comment:企业微信KEY"` |
|||
WechatId string `json:"wechatid" gorm:"column:wx_key;type:varchar(255);not null;comment:微信KEY"` |
|||
} |
|||
|
|||
func (WorkMan *WorkMan) TableName() string { |
|||
return "worker_man" |
|||
} |
|||
|
|||
//获取职务分类内容
|
|||
func (cont *WorkMan) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_Master.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//个人信息附表
|
|||
type WorkManAttribute struct { |
|||
KeyAttr int64 `json:"key" gorm:"column:wmd_key;type:bigint(50) unsigned;default:0;not null;comment:唯一识别符"` |
|||
Name string `json:"name" gorm:"column:wmd_name;type:varchar(50);not null;comment:姓名"` |
|||
Gender int `json:"gender" gorm:"column:wmd_gender;type:tinyint(1) unsigned;default:1;not null;comment:性别(1:男;2:女)"` |
|||
Age int `json:"age" gorm:"column:wmd_age;type:tinyint(3) unsigned;default:1;not null;comment:年龄"` |
|||
Tel string `json:"tel" gorm:"column:wmd_tel;type:varchar(25);not null;comment:联系方式"` |
|||
Category int `json:"category" gorm:"column:wmd_category;type:tinyint(1) unsigned;default:1;not null;comment:人员类别(1:正式工;2:合同工;3:实习生)"` |
|||
CertificatesType int `json:"certificatesType" gorm:"column:wmd_certificates_type;type:tinyint(1) unsigned;default:1;not null;comment:证件类型(1:身份证;2:驾驶证;3:军人证;4:护照;5:居住证)"` |
|||
CertificatesNum string `json:"certificatesNum" gorm:"column:wmd_certificates_number;type:varbinary(50);comment:证件编号"` |
|||
Birthday int64 `json:"birthday" gorm:"column:wmd_birthday;type:bigint(20) unsigned;default:0;not null;comment:出生日期"` |
|||
EntryTime int64 `json:"entryTime" gorm:"column:wmd_entry_time;type:bigint(20) unsigned;default:0;not null;comment:入职日期"` |
|||
QuitTimeAttr int64 `json:"quitTime" gorm:"column:wmd_quit_time;type:bigint(20) unsigned;default:0;not null;comment:离职日期"` |
|||
EiteTimeAttr int64 `json:"eiteTime" gorm:"column:wmd_eite_time;type:bigint(20) unsigned;default:0;not null;comment:修改时间"` |
|||
Addrest string `json:"addrest" gorm:"column:wmd_addrest;type:varchar(255);comment:家庭住址"` |
|||
Icon string `json:"icon" gorm:"column:wmd_icon;type:varchar(255);comment:照片"` |
|||
NickName string `json:"nickName" gorm:"column:wmd_nickname;type:varchar(255);comment:昵称"` |
|||
} |
|||
|
|||
func (WorkManAttribute *WorkManAttribute) TableName() string { |
|||
return "worker_man_data" |
|||
} |
|||
|
|||
//个人详细信息
|
|||
type PersonalDetails struct { |
|||
WorkMan |
|||
WorkManAttribute |
|||
} |
|||
|
|||
//Redis身份识别
|
|||
type RedisUserInfo struct { |
|||
Id string `json:"id"` |
|||
Number string `json:"number"` |
|||
DepartmentId string `json:"departmentid"` |
|||
WorkshopId string `json:"workshopid"` |
|||
PostId string `json:"postid"` |
|||
Key string `json:"key"` |
|||
Group string `json:"group"` |
|||
Tema string `json:"tema"` |
|||
WorkWechatId string `json:"workwechatid"` |
|||
WechatId string `json:"wechatid"` |
|||
Name string `json:"name"` |
|||
NickName string `json:"nickname"` |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//职务信息及类别、等级视图
|
|||
type OrgContType struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
|||
Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
TypeName string `json:"typename" gorm:"column:typename;type:varchar(255) unsigned;default:'';not null;comment:类型名称"` |
|||
Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` |
|||
IsPower int `json:"ispower" gorm:"column:ispower;type:int(1) unsigned;default:2;not null;comment:是否为实权部门"` |
|||
} |
|||
|
|||
func (OrgContType *OrgContType) TableName() string { |
|||
return "org_cont_type" |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *OrgContType) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,61 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//员工档案(主)
|
|||
type PersonArchives struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
|||
Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"` |
|||
HireClass int `json:"hireclass" gorm:"column:hire_class;type:tinyint(1) unsigned;default:1;not null;comment:雇佣类型(1:雇佣入职;2:再入职;)"` |
|||
EmpType int `json:"emptype" gorm:"column:emp_type;type:tinyint(1) unsigned;default:1;not null;comment:用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)"` |
|||
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` |
|||
MainDeparment int64 `json:"maindeparment" gorm:"column:maindeparment;type:bigint(20) unsigned;default:0;not null;comment:主部门"` |
|||
Deparment string `json:"deparment" gorm:"column:deparment;type:text;comment:部门"` |
|||
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` |
|||
TeamId int64 `json:"teamid" gorm:"column:teamid;type:bigint(20) unsigned;default:0;not null;comment:班组"` |
|||
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"` |
|||
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:2;not null;comment:职务分类"` |
|||
JobId int64 `json:"jobid" gorm:"column:job_id;type:bigint(20) unsigned;default:0;not null;comment:职务"` |
|||
JobLeve int64 `json:"jobleve" gorm:"column:job_leve;type:bigint(20) unsigned;default:0;not null;comment:职务等级"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` |
|||
EiteTime int64 `json:"eitetime" gorm:"column:eite_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
|||
Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255) unsigned;default:'';not null;comment:微信UserId"` |
|||
WorkWechat string `json:"workwechat" gorm:"column:work_wechat;type:varchar(255) unsigned;default:'';not null;comment:企业微信UserId"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
IsAdmin int `json:"isadmin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管` |
|||
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"` |
|||
Role string `json:"role" gorm:"column:role;type:longtext;comment:角色"` |
|||
|
|||
EmpTypeName string `json:"emptypename" gorm:"column:emp_type_name;type:varchar(255) unsigned;default:'';not null;comment:用工关系中文"` |
|||
HireClassName string `json:"hireclassname" gorm:"column:hire_class_name;type:varchar(255) unsigned;default:'';not null;comment:雇佣类型中文"` |
|||
|
|||
SunMainDeparment int64 `json:"sunmaindeparment" gorm:"column:sun_main_deparment;type:bigint(20) unsigned;default:0;not null;comment:主部门"` |
|||
} |
|||
|
|||
func (PersonArchives *PersonArchives) TableName() string { |
|||
return "person_archives" |
|||
} |
|||
|
|||
//编辑员工档案
|
|||
func (PersonArchives *PersonArchives) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&PersonArchives).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取员工档案
|
|||
func (cont *PersonArchives) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//员工档案(主)
|
|||
type Personnel struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
|||
HireClass int `json:"hireclass" gorm:"column:hire_class;type:tinyint(1) unsigned;default:1;not null;comment:雇佣类型(1:雇佣入职;2:再入职;)"` |
|||
PositionLevel int64 `json:"positionleveles" gorm:"column:positionleveles;type:bigint(20) unsigned;default:0;not null;comment:职位"` |
|||
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"` |
|||
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` |
|||
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` |
|||
EmpType int `json:"emptype" gorm:"column:emp_type;type:tinyint(1) unsigned;default:1;not null;comment:用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)"` |
|||
Deparment string `json:"deparment" gorm:"column:deparment;type:text;comment:部门"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` |
|||
EiteTime int64 `json:"eitetime" gorm:"column:eite_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
|||
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:2;not null;comment:职务分类"` |
|||
PositionGrade int64 `json:"positiongrade" gorm:"column:position_grade;type:bigint(20) unsigned;default:0;not null;comment:入职职等"` |
|||
Role string `json:"role" gorm:"column:role;type:longtext;comment:角色"` |
|||
Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255) unsigned;default:'';not null;comment:微信UserId"` |
|||
WorkWechat string `json:"workwechat" gorm:"column:work_wechat;type:varchar(255) unsigned;default:'';not null;comment:企业微信UserId"` |
|||
Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"` |
|||
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
IsAdmin int `json:"isadmin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管` |
|||
} |
|||
|
|||
func (Personnel *Personnel) TableName() string { |
|||
return "personnel" |
|||
} |
|||
|
|||
//编辑员工档案
|
|||
func (Personnel *Personnel) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&Personnel).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取员工档案
|
|||
func (cont *Personnel) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package models |
|||
|
|||
import "key_performance_indicators/overall" |
|||
|
|||
//人员变动记录
|
|||
type PersonnelChangeRecord struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
|||
Type int `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:1;comment:变动类型(1:雇佣入职;2:再入职;3:职位分配;4:转正;5:停薪留职;6:退休;7:辞退;8:离职)"` |
|||
Reason string `json:"reason" gorm:"column:reason;type:text;comment:变动原因"` |
|||
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;comment:职位"` |
|||
JobId int64 `json:"jobid" gorm:"column:job_id;type:bigint(20) unsigned;default:0;comment:职务"` |
|||
JobLevel int64 `json:"joblevel" gorm:"column:job_level;type:bigint(20) unsigned;default:'';comment:职务等级"` |
|||
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:0;comment:职务分类"` |
|||
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;comment:入职公司"` |
|||
MainDepartment int64 `json:"maindepartment" gorm:"column:main_department;type:bigint(20) unsigned;default:0;comment:主部门"` |
|||
Department string `json:"department" gorm:"column:department;type:varchar(255) unsigned;default:0;comment:入职分厂"` |
|||
Adminorg int64 `json:"adminorg" gorm:"column:adminorg;type:bigint(20) unsigned;default:0;comment:入职行政组织"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;comment:写入时间"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
} |
|||
|
|||
func (PersonnelChangeRecord *PersonnelChangeRecord) TableName() string { |
|||
return "personnel_change_record" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (PersonnelChangeRecord *PersonnelChangeRecord) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&PersonnelChangeRecord).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
type ManTransferLog struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
|||
Type int `json:"classtype" gorm:"column:classtype;type:tinyint(1) unsigned;default:1;comment:变动类型(1:雇佣入职;2:再入职;3:职位分配;4:转正;5:停薪留职;6:退休;7:辞退;8:离职)"` |
|||
Reason string `json:"reason" gorm:"column:reason;type:text;comment:变动原因"` |
|||
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;comment:职位"` |
|||
JobId int64 `json:"jobid" gorm:"column:job_id;type:bigint(20) unsigned;default:0;comment:职务"` |
|||
JobLevel int64 `json:"joblevel" gorm:"column:job_level;type:bigint(20) unsigned;default:'';comment:职务等级"` |
|||
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:0;comment:职务分类"` |
|||
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;comment:入职公司"` |
|||
MainDepartment int64 `json:"maindepartment" gorm:"column:main_department;type:bigint(20) unsigned;default:0;comment:主部门"` |
|||
Department string `json:"department" gorm:"column:department;type:varchar(255) unsigned;default:0;comment:入职分厂"` |
|||
Adminorg int64 `json:"adminorg" gorm:"column:adminorg;type:bigint(20) unsigned;default:0;comment:入职行政组织"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;comment:写入时间"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
} |
|||
|
|||
func (ManTransferLog *ManTransferLog) TableName() string { |
|||
return "man_transfer_log" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (ManTransferLog *ManTransferLog) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&ManTransferLog).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//员工附属信息
|
|||
|
|||
type PersonnelContent struct { |
|||
Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` |
|||
Idcardno string `json:"idcardno" gorm:"column:idcardno;type:varchar(50) unsigned;default:'';not null;comment:身份证号"` |
|||
Passportno string `json:"passportno" gorm:"column:passportno;type:varchar(50) unsigned;default:'';not null;comment:护照号码"` |
|||
Globalroaming string `json:"globalroaming" gorm:"column:globalroaming;type:varchar(50) unsigned;default:'';not null;comment:国际区号"` |
|||
Mobilephone string `json:"mobilephone" gorm:"column:mobilephone;type:varchar(50) unsigned;default:'';not null;comment:手机号码"` |
|||
Email string `json:"email" gorm:"column:email;type:varchar(255) unsigned;default:'';not null;comment:电子邮件"` |
|||
Gender int `json:"gender" gorm:"column:gender;type:tinyint(1) unsigned;default:1;not null;comment:性别(1:男性;2:女性;3:中性)"` |
|||
Birthday int64 `json:"birthday" gorm:"column:birthday;type:bigint(20) unsigned;default:0;not null;comment:birthday"` |
|||
Myfolk string `json:"myfolk" gorm:"column:myfolk;type:varchar(50) unsigned;default:'';not null;comment:民族"` |
|||
Nativeplace string `json:"nativeplace" gorm:"column:nativeplace;type:varchar(255) unsigned;default:'';not null;comment:籍贯"` |
|||
Idcardstartdate int64 `json:"idcardstartdate" gorm:"column:idcardstartdate;type:bigint(20) unsigned;default:0;not null;comment:身份证有效期开始"` |
|||
Idcardenddate int64 `json:"idcardenddate" gorm:"column:idcardenddate;type:bigint(20) unsigned;default:0;not null;comment:身份证有效期结束"` |
|||
Idcardaddress string `json:"idcardaddress" gorm:"column:idcardaddress;type:varchar(255) unsigned;default:'';not null;comment:身份证地址"` |
|||
IdcardIssued string `json:"idcardIssued" gorm:"column:idcardIssued;type:varchar(255) unsigned;default:'';not null;comment:身份证签发机关"` |
|||
Health int `json:"health" gorm:"column:health;type:tinyint(1) unsigned;default:1;not null;comment:健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)"` |
|||
Maritalstatus int `json:"maritalstatus" gorm:"column:maritalstatus;type:tinyint(1) unsigned;default:1;not null;comment:婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)"` |
|||
Internaltelephone string `json:"internaltelephone" gorm:"column:internaltelephone;type:varchar(255) unsigned;default:'';not null;comment:内线电话"` |
|||
Currentresidence string `json:"currentresidence" gorm:"column:currentresidence;type:varchar(255) unsigned;default:'';not null;comment:现居住地址"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
Constellation int `json:"constellationing" gorm:"column:constellationing;type:tinyint(3) unsigned;comment:星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)"` |
|||
Isdoubleworker int `json:"isdoubleworker" gorm:"column:isdoubleworker;type:tinyint(1) unsigned;default:1;comment:是否双职工(1:是;2:否)"` |
|||
Isveterans int `json:"isveterans" gorm:"column:isveterans;type:tinyint(1) unsigned;default:1;comment:是否为退役军人(1:是;2:否)"` |
|||
Veteransnumber string `json:"veteransnumber" gorm:"column:veteransnumber;type:varchar(255) unsigned;default:'';comment:退役证编号"` |
|||
Jobstartdate int64 `json:"jobstartdate" gorm:"column:jobstartdate;type:bigint(20) unsigned;default:0;comment:参加工作日期"` |
|||
Entrydate int64 `json:"entrydate" gorm:"column:entrydate;type:bigint(20) unsigned;default:0;comment:入职日期"` |
|||
Probationperiod int `json:"probationperiod" gorm:"column:probationperiod;type:int(5) unsigned;default:0;comment:试用期"` |
|||
Planformaldate int64 `json:"planformaldate" gorm:"column:planformaldate;type:bigint(20) unsigned;default:0;comment:预计转正日期"` |
|||
PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;type:tinyint(3) unsigned;default:1;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
|
|||
MaritalstatusCn string `json:"maritalstatuscn" gorm:"column:maritalstatus_cn;type:varchar(50) unsigned;default:'';not null;comment:婚姻状况汉字说明"` |
|||
ConstellationingCn string `json:"constellationingcn" gorm:"column:constellationing_cn;type:varchar(50) unsigned;default:'';not null;comment:星座汉字说明"` |
|||
PoliticalOutlookCn string `json:"politicaloutlookcn" gorm:"column:political_outlook_cn;type:varchar(50) unsigned;default:'';not null;comment:政治面貌汉字说明"` |
|||
HealthCn string `json:"healthcn" gorm:"column:health_cn;type:varchar(50) unsigned;default:'';not null;comment:健康状况中文说明"` |
|||
} |
|||
|
|||
func (PersonnelContent *PersonnelContent) TableName() string { |
|||
return "personnel_content" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (PersonnelContent *PersonnelContent) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&PersonnelContent).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取职务分类内容
|
|||
func (cont *PersonnelContent) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//教育经历
|
|||
|
|||
type PersonnelEducation struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;comment:员工工号"` |
|||
Education int `json:"education" gorm:"column:education;type:int(5) unsigned;default:1;comment:学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)"` |
|||
GraduationSchool string `json:"graduationschool" gorm:"column:graduation_school;type:varchar(255) unsigned;default:'';comment:毕业学校"` |
|||
Subject string `json:"subject" gorm:"column:subject;type:varchar(255) unsigned;default:'';comment:专业"` |
|||
AdmissionTime int64 `json:"admissiontime" gorm:"column:admission_time;type:bigint(20) unsigned;default:0;comment:入学时间"` |
|||
GraduationTime int64 `json:"graduationtime" gorm:"column:graduation_time;type:bigint(20) unsigned;default:0;comment:毕业时间"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;comment:写入时间"` |
|||
Level int `json:"level" gorm:"column:level;type:tinyint(1) unsigned;default:1;comment:学历类型(1:普通;2:第一学历;3:最高学历)"` |
|||
AcademicDegree int `json:"academicdegree" gorm:"column:academic_degree;type:tinyint(2) unsigned;default:1;comment:学位(1:无;2:学士;3:硕士;4:博士)"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
|
|||
AcademicDegreeCn string `json:"academicdegreecn" gorm:"column:academic_degree_cn;type:varchar(30) unsigned;comment:学位中文说明"` |
|||
EducationCn string `json:"educationcn" gorm:"column:education_cn;type:varchar(30) unsigned;comment:学历中文说明"` |
|||
} |
|||
|
|||
func (PersonnelEducation *PersonnelEducation) TableName() string { |
|||
return "personnel_education" |
|||
} |
|||
|
|||
//编辑教育经历内容
|
|||
func (PersonnelEducation *PersonnelEducation) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&PersonnelEducation).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取教育经历内容
|
|||
func (cont *PersonnelEducation) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//图片库
|
|||
type PhotosGallery struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Url string `json:"url" gorm:"column:url;type:varchar(255) unsigned;default:'';not null;comment:图片地址"` |
|||
ImgPath string `json:"imgpath" gorm:"column:img_path;type:varchar(255) unsigned;default:'';not null;comment:物理地址"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:文档名称"` |
|||
FileSize string `json:"filesize" gorm:"column:file_size;type:varchar(255) unsigned;default:'';not null;comment:文档大小"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
AscriptionId int64 `json:"ascriptionid" gorm:"column:ascription_id;type:bigint(20) unsigned;default:0;not null;comment:归属"` |
|||
AscriptionDataSheet string `json:"ascriptiondatasheet" gorm:"column:ascription_data_sheet;type:varchar(255) unsigned;default:'';not null;comment:归属拿个数据表"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
} |
|||
|
|||
func (PhotosGallery *PhotosGallery) TableName() string { |
|||
return "photos_gallery" |
|||
} |
|||
|
|||
//编辑图片库内容
|
|||
func (cont *PhotosGallery) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取图片库内容
|
|||
func (cont *PhotosGallery) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_MANAGE_ARCHIVES.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//删除内容
|
|||
func (cont *PhotosGallery) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_MANAGE_ARCHIVES.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//职位(岗位)
|
|||
type Position struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:职位编码"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:职位名称"` |
|||
Duties int64 `json:"duties" gorm:"column:duties;type:bigint(20) unsigned;default:0;not null;comment:职务"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
AdministrativeOrganization int64 `json:"administrativeorganization" gorm:"column:administrative_organization;type:bigint(20) unsigned;default:0;not null;comment:归属行政组织"` |
|||
Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` |
|||
PersonInCharge int `json:"personincharge" gorm:"column:person_in_charge;type:int(1) unsigned;default:2;not null;comment:是否为本部门负责人(1:是;2:否)"` |
|||
Department int64 `json:"department" gorm:"column:department;type:bigint(20) unsigned;default:0;not null;comment:部门"` |
|||
MenuPermit string `json:"menupermit" gorm:"column:menu_permit;type:longtext;comment:菜单许可证"` |
|||
ButtonPermit string `json:"buttonpermit" gorm:"column:button_permit;type:longtext;comment:按钮许可"` |
|||
School int64 `json:"school" gorm:"column:school;type:bigint(20) unsigned;default:0;not null;comment:部门"` |
|||
KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
|||
} |
|||
|
|||
func (Position *Position) TableName() string { |
|||
return "position" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (cont *Position) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取行政组织内容
|
|||
func (cont *Position) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//根据条件获取总数
|
|||
func (cont *Position) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package models |
|||
|
|||
import "key_performance_indicators/overall" |
|||
|
|||
//职位等级
|
|||
type PositionLevel struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:等级编号"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:等级名称"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
PositionId int64 `json:"positionid" gorm:"column:positionid;type:bigint(20) unsigned;default:0;not null;comment:归属哪个职务"` |
|||
} |
|||
|
|||
func (PositionLevel *PositionLevel) TableName() string { |
|||
return "position_level" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (PositionLevel *PositionLevel) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&PositionLevel).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//职务与岗位视图
|
|||
|
|||
type PostDutiesJob struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:职位编码"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:职位名称"` |
|||
PersonInCharge int `json:"personincharge" gorm:"column:perincha;type:int(1) unsigned;default:2;not null;comment:是否为本部门负责人(1:是;2:否)"` |
|||
Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` |
|||
Duties int64 `json:"duties" gorm:"column:duties;type:bigint(20) unsigned;default:0;not null;comment:职务"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
AdministrativeOrganization int64 `json:"administrativeorganization" gorm:"column:adm_org;type:bigint(20) unsigned;default:0;not null;comment:归属行政组织"` |
|||
Department int64 `json:"department" gorm:"column:department;type:bigint(20) unsigned;default:0;not null;comment:部门"` |
|||
MenuPermit string `json:"menupermit" gorm:"column:menu_permit;type:longtext;comment:菜单许可证"` |
|||
ButtonPermit string `json:"buttonpermit" gorm:"column:button_permit;type:longtext;comment:按钮许可"` |
|||
School int64 `json:"school" gorm:"column:school;type:bigint(20) unsigned;default:0;not null;comment:部门"` |
|||
DutiesName string `json:"dutiesname" gorm:"column:duties_name;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` |
|||
DutiesNumber string `json:"dutiesnumber" gorm:"column:duties_number;type:varchar(50) unsigned;default:'';not null;comment:编码"` |
|||
Weight int64 `json:"weight" gorm:"column:weight;type:bigint(20) unsigned;default:1;not null;comment:权重"` |
|||
JobType int64 `json:"jobtype" gorm:"column:job_type;type:bigint(20) unsigned;default:0;not null;comment:归属职务类型"` |
|||
JobName string `json:"jobname" gorm:"column:job_name;type:varchar(255) unsigned;default:'';not null;comment:职务分类名称"` |
|||
} |
|||
|
|||
func (PostDutiesJob *PostDutiesJob) TableName() string { |
|||
return "post_duties_job" |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *PostDutiesJob) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package models |
|||
|
|||
import "key_performance_indicators/overall" |
|||
|
|||
//角色组(审批流程使用)
|
|||
type RoleGroup struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:srg_id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Title string `json:"title" gorm:"column:srg_name;type:text;comment:角色名称"` |
|||
Group int64 `json:"group" gorm:"column:srg_group;type:bigint(20) unsigned;default:0;not null;comment:角色归属"` |
|||
Addtime int64 `json:"addtime" gorm:"column:srg_time;type:bigint(20) unsigned;default:0;not null;comment:添加时间"` |
|||
State int `json:"state" gorm:"column:srg_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
Contentes string `json:"content" gorm:"column:srg_extatry;type:mediumtext;comment:操作组"` |
|||
Type int `json:"type" gorm:"column:srg_type;type:int(1) unsigned;default:1;not null;comment:操作类型(1:部门矩阵;2:个人)"` |
|||
} |
|||
|
|||
func (RoleGroup *RoleGroup) TableName() string { |
|||
return "step_role_group" |
|||
} |
|||
|
|||
//获取详情
|
|||
func (cont *RoleGroup) GetCont(where interface{}, filed ...string) error { |
|||
gormDb := overall.CONSTANT_DB_Master.Where(where) |
|||
if len(filed) > 0 { |
|||
for _, v := range filed { |
|||
gormDb = gormDb.Select(v) |
|||
} |
|||
} |
|||
err := gormDb.First(&cont).Error |
|||
return err |
|||
} |
|||
|
|||
//编辑内容
|
|||
func (cont *RoleGroup) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//菜单
|
|||
type SystemMenu struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:m_id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Title string `json:"title" gorm:"column:m_title;type:varchar(255);not null;comment:菜单名称"` |
|||
State int `json:"state" gorm:"column:m_steat;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` |
|||
ParentId int64 `json:"parentId" gorm:"column:m_parent;type:bigint(30) unsigned;default:0;not null;comment:'父级(顶级:0)"` |
|||
ApiUrl string `json:"apiUrl" gorm:"column:m_url;type:varchar(255);not null;comment:地址"` |
|||
Time int64 `json:"time" gorm:"column:m_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"` |
|||
EiteTime int64 `json:"eiteTime" gorm:"column:m_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"` |
|||
UserId int64 `json:"userId" gorm:"column:m_user_id;type:bigint(20) unsigned;not null;default:0;comment:写入人"` |
|||
Sort int `json:"sort" gorm:"column:m_sort;type:tinyint(3) unsigned;default:0;not null;comment:排序"` |
|||
} |
|||
|
|||
func (SystemMenu *SystemMenu) TableName() string { |
|||
return "system_menu" |
|||
} |
|||
|
|||
//菜单管理
|
|||
type SystemMenuOperation struct { |
|||
SystemMenu |
|||
MenuPermit []MenuOperation `json:"menupermit"` |
|||
} |
|||
|
|||
//根据条件获取总数
|
|||
func (cont *SystemMenu) CountCont(whereMap map[string]interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
//获取行政组织内容
|
|||
func (cont *SystemMenu) GetCont(whereMap map[string]interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_Master.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
package models |
|||
|
|||
import "key_performance_indicators/overall" |
|||
|
|||
type SystemRole struct { |
|||
Id int64 `json:"id" gorm:"column:r_id;type:bigint(20) unsigned;not null;comment:Id"` |
|||
Title string `json:"title" gorm:"column:r_title;type:varchar(36);not null;comment:角色名称"` |
|||
State int `json:"state" gorm:"column:r_set;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` |
|||
Attribute int64 `json:"attribute" gorm:"column:r_attribute;type:bigint(20) unsigned;default:0;not null;comment:属性"` |
|||
Gode int `json:"gode" gorm:"column:r_gode;type:tinyint(1) unsigned;default:1;not null;comment:继承属性(1:系统管理员;2:分厂管理员)"` |
|||
Time int64 `json:"time" gorm:"column:r_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
UserId int64 `json:"userId" gorm:"column:r_user_id;type:bigint(50) unsigned;default:0;not null;comment:写入人"` |
|||
Jurisdiction string `json:"jurisdiction" gorm:"column:r_jurisdiction;type:text;not null;comment:权限"` |
|||
MenuOper string `json:"menuoper" gorm:"column:r_menu_oper;type:text;not null;comment:权限"` |
|||
Wand int `json:"wand" gorm:"column:r_wand;type:tinyint(2) unsigned;default:0;not null;comment:权杖"` |
|||
Group int64 `json:"group" gorm:"column:r_group;type:bigint(20) unsigned;not null;default:3;comment:归属集团"` |
|||
} |
|||
|
|||
func (SystemRole *SystemRole) TableName() string { |
|||
return "system_role" |
|||
} |
|||
|
|||
//获取详情
|
|||
func (cont *SystemRole) GetCont(where interface{}, filed ...string) error { |
|||
gormDb := overall.CONSTANT_DB_Master.Where(where) |
|||
if len(filed) > 0 { |
|||
for _, v := range filed { |
|||
gormDb = gormDb.Select(v) |
|||
} |
|||
} |
|||
err := gormDb.First(&cont).Error |
|||
return err |
|||
} |
|||
|
|||
//编辑内容
|
|||
func (cont *SystemRole) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package models |
|||
|
|||
import "key_performance_indicators/overall" |
|||
|
|||
//系统用户表
|
|||
type SystemUser struct { |
|||
Id int64 `json:"id" gorm:"column:u_id;type:bigint(20) unsigned;not null;comment:Id"` |
|||
Name string `json:"name" gorm:"column:u_name;type:varchar(36);not null;comment:用户名"` |
|||
PassWord string `json:"passWord" gorm:"column:u_password;type:varchar(30);not null;comment:密码"` |
|||
Role int64 `json:"role" gorm:"column:u_role;type:bigint(20) unsigned;not null;default:1;comment:用户类型"` |
|||
State int `json:"state" gorm:"column:u_set;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` |
|||
Attribute int64 `json:"attribute" gorm:"column:u_attribute;type:bigint(20) unsigned;not null;default:0;comment:账号属性"` |
|||
Time int64 `json:"time" gorm:"column:u_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"` |
|||
EiteTime int64 `json:"eiteTime" gorm:"column:u_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"` |
|||
Key int64 `json:"key" gorm:"column:u_key;type:bigint(50) unsigned;default:0;not null;comment:唯一识别码"` |
|||
Group int64 `json:"group" gorm:"column:u_group;type:bigint(20) unsigned;not null;default:0;comment:集团公司"` |
|||
Wand int `json:"wand" gorm:"column:u_wand;type:tinyint(3) unsigned;default:0;not null;comment:权重"` |
|||
} |
|||
|
|||
func (SystemUser *SystemUser) TableName() string { |
|||
return "system_user" |
|||
} |
|||
|
|||
//获取详情
|
|||
func (cont *SystemUser) GetCont(where interface{}, filed ...string) error { |
|||
gormDb := overall.CONSTANT_DB_Master.Where(where) |
|||
if len(filed) > 0 { |
|||
for _, v := range filed { |
|||
gormDb = gormDb.Select(v) |
|||
} |
|||
} |
|||
err := gormDb.First(&cont).Error |
|||
return err |
|||
} |
|||
|
|||
//编辑内容
|
|||
func (cont *SystemUser) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
package models |
|||
|
|||
import "key_performance_indicators/overall" |
|||
|
|||
//系统管理员属性资料
|
|||
type SystemUserAttribute struct { |
|||
IdAttr int64 `json:"id" gorm:"column:ua_id;type:bigint(50) unsigned;not null;comment:Id"` |
|||
NameAttr string `json:"name" gorm:"column:ua_name;type:varchar(20);not null;comment:姓名"` |
|||
Tel string `json:"tel" gorm:"column:ua_tel;type:varchar(30);not null;default:0;comment:电话"` |
|||
TimeAttr int64 `json:"time" gorm:"column:ua_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
} |
|||
|
|||
func (SystemUserAttribute *SystemUserAttribute) TableName() string { |
|||
return "system_user_attribute" |
|||
} |
|||
|
|||
//获取详情
|
|||
func (cont *SystemUserAttribute) GetCont(where interface{}, filed ...string) error { |
|||
gormDb := overall.CONSTANT_DB_Master.Where(where) |
|||
if len(filed) > 0 { |
|||
for _, v := range filed { |
|||
gormDb = gormDb.Select(v) |
|||
} |
|||
} |
|||
err := gormDb.First(&cont).Error |
|||
return err |
|||
} |
|||
|
|||
//编辑内容
|
|||
func (cont *SystemUserAttribute) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//班组
|
|||
type TeamGroup struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:班组名称"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
} |
|||
|
|||
func (TeamGroup *TeamGroup) TableName() string { |
|||
return "teamgroup" |
|||
} |
|||
|
|||
//编辑班组内容
|
|||
func (TeamGroup *TeamGroup) EiteTeamGroupCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&TeamGroup).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取详细内容
|
|||
func (cont *TeamGroup) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package models |
|||
|
|||
//企业微信人员架构
|
|||
type WechatUsers struct { |
|||
Uid int64 `json:"uid" gorm:"column:u_id;type:bigint(20) unsigned;default:0;not null;comment:id"` |
|||
Userid string `json:"userid" gorm:"column:userid;type:varchar(255);not null;comment:wechat user id企业微信用户ID"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(100);not null;comment:姓名"` |
|||
Department string `json:"department" gorm:"column:department;type:text;comment:归属部门json"` |
|||
Position string `json:"position" gorm:"column:position;type:varchar(255);not null;comment:企业微信职务"` |
|||
Mobile string `json:"mobile" gorm:"column:mobile;type:varchar(100);not null;comment:企业微信电话"` |
|||
Gender int `json:"gender" gorm:"column:gender;type:tinyint(1) unsigned;default:1;not null;comment:性别。1表示男性,2表示女性"` |
|||
Email string `json:"email" gorm:"column:email;type:varchar(255);not null;comment:邮箱"` |
|||
Avatar string `json:"avatar" gorm:"column:avatar;type:varchar(255);not null;comment:员工头像"` |
|||
Status int `json:"status" gorm:"column:status;type:tinyint(1) unsigned;default:1;not null;comment:激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业。"` |
|||
Extattr string `json:"extattr" gorm:"column:extattr;type:mediumtext;comment:企业微信员工扩展属性"` |
|||
MainDepartment int64 `json:"main_department" gorm:"column:main_department;type:int(8) unsigned;default:0;not null;comment:主部门"` |
|||
QrCode string `json:"qr_code" gorm:"column:qr_code;type:text;comment:员工个人二维码,扫描可添加为外部联系人(注意返回的是一个url,可在浏览器上打开该url以展示二维码);第三方仅通讯录应用可获取;对于非第三方创建的成员,第三方通讯录应用也不可获取"` |
|||
IsLeaderInDept string `json:"is_leader_in_dept" gorm:"column:is_leader_in_dept;type:text;comment:表示在所在的部门内是否为上级。0-否;1-是。是一个列表,数量必须与department一致。第三方仅通讯录应用可获取;对于非第三方创建的成员,第三方通讯录应用也不可获取"` |
|||
ThumbAvatar string `json:"thumb_avatar" gorm:"column:thumb_avatar;type:varchar(255);not null;comment:头像缩略图url"` |
|||
UserNumber string `json:"user_number" gorm:"column:user_number;type:varchar(8);not null;comment:工号"` |
|||
SysBf int64 `json:"sys_bf" gorm:"column:sys_bf;type:int(20) unsigned;default:0;not null;comment:系统分厂"` |
|||
SysWs int64 `json:"sys_ws" gorm:"column:sys_ws;type:int(20) unsigned;default:0;not null;comment:系统工段"` |
|||
SysPs int64 `json:"sys_ps" gorm:"column:sys_ps;type:int(20) unsigned;default:0;not null;comment:系统职务"` |
|||
WmTema int64 `json:"wm_tema" gorm:"column:wm_tema;type:int(20) unsigned;default:0;not null;comment:系统班组"` |
|||
IsAdmin int `json:"is_admin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:管理员1、否;2:是"` |
|||
IsRole int64 `json:"is_role" gorm:"column:is_role;type:int(20) unsigned;default:0;not null;comment:角色"` |
|||
Pwd string `json:"pwd" gorm:"column:pwd;type:varchar(255);not null;comment:密码"` |
|||
Time int64 `json:"time" gorm:"column:time;type:int(20) unsigned;default:0;not null;comment:写入时间"` |
|||
} |
|||
|
|||
func (WechatUsers *WechatUsers) TableName() string { |
|||
// return "wechatusers_es"
|
|||
return "wechatusers" |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
//工作履历
|
|||
type WorkHistory struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
|||
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:工号"` |
|||
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:身份识别"` |
|||
Company string `json:"company" gorm:"column:company;type:varchar(255) unsigned;default:'';comment:公司"` |
|||
Deparment string `json:"deparment" gorm:"column:deparment;type:varchar(255) unsigned;default:'';comment:部门"` |
|||
Job string `json:"job" gorm:"column:job;type:varchar(255) unsigned;default:'';comment:职务"` |
|||
EntryTime int64 `json:"entrytime" gorm:"column:entry_time;type:bigint(20) unsigned;default:0;not null;comment:入职时间"` |
|||
Leavedate int64 `json:"leavedate" gorm:"column:leavedate;type:bigint(20) unsigned;default:0;not null;comment:离职日期"` |
|||
Witness string `json:"witness" gorm:"column:witness;type:varchar(255) unsigned;default:'';comment:证明人"` |
|||
WitnessTel string `json:"witnesstel" gorm:"column:witness_tel;type:varchar(255) unsigned;default:'';comment:证明人电话"` |
|||
Remarks string `json:"remarks" gorm:"column:remarks;type:text unsigned;default:'';comment:备注"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
} |
|||
|
|||
func (WorkHistory *WorkHistory) TableName() string { |
|||
return "work_history" |
|||
} |
|||
|
|||
//编辑职务分类内容
|
|||
func (cont *WorkHistory) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
//获取行政组织内容
|
|||
func (cont *WorkHistory) GetCont(whereMap interface{}, field ...string) (err error) { |
|||
gormDb := overall.CONSTANT_DB_HR.Model(&cont) |
|||
if len(field) > 0 { |
|||
fieldStr := strings.Join(field, ",") |
|||
gormDb = gormDb.Select(fieldStr) |
|||
} |
|||
gormDb = gormDb.Where(whereMap) |
|||
err = gormDb.First(&cont).Error |
|||
return |
|||
} |
|||
|
|||
//根据条件获取总数
|
|||
func (cont *WorkHistory) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package publicmethod |
|||
|
|||
var ErrorCodeMsg = map[int]string{ |
|||
0: "成功", |
|||
1: "", |
|||
100: "提交的数据格式错误!", |
|||
101: "提交的数据不能为空!", |
|||
103: "该数据已经存在!请不要重复添加", |
|||
104: "数据写入失败!", |
|||
105: "数据查询失败!", |
|||
106: "编辑失败!", |
|||
107: "未能查询到数据!", |
|||
108: "删除失败", |
|||
2000: "账户或密码错误!", |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package publicmethod |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"errors" |
|||
"fmt" |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall" |
|||
"net/http" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//格式化输出
|
|||
func Result(code int, data interface{}, c *gin.Context, msgAry ...string) { |
|||
var msg string |
|||
if _, isTrue := ErrorCodeMsg[code]; isTrue { |
|||
msg = ErrorCodeMsg[code] |
|||
} |
|||
if len(msgAry) > 0 { |
|||
for _, v := range msgAry { |
|||
msg = fmt.Sprintf("%v。%v", msg, v) |
|||
} |
|||
} |
|||
c.JSON(http.StatusOK, Reply{code, msg, data}) //输出json格式数据
|
|||
} |
|||
|
|||
//列表输出标准格式
|
|||
/* |
|||
@total 总数 |
|||
@count 当前页总数 |
|||
@page 页数 |
|||
@pageSize 每页显示数量 |
|||
@data 返回数据 |
|||
*/ |
|||
func ResultList(code, page, pageSize int, total, count int64, data interface{}, c *gin.Context) (printMap map[string]interface{}) { |
|||
outMap := MapOut[string]() |
|||
outMap["count"] = count |
|||
outMap["total"] = total |
|||
outMap["page"] = page |
|||
outMap["pageSize"] = pageSize |
|||
outMap["list"] = data |
|||
printMap = outMap |
|||
Result(code, outMap, c) |
|||
return |
|||
} |
|||
|
|||
//登录信息转换
|
|||
func LoginMyCont(c *gin.Context) (myCont models.ManCont, err error) { |
|||
context, exi := c.Get(overall.MyContJwt) |
|||
if exi != true { |
|||
err = errors.New("对不起!你没有该功能的操作权限!1") |
|||
return |
|||
} |
|||
jsonCont, jsonErr := json.Marshal(context) |
|||
if jsonErr != nil { |
|||
err = jsonErr |
|||
return |
|||
} |
|||
jsonUnErr := json.Unmarshal(jsonCont, &myCont) |
|||
if jsonUnErr != nil { |
|||
err = jsonUnErr |
|||
return |
|||
} |
|||
return |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
package publicmethod |
|||
|
|||
import ( |
|||
"fmt" |
|||
"key_performance_indicators/overall" |
|||
"log" |
|||
"os" |
|||
"time" |
|||
) |
|||
|
|||
//日志相关操作
|
|||
//判断文件夹是否存在,不存在得话就创建
|
|||
/* |
|||
@path 日志文件夹 |
|||
*/ |
|||
func PathExists(path string) bool { |
|||
_, err := os.Stat(path) |
|||
// fmt.Printf("path----->%v\n", err)
|
|||
if err == nil { |
|||
return true |
|||
} |
|||
if os.IsNotExist(err) { |
|||
mkdirErr := os.Mkdir(path, os.ModePerm) |
|||
if mkdirErr == nil { |
|||
return true |
|||
} else { |
|||
return false |
|||
} |
|||
} |
|||
return true |
|||
} |
|||
|
|||
//写日志
|
|||
func WriteLog(class string, errmsg ...any) { |
|||
// var ErrorLog *log.Logger
|
|||
fileName := fmt.Sprintf("./%v/%v", overall.CONSTANT_CONFIG.Logsetup.Path, UnixTimeToDay(time.Now().Unix(), 21)) |
|||
// fmt.Printf("fileName--->%v\n", fileName)
|
|||
if PathExists(fileName) != true { |
|||
return |
|||
} |
|||
logFilePath := fmt.Sprintf("%v/%v.log", fileName, UnixTimeToDay(time.Now().Unix(), 20)) |
|||
file, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0766) |
|||
if err != nil { |
|||
log.Fatalln("Failed to open error log file: ", err) |
|||
} |
|||
// fmt.Printf("logFilePath--->%v\n", logFilePath)
|
|||
errLevel := "[Trace] " |
|||
switch class { |
|||
case "i": |
|||
errLevel = "[Info] " |
|||
case "w": |
|||
errLevel = "[Warning] " |
|||
case "e": |
|||
errLevel = "[Error] " |
|||
case "write": |
|||
errLevel = "[Write] " |
|||
case "add": |
|||
errLevel = "[Add] " |
|||
case "edit": |
|||
errLevel = "[Edit] " |
|||
case "del": |
|||
errLevel = "[Delete] " |
|||
default: |
|||
errLevel = "[Trace] " |
|||
} |
|||
|
|||
loger := log.New(file, errLevel, log.Ldate|log.Ltime) |
|||
loger.SetFlags(log.Ldate | log.Ltime) |
|||
loger.Println(errmsg) |
|||
return |
|||
} |
|||
@ -0,0 +1,488 @@ |
|||
package publicmethod |
|||
|
|||
import ( |
|||
"bytes" |
|||
"crypto/md5" |
|||
"crypto/rand" |
|||
"crypto/sha1" |
|||
"encoding/hex" |
|||
"errors" |
|||
"fmt" |
|||
"key_performance_indicators/middleware/grocerystore" |
|||
"key_performance_indicators/models" |
|||
"key_performance_indicators/overall" |
|||
"math" |
|||
"math/big" |
|||
"reflect" |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/mozillazg/go-pinyin" |
|||
"gorm.io/gorm" |
|||
) |
|||
|
|||
//全局函数处理
|
|||
//编号,纯数字
|
|||
func TableNumber(class ...string) (number int64) { |
|||
result, _ := rand.Int(rand.Reader, big.NewInt(8999)) |
|||
numberTeam := result.Int64() + 1000 |
|||
numberStr := fmt.Sprintf("%v%v", time.Now().Unix(), numberTeam) |
|||
if len(class) > 0 { |
|||
resultLong, _ := rand.Int(rand.Reader, big.NewInt(8999999)) |
|||
numberTeamLong := resultLong.Int64() + 1000000 |
|||
numberStr = fmt.Sprintf("%v%v", time.Now().Unix(), numberTeamLong) |
|||
} |
|||
number, _ = strconv.ParseInt(numberStr, 10, 64) |
|||
return |
|||
} |
|||
|
|||
//初始化map(泛型)
|
|||
func MapOut[T GenericityVariable]() (data map[T]interface{}) { |
|||
data = make(map[T]interface{}) //必可不少,分配内存
|
|||
return data |
|||
} |
|||
|
|||
//时间搓转换成日期
|
|||
/* |
|||
@timestamp 待转换的时间戳 |
|||
@timeType 转换类型 |
|||
*/ |
|||
func UnixTimeToDay(timeStamp int64, timeType int) (dateStr string) { |
|||
timeTemplate := "2006-01-02 15:04:05" //常规类型
|
|||
switch timeType { |
|||
case 1: |
|||
timeTemplate = "2006/01/02 15:04:05" |
|||
case 2: |
|||
timeTemplate = "2006/01/02 15:04" |
|||
case 3: |
|||
timeTemplate = "2006/01/02 15" |
|||
case 4: |
|||
timeTemplate = "2006/01/02" |
|||
case 5: |
|||
timeTemplate = "15:04:05" |
|||
case 6: |
|||
timeTemplate = "15:04" |
|||
case 7: |
|||
timeTemplate = "15" |
|||
case 8: |
|||
timeTemplate = "04:05" |
|||
case 9: |
|||
timeTemplate = "04" |
|||
case 10: |
|||
timeTemplate = "05" |
|||
case 11: |
|||
timeTemplate = "2006-01-02 15:04:05" |
|||
case 12: |
|||
timeTemplate = "2006-01-02 15:04" |
|||
case 13: |
|||
timeTemplate = "2006-01-02 15" |
|||
case 14: |
|||
timeTemplate = "2006-01-02" |
|||
case 15: |
|||
timeTemplate = "2006-01" //年月
|
|||
case 16: |
|||
timeTemplate = "2006" //年
|
|||
case 17: |
|||
timeTemplate = "01" //月
|
|||
case 18: |
|||
timeTemplate = "02" //日
|
|||
case 19: //季度
|
|||
dayMonth := time.Unix(timeStamp, 0).Format("01") |
|||
datMonthFloat, datMonthFloatErr := strconv.ParseFloat(dayMonth, 10) |
|||
if datMonthFloatErr == nil { |
|||
dateStr = strconv.FormatFloat(math.Ceil(datMonthFloat/3), 'f', -1, 64) |
|||
} |
|||
dateStr = "1" |
|||
case 20: |
|||
timeTemplate = "20060102" |
|||
case 21: |
|||
timeTemplate = "200601" |
|||
default: |
|||
timeTemplate = "2006-01-02 15:04:05" //常规类型
|
|||
} |
|||
dateStr = time.Unix(timeStamp, 0).Format(timeTemplate) |
|||
return |
|||
} |
|||
|
|||
/* |
|||
日期转时间戳 |
|||
*/ |
|||
func DateToTimeStamp(dataStr string) (timeStamp int64, isTrue bool) { |
|||
isTrue = false |
|||
tmp := "2006-01-02 15:04:05" |
|||
res, err := time.ParseInLocation(tmp, dataStr, time.Local) |
|||
timeStamp = res.Unix() |
|||
if err == nil { |
|||
isTrue = true |
|||
} |
|||
return |
|||
} |
|||
|
|||
//数据库查询翻页
|
|||
func LimitPage(page, pageSize int) (offSet int) { |
|||
if page < 1 { |
|||
page = 1 |
|||
} |
|||
offSet = pageSize * (page - 1) |
|||
if offSet < 0 { |
|||
offSet = 0 |
|||
} |
|||
return |
|||
} |
|||
|
|||
//中文首字母大写
|
|||
func ChineseFirstWordCapitalize(wordStr string) (firstWord string) { |
|||
pinYinSub := pinyin.NewArgs() |
|||
rows := pinyin.Pinyin(wordStr, pinYinSub) |
|||
for i := 0; i < len(rows); i++ { |
|||
if len(rows[i]) != 0 { |
|||
str := rows[i][0] |
|||
pi := str[0:1] |
|||
firstWord += string(bytes.ToUpper([]byte(pi))) |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
// ZeroFillByStr
|
|||
// @Description: 字符串补零
|
|||
// @param str :需要操作的字符串
|
|||
// @param resultLen 结果字符串的长度
|
|||
// @param reverse true 为前置补零,false 为后置补零
|
|||
// @return string
|
|||
//
|
|||
func ZeroFillByStr(str string, resultLen int, reverse bool) string { |
|||
if len(str) > resultLen || resultLen <= 0 { |
|||
return str |
|||
} |
|||
if reverse { |
|||
return fmt.Sprintf("%0*s", resultLen, str) //不足前置补零
|
|||
} |
|||
result := str |
|||
for i := 0; i < resultLen-len(str); i++ { |
|||
result += "0" |
|||
} |
|||
return result |
|||
} |
|||
|
|||
/* |
|||
*加密算法 |
|||
*/ |
|||
type Md5Encryption struct { |
|||
Code string `json:"code"` |
|||
AppKey string `json:"appKey"` |
|||
} |
|||
|
|||
func (m *Md5Encryption) Md5EncryptionAlgorithm() (md5Val string) { |
|||
if m.AppKey == "" { |
|||
m.Md5EncryptionInit(m.Code) |
|||
} |
|||
// fmt.Printf("Code ====> %v\n", m.Code)
|
|||
// fmt.Printf("AppKey ====> %v\n", m.AppKey)
|
|||
|
|||
mdNew := md5.New() |
|||
mdNew.Write([]byte(m.AppKey)) |
|||
keyMd5 := fmt.Sprintf("%x", mdNew.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step1:--AppKey-加密->%v\n", keyMd5)
|
|||
|
|||
codeNewMd1 := md5.New() |
|||
codeNewMd1.Write([]byte(m.Code)) |
|||
codeMd1 := fmt.Sprintf("%x", codeNewMd1.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step2:--CodeString-加密->%v\n", codeMd1)
|
|||
|
|||
yiCeng := codeMd1 + keyMd5 |
|||
|
|||
// fmt.Printf("Step3:--CodeString+AppKey-->%v\n", yiCeng)
|
|||
|
|||
yiCengNew := md5.New() |
|||
yiCengNew.Write([]byte(yiCeng)) |
|||
yiCengMd5 := fmt.Sprintf("%x", yiCengNew.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step4:--one-加密->%v\n", yiCengMd5)
|
|||
|
|||
erCeng := yiCengMd5 + m.AppKey |
|||
|
|||
// fmt.Printf("Step5:--one + AppKey->%v\n", erCeng)
|
|||
|
|||
// fmt.Printf("AppKey ===2=> %v\n", m.AppKey)
|
|||
|
|||
erCengNew := md5.New() |
|||
erCengNew.Write([]byte(erCeng)) |
|||
md5Val = fmt.Sprintf("%x", erCengNew.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step6:--therr--加密-->%v\n", md5Val)
|
|||
|
|||
// md5Val = codeMd1
|
|||
return |
|||
} |
|||
|
|||
func (m *Md5Encryption) Md5EncryptionAlgorithmFj() (md5Val string, outlog []string) { |
|||
if m.AppKey == "" { |
|||
m.Md5EncryptionInit(m.Code) |
|||
} |
|||
// fmt.Printf("Code ====> %v\n", m.Code)
|
|||
// fmt.Printf("AppKey ====> %v\n", m.AppKey)
|
|||
|
|||
outlog = append(outlog, fmt.Sprintf("Code ====> %v", m.Code)) |
|||
outlog = append(outlog, fmt.Sprintf("AppKey ====> %v", m.AppKey)) |
|||
|
|||
mdNew := md5.New() |
|||
mdNew.Write([]byte(m.AppKey)) |
|||
keyMd5 := fmt.Sprintf("%x", mdNew.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step1:--AppKey-加密->%v\n", keyMd5)
|
|||
outlog = append(outlog, fmt.Sprintf("Step1:--AppKey-加密->%v", keyMd5)) |
|||
|
|||
codeNewMd1 := md5.New() |
|||
codeNewMd1.Write([]byte(m.Code)) |
|||
codeMd1 := fmt.Sprintf("%x", codeNewMd1.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step2:--CodeString-加密->%v\n", codeMd1)
|
|||
outlog = append(outlog, fmt.Sprintf("Step2:--CodeString-加密->%v", codeMd1)) |
|||
|
|||
yiCeng := codeMd1 + keyMd5 |
|||
|
|||
// fmt.Printf("Step3:--CodeString+AppKey-->%v\n", yiCeng)
|
|||
outlog = append(outlog, fmt.Sprintf("Step3:--CodeString+AppKey-->%v", yiCeng)) |
|||
|
|||
yiCengNew := md5.New() |
|||
yiCengNew.Write([]byte(yiCeng)) |
|||
yiCengMd5 := fmt.Sprintf("%x", yiCengNew.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step4:--one-加密->%v\n", yiCengMd5)
|
|||
outlog = append(outlog, fmt.Sprintf("Step4:--one-加密->%v", yiCengMd5)) |
|||
|
|||
erCeng := yiCengMd5 + m.AppKey |
|||
|
|||
// fmt.Printf("Step5:--one + AppKey->%v\n", erCeng)
|
|||
outlog = append(outlog, fmt.Sprintf("Step5:--one + AppKey->%v", erCeng)) |
|||
|
|||
// fmt.Printf("AppKey ===2=> %v\n", m.AppKey)
|
|||
|
|||
erCengNew := md5.New() |
|||
erCengNew.Write([]byte(erCeng)) |
|||
md5Val = fmt.Sprintf("%x", erCengNew.Sum(nil)) |
|||
|
|||
// fmt.Printf("Step6:--therr--加密-->%v\n", md5Val)
|
|||
outlog = append(outlog, fmt.Sprintf("Step6:--therr--加密-->%v", md5Val)) |
|||
|
|||
// md5Val = codeMd1
|
|||
return |
|||
} |
|||
|
|||
//初始化程序
|
|||
func (m *Md5Encryption) Md5EncryptionInit(code string) { |
|||
m.AppKey = overall.CONSTANT_CONFIG.Appsetup.AppKey |
|||
m.Code = code |
|||
} |
|||
|
|||
//sha1算法
|
|||
func Sha1Encryption(str string) string { |
|||
sha1 := sha1.New() |
|||
sha1.Write([]byte(str)) |
|||
return hex.EncodeToString(sha1.Sum(nil)) |
|||
} |
|||
|
|||
//计算当前时间N个月后的时间
|
|||
/* |
|||
@timeStamp 当前时间戳 |
|||
@futureTime 正数多少时间后,负数多少时间前 |
|||
*/ |
|||
func GetFutureMonthTime(timeStamp int64, futureTime, class int) (dateStr int64) { |
|||
timeUnix := time.Unix(timeStamp, 0) |
|||
addDate := timeUnix.AddDate(0, 0, futureTime) |
|||
switch class { |
|||
case 2: |
|||
addDate = timeUnix.AddDate(0, futureTime, 0) |
|||
case 3: |
|||
addDate = timeUnix.AddDate(futureTime, 0, 0) |
|||
default: |
|||
addDate = timeUnix.AddDate(0, 0, futureTime) |
|||
} |
|||
|
|||
dateStr = addDate.Unix() |
|||
return |
|||
} |
|||
|
|||
//判断字符串是否在切片中 泛型
|
|||
func IsInTrue[T GenericityVariable](key T, keyAry []T) (isTrue bool) { |
|||
isTrue = false |
|||
for _, v := range keyAry { |
|||
if v == key { |
|||
return true |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
//获取两个切片得差集
|
|||
func DifferenceSet[T GenericityVariable](one, two []T) []T { |
|||
var three []T |
|||
temp := map[T]struct{}{} |
|||
for _, val := range two { |
|||
if _, ok := temp[val]; !ok { |
|||
temp[val] = struct{}{} |
|||
} |
|||
} |
|||
for _, val := range one { |
|||
if _, ok := temp[val]; !ok { |
|||
three = append(three, val) |
|||
} |
|||
} |
|||
return three |
|||
} |
|||
|
|||
//判断类型转换成
|
|||
/* |
|||
字符转int |
|||
*/ |
|||
func StringToInt(val interface{}) (int, error) { |
|||
switch val.(type) { |
|||
case string: |
|||
return strconv.Atoi(val.(string)) |
|||
case int: |
|||
return val.(int), nil |
|||
default: |
|||
return 0, nil |
|||
} |
|||
return 0, nil |
|||
} |
|||
|
|||
/* |
|||
字符转int64 |
|||
*/ |
|||
func StringToInt64(val interface{}) (int64, error) { |
|||
switch val.(type) { |
|||
case string: |
|||
return strconv.ParseInt(val.(string), 10, 64) |
|||
case int: |
|||
return int64(val.(int)), nil |
|||
case int64: |
|||
return val.(int64), nil |
|||
default: |
|||
return 0, nil |
|||
} |
|||
return 0, nil |
|||
} |
|||
|
|||
//获取人员TokenRedis 信息
|
|||
func GetUserRedisToken(number string) (manCont models.ManCont, err error) { |
|||
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) |
|||
useMap, isTrue := redisClient.HashGetAll(redisMyContKey) |
|||
if isTrue == false { |
|||
err.Error() |
|||
return |
|||
} |
|||
// fmt.Printf("%v\n", useMap)
|
|||
err = MapToStruct(useMap, &manCont, "json") |
|||
return |
|||
} |
|||
|
|||
//获取人员Redis信息
|
|||
func GetUserRedisCont(number string) (manCont models.ManCont, err error) { |
|||
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) |
|||
useMap, isTrue := redisClient.HashGetAll(redisMyContKey) |
|||
if isTrue == false { |
|||
err.Error() |
|||
return |
|||
} |
|||
// fmt.Printf("%v\n", useMap)
|
|||
// var manInfo models.ManCont
|
|||
err = MapToStruct(useMap, &manCont, "json") |
|||
// manCont = manInfo
|
|||
return |
|||
} |
|||
|
|||
//获取人员Redis信息返回指针
|
|||
func GetUserRedisContPointer(number string) (manCont models.ManCont, err error) { |
|||
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, number) |
|||
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5) |
|||
useMap, isTrue := redisClient.HashGetAll(redisMyContKey) |
|||
if isTrue == false { |
|||
err.Error() |
|||
return |
|||
} |
|||
// fmt.Printf("%v\n", useMap)
|
|||
// var manInfo models.ManCont
|
|||
err = MapToStruct(useMap, &manCont, "json") |
|||
// manCont = manInfo
|
|||
return |
|||
} |
|||
|
|||
/* |
|||
map[string]string 转 struct |
|||
*/ |
|||
func MapToStruct(mapString map[string]string, structInterface interface{}, tag string) (err error) { |
|||
strType := reflect.TypeOf(structInterface) |
|||
strValue := reflect.ValueOf(structInterface) |
|||
switch strType.Kind() { |
|||
case reflect.Ptr: |
|||
if strType.Elem().Kind() != reflect.Struct { |
|||
// fmt.Printf("1-->%v\n", strType.Elem().Kind().String())
|
|||
return errors.New("需要*struct类型,却传入*" + strType.Elem().Kind().String() + "类型") |
|||
} |
|||
default: |
|||
// fmt.Printf("2-->%v\n", strType.Kind().String())
|
|||
return errors.New("需要*struct类型,却传入" + strType.Kind().String() + "类型") |
|||
} |
|||
// fmt.Printf("strType--->%v---strValue---->%v\n", strType, strValue)
|
|||
strTypeElem := strType.Elem() |
|||
strValueElem := strValue.Elem() |
|||
strTypeNum := strTypeElem.NumField() |
|||
// fmt.Printf("strTypeElem--->%v---strValueElem---->%v---------strTypeNum--------->%v\n", strTypeElem, strValueElem, strTypeNum)
|
|||
for i := 0; i < strTypeNum; i++ { |
|||
fieldName := strTypeElem.Field(i).Name |
|||
if tag != "" { |
|||
fieldName = strTypeElem.Field(i).Tag.Get(tag) |
|||
} |
|||
value, ok := mapString[fieldName] |
|||
if !ok { |
|||
continue |
|||
} |
|||
// fmt.Printf("name--->%v---tag---->%v----value---->%v----ok---->%v\n", fieldName, tag, value, ok)
|
|||
if strValueElem.Field(i).CanSet() { |
|||
// fmt.Printf("Type--->%v---value---->%v\n", strValueElem.Field(i).Type(), reflect.TypeOf(value))
|
|||
valType := fmt.Sprintf("%v", strValueElem.Field(i).Type()) |
|||
switch valType { |
|||
case "int": |
|||
valueInt, _ := strconv.Atoi(value) |
|||
strValueElem.Field(i).Set(reflect.ValueOf(valueInt)) |
|||
case "int32": |
|||
valueInt32, _ := strconv.ParseInt(value, 10, 32) |
|||
strValueElem.Field(i).Set(reflect.ValueOf(int32(valueInt32))) |
|||
case "int64": |
|||
valueInt64, _ := strconv.ParseInt(value, 10, 64) |
|||
strValueElem.Field(i).Set(reflect.ValueOf(valueInt64)) |
|||
case "float32": |
|||
valuefloat32, _ := strconv.ParseFloat(value, 32) |
|||
strValueElem.Field(i).Set(reflect.ValueOf(float32(valuefloat32))) |
|||
case "float64": |
|||
valuefloat64, _ := strconv.ParseFloat(value, 64) |
|||
strValueElem.Field(i).Set(reflect.ValueOf(valuefloat64)) |
|||
case "string": |
|||
strValueElem.Field(i).Set(reflect.ValueOf(value)) |
|||
default: |
|||
|
|||
} |
|||
} else { |
|||
continue |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
//翻页设置
|
|||
func PageTurningSettings(gormDb *gorm.DB, page, pageSize int) *gorm.DB { |
|||
if page < 0 { |
|||
page = 1 |
|||
} |
|||
if pageSize < 0 { |
|||
pageSize = 10 |
|||
} |
|||
gormDb = gormDb.Limit(pageSize).Offset(LimitPage(page, pageSize)) |
|||
return gormDb |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package publicmethod |
|||
|
|||
//泛型基础变量类型
|
|||
type GenericityVariable interface { |
|||
int | int8 | int16 | int32 | int64 | float32 | float64 | string |
|||
} |
|||
|
|||
//格式化输出
|
|||
type Reply struct { |
|||
Code int `json:"code"` |
|||
Msg string `json:"msg"` |
|||
Data interface{} `json:"data"` |
|||
} |
|||
|
|||
//翻页信息
|
|||
type PagesTurn struct { |
|||
Page int `json:"page"` |
|||
PageSize int `json:"pagesize"` |
|||
} |
|||
|
|||
//通用ID结构体
|
|||
type PublicId struct { |
|||
Id string `json:"id"` |
|||
} |
|||
|
|||
//通用编辑状态结构体
|
|||
type PublicState struct { |
|||
PublicId |
|||
State int `json:"state"` |
|||
IsTrue int `json:"istrue"` //1:强制删除;非1:软删除
|
|||
} |
|||
|
|||
//通用图片结构体列表
|
|||
type PubilcImageList struct { |
|||
Id string `json:"id"` |
|||
Url string `json:"url"` //图片地址
|
|||
Name string `json:"name"` //文档名称
|
|||
FileSize string `json:"filesize"` //文档大小
|
|||
} |
|||
|
|||
//通用图片结构体内容
|
|||
type PubilcImageCont struct { |
|||
PubilcImageList |
|||
Imgpath string `json:"imgpath"` //物理地址
|
|||
AscriptionId string `json:"ascriptionid"` //归属
|
|||
} |
|||
Loading…
Reference in new issue