When designing the DAO interface, it is better to have higher versatility or higher independence.

1. For example: I now have a need to obtain student data, query data according to student primary key and student status, and query data according to student primary key and student name
should I write these two in one SQL to deal with, or write two SQL to deal with
table separately: user has these fields id,status,name,age.
according to the demand, I am writing two DAO interfaces. Or write an interface to filter query data according to criteria
method 1:
getUser (id, status); Select * from user where id = {- sharpid} and status = {- sharpstatus};
getUser (id, name); select * from user where id = {- sharpid} and name = {- sharpname};

method 2:
getUser (id, status, name);

select * from user where id = {- sharpid}
< if status! = null >
and status = {- sharpstatus}
< / if >
< if name! = null >

and name = {-sharpname}

< / if >

Mar.10,2021

first, it can be regarded as a single responsibility

Menu