syntax = "proto3"; //版本声明,使用v3版本

package fsservice;
option go_package = "gitee.com/fusenpack/fusen-service;service";

// 导入google/api/annotations.proto 注释依赖
import "google/api/annotations.proto";
import "service/basic.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/any.proto";


//定义服务
service info {
    // 用户信息
    rpc UserInfo(UserInfoRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/user"
            body: "*"
        };
    }


    // 用户个人资料查询
    rpc UserProfile(QueryProfileRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/user/profile"
            body: "*"
        };
    }

    // 获取默认用户个人资料
    rpc DefaultUserProfile(DefaultProfileRequest) returns (basic.Response) {
        option (google.api.http) = {
            get: "/api/info/user/profile/default/{request}"
        };
    }

    // 更新用户个人资料
    rpc UpdateProfileBase(ProfileRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/user/profile/base/update"
            body: "*"
        };
    }

    // 设置默认地址
    rpc AddressDefault(AddressDefaultRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/address/default"
            body: "*"
        };
    }

    // 添加地址
    rpc AddressAdd(AddressRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/address/add"
            body: "*"
        };
    }

    // 更新地址
    rpc AddressUpdate(AddressRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/address/update"
            body: "*"
        };
    }

    // 更新地址使用状态
    rpc AddressUsedUpdate(AddressIdRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/address/update/used"
            body: "*"
        };
    }

    // 删除地址
    rpc AddressDelete(AddressIdRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/address/delete"
            body: "*"
        };
    }

    // 获取地址列表
    rpc AddressList(basic.Request) returns (basic.Response) {
        option (google.api.http) = {
            get: "/api/info/address/list"
        };
    }

    // 获取餐厅列表
    rpc RestaurantList(basic.Request) returns (basic.Response) {
        option (google.api.http) = {
            get: "/api/info/restaurant/list"
        };
    }

    // 搜索建议
    rpc PreLogoSearchSuggestions(PreLogoSearchSuggestionsRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/prelogo/search/suggestions"
            body: "*"
        };
    }

    // 搜索
    rpc PreLogoSearch(PreLogoSearchRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/prelogo/search"
            body: "*"
        };
    }

    // 联系我们
    rpc ContactUs(ContactUsRequest) returns (basic.Response) {
        option (google.api.http) = {
            post: "/api/info/contact/us"
            body: "*"
        };
    }

}

//定义产品服务
service product {
    // 产品详情
    rpc GetProductDetail(GetProductDetailReq) returns (basic.Response) {
        option (google.api.http) = {
            get: "/api/product/get_product_detail"
        };
    }
    //获取产品列表
    rpc GetProductList(GetProductListReq) returns (basic.Response) {
        option (google.api.http) = {
            get: "/api/product/tag_product_list"
        };
    }
    //计算产品价格
    rpc CalculateProductPrice(CalculateProductPriceReq) returns (CalculateProductPriceRsp) {
        option (google.api.http) = {
            post: "/api/product/calculate_product_price"
            body: "*"
        };
    }
}

message UserInfoRequest {
    repeated string module = 1; // 模块
}

message QueryProfileRequest {
    string top_key = 1; // 首键
}

message QueryProfileResponse {
    google.protobuf.Struct data = 1;
}

message DefaultProfileRequest {
    string request = 1; // 请求
}

message ProfileRequest {
    ProfileBase base = 1; // 基础个人资料
    SubscriptionStatus sub_status = 2; // 订阅状态
}

message ProfileBase {
    optional string first_name = 1; // 名字
    optional string last_name = 2; // 姓氏
    optional string email = 4; // 电子邮件
    optional string mobile = 5; // 手机号码
    optional string resetaurant = 6; // 餐厅
    optional string company = 7; // 公司
}

message SubscriptionStatus {
    NotificationEmail notification_email = 1; // 邮件通知设置
    NotificationPhone notification_phone = 2; // 电话通知设置
}

message NotificationEmail {
    bool order_update = 1; // 订单更新
    bool newseleter = 2; // 新闻订阅
}

message NotificationPhone {
    bool order_update = 1; // 订单更新
    bool newseleter = 2; // 新闻订阅
}

message AddressObjectRequest {
    int64 address_id = 1; // 地址ID
   string address_name = 2; // 地址名称
}

message AddressIdRequest {
    int64 address_id = 1; // 地址ID
}

message AddressDefaultRequest {
    int64 address_id = 1; // 地址ID
    int64 is_default = 2; // 是否默认
}

message AddressRequest {
    int64 address_id = 1; // 地址ID(已弃用)
    int64 is_default = 2; // 是否默认
    string first_name = 3; // 名字
    string last_name = 4; // 姓氏
    string mobile = 5; // 手机号码
    string zip_code = 6; // 邮政编码
    string street = 7; // 街道
    string suite = 8; // 套房
    string city = 9; // 城市
    string state = 10; // 省份
}

message PreLogoSearchSuggestionsRequest {
    string keywords = 1; // 关键字
}

message PreLogoSearchRequest {
    string zip_code = 1; // 邮编
    string keywords = 2; // 关键字
}

message ContactUsRequest {
    string name = 1; // 姓名
    string email = 2; // 电子邮件
    string phone = 3; // 电话号码
    string message = 4; // 消息内容
}

//获取产品详情
message GetProductDetailReq{
    int64   product_id = 1;
    string  template_tag = 2;
    int64   selected_color_index = 3;
    string  logo = 4;
}
//获取产品列表
message GetProductListReq{
    int64   basic_tag_id = 1;  //传入则以该分类为最高层分类查询
    int64   merchant_type = 2; //商户类型
    string  template_tag = 3;  //模板标签
    bool    with_product = 4;  //是否携带分类下的产品
}
//计算产品价格
message CalculateProductPriceReq{
    int64 product_id = 1;
    int64 size_id = 2;
    int64 fitting_id = 3;
    int64 purchase_quantity = 4;
}
message CalculateProductPriceRsp{
    string      item_price = 1;
    string      total_price = 2;
    StepRange   step_range = 3;
}
message StepRange{
    int64   start = 1;//起点
    int64   end = 2;//终点
    string  range_description = 3;//描述
    string  item_price = 4;//单价
}