You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
6.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package BaseStudentService
import (
"context"
"dsBaseWeb/Business/BaseStudent/BaseStudentProto"
"dsBaseWeb/Utils/GRpcUtil"
"dsBaseWeb/Utils/LogUtil"
"errors"
"strings"
"time"
)
/**
功能:获取学生列表
作者:吴缤
时间2020-06-02 15:16:46
*/
func PageBaseStudent(queryArg BaseStudentProto.QueryArg) (*BaseStudentProto.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服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.PageBaseStudent(ctx, &queryArg)
if err != nil {
LogUtil.Error("获取学生列表错误: ", err.Error())
}
return Reply, err
}
/**
功能:获取学生信息
作者:吴缤
时间2020-06-02 15:17:24
*/
func GetBaseStudent(modelArg BaseStudentProto.ModelArg) (*BaseStudentProto.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服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.GetBaseStudent(ctx, &modelArg)
if err != nil {
LogUtil.Error("获取学生信息错误: ", err.Error())
}
return Reply, err
}
/**
功能:增加学生信息
作者:吴缤
时间2020-06-02 15:17:50
*/
func AddBaseStudent(modelArg BaseStudentProto.ModelArg) (*BaseStudentProto.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服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.AddBaseStudent(ctx, &modelArg)
if err != nil {
LogUtil.Error("增加学生信息错误: ", err.Error())
}
return Reply, err
}
/**
功能:删除学生信息
作者:吴缤
时间2020-06-02 15:18:18
*/
func DeleteBaseStudent(deleteIdsArg BaseStudentProto.DeleteIdsArg) (*BaseStudentProto.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服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.DeleteBaseStudent(ctx, &deleteIdsArg)
if err != nil {
LogUtil.Error("删除学生信息错误: ", err.Error())
}
return Reply, err
}
/**
功能:增加学生信息
作者:吴缤
时间2020-06-02 15:18:43
*/
func UpdateBaseStudent(modelArg BaseStudentProto.ModelArg) (*BaseStudentProto.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服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.UpdateBaseStudent(ctx, &modelArg)
if err != nil {
LogUtil.Error("增加学生信息错误: ", err.Error())
}
return Reply, err
}
/**
功能:学生调整班级
作者:吴缤
时间2020-06-02 10:15:06
*/
func ReviseStudentClass(ids string, classId string) (*BaseStudentProto.Reply, error) {
idsArr := strings.Split(ids, ",")
//1、准备动作连接服务器
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
conn := GRpcUtil.GetConnection()
if conn == nil {
return nil, errors.New("RPC服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.ReviseStudentClass(ctx, &BaseStudentProto.ReviseArg{Ids: idsArr, ClassId: classId})
if err != nil {
LogUtil.Error("学生调整班级错误: ", err.Error())
}
return Reply, err
}
/**
功能导出本校学生账号信息到EXCEL
作者:吴缤
时间2020-06-02 15:18:43
*/
func ExportStudentAccountInfoExcel(modelArg BaseStudentProto.ModelArg) (*BaseStudentProto.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服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.ExportStudentAccountInfoExcel(ctx, &modelArg)
if err != nil {
LogUtil.Error("导出学生信息错误: ", err.Error())
}
return Reply, err
}
/**
功能导出本校学生信息到EXCEL
作者:吴缤
时间2020-06-02 15:18:43
*/
func ExportStudentInfoExcel(modelArg BaseStudentProto.ModelArg) (*BaseStudentProto.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服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.ExportStudentInfoExcel(ctx, &modelArg)
if err != nil {
LogUtil.Error("导出学生信息错误: ", err.Error())
}
return Reply, err
}
/**
功能:导入本校学生信息
作者:吴缤
时间2020-06-14 14:18:43
*/
func ImportStudentInfoExcel(importArg BaseStudentProto.ImportArg) (*BaseStudentProto.Reply, error) {
//1、准备动作连接服务器
ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second)
defer cancel()
conn := GRpcUtil.GetConnection()
if conn == nil {
return nil, errors.New("RPC服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.ImportStudentInfoExcel(ctx, &importArg)
if err != nil {
LogUtil.Error("导入学生信息错误: ", err.Error())
}
return Reply, err
}
func StudentTransfer(arg BaseStudentProto.StudentTransferArg) (*BaseStudentProto.Reply, error) {
//1、准备动作连接服务器
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
conn := GRpcUtil.GetConnection()
if conn == nil {
return nil, errors.New("RPC服务未启动")
}
//2、业务传参
c := BaseStudentProto.NewBaseStudentManageClient(conn)
Reply, err := c.StudentTransfer(ctx, &arg)
if err != nil {
LogUtil.Error("学生调转学校错误: ", err.Error())
}
return Reply, err
}