项目正式——数据访问接口模块

数据访问接口模块

image
image
image
现在的要求
image
image
image
在URL输入
image

数据访问接口-HTTP协议的本质

image
http基础知识
image
image
image
写一个普通的server程序用来接受浏览器的请求报文以便于分析image
image

image
image
image
image
image
模拟请求报文的发送
image
注意这里网页的内容比较多,调用一次智能读取到一部分的数据,
image
输出到文件保存起来
image
image
image
image
还能抓取图片的地址
image

数据访问接口-HTTP协议示例

image
image
image
代码逻辑很简单
写网页很难,但是写需要效率的csv很简单
image
注意我这里没有这么老的时间
url需要授权 数据库密码 以及接口名数据库 以及访问数据库的条件和参数
image

数据访问接口-表的设计

上个程序中数据访问借口是写死的,需要更新
image
这张图概括了接口的内容
image
image
平台访问日志可以形成如上图
表的具体解析
image
image
测试数据
创建表之间有顺序有要求

依赖表1 去双引号
-- 删除外键约束
alter table T_INTERCFG
   drop constraint FK_INTERCFG_DATATYPE;

-- 删除表
drop table T_INTERCFG cascade constraints;

-- 创建序列
create sequence SEQ_INTERCFG increment by 1 minvalue 1 nocycle;

-- 创建表
create table T_INTERCFG 
(
   intername          varchar2(30)         not null,
   typeid             varchar2(30),
   intercname         varchar2(100),
   selectsql          varchar2(1000)       not null,
   colstr             varchar2(300)        not null,
   bindin             varchar2(300),
   orderby            number(5),
   memo               varchar2(300),
   rsts               number(15)           default 1 not null,
   upttime            date                 default sysdate not null,
   recid              number(15)           not null,
   constraint PK_INTERCFG primary key (intername),
   constraint INTERCFG_KEYID unique (typeid)
);

-- 添加表注释
comment on table T_INTERCFG is
'本表存放了全部接口的配置参数。';

-- 添加列注释
comment on column T_INTERCFG.intername is
'接口代码,英文名。';

comment on column T_INTERCFG.typeid is
'数据种类。';

comment on column T_INTERCFG.intercname is
'接口名称,中文名。';

comment on column T_INTERCFG.selectsql is
'接口SQL。';

comment on column T_INTERCFG.colstr is
'输出列名,列名之间用逗号分隔。';

comment on column T_INTERCFG.bindin is
'接口参数,参数之间用逗号分隔。';

comment on column T_INTERCFG.orderby is
'显示顺序。';

comment on column T_INTERCFG.memo is
'备注。';

comment on column T_INTERCFG.rsts is
'记录状态,1-启用;2-禁用。';

comment on column T_INTERCFG.upttime is
'更新时间。';

comment on column T_INTERCFG.recid is
'记录编号,从与本表同名的序列生成器中获取。';

-- 添加外键约束
alter table T_INTERCFG
   add constraint FK_INTERCFG_DATATYPE foreign key (typeid)
      references T_DATATYPE (typeid);
依赖表2 去双引号
-- 删除表
drop table T_USERINFO cascade constraints;

-- 创建序列
create sequence SEQ_USERINFO increment by 1 minvalue 1 nocycle;

-- 创建表
create table T_USERINFO 
(
   username           varchar2(30)         not null,
   passwd             varchar2(30)         not null,
   appname            varchar2(50)         not null,
   ip                 varchar2(50),
   contacts           varchar2(50),
   tel                varchar2(50),
   email              varchar2(50),
   memo               varchar2(300),
   rsts               number(1)            default 1 not null,
   upttime            date                 default sysdate not null,
   recid              number(15)           not null,
   constraint PK_USERINFO primary key (username),
   constraint USERINFO_KEYID unique (appname)
);

-- 添加表注释
comment on table T_USERINFO is
'本表存放了客户端的身份认证信息。';

-- 添加列注释
comment on column T_USERINFO.username is
'用户名。';

comment on column T_USERINFO.passwd is
'密码。';

comment on column T_USERINFO.appname is
'应用名称。';

comment on column T_USERINFO.ip is
'绑定ip,多个ip之间用逗号分隔。';

comment on column T_USERINFO.contacts is
'联系人。';

comment on column T_USERINFO.tel is
'联系电话。';

comment on column T_USERINFO.email is
'联系邮箱。';

comment on column T_USERINFO.memo is
'备注。';

comment on column T_USERINFO.rsts is
'记录状态,1-启用;2-禁用。';

comment on column T_USERINFO.upttime is
'更新时间。';

comment on column T_USERINFO.recid is
'记录编号,从与本表同名的序列生成器中获取。';

数据访问接口-功能的实现(上)

image
接受线程接受客户端的请求报文,放到接受队列中,工作线程从接收队列获取请求报文并且解析,执行sql语句获取数据生成相应报文交给发送队列,发送线程获取相应报文发送给客户端。
接受线程只有一个,工作线程多个,发送线程只有一个
image
注重理清生产消费者模型思路
client3测试客户端
image
image
知道大概流程,看懂bak再说吧

数据访问接口-功能的实现(下)数据访问接口-功能的实现(下)

然后工作线程连接数据库, 用一个子函数实现sql语句的查询由用户自己输入,在服务器查询数据库,查询完拼接相应报文让后发给客户端

posted @ 2023-11-20 10:04  游客0721  阅读(44)  评论(0)    收藏  举报