123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package service
- import (
- "app.yhyue.com/moapp/jybase/go-xweb/log"
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical"
- "fmt"
- "time"
- )
- type AuthService struct{}
- //认证信息保存
- func (b AuthService) UserAuthInfoSave(in *medical.UserInfo) (bool, string) {
- //先判断用户是否存在
- user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
- "user_id": in.UserId, "appid": in.Appid,
- }, "id", "")
- if user != nil {
- if in.OperationType == "add" {
- return false, "用户已验证"
- }
- } else {
- if in.OperationType == "update" {
- return false, "用户未认证,不可修改"
- }
- }
- if in.OperationType == "update" {
- //修改处理
- data := map[string]interface{}{
- "name": in.Name,
- "phone": in.Phone,
- "position": in.Position,
- "department": in.Department,
- "mail": in.Mail,
- "ent_code": in.EntCode,
- "ent_name": in.EntName,
- }
- ok1 := entity.BaseMysql.Update(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{"user_id": in.UserId, "appid": in.Appid}, data)
- if ok1 {
- return true, ""
- } else {
- log.Println(fmt.Sprintf("认证修改失败:入参:%v:%v,", in.UserId, data))
- return false, "修改失败"
- }
- } else {
- //新增处理
- data := map[string]interface{}{
- "name": in.Name,
- "phone": in.Phone,
- "position": in.Position,
- "department": in.Department,
- "mail": in.Mail,
- "ent_code": in.EntCode,
- "ent_name": in.EntName,
- "user_id": in.UserId,
- "create_time": time.Now().Local(),
- "appid": in.Appid,
- }
- ok := entity.BaseMysql.Insert(entity.DOMAIN_CAPITAL_RETENTION, data)
- if ok > 0 {
- return true, ""
- } else {
- log.Println(fmt.Sprintf("认证失败:参数:%v", data))
- return false, "认证失败"
- }
- }
- }
- //认证信息查询
- func (b AuthService) UserAuthInfo(in *medical.CommonReq) *map[string]interface{} {
- //先判断用户是否存在
- user := entity.BaseMysql.FindOne(entity.DOMAIN_CAPITAL_RETENTION, map[string]interface{}{
- "user_id": in.UserId, "appid": in.Appid,
- }, "id", "")
- return user
- }
|