关于0代码和低代码的开发,作者也写过好多篇文章介绍了,目前功能也还在逐步优化中,并且已经在好几个商业项目中使用过了,今天我们继续讲解低代码或0代码中的sql解析规则 

 

零代码、低代码对于软件市场的影响:需要入坑的小白一定要看哦_无极低码的博客-CSDN博客

无极低代码平台是作者自己定义的一套解析规则,相对mybatis来说更轻量和简单,只要会写sql基本不需要任何额外的知识就可以进行数据接口的开发。

sql类型

无极低码采用的是md文件格式,当然改为txt也没问题,重要的是内容

下面是一个包含了单表增删改查的功能,是自动生成的,可以满足多条件检索,多参数修改等,先看一下内容我们稍后解释

select
===
select id ,name ,phone ,pass ,headpic ,create_time createTime,org_code orgCode,user_type userType from d_base_user where 1=1 
@byid
 and id =#byid#
@byIn_id
 and id in(#byIn_id#)
@byname
  and name='#byname#'
@byphone
  and phone='#byphone#'
@bypass
  and pass='#bypass#'
@byheadpic
  and headpic='#byheadpic#'
@bystartcreateTime&&byendcreateTime
 and  create_time between '#bystartcreateTime#' and '#byendcreateTime#'
@byorgCode
  and org_code='#byorgCode#'
@byuserType
  and user_type=#byuserType#
;

selectOneByid
===
select id ,name ,phone ,pass ,headpic ,create_time createTime,org_code orgCode,user_type userType from d_base_user where 1=1 
@byid
 and id =#byid#
@byIn_id
 and id in(#byIn_id#)
@byname
  and name='#byname#'
@byphone
  and phone='#byphone#'
@bypass
  and pass='#bypass#'
@byheadpic
  and headpic='#byheadpic#'
@bystartcreateTime&&byendcreateTime
 and  create_time between '#bystartcreateTime#' and '#byendcreateTime#'
@byorgCode
  and org_code='#byorgCode#'
@byuserType
  and user_type=#byuserType#
;

delete
===
delete  from d_base_user where 1=1 
@byid
 and id =#byid#
@byIn_id
 and id in(#byIn_id#)
@byname
  and name='#byname#'
@byphone
  and phone='#byphone#'
@bypass
  and pass='#bypass#'
@byheadpic
  and headpic='#byheadpic#'
@bystartcreateTime&&byendcreateTime
 and  create_time between '#bystartcreateTime#' and '#byendcreateTime#'
@byorgCode
  and org_code='#byorgCode#'
@byuserType
  and user_type=#byuserType#
;

insert
===
insert ignore into d_base_user(name,phone,pass,headpic,create_time,org_code,user_type) 
 VALUES('@#name#','@#phone#','@#pass#','@#headpic#',NOW(),'#orgCode#',#userType#);

update
===
update d_base_user set 
@id
 id=#id#,
@name
 name='#name#',
@phone
 phone='#phone#',
@pass
 pass='#pass#',
@headpic
 headpic='#headpic#',
@createTime
 create_time='#createTime#',
@orgCode
 org_code='#orgCode#',
@userType
 user_type=#userType#
 where 1=1 
@byid
 and id =#byid#
@byIn_id
 and id in(#byIn_id#)
@byname
  and name='#byname#'
@byphone
  and phone='#byphone#'
@bypass
  and pass='#bypass#'
@byheadpic
  and headpic='#byheadpic#'
@byStartcreateTime&&byEndcreateTime
 and  create_time between '#byStartcreateTime#' and '#byEndcreateTime#'
@bycreateTime
  and create_time='#bycreateTime#'
@byorgCode
  and org_code='#byorgCode#'
@byuserType
  and user_type='#byuserType#'

 

 这里面我们可以看到是一个单表数据查询,需要输出的字段我们可以自己定义,多条件组合通过@+字段方式动态拼接,而@后的这个参数是暴露给前端的字段可以随便写,如果前端在调用接口的时候传了参数就会动态拼接进去,比如:select id ,name ,phone ,pass ,headpic ,create_time createTime,org_code orgCode,user_type userType from d_base_user where 1=1 
@byid
 and id =#byid#

前端接口调用过程中传递了参数byid,sql的最终执行结果就是:

select id ,name ,phone ,pass ,headpic ,create_time createTime,org_code orgCode,user_type userType from d_base_user where 1=1  and id=1

前端接口调用过程中传递了参数byid和byheadpic,sql的最终执行结果就是:

select id ,name ,phone ,pass ,headpic ,create_time createTime,org_code orgCode,user_type userType from d_base_user where 1=1  and id=1 and byheadpic='http//www.baidu.com/img.png'

数据类型

数字类型:and id =#byid#

字符串类型:and byheadpic=’#byheadpic#‘

in条件

@byIn_id
 and id in(#byIn_id#)

like模糊条件

@bychecks
  and checks like '%#bychecks#%'

时间段条件

@bystartmodifiedTime&&byendmodifiedTime
 and  modified_time between '#bystartmodifiedTime#' and '#byendmodifiedTime#'

 插入

insert
===
insert ignore into d_code_manager(code_num,simple_name,name,modified_time,size) 
 VALUES(#codeNum#,'#simpleName#','@#name#',NOW(),#size#);

##之间表示数字

'##'之间表示字符串

'@##'之间的字符串表示该字段不允许为空

就这点规则了,我想10分钟应该可以学会了吧

Logo

低代码爱好者的网上家园

更多推荐