반응형
GET
@GetMapping("/user/{user_no}/history/list")
public List<UserHistoryDto> getUseData(@PathVariable("user_no") String user_no,
@RequestParam("history_type") String htype,
@RequestParam("start_date") String startDate,
@RequestParam("end_date") String endDate) {
List<UserHistoryDto> result = userHistoryService.getUserHistory(user_no, htype, startDate, endDate);
return result;
}
@RequestMapping(value = "/user/{user_no}/history/list", method = RequestMethod.GET)
public List<UserHistoryDto> getUseData(@PathVariable("user_no") String user_no,
@RequestParam("history_type") String htype,
@RequestParam("start_date") String startDate,
@RequestParam("end_date") String endDate) {
List<UserHistoryDto> result = userHistoryService.getUserHistory(user_no, htype, startDate, endDate);
return result;
}
path Variable
* url : "~~~~{user_no}~~~~"
* 파라미터 : @PathVariable("user_no") String 변수명
request Param
* @RequestParam("인터페이스에 정한대로..") String 변수명
* @RequestParam("인터페이스에 정한대로..") int 변수명
POST
@PostMapping("/user/{user_no}/history")
public String postMethod(@RequestBody ParamDto dto) {
return "OK";
}
@RequestMapping(method = RequestMethod.POST, path = "/user/{user_no}/history")
public String postMethod(@RequestBody ParamDto dto) {
return "OK";
}
SeviceImpl
@Service
@RequiredArgsConstructor
public class UserServiceimpl implements UserService {
@Autowired
private final UseraMapper userMapper;
@Override
public UserDto getUserData(String user_no) {
UserDto result = usedataMapper.getUseData(user_no);
return result;
}
}
@Override 필수...
Mapper
List<LoginHistoryDto> getUsedList(@Param("user_no") String user_no,
@Param("start_dt") String start_dt,
@Param("end_dt") String end_dt);
Xml
<select id="getUserInfo" parameterType="String" resultType="~~.UserDto">
SELECT user_name
, last_login_date
, ~~~
FROM user_table
WHERE 1=1
AND user_no=#{user_no}
</select>
Dto
package com........;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class UserDto {
private String user_no;
private String name;
private Integer age;
private String phoneNumber;
}
반응형
'백엔드 > 스프링' 카테고리의 다른 글
좋은 객체 지향의 5가지 원칙 (SOLID) (0) | 2022.10.10 |
---|