|
|
package GovAreaService
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
"dsBaseWeb/Business/GovArea/GovAreaProto"
|
|
|
"dsBaseWeb/Utils/GRpcUtil"
|
|
|
"dsBaseWeb/Utils/LogUtil"
|
|
|
"errors"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
/**
|
|
|
功能:根据行政区划码获取下级行政区划
|
|
|
作者:吴缤
|
|
|
时间:2020-04-20
|
|
|
*/
|
|
|
func GetGovArea(areaCode string, actionPersonId string, actionIpAddress string) (*GovAreaProto.Reply, error) {
|
|
|
//1、准备动作:连接服务器
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
defer cancel()
|
|
|
conn := GRpcUtil.GetConnection()
|
|
|
if conn == nil {
|
|
|
return nil, errors.New("RPC服务未启动!")
|
|
|
}
|
|
|
c := GovAreaProto.NewGovAreaManageClient(conn)
|
|
|
Reply, err := c.GetGovArea(ctx, &GovAreaProto.ModelArg{AreaCode: areaCode, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if err != nil {
|
|
|
LogUtil.Error("根据行政区划码获取下级行政区划错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:根据行政区划码获取下级行政区划
|
|
|
作者:吴缤
|
|
|
时间:2020-04-20
|
|
|
*/
|
|
|
func PageGovArea(page int32, limit int32, areaCode string, actionPersonId string, actionIpAddress string) (*GovAreaProto.Reply, error) {
|
|
|
//1、准备动作:连接服务器
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
defer cancel()
|
|
|
conn := GRpcUtil.GetConnection()
|
|
|
if conn == nil {
|
|
|
return nil, errors.New("RPC服务未启动!")
|
|
|
}
|
|
|
c := GovAreaProto.NewGovAreaManageClient(conn)
|
|
|
Reply, err := c.PageGovArea(ctx, &GovAreaProto.QueryArg{Page: page, Limit: limit, AreaCode: areaCode, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if err != nil {
|
|
|
LogUtil.Error("根据行政区划码获取下级行政区划错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:增加行政区划
|
|
|
作者:吴缤
|
|
|
时间:2020-04-21
|
|
|
*/
|
|
|
func AddGovArea(areaCode string, areaName string, masterCode string, areaLevelId int32, areaTypeId int32, actionPersonId string, actionIpAddress string) (*GovAreaProto.Reply, error) {
|
|
|
//1、准备动作:连接服务器
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
defer cancel()
|
|
|
conn := GRpcUtil.GetConnection()
|
|
|
if conn == nil {
|
|
|
return nil, errors.New("RPC服务未启动!")
|
|
|
}
|
|
|
c := GovAreaProto.NewGovAreaManageClient(conn)
|
|
|
Reply, err := c.AddGovArea(ctx, &GovAreaProto.ModelArg{AreaCode: areaCode, AreaName: areaName, MasterCode: masterCode, AreaLevelId: areaLevelId, AreaTypeId: areaTypeId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if err != nil {
|
|
|
LogUtil.Error("增加行政区划错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:修改行政区划
|
|
|
作者:吴缤
|
|
|
时间:2020-04-21
|
|
|
*/
|
|
|
func UpdateGovArea(areaCode string, areaName string, masterCode string, areaTypeId int32, actionPersonId string, actionIpAddress string) (*GovAreaProto.Reply, error) {
|
|
|
//1、准备动作:连接服务器
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
defer cancel()
|
|
|
conn := GRpcUtil.GetConnection()
|
|
|
if conn == nil {
|
|
|
return nil, errors.New("RPC服务未启动!")
|
|
|
}
|
|
|
c := GovAreaProto.NewGovAreaManageClient(conn)
|
|
|
Reply, err := c.UpdateGovArea(ctx, &GovAreaProto.ModelArg{AreaCode: areaCode, AreaName: areaName, MasterCode: masterCode, AreaTypeId: areaTypeId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if err != nil {
|
|
|
LogUtil.Error("修改行政区划错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:删除行政区划
|
|
|
作者:吴缤
|
|
|
时间:2020-04-21
|
|
|
*/
|
|
|
func DeleteGovArea(areaCode string, actionPersonId string, actionIpAddress string) (*GovAreaProto.Reply, error) {
|
|
|
idsArr := strings.Split(areaCode, ",")
|
|
|
//1、准备动作:连接服务器
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
defer cancel()
|
|
|
conn := GRpcUtil.GetConnection()
|
|
|
if conn == nil {
|
|
|
return nil, errors.New("RPC服务未启动!")
|
|
|
}
|
|
|
c := GovAreaProto.NewGovAreaManageClient(conn)
|
|
|
Reply, err := c.DeleteGovArea(ctx, &GovAreaProto.DeleteIdsArg{Ids: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
|
|
|
if err != nil {
|
|
|
LogUtil.Error("删除行政区划错误: ", err.Error())
|
|
|
}
|
|
|
return Reply, err
|
|
|
}
|