package service

import (
	"log"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestOpenPower(t *testing.T) {
	//信息发布
	err := OpenPower("10000", "xxfb_gyxx", 4, 0, 64, 221, 1, "", "")
	//医疗领域化
	//err := OpenPower("10000", "lyh", 13, 0, 13485, 0, 1, "", "")
	//医疗领域化
	//err := OpenPower("10000", "special_nosale_goods", 24, 13488, 64, 221, 1, "", "")
	assert.Nil(t, err)
}

func TestCancelPower(t *testing.T) {
	//信息发布
	//b, err := CancelPower("10000", "xxfb_gyxx", 4, 11686, 0)
	//医疗领域化
	b, err := CancelPower("10000", "special_nosale_goods", 46, 0, 3, 1)
	assert.Nil(t, err)
	assert.True(t, b)
}

func TestHasPowers(t *testing.T) {
	//企业
	powers, err := HasPowers("10000", 1080194, 1080192, 356303, 96589)
	//个人
	//powers, err := HasPowers("10000", 13485, 0, 0, 0)
	assert.Nil(t, err)
	t.Log(powers)
}

func TestCfReEmpower(t *testing.T) {
	v, err := ReEmpower("10000", []string{"bi_dx_yjtj", "bi_dx_zxdx", "bi_dx_rcgl", "bi_dx_wjsgjkh", "bi_dx_shxs", "bi_dx_xszl", "bi_dx_xsemx"}, 1, []int64{3870, 123, 456})
	log.Println("--------", v)
	assert.Nil(t, err)
	assert.Equal(t, int64(1), v)
	//v, err = ReEmpower("10000", "znsj_jqr_use", 14184, []int64{4271})
	//assert.Nil(t, err)
	//assert.Equal(t, int64(1), v)
}

func TestCrReEmpower(t *testing.T) {
	v, err := CrReEmpower("10000", []string{"bi_电销菜单管理"}, []string{"bi_dx_yjtj", "bi_dx_qbxs", "bi_dx_zxdx"}, 1, []int64{3870, 123, 456})
	assert.Nil(t, err)
	assert.Equal(t, int64(1), v)
	//v, err = ReEmpower("10000", "znsj_jqr_use", 14184, []int64{4271})
	//assert.Nil(t, err)
	//assert.Equal(t, int64(1), v)
}

func TestAddEmpower(t *testing.T) {
	v, err := Empower("10000", []string{"bi_dx_ghxs", "bi_dx_zxdx", "bi_dx_rcgl", "bi_dx_wjsgjkh", "bi_dx_shxs", "bi_dx_xszl"}, 1, []int64{3870, 123, 456, 6763})
	assert.Nil(t, err)
	assert.Equal(t, int64(1), v)
}

func TestCancelEmpower(t *testing.T) {
	//v, err := CancelEmpower("10000", []string{"bi_dx_ghxs", "bi_dx_zxdx", "bi_dx_rcgl", "bi_dx_wjsgjkh", "bi_dx_shxs", "bi_dx_xszl"}, 1, []int64{3870, 123, 456})
	v, err := CancelEmpower("10000", []string{"bi_dx_wjsgjkh", "bi_dx_rcgl", "bi_dx_yjtj"}, 1, []int64{3870})
	assert.Nil(t, err)
	assert.Equal(t, int64(1), v)
}

func TestCancelAllEmpower(t *testing.T) {
	v, err := CancelAllEmpower("10000", []string{"bi_电销菜单管理"}, 1, []int64{3870})
	assert.Nil(t, err)
	assert.Equal(t, int64(1), v)
}

func TestEmpowerList(t *testing.T) {
	count, list, err := EmpowerList("10000", "znsj_kf_use", 14184, 2, 1)
	assert.Nil(t, err)
	t.Log(count, list)
}

func TestWaitEmpowerDetail(t *testing.T) {
	r, err := WaitEmpowerDetail("10000", "znsj_kf_use", 14184)
	assert.Nil(t, err)
	t.Log(r)
}
