当前位置: 首页 > news >正文

寿光建设银行光明路网站站长是什么职位

寿光建设银行光明路网站,站长是什么职位,厦门个人网站建设,上海市今天社会面疫情背景 一位商业大亨,他非常看好国内的社交产品赛道,想要造一款属于的社交产品,于是他找到了负责软件研发的小明。 小明跟张三一拍即合,小明决定跟张三大干一番。 社交产品MVP版本需求 MVP指:Minimum Viable Product&…

背景

一位商业大亨,他非常看好国内的社交产品赛道,想要造一款属于的社交产品,于是他找到了负责软件研发的小明。 小明跟张三一拍即合,小明决定跟张三大干一番。

社交产品MVP版本需求

MVP指:Minimum Viable Product,即最小可行产品

张三希望以最快的时间看到一款属于自己的社交产品,于是有了接下来的需求。

1.用户服务--已完成

注册、登录、查看个人信息、更新个人信息、注销功能

2.推文服务

发布推文、查看推文、更新推文、删除推文、我的推文列表

用户服务详细需求

张三跟小明很快就赶出了MVP版的用户服务的详细需求

1.注册功能。
支持账号密码注册功能:
  • 账号6-16位,支持数字大小写不敏感的字母和特殊字符_且必须是英文字符开头
  • 密码必须8-32位,支持数字大小写敏感的字母
2.登录功能。
  • 支持账号密码登录功能
3.更新个人信息功能。
  • 支持更新的信息:头像、昵称、个性签名、性别、地区
4.查看个人信息功能。
  • 查看个人的信息:头像、昵称、个性签名、性别、地区
5.注销功能。
  • 注销功能:申请注销后,7天内没有登录,则把账号注销
  • 查看已注销的用户信息时,昵称显示已注销,头像设置展示为默认的官方头像

推文服务详细需求

张三跟小明很快就赶出了MVP版的推文系统的详细需求:

功能1:推文
  • 发表推文。推文最大长度限制10000字符,标题可选,推文必填
  • 查看推文。展示的信息字段:标题、内容、时间(优先展示编辑时间,其次发表时间)
  • 更新推文。支持更新的字段:标题、推文。标题可选,推文必填
  • 删除推文。真实删除,从数据库中移除数据
  • 我的推文列表。查看已经发表过的推文,按发表时间排序排列
功能2:互动
  • 浏览推文。浏览推文按计算方式:每篇推文,点击进入详情累计加1,同一用户24小时内浏览多次,只累计加1
  • 点赞推文。点赞数计算方式:用户点赞+1,取消点赞-1
  • 评论推文
    • 无限层级评论
    • 评论数计算方式:所有能展示的评论数量。比如有1条评论,这条评论有3条子评论,评论的总数量是4.如果删除这条评论,那么评论的总数量是0
  • 分享推文。分享数计算方式:每篇推文,分享累计加1,同一用户24小时内分享多次,只累计加1
  • 收藏推文。点赞数计算方式:用户点赞+1,取消点赞-1

开发环境的搭建

0.安装go语言,推荐使用1.22以上的版本

1.安装goctl,用于提升效率,生成各种代码

go install github.com/zeromicro/go-zero/tools/goctl@latest

2.安装protoc,微服务grpc需要用到的组件

goctl env check --install --verbose --force

3.mysql

docker run -p 3306:3306 --name test-mysql -v mysql:/var/lib/mysql/ -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest

4.redis

docker run -d --name redis -p 6379:6379 redis

5.etcd


# etcd服务
docker network create demo-network --driver bridge
docker run -d --name etcd-server --network demo-network --publish  2379:2379 --publish  2380:2380 --env ALLOW_NONE_AUTHENTICATION=yes --env ETCD_ADVERTISE_CLIENT_URLS=http://etcd-server:2379 bitnami/etcd:latest
# 检查etcd容器ip
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' etcd-server
# (可选)etcd keeper http://127.0.0.1:8080/
docker run -d -p 8080:8080 -e ETCD_SERVERS=http://172.18.0.2:2379 --network=demo-network --name etcd-keeper evildecay/etcdkeeper

实现用户服务

1.注册功能
支持账号密码注册:
  • 账号6-16位,支持数字大小写不敏感的字母和特殊字符_且必须是英文字符开头
  • 密码必须8-32位,支持数字大小写敏感的字母
  • 支持账号密码登录功能
2.登录功能
  • 如果该用户申请注销账号了,登录后自动取消注销
3.个人信息。包含查看、更新
  • 查看/更新的个人信息:头像、昵称、个性签名(255字符以内)、性别、地区

4.注销账号功能

  • 注销功能:申请注销后,7天内没有登录,则把账号注销
  • 查看已注销的用户信息时,昵称显示已注销,头像设置展示为默认的官方头像


初始化user服务

# 初始化user rpc服务
goctl rpc new user
# 安装依赖
go mod tidy
create table user
(id         bigint auto_increment comment '主键id'primary key,avatar     varchar(255) default '' not null comment '头像链接地址',nickname   char(32)     default '' not null comment '昵称',account    char(32)     default '' not null comment '账号',password   char(32)     default '' not null comment '密码',bio        varchar(255) default '' not null comment '个人简介 Biography',gender     tinyint      default 2  not null comment '性别 0 女 1 男 2 未知',region     varchar(20)  default '' not null comment '地区',status     tinyint      default 0  not null comment '用户状态0 正常 1 注销中 2 已注销',created_at int          default 0  not null comment '创建时间',updated_at int          default 0  not null comment '更新时间',deleted_at int          default 0  not null comment '删除时间',constraint user_pkunique (account)
)comment '用户表' collate = utf8mb4_bin;
# 项目根目录下执行
# 加上 -c 参数可生成集成缓存的model代码
# --ignore-columns -i 忽略字段控制
goctl model mysql datasource -url="root:123456@tcp(127.0.0.1:3306)/go_zero_demo" -table="user"  -dir="./user/model" --ignore-columns -i

user服务功能实现

定义proto
syntax = "proto3";package user;
option go_package="./user";message UserInfo {int64 UserId  = 1;        // 主键idstring Avatar = 2;     // 头像链接地址string Nickname  = 3;  // 昵称string Account    = 4; // 账号string Password  = 5; // 密码string Bio       = 6; // 个人简介 Biographyint64 Gender     = 7; // 性别 0 女 1 男 2 未知string Region     = 8; // 地区int64 Status     = 9; // 地区int64 CreatedAt = 10; // 创建时间int64 UpdatedAt = 11; //更新时间
}message RegisterReq {string Account = 1; // 自定义账号string Password = 2; // 密码
}
message RegisterResp {int64 UserId = 1; // 用户ID
}message LoginReq {string Account = 1; // 自定义账号string Password = 2; // 密码
}
message LoginResp {string SessionId = 1; // 用户登录标识
}message CancellationReq {int64 UserId = 1; // 用户ID
}
message CancellationResp {}message GetUsersReq {int64 UserId = 1; // 用户ID
}
message GetUsersResp {UserInfo UserInfo = 1;
}message UpdateUserReq {UserInfo UserInfo = 1;
}
message UpdateUserResp {}service User {// 注册rpc Register(RegisterReq) returns(RegisterResp);// 登录rpc Login(LoginReq) returns(LoginResp);// 注销rpc Cancellation(CancellationReq) returns(CancellationResp);// 查用户信息rpc GetUsers(GetUsersReq) returns(GetUsersResp);// 更新用户信息rpc UpdateUser(UpdateUserReq) returns(UpdateUserResp);
}
# 项目根目录下执行
goctl rpc protoc user/user.proto --go_out=./user --go-grpc_out=./user --zrpc_out=./user
1.注册功能
功能逻辑代码::./user/internal/logic/registerlogic.go
测试代码::./user/internal/logic/registerlogic_test.go
2.登录功能
功能逻辑代码::./user/internal/logic/loginlogic.go
测试代码::./user/internal/logic/loginlogic.go
3.注销功能
功能逻辑代码::./user/internal/logic/cancellationlogic.go
测试代码::./user/internal/logic/cancellationlogic_test.go
4.个人信息
查看个人信息
功能逻辑代码::./user/internal/logic/getuserslogic.go
测试代码::./user/internal/logic/getuserslogic_test.go
更新个人信息
功能逻辑代码::./user/internal/logic/updateuserlogic.go
测试代码::./user/internal/logic/updateuserlogic_test.go

实现推文服务

初始化推文post服务

goctl rpc new user
go mod tidy
create table post
(id         bigint auto_increment comment '主键id',user_id    bigint   				 			 not null comment '用户id',title      varchar(255) default '' not null comment '标题',content    text         					 not null comment '推文内容',status     tinyint      default 0  not null comment '状态 0 正常 1 已删除',views      int          default 0  not null comment '浏览数',likes      int          default 0  not null comment '点赞数',comments   int          default 0  not null comment '评论数',shares     int          default 0  not null comment '分享数',collects   int          default 0  not null comment '收藏数',created_at int          default 0  not null comment '发表时间',updated_at int          default 0  not null comment '更新时间',deleted_at int          default 0  not null comment '删除时间',constraint post_pkprimary key (id)
)comment '推文表' collate = utf8mb4_bin;
# 项目根目录下执行
# 加上 -c 参数可生成集成缓存的model代码
# --ignore-columns -i 忽略字段控制
goctl model mysql datasource -url="root:123456@tcp(127.0.0.1:3306)/go_zero_demo" -table="post"  -dir="./post/model" --ignore-columns -i

post服务功能实现

定义proto
syntax = "proto3";package post;
option go_package="./post";// 定义实体结构
message PostData {int64 Id = 1; // idstring Title = 2; // 标题string Content = 3; // 内容int64 Views = 4; // 查看数int64 Likes = 5; // 喜欢数int64 Comments = 6; // 评论数int64 Shares = 7; // 分享数int64 Collects = 8; // 收藏数}message CreatePostReq {PostData PostData = 1;
}message CreatePostResp {}message UpdatePostReq {PostData PostData = 1;
}message UpdatePostResp {}message DeletePostReq {int64 PostId = 1;
}message DeletePostResp {}message GetPostReq {int64 PostId = 1;
}message GetPostResp {}message BatchPostReq {repeated int64 PostId = 1;
}message BatchPostResp {repeated PostData Infos = 1;
}message GetUserPostListReq {int64 UserId = 1; // 用户ID
}message GetUserPostListResp {repeated PostData Infos = 1;
}service Post {// 发表推文rpc CreatePost(CreatePostReq) returns(CreatePostResp);// 更新推文rpc UpdatePost(UpdatePostReq) returns(UpdatePostResp);// 删除推文rpc DeletePost(DeletePostReq) returns(DeletePostReq);// 获取单条推文rpc GetPost(GetPostReq) returns(GetPostResp);// 批量获取推文rpc BatchPost(BatchPostReq) returns(BatchPostResp);// 用户用户推文列表rpc GetUserPostList(GetUserPostListReq) returns(GetUserPostListResp);
}
# 项目根目录下执行
goctl rpc protoc post/post.proto --go_out=./post --go-grpc_out=./post --zrpc_out=./post
1.发表推文功能
功能逻辑代码::./post/internal/logic/createpostlogic.go
测试代码::./post/internal/logic/createpostlogic_test.go
2.查看推文功能
功能逻辑代码::./post/internal/logic/getpostlogic.go
测试代码::./post/internal/logic/getpostlogic_test.go
3.更新推文功能
功能逻辑代码::./post/internal/logic/updatepostlogic.go
测试代码::./post/internal/logic/updatepostlogic_test.go
4.删除推文功能
功能逻辑代码::./post/internal/logic/deletepostlogic.go
测试代码::./post/internal/logic/deletepostlogic_test.go
5.查看用户推文列表功能
功能逻辑代码::./post/internal/logic/getuserpostlistlogic.go
测试代码::./post/internal/logic/getuserpostlistlogic_test.go

实现API服务

初始化bff服务

goctl api new bff# 生成api代码
goctl api go -api ./bff/bff.api -dir ./bff/

其它

1.跨域配置

func StartHttpServer(configFile *string) {var c config.Configconf.MustLoad(*configFile, &c)server := rest.MustNewServer(c.RestConf, rest.WithCustomCors( //跨域处理func(header http.Header) {header.Set("Access-Control-Allow-Origin", "*")header.Set("Access-Control-Allow-Headers", "*")header.Set("Access-Control-Allow-Methods", "POST,OPTIONS")header.Set("Access-Control-Allow-Credentials", "true")}, nil, "*"))defer server.Stop()……server.Start()
}

2.服务依赖配置

UserRpcConf:Etcd:Key: dev.user.rpc
# 默认是两秒Timeout: 4500 
# 当值为 true 时,不会阻塞 rpc 链接NonBlock: false

弱依赖可配置为 true,否则初始化rpc的时候会报以下错误

rpc dial: etcd://127.0.0.1:2379/dev.user.rpc, error: context deadline exceeded, make sure rpc service "dev.user.rpc" is already started

http://www.yidumall.com/news/72972.html

相关文章:

  • 网站建设注意事项百度灰色关键词代发
  • 淳安网站建设桂平seo关键词优化
  • 西安保洁公司网站建设雏鸟app网站推广
  • 做网站需提供什么资料何鹏seo
  • wordpress第三性百度seo排名原理
  • 网站项目名称软件怎么推广
  • 网站让女友做色情模特大侠seo外链自动群发工具
  • 挂机宝可以做网站吗广州市新闻发布
  • 网站建设合同 简单学新媒体运营最好的培训学校
  • 乐清市网站建设太原网站关键词排名
  • 苏州做网站建设淘宝数据分析
  • 连云港网站建设百度谷歌seo优化
  • wordpress如何在文章底部添加目录遵义网站seo
  • 网站建设手机站俄罗斯搜索引擎推广
  • 做网站 广告收入seo三人行论坛
  • wordpress调用文章阅读量百度快照如何优化
  • 朋友找做网站都要收定金购物网站大全
  • 哈尔滨网站建设一薇ls15227营销策略案例
  • 做不锈钢的网站有哪些凡科建站官网登录
  • 跨境电商平台数据成都专业的整站优化
  • 有什么可以做任务赚钱的网站seo快速软件
  • phpcms做的网站有哪些如何利用互联网进行宣传推广
  • 网站域名必须备案吗免费收录网站
  • 外链网盘网站注册网站
  • 导航网站怎么做seo公司网站注册流程和费用
  • 重庆招聘网站建设线上销售怎么做
  • 简单的旅游网站怎么做最好的免费推广平台
  • 福州建设工程质量监督网站环球军事网
  • 医院网站怎么建设西安百度推广竞价托管
  • 佛山网页制作设计dz论坛seo