Java链式命名规则

x33g5p2x  于2021-09-30 转载在 Java  
字(2.1k)|赞(0)|评价(0)|浏览(329)

Java链式命名规则

数据库->dao->service->controller 这样链式调用那么我们可以将接口名称保持一致

当然不止在这种场景可以使用在很多场景下都可以…

这样可阅读性非常好,通过接口名称就能知道整体干了啥事情…,然后后期的扩展维护也

查询

Assign : 是查询指定列的时候使用,查询全部的时候可以省略

查询指定一个列: Assign{列}

查询多个列: AssignMap

Map代表显示多个指定列 ,或者使用Dto

名称介绍返回类型
getStudentAll查询Student表显示全部数据和字段List<Object>
getStudentAssignName查询Student表只显示name列List<String>
getStudentAssignNameOne查询Student表只显示name列String
getStudentAssignMap查询Student表多个字段List<Map<String, Object>>
getStudentAssignMapOne查询Student表多个字段Map<String, Object>
getStudentAssignMapByAge查询Student表多个字段,赛选条件是age=ageList<Map<String, Object>>
getStudentById查询Student表显示全部字段,赛选条件是id=idObject
getStudentByNameAndAge查询Student表显示全部字段,赛选条件是id=id and name=nameObject

可以使用的赛选关键字:

关键字方法名sql
Andget{表名}ByNameAndPwdwhere name= ? and pwd =?
Orget{表名}ByNameOrSexwhere name= ? or sex=?
Equalsget{表名}ByIdEqualswhere id= ?
Betweenget{表名}ByIdBetweenwhere id between ? and ?
LessThanget{表名}IdLessThanwhere id < ?
LessThanEqualsget{表名}ByIdLessThanEqualswhere id <= ?
GreaterThanget{表名}ByIdGreaterThanwhere id > ?
GreaterThanEqualsget{表名}ByIdGreaterThanEqualswhere id > = ?
Afterget{表名}ByIdAfterwhere id > ?
Beforeget{表名}ByIdBeforewhere id < ?
IsNullget{表名}ByNameIsNullwhere name is null
isNotNull,NotNullget{表名}ByNameNotNullwhere name is not null
Likeget{表名}ByNameLikewhere name like ?
NotLikeget{表名}ByNameNotLikewhere name not like ?
StartingWithget{表名}ByNameStartingWithwhere name like ‘?%’
EndingWithget{表名}ByNameEndingWithwhere name like ‘%?’
Containingget{表名}ByNameContainingwhere name like ‘%?%’
OrderByget{表名}ByIdOrderByXDescwhere id=? order by x desc
Notget{表名}ByNameNotwhere name <> ?
Inget{表名}ByIdIn(Collection<?> c)where id in (?)
NotInget{表名}ByIdNotIn(Collection<?> c)where id not in (?)
TRUEget{表名}ByAaaTuewhere aaa = true
FALSEget{表名}ByAaaFalsewhere aaa = false
IgnoreCaseget{表名}ByNameIgnoreCasewhere UPPER(name)=UPPER(?)

增加

添加这个就比较简单了,来回也就几种

关键字介绍方法名
add添加一行add{表名}
batchAdd添加多行batchAdd(表名)

删除

名称介绍SQL
del{表名}ById删除指定ID数据delete from 表 where id=id
batchDel{表名}ByAge删除指定Age数据delete from 表 where age>10
batchDel{表名}All删除全部delete from 表

赛选的关键字可以参考查询

修改

名称介绍SQL
alter{表名}ById修改指定ID数据delete from 表 where id=id
alter{表名}ByAge删除多个delete from 表 where age>10

赛选的关键字可以参考查询,修改的具体内容依据do

相关文章

微信公众号

最新文章

更多