File tree 4 files changed +19
-9
lines changed
src/main/java/com/epkorea/backoffice
4 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ dependencies {
24
24
compileOnly ' org.projectlombok:lombok'
25
25
annotationProcessor ' org.projectlombok:lombok'
26
26
testImplementation ' org.springframework.boot:spring-boot-starter-test'
27
+ implementation ' org.hibernate:hibernate-core:5.6.5.Final'
28
+
27
29
28
30
implementation(' nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect' )
29
31
implementation ' org.springframework.boot:spring-boot-starter-data-jpa'
Original file line number Diff line number Diff line change 4
4
import com .epkorea .backoffice .dto .UserLoginDto ;
5
5
import com .epkorea .backoffice .service .UserService ;
6
6
import org .springframework .beans .factory .annotation .Autowired ;
7
+ import org .springframework .lang .Nullable ;
7
8
import org .springframework .stereotype .Controller ;
8
- import org .springframework .web .bind .annotation .GetMapping ;
9
- import org .springframework .web .bind .annotation .ModelAttribute ;
10
- import org .springframework .web .bind .annotation .PostMapping ;
11
- import org .springframework .web .bind .annotation .RequestMapping ;
9
+ import org .springframework .web .bind .annotation .*;
12
10
import org .springframework .web .servlet .ModelAndView ;
13
11
14
12
import javax .servlet .http .HttpServletRequest ;
@@ -22,10 +20,10 @@ public class UserController {
22
20
private UserService userService ;
23
21
24
22
@ GetMapping ("/all" )
25
- public ModelAndView getAllUsers () {
26
- ModelAndView modelAndView = new ModelAndView ();
27
- List <UserDto .Response > users = userService .findAllUserInfo ();
23
+ public ModelAndView getAllUsers (@ RequestParam @ Nullable String condition , @ RequestParam @ Nullable String kwd ) {
24
+ List <UserDto .Response > users = userService .findAllUserInfo (condition , kwd );
28
25
26
+ ModelAndView modelAndView = new ModelAndView ();
29
27
modelAndView .addObject ("admin_list" , users );
30
28
modelAndView .setViewName ("admin_list" );
31
29
return modelAndView ;
Original file line number Diff line number Diff line change 10
10
public interface UserRepository extends JpaRepository <User , Long > {
11
11
User findByUseridAndPassword (String userid , String password );
12
12
List <UserMapper > findAllBy ();
13
+ List <UserMapper > findAllByUseridLike (String userid );
14
+
13
15
}
Original file line number Diff line number Diff line change 8
8
import org .springframework .beans .factory .annotation .Autowired ;
9
9
import org .springframework .stereotype .Service ;
10
10
11
+ import java .util .ArrayList ;
11
12
import java .util .List ;
12
13
import java .util .stream .Collectors ;
13
14
@@ -17,9 +18,16 @@ public class UserService {
17
18
@ Autowired
18
19
private UserRepository userRepository ;
19
20
20
- public List <UserDto .Response > findAllUserInfo () {
21
- List <UserMapper > userList = userRepository . findAllBy ();
21
+ public List <UserDto .Response > findAllUserInfo (String condition , String kwd ) {
22
+ List <UserMapper > userList = new ArrayList <> ();
22
23
24
+ if (condition != null && kwd != null && !condition .isBlank () && !kwd .isBlank ()) {
25
+ if (condition .equals ("userid" )) {
26
+ userList = userRepository .findAllByUseridLike (kwd );
27
+ }
28
+ } else {
29
+ userList = userRepository .findAllBy ();
30
+ }
23
31
return userList .stream ().map (UserDto .Response ::new ).collect (Collectors .toList ());
24
32
}
25
33
You can’t perform that action at this time.
0 commit comments