Browse Source

根据身份证号验证生日及年龄

v1
超级管理员 2 years ago
parent
commit
976e602bf9
  1. 33
      api/shiyan/maptostruct/shiyan.go
  2. 2
      api/version1/entry.go
  3. 125
      api/version1/newsclass/newsapi.go
  4. 40
      api/version1/newsclass/type.go
  5. 1
      api/version1/taskplatform/taskflow/runflow.go
  6. 11
      api/version1/user/type.go
  7. 303
      api/version1/user/userCont.go
  8. 2
      apirouter/apishiyan/maptostruct.go
  9. 2
      apirouter/entry.go
  10. 18
      apirouter/v1/newsclassrouter/apirouter.go
  11. 4
      apirouter/v1/newsclassrouter/type.go
  12. 7
      apirouter/v1/userRouters/pc.go
  13. 3
      initialization/route/initRoute.go
  14. 3
      models/modelshr/man_cont.go
  15. 114
      overall/publicmethod/technique.go
  16. 6
      overall/publicmethod/type.go

33
api/shiyan/maptostruct/shiyan.go

@ -454,3 +454,36 @@ func (a *ApiMethod) JiaMiShiYan(c *gin.Context) {
sendData["singStr"] = singStr
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-11-08 16:04:39
@ 功能: 根据身份证号获取生日和年龄
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) GenJuIdNumber(c *gin.Context) {
var requestData publicmethod.PublicName
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
shengti := publicmethod.GetBirthday(requestData.Name)
var myAge publicmethod.BirthdayAge
myAge.GetAgeByBirthday(requestData.Name)
sendData := publicmethod.MapOut[string]()
sendData["shengti"] = shengti
sendData["myAge"] = myAge
publicmethod.Result(0, sendData, c)
}

2
api/version1/entry.go

@ -6,6 +6,7 @@ import (
"appPlatform/api/version1/grantpowers"
matrixapi "appPlatform/api/version1/matrixApi"
"appPlatform/api/version1/menus"
"appPlatform/api/version1/newsclass"
"appPlatform/api/version1/publicapi"
"appPlatform/api/version1/taskplatform/taskflow"
"appPlatform/api/version1/taskplatform/taskmanagement"
@ -22,6 +23,7 @@ type ApiEntry struct {
CustomerFormApi customerform.ApiMethod //自定表单
TaskManagementApi taskmanagement.ApiMethod
TaskFlowApi taskflow.ApiMethod
NewsClassApi newsclass.ApiMethod //新闻类
}
var AppApiEntry = new(ApiEntry)

125
api/version1/newsclass/newsapi.go

@ -0,0 +1,125 @@
package newsclass
import (
"appPlatform/models/modelbookimg"
"appPlatform/models/modelshr"
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"strconv"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2023-11-09 10:18:58
@ 功能: 热门新闻
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) HotNews(c *gin.Context) {
var requestData HosNewsParameter
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(10001, err, c)
return
}
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 7
}
if requestData.Types == 0 {
requestData.Types = 1
}
context, _ := c.Get(overall.MyContJwt)
var userCont modelshr.ManCont
userCont.GetLoginCont(context)
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSonAllId(userCont.MainDeparment)
sunOrg.Id = append(sunOrg.Id, userCont.MainDeparment)
var orgListInfo []modelshr.OrgContType
overall.CONSTANT_DB_HR.Select("`id`,`level`").Where("`id` IN ?", sunOrg.Id).Find(&orgListInfo)
var orgAry []int64
var workPost []int64
for i := 0; i < len(orgListInfo); i++ {
// var orgType modelshr.OrgContType
// orgType.GetCont(map[string]interface{}{"`id`": orgListInfo[i].OrganizationType}, "`level`")
if orgListInfo[i].Level >= 6 {
workPost = append(workPost, orgListInfo[i].Id)
} else {
orgAry = append(orgAry, orgListInfo[i].Id)
}
}
var list []modelbookimg.GraphicForm
gormDb := overall.CONSTANT_DB_IMAGES_TEST.Model(&modelbookimg.GraphicForm{}).Select("`g_id`,`g_title`,`g_content`,`g_text_name`,`g_test_url`,`g_physics_path`,`g_add_time`,`g_read`,`g_com_sum`,`g_collection_sum`,`g_likes`,`g_step_on`")
if requestData.Types == 5 {
gormDb = gormDb.Where("`g_recommend` = 1")
}
gormDb = gormDb.Where("`g_state` = 2")
gormDb = gormDb.Where("`g_visit_strat` = 1 OR (`g_visit_strat` = 2 AND `g_bf_id` IN ?) OR (`g_visit_strat` = 3 AND `g_ws_id` IN ?) OR (`g_visit_strat` = 4 AND FIND_IN_SET(?,`g_range`))", orgAry, workPost, userCont.Id)
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
switch requestData.Types {
case 1:
gormDb = gormDb.Order("`g_read` DESC").Order("`g_add_time` DESC")
case 2:
gormDb = gormDb.Order("`g_com_sum` DESC").Order("`g_add_time` DESC")
case 3:
gormDb = gormDb.Order("`g_collection_sum` DESC").Order("`g_add_time` DESC")
case 4:
gormDb = gormDb.Order("`g_likes` DESC").Order("`g_add_time` DESC")
case 5:
gormDb = gormDb.Order("`g_recommend` DESC").Order("`g_add_time` DESC")
case 6:
gormDb = gormDb.Order("`g_step_on` DESC").Order("`g_add_time` DESC")
default:
gormDb = gormDb.Order("`g_add_time` DESC")
}
err = gormDb.Find(&list).Error
if err != nil && len(list) < 1 {
publicmethod.Result(0, err, c)
return
}
var sendList []SendHotNews
for _, v := range list {
var sendCont SendHotNews
sendCont.Id = strconv.FormatInt(v.Id, 10)
sendCont.Title = v.Title //"title"`
sendCont.PageInfo = v.Content //"pageInfo"`
sendCont.FileName = v.TextName //"fileName"`
sendCont.FileUrl = v.TestUrl //"fileUrl"`
sendCont.FilePath = v.PhysicsPath //"filePath"`
sendCont.PageType = 1 //"pagetype"`
if v.TestUrl != "" {
sendCont.PageType = 2
}
sendCont.Time = publicmethod.UnixTimeToDay(v.AddTime, 24) //"time"`
sendCont.ReadNumber = v.Read //readNumber"`
sendCont.CommentNumber = v.ComSum //commentNumber"`
sendCont.CollectNumber = v.CollectionSum //collectNumber"`
sendCont.LikeNumber = v.Likes //likeNumber"`
sendCont.CriticizeNumber = v.StepOn //criticizeNumber"`
sendList = append(sendList, sendCont)
}
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c)
}

40
api/version1/newsclass/type.go

@ -0,0 +1,40 @@
package newsclass
import (
"appPlatform/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 HosNewsParameter struct {
publicmethod.PagesTurn
Types int `json:"type"` //1:热点新闻(阅读量);2:评论;3:收藏;4:点赞;5:推荐;6:最差文章
}
// 发送内容
type SendHotNews struct {
publicmethod.PublicId
Title string `json:"title"`
PageInfo string `json:"pageInfo"`
FileName string `json:"fileName"`
FileUrl string `json:"fileUrl"`
FilePath string `json:"filePath"`
PageType int `json:"pagetype"`
Time string `json:"time"`
ReadNumber int `json:"readNumber"`
CommentNumber int `json:"commentNumber"`
CollectNumber int `json:"collectNumber"`
LikeNumber int `json:"likeNumber"`
CriticizeNumber int `json:"criticizeNumber"`
}

1
api/version1/taskplatform/taskflow/runflow.go

@ -70,6 +70,7 @@ func (n *NodePublicInfo) CircularParsing(step int) (nodeList []RunFlow) {
case 1: //指定成员
nodeInfo.Operator = OperatorHandle(n.NodeUserList)
case 2: //主管
case 3: //行政岗位
case 4: //发起人自选
case 5: //发起人自己

11
api/version1/user/type.go

@ -34,4 +34,15 @@ type SendUserCont struct {
Roles []string `json:"roles"`
Perms []string `json:"perms"`
Managementcope []string `json:"managementcope"` //可操作得行政组织
GenderStr string `json:"genderstr"` //性别
PostList []string `json:"postlist"` //性别
EmpType int `json:"emptype"`
Mobilephone string `json:"mobilephone"`
Currentresidence string `json:"currentresidence"`
}
// 年龄结构
type AgeType struct {
publicmethod.PublicName
Value int `json:"value"`
}

303
api/version1/user/userCont.go

@ -6,6 +6,8 @@ import (
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
@ -55,6 +57,9 @@ func (a *ApiMethod) GetUserCont(c *gin.Context) {
orgCont.GetCont(map[string]interface{}{"`id`": myContInfo.MainDeparment}, "`name`")
sendData.OrganizationName = orgCont.Name //行政组织名称
sendData.Avatar = myContInfo.Icon
if myContInfo.IconPhpto != "" {
sendData.Avatar = myContInfo.IconPhpto
}
roleList := strings.Split(myContInfo.Role, ",")
// roleList = append(roleList, "ROOT")
sendData.Roles = roleList
@ -63,9 +68,98 @@ func (a *ApiMethod) GetUserCont(c *gin.Context) {
// menuPoint, opeart, orgList := GetUserPower("appsystem", myContInfo.Position, roleList)
// fmt.Printf("menuPoint======>%v\nopeart======>%v\norgList======>%v\n", menuPoint, opeart, orgList)
sendData.Perms = menuPoint
switch myContInfo.Gender {
case 1:
sendData.GenderStr = "男"
case 2:
sendData.GenderStr = "女"
default:
sendData.GenderStr = "第三性别"
}
sendData.EmpType = myContInfo.EmpType
sendData.PostList = GainOrgPostLog(myContInfo.Key)
sendData.Mobilephone = myContInfo.Mobilephone
sendData.Currentresidence = myContInfo.Currentresidence
publicmethod.Result(0, sendData, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-11-07 10:19:45
@ 功能: 获取集团内任职记录
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func GainOrgPostLog(uid int64) (postLog []string) {
var workHistory []modelshr.InsideWorkHistory
err := overall.CONSTANT_DB_HR.Where("`state` = 1 AND `end_time` = 0 AND `key` = ?", uid).Order("`assign_type` ASC").Order("`start_time` DESC").Find(&workHistory).Error
if err != nil && len(workHistory) < 1 {
return
}
for _, v := range workHistory {
var orgList []int64
var orgNameList []string
if !publicmethod.IsInTrue[int64](v.Company, orgList) {
orgList = append(orgList, v.Company)
var orgOne modelshr.AdministrativeOrganization
orgOne.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`")
orgNameList = append(orgNameList, orgOne.Name)
}
if !publicmethod.IsInTrue[int64](v.Department, orgList) {
orgList = append(orgList, v.Department)
var orgTwo modelshr.AdministrativeOrganization
orgTwo.GetCont(map[string]interface{}{"`id`": v.Department}, "`name`")
orgNameList = append(orgNameList, orgTwo.Name)
}
if !publicmethod.IsInTrue[int64](v.WorkShop, orgList) {
orgList = append(orgList, v.WorkShop)
var orgTree modelshr.AdministrativeOrganization
orgTree.GetCont(map[string]interface{}{"`id`": v.WorkShop}, "`name`")
orgNameList = append(orgNameList, orgTree.Name)
}
if !publicmethod.IsInTrue[int64](v.WorkshopSection, orgList) {
orgList = append(orgList, v.WorkshopSection)
var orgTree modelshr.AdministrativeOrganization
orgTree.GetCont(map[string]interface{}{"`id`": v.WorkshopSection}, "`name`")
orgNameList = append(orgNameList, orgTree.Name)
}
fmt.Println(orgNameList)
fmt.Println(orgList)
fmt.Println(v.WorkshopSection)
if len(orgNameList) > 0 {
allOrgName := strings.Join(orgNameList, " / ")
if v.Position != 0 {
var postCont modelshr.Position
postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`")
if v.GradePositions != 0 {
allOrgName = fmt.Sprintf("%v %v级%v", allOrgName, v.GradePositions, postCont.Name)
} else {
allOrgName = fmt.Sprintf("%v %v", allOrgName, postCont.Name)
}
}
if v.AssignType == 1 {
allOrgName = fmt.Sprintf("%v(主职)", allOrgName)
postLog = append(postLog, allOrgName)
} else {
allOrgName := fmt.Sprintf("%v(兼职)", allOrgName)
postLog = append(postLog, allOrgName)
}
}
}
return
}
/*
*
@ 作者: 秦东
@ -152,3 +246,212 @@ func GetUserPower(appType string, postId int64, roleList []string) (menuPoint, o
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-11-08 16:37:43
@ 功能: 统计行政组织下人员年龄比例
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) StatisticalAgeRatio(c *gin.Context) {
var requestData publicmethod.PublicId
err := c.ShouldBindJSON(&requestData)
if err != nil {
publicmethod.Result(100, err, c)
return
}
if requestData.Id == "" {
requestData.Id = "309"
}
orgId, _ := strconv.ParseInt(requestData.Id, 10, 64)
var sunOrg publicmethod.GetOrgAllParent
sunOrg.GetOrgSonAllId(orgId)
sunOrg.Id = append(sunOrg.Id, orgId)
var idCard []string
err = overall.CONSTANT_DB_HR.Model(&modelshr.ManCont{}).Select("COALESCE(`idcardno`,'')").Where("`admin_org` IN ? AND emp_type BETWEEN ? AND ?", sunOrg.Id, 1, 10).Find(&idCard).Error
if err != nil && len(idCard) < 1 {
publicmethod.Result(107, err, c)
return
}
var ageAry []int
// jisuan
for i := 0; i < len(idCard); i++ {
if idCard[i] != "" {
var myAge publicmethod.BirthdayAge
myAge.GetAgeByBirthday(idCard[i])
// if publicmethod.IsInTrue[int](myAge.Age,ageAry){}
ageAry = append(ageAry, myAge.Age)
}
}
if len(ageAry) < 1 {
publicmethod.Result(107, err, c)
return
}
//根据维度序号排序
sort.Slice(ageAry, func(i, j int) bool {
return ageAry[i] < ageAry[j]
})
maxAge := ageAry[len(ageAry)-1]
// maxAge = 42
ageNumberList := publicmethod.StatisticalDuplication[int](ageAry)
ageMap := make(map[int]int)
if len(ageNumberList) > 0 {
for i, v := range ageNumberList {
if i <= maxAge && i <= 20 {
if _, isOk := ageMap[20]; isOk {
ageMap[20] = ageMap[20] + v
} else {
ageMap[20] = v
}
}
if i <= maxAge && i <= 25 && i > 20 {
if _, isOk := ageMap[25]; isOk {
ageMap[25] = ageMap[25] + v
} else {
ageMap[25] = v
}
}
if i <= maxAge && i <= 30 && i > 25 {
if _, isOk := ageMap[30]; isOk {
ageMap[30] = ageMap[30] + v
} else {
ageMap[30] = v
}
}
if i <= maxAge && i <= 35 && i > 30 {
if _, isOk := ageMap[35]; isOk {
ageMap[35] = ageMap[35] + v
} else {
ageMap[35] = v
}
}
if i <= maxAge && i <= 40 && i > 35 {
if _, isOk := ageMap[40]; isOk {
ageMap[40] = ageMap[40] + v
} else {
ageMap[40] = v
}
}
if i <= maxAge && i <= 45 && i > 40 {
if _, isOk := ageMap[45]; isOk {
ageMap[45] = ageMap[45] + v
} else {
ageMap[45] = v
}
}
if i <= maxAge && i <= 50 && i > 45 {
if _, isOk := ageMap[50]; isOk {
ageMap[50] = ageMap[50] + v
} else {
ageMap[50] = v
}
}
if i <= maxAge && i <= 55 && i > 50 {
if _, isOk := ageMap[55]; isOk {
ageMap[55] = ageMap[55] + v
} else {
ageMap[55] = v
}
}
if i <= maxAge && i <= 60 && i > 55 {
if _, isOk := ageMap[60]; isOk {
ageMap[60] = ageMap[60] + v
} else {
ageMap[60] = v
}
}
if i <= maxAge && i > 60 {
if _, isOk := ageMap[70]; isOk {
ageMap[70] = ageMap[70] + v
} else {
ageMap[70] = v
}
}
}
}
var sendAgeAry []AgeType
if len(ageMap) > 0 {
if ageVal, isOk := ageMap[20]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "20岁以下"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[25]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "20岁-25岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[30]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "25岁-30岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[35]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "30岁-35岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[40]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "35岁-40岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[45]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "40岁-45岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[50]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "45岁-50岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[55]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "50岁-55岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[60]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "55岁-60岁(含)"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
if ageVal, isOk := ageMap[70]; isOk {
var sendAgeCont AgeType
sendAgeCont.Name = "60岁以上"
sendAgeCont.Value = ageVal
sendAgeAry = append(sendAgeAry, sendAgeCont)
}
}
sheng := publicmethod.MapOut[string]()
sheng["aaffg"] = ageNumberList
sheng["ageAry"] = ageAry
sheng["maxAge"] = maxAge
sheng["ageMap"] = ageMap
sheng["sendAgeAry"] = sendAgeAry
publicmethod.Result(0, sendAgeAry, c)
}

2
apirouter/apishiyan/maptostruct.go

@ -31,5 +31,7 @@ func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter.POST("test_table", methodBinding.TestTable) //测试表格字段类型
apiRouter.GET("jia_mi", methodBinding.JiaMiShiYan) //加密实验
apiRouter.POST("genJuIdNumber", methodBinding.GenJuIdNumber) //根据身份证号获取生日和年龄
}
}

2
apirouter/entry.go

@ -8,6 +8,7 @@ import (
"appPlatform/apirouter/v1/grantsystempower"
matrixrouters "appPlatform/apirouter/v1/matrixRouters"
menusrouters "appPlatform/apirouter/v1/menusRouters"
"appPlatform/apirouter/v1/newsclassrouter"
"appPlatform/apirouter/v1/public"
"appPlatform/apirouter/v1/taskrouter"
userrouters "appPlatform/apirouter/v1/userRouters"
@ -25,6 +26,7 @@ type RouterGroup struct {
SignCodeRouter authenticationroute.ApiRouter
CustomerFormRouter customerformrouter.ApiRouter
TaskRouter taskrouter.ApiRouter
NewsClassApiRouter newsclassrouter.ApiRouter
}
var RouterGroupEntry = new(RouterGroup)

18
apirouter/v1/newsclassrouter/apirouter.go

@ -0,0 +1,18 @@
package newsclassrouter
import (
"appPlatform/api/version1"
"github.com/gin-gonic/gin"
)
// 新闻类接口路由
func (a *ApiRouter) RouterGroup(router *gin.RouterGroup) {
apiRouter := router.Group("news")
var newsClassRouter = version1.AppApiEntry.NewsClassApi
{
apiRouter.GET("", newsClassRouter.Index) //入口
apiRouter.POST("", newsClassRouter.Index) //入口
apiRouter.POST("hot_news", newsClassRouter.HotNews) //属性文章
}
}

4
apirouter/v1/newsclassrouter/type.go

@ -0,0 +1,4 @@
package newsclassrouter
//新闻类路由设定
type ApiRouter struct{}

7
apirouter/v1/userRouters/pc.go

@ -12,8 +12,9 @@ func (a *ApiRouter) RouterGroupPc(router *gin.RouterGroup) {
var methodBinding = version1.AppApiEntry.UserApi
{
apiRouter.GET("", methodBinding.Index) //入口
apiRouter.POST("", methodBinding.Index) //入口
apiRouter.GET("get_user_cont", methodBinding.GetUserCont) //获取登陆人信息
apiRouter.GET("", methodBinding.Index) //入口
apiRouter.POST("", methodBinding.Index) //入口
apiRouter.GET("get_user_cont", methodBinding.GetUserCont) //获取登陆人信息
apiRouter.POST("statisticalAgeRatio", methodBinding.StatisticalAgeRatio) //获取登陆人信息
}
}

3
initialization/route/initRoute.go

@ -67,6 +67,9 @@ func InitialRouter() *gin.Engine {
//工作台
taskRouterApi := apirouter.RouterGroupEntry.TaskRouter
taskRouterApi.RouterGroupPc(VerifyIdentity)
//注册新闻类接口
newsClassApiRouter := apirouter.RouterGroupEntry.NewsClassApiRouter
newsClassApiRouter.RouterGroup(VerifyIdentity)
}
//验证身份接口 无需鉴权Url(主要web端使用)
VerifyIdentityWeb := router.Group("")

3
models/modelshr/man_cont.go

@ -10,7 +10,8 @@ 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:头像"`
Icon string `json:"icon" gorm:"column:icon;type:longtext;comment:头像"`
IconPhpto string `json:"iconphoto" gorm:"column:icon_photo;type:longtext;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:入职公司"`

114
overall/publicmethod/technique.go

@ -167,6 +167,12 @@ func UnixTimeToDay(timeStamp int64, timeType int) (dateStr string) {
dateStr = "1"
}
}
case 24:
timeTemplate = "2006.01.02"
case 25:
timeTemplate = "2006.01"
case 26:
timeTemplate = "01.02"
default:
timeTemplate = "2006-01-02 15:04:05" //常规类型
}
@ -2420,3 +2426,111 @@ func TypeToClass(val interface{}, timeClass int) (str string) {
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2023-11-08 16:03:24
@ 功能: 根据身份证获取对应生日
@ 参数
#cardId 身份证号码
@ 返回值
#生日
@ 方法原型
#
*/
func GetBirthday(cardId string) string {
if len(cardId) < 15 {
return ""
}
// 兼容第一代15位身份证号码
if len(cardId) == 15 {
// 第一代身份证年份都是19开头的
return fmt.Sprintf("19%s", cardId[6:12])
} else {
return cardId[6:14]
}
}
/*
*
@ 作者: 秦东
@ 时间: 2023-11-08 16:10:28
@ 功能: 根据生日日期得到用户年龄
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (b *BirthdayAge) GetAgeByBirthday(cardId string) {
if len(cardId) < 15 {
return
}
birthday := GetBirthday(cardId)
if len(birthday) < 1 {
b.Age = 0
}
year, _ := strconv.Atoi(birthday[0:4])
month, _ := strconv.Atoi(birthday[4:6])
day, _ := strconv.Atoi(birthday[6:])
var months string
if month < 10 {
months = fmt.Sprintf("0%v", month)
} else {
months = strconv.Itoa(month)
}
var days string
if day < 10 {
days = fmt.Sprintf("0%v", day)
} else {
days = strconv.Itoa(day)
}
b.Birthday = fmt.Sprintf("%v-%v-%v", year, months, days)
// 计算当前日期与生日中年月日都差值
now := time.Now()
age := now.Year() - year
moreMonth := int(now.Month()) - month
moreDay := now.Day() - day
// 未到生日月份,或者到了月份,但未到生日日期,年龄都要减1岁
if moreMonth < 0 || (moreMonth == 0 && moreDay < 0) {
age--
}
// 不要出现负值
if age < 0 {
age = 0
}
b.Age = age
}
// 统计元素重复出现的次数
/*
@ary 数组切片
*/
func StatisticalDuplication[T GenericityVariable](ary []T) (mapAry map[T]int) {
mapAry = make(map[T]int)
count := 0
for i := 0; i < len(ary); i++ {
for n := 0; n < len(ary); n++ {
if ary[i] == ary[n] {
count++
}
}
mapAry[ary[i]] = count
count = 0
}
return
}

6
overall/publicmethod/type.go

@ -331,3 +331,9 @@ type AppMenusOptionsThree struct {
Value int `json:"value"` //类型对照
Children []AppMenusOptionsThree `json:"children"` //子路由列表
}
// 根据身份证号计算生日及年龄
type BirthdayAge struct {
Birthday string
Age int
}

Loading…
Cancel
Save