Browse Source

Merge remote-tracking branch 'origin/master'

WH01243 3 năm trước cách đây
mục cha
commit
d11ad39c00

+ 1 - 0
api/medical/internal/logic/public/isclaimedlogic.go

@@ -40,6 +40,7 @@ func (l *IsClaimedLogic) IsClaimed(req *types.IsClaimedReq) (resp *types.CommonR
 		UserId: int64(req.UserId),
 		EntId:  entID,
 		Type:   int64(req.Type),
+		AppId:  req.AppId,
 	})
 	return &types.CommonRes{
 		Error_msg:  rs.ErrorMsg,

+ 1 - 0
api/medical/internal/types/types.go

@@ -82,6 +82,7 @@ type IsClaimedReq struct {
 	UserId    int    `header:"newUserId"`      // 用户id
 	CompanyId string `json:"company_id"`       // 机构id
 	Type      int    `json:"type,options=1|2"` // 1 医疗机构 2 经销商
+	AppId     string `header:"appId"`          // appid
 }
 
 type GetNewMsgListReq struct {

+ 1 - 0
api/medical/medical.api

@@ -84,6 +84,7 @@ type IsClaimedReq {
 	UserId    int    `header:"newUserId"`      // 用户id
 	CompanyId string `json:"company_id"`       // 机构id
 	Type      int    `json:"type,options=1|2"` // 1 医疗机构 2 经销商
+	AppId     string `header:"appId"`          // appid
 }
 
 // 获取机构信息请求

+ 2 - 2
service/portrait.go

@@ -300,8 +300,8 @@ func (this *PortraitService) MedicalProdcutList(companyId string, user_id int64)
 		return nil, errors.New(entity.NO_DATA_ERROR_MSG)
 	}
 	//查找基本信息
-	rdata := this.GlobalCommonData.SelectBySql(fmt.Sprintf(`SELECT product_name,regno,approve_date,validity_date,manage_type,regist_type
-															from %s where company_id =? order by id desc`, entity.Product_baseinfo), companyId)
+	rdata := this.Mysql.SelectBySql(fmt.Sprintf(`SELECT product_name,regno,approve_date,validity_date,manage_type,regist_type
+															from %s where company_id =? order by product_id desc`, entity.Product_baseinfo), companyId)
 	if rdata == nil || len(*rdata) == 0 {
 		return nil, errors.New(entity.NO_DATA_ERROR_MSG)
 	}

+ 308 - 51
service/portrait_test.go

@@ -3,57 +3,192 @@ package service
 import (
 	"reflect"
 	"testing"
+	"time"
 
 	"bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
 )
 
-/*var PortService PortraitService
-var MyConn *entity.Conn*/
+var MyConn = InitDb() // 显式初始化数据库
 
-/*func init() {
-	entity.Mysql = &mysql.Mysql{
-		Address:      "192.168.3.217:4000",
-		UserName:     "root",
-		PassWord:     "=PDT49#80Z!RVv52_z",
-		DBName:       "medical_fileld_data",
-		MaxOpenConns: 5,
-		MaxIdleConns: 5,
-	}
-	entity.Mysql.Init()
-	BaseMysqlConn := &mysql.Mysql{
-		Address:      "192.168.3.217:4000",
-		UserName:     "root",
-		PassWord:     "=PDT49#80Z!RVv52_z",
-		DBName:       "base_service",
-		MaxOpenConns: 5,
-		MaxIdleConns: 5,
-	}
-	BaseMysqlConn.Init()
-	CommonMysql := &mysql.Mysql{
-		Address:      "192.168.3.217:4000",
-		UserName:     "root",
-		PassWord:     "=PDT49#80Z!RVv52_z",
-		DBName:       "global_common_data",
-		MaxOpenConns: 5,
-		MaxIdleConns: 5,
-	}
-	CommonMysql.Init()
-	MyConn = &entity.Conn{
-		Mysql:     entity.Mysql,
-		BaseMysql: BaseMysqlConn,
-	}
-	elastic.InitElasticSize("http://192.168.3.206:9800", 30)
+func TestEncodeId(t *testing.T) {
+	type args struct {
+		sid string
+	}
+	tests := []struct {
+		name string
+		args args
+		want string
+	}{
+		// TODO: Add test cases.
+		{
+			name: "错误的",
+			args: args{
+				sid: "",
+			},
+		},
+		{
+			name: "正确的",
+			args: args{
+				sid: "ABCYFxeYy4eMy84I3xlcAcoDzBfHjd3XGh1PB4jLC4gfFJwcjssIBkeN3RmWnEaDlxTDME%3D",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if got := EncodeId(tt.args.sid); got != tt.want {
+				t.Errorf("EncodeId() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
 
-	PortService = *NewPortrait(MyConn)
-}*/
+func TestNewPortrait(t *testing.T) {
+	type args struct {
+		conn *entity.Conn
+	}
+	tests := []struct {
+		name string
+		args args
+		want *PortraitService
+	}{
+		// TODO: Add test cases.
+		{
+			args: args{
+				conn: PortService.Conn,
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if got := NewPortrait(tt.args.conn); !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("NewPortrait() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestPortraitService_CommonPare(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	type args struct {
+		companyName string
+	}
+	tests := []struct {
+		name             string
+		fields           fields
+		args             args
+		wantMustQueryArr []string
+	}{
+		// TODO: Add test cases.
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: tt.fields.Conn,
+			}
+			if gotMustQueryArr := this.CommonPare(tt.args.companyName); !reflect.DeepEqual(gotMustQueryArr, tt.wantMustQueryArr) {
+				t.Errorf("CommonPare() = %v, want %v", gotMustQueryArr, tt.wantMustQueryArr)
+			}
+		})
+	}
+}
+
+func TestPortraitService_DistributorInfo(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	type args struct {
+		companyId string
+		user_id   int64
+	}
+	tests := []struct {
+		name    string
+		fields  fields
+		args    args
+		want    *entity.DistributorInfo
+		wantErr bool
+	}{
+		// TODO: Add test cases.
+		{
+			args: args{
+				companyId: "错的",
+				user_id:   0,
+			},
+		},
+		{
+			args: args{
+				companyId: "30d041422855fda867a356b3994a67ea",
+				user_id:   1,
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: MyConn,
+			}
+			got, err := this.DistributorInfo(tt.args.companyId, tt.args.user_id)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("DistributorInfo() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("DistributorInfo() got = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestPortraitService_Export(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	type args struct {
+		mongoUid    string
+		companyName string
+		ids         string
+	}
+	tests := []struct {
+		name    string
+		fields  fields
+		args    args
+		want    string
+		wantErr bool
+	}{
+		// TODO: Add test cases.
+		{
+			args: args{
+				mongoUid:    "qweqwe",
+				companyName: "沛县中医院",
+				ids:         "",
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: MyConn,
+			}
+			got, err := this.Export(tt.args.mongoUid, tt.args.companyName, tt.args.ids)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("Export() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if got != tt.want {
+				t.Errorf("Export() got = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
 
 func TestPortraitService_Info(t *testing.T) {
-	MyConn := PortService.Conn
 	type fields struct {
 		Conn *entity.Conn
 	}
 	type args struct {
 		companyId string
+		user_id   int64
 	}
 	tests := []struct {
 		name    string
@@ -70,6 +205,7 @@ func TestPortraitService_Info(t *testing.T) {
 			},
 			args: args{
 				companyId: "25caa43ce64036dfd1f55635e06394a6",
+				user_id:   69717,
 			},
 		},
 		{
@@ -79,6 +215,7 @@ func TestPortraitService_Info(t *testing.T) {
 			},
 			args: args{
 				companyId: "",
+				user_id:   69717,
 			},
 		},
 		{
@@ -88,6 +225,7 @@ func TestPortraitService_Info(t *testing.T) {
 			},
 			args: args{
 				companyId: "错的",
+				user_id:   1,
 			},
 		},
 	}
@@ -96,7 +234,7 @@ func TestPortraitService_Info(t *testing.T) {
 			this := &PortraitService{
 				Conn: tt.fields.Conn,
 			}
-			got, err := this.Info(tt.args.companyId, int64(0))
+			got, err := this.Info(tt.args.companyId, tt.args.user_id)
 			if (err != nil) != tt.wantErr {
 				t.Errorf("Info() error = %v, wantErr %v", err, tt.wantErr)
 				return
@@ -108,33 +246,75 @@ func TestPortraitService_Info(t *testing.T) {
 	}
 }
 
-func TestPortraitService_List(t *testing.T) {
-	MyConn := PortService.Conn
+func TestPortraitService_IsFollow(t *testing.T) {
 	type fields struct {
 		Conn *entity.Conn
 	}
 	type args struct {
 		companyId string
-		pagesize  int64
-		pagenum   int64
+		user_id   int64
+		types     int64
+	}
+	tests := []struct {
+		name   string
+		fields fields
+		args   args
+		want   int64
+	}{
+		// TODO: Add test cases.
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: tt.fields.Conn,
+			}
+			if got := this.IsFollow(tt.args.companyId, tt.args.user_id, tt.args.types); got != tt.want {
+				t.Errorf("IsFollow() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestPortraitService_List(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	type args struct {
+		companyName string
+		pageSize    int64
+		pageNum     int64
+		isExport    bool
 	}
 	tests := []struct {
 		name    string
 		fields  fields
 		args    args
-		want    *entity.PortraitInfo
+		want    *[]*entity.GetNewMsgList
+		want1   int64
 		wantErr bool
 	}{
-		// TODO: Add test cases.
 		{
 			name: "招标动态",
 			fields: fields{
 				Conn: MyConn,
 			},
 			args: args{
-				companyId: "张家港市凤凰镇人民政府",
-				pagesize:  5,
-				pagenum:   1,
+				companyName: "沛县中医院",
+				pageSize:    5,
+				pageNum:     1,
+				isExport:    false,
+			},
+		},
+		{
+			name: "错误的招标动态",
+			fields: fields{
+				Conn: MyConn,
+			},
+			args: args{
+				companyName: "沛县中医院123123",
+				pageSize:    5,
+				pageNum:     1,
+				isExport:    false,
 			},
 		},
 	}
@@ -143,13 +323,90 @@ func TestPortraitService_List(t *testing.T) {
 			this := &PortraitService{
 				Conn: tt.fields.Conn,
 			}
-			got, _, err := this.List(tt.args.companyId, tt.args.pagesize, tt.args.pagenum, false)
+			got, got1, err := this.List(tt.args.companyName, tt.args.pageSize, tt.args.pageNum, tt.args.isExport)
 			if (err != nil) != tt.wantErr {
-				t.Errorf("Info() error = %v, wantErr %v", err, tt.wantErr)
+				t.Errorf("List() error = %v, wantErr %v", err, tt.wantErr)
 				return
 			}
 			if !reflect.DeepEqual(got, tt.want) {
-				t.Errorf("Info() got = %v, want %v", got, tt.want)
+				t.Errorf("List() got = %v, want %v", got, tt.want)
+			}
+			if got1 != tt.want1 {
+				t.Errorf("List() got1 = %v, want %v", got1, tt.want1)
+			}
+		})
+	}
+}
+
+func TestPortraitService_MedicalProdcutList(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	type args struct {
+		companyId string
+		user_id   int64
+	}
+	tests := []struct {
+		name    string
+		fields  fields
+		args    args
+		want    *[]entity.MedicalEquipment
+		wantErr bool
+	}{
+		// TODO: Add test cases.
+		{
+			args: args{
+				companyId: "30d041422855fda867a356b3994a67ea",
+				user_id:   0,
+			},
+		},
+		{
+			args: args{
+				companyId: "30d041422855fda867a356b3994a67ea",
+				user_id:   1,
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: MyConn,
+			}
+			got, err := this.MedicalProdcutList(tt.args.companyId, tt.args.user_id)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("MedicalProdcutList() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("MedicalProdcutList() got = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}
+
+func TestPortraitService_PareTimeSelect(t *testing.T) {
+	type fields struct {
+		Conn *entity.Conn
+	}
+	tests := []struct {
+		name   string
+		fields fields
+		wantSt time.Time
+		wantEt time.Time
+	}{
+		// TODO: Add test cases.
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			this := &PortraitService{
+				Conn: tt.fields.Conn,
+			}
+			gotSt, gotEt := this.PareTimeSelect()
+			if !reflect.DeepEqual(gotSt, tt.wantSt) {
+				t.Errorf("PareTimeSelect() gotSt = %v, want %v", gotSt, tt.wantSt)
+			}
+			if !reflect.DeepEqual(gotEt, tt.wantEt) {
+				t.Errorf("PareTimeSelect() gotEt = %v, want %v", gotEt, tt.wantEt)
 			}
 		})
 	}