package 생성
This commit is contained in:
parent
56b81bd8dc
commit
cf5595289c
15
pom.xml
15
pom.xml
@ -12,7 +12,7 @@
|
||||
<artifactId>mjon_api</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mjon_api</name>
|
||||
<description>mjon_api</description>
|
||||
<description>mjon api server</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
@ -36,11 +36,18 @@
|
||||
<artifactId>h2</artifactId>
|
||||
<!-- <scope>test</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.mariadb.jdbc</groupId>-->
|
||||
<!-- <artifactId>mariadb-java-client</artifactId>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.30</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.itn.mjon_api;
|
||||
package com.itn.mjonApi;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
36
src/main/java/com/itn/mjonApi/cmn/msg/RestResponse.java
Normal file
36
src/main/java/com/itn/mjonApi/cmn/msg/RestResponse.java
Normal file
@ -0,0 +1,36 @@
|
||||
package com.itn.mjonApi.cmn.msg;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class RestResponse {
|
||||
|
||||
private HttpStatus status;
|
||||
|
||||
private String message;
|
||||
|
||||
private LocalDateTime localDateTime;
|
||||
|
||||
private List<?> objectList;
|
||||
|
||||
|
||||
public RestResponse(HttpStatus status, String message, LocalDateTime timestamp) {
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
this.localDateTime = timestamp;
|
||||
}
|
||||
public RestResponse(HttpStatus status, String message, List<?> objectList, LocalDateTime timestamp) {
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
this.objectList = objectList;
|
||||
this.localDateTime = timestamp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.itn.mjonApi.mjon.member.mapper;
|
||||
|
||||
import com.itn.mjonApi.mjon.member.mapper.domain.MyMsgVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MyMsgMapper {
|
||||
List<MyMsgVO> findAll();
|
||||
|
||||
@Select("select * from MJ_MYMSG")
|
||||
List<MyMsgVO> findAll_2();
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.itn.mjonApi.mjon.member.mapper.domain;
|
||||
/*
|
||||
table : mj_mymsg
|
||||
comment : '내문자 보관함';
|
||||
*/
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MyMsgVO {
|
||||
|
||||
private Integer msgId; /*auto_increment comment '문자 고유아이디' primary key*/
|
||||
private String mberId; /*comment '회원 아이디'*/
|
||||
private String esntlId; /*null comment '회원고유 아이디'*/
|
||||
private String subject; /*null comment '문자 제목'*/
|
||||
private String smsTxt; /*null comment '문자 내용'*/
|
||||
private String smsLen; /*null comment '문자 길이'*/
|
||||
private String atchFileId1; /*null comment '첨부파일번호'*/
|
||||
private String atchFileId2; /*null comment '첨부파일번호'*/
|
||||
private String atchFileId3; /*null comment '첨부파일번호'*/
|
||||
private String regdate; /*null comment '등록일자'*/
|
||||
private String msgType; /*default 'S' null comment '문자종류'*/
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.itn.mjonApi.mjon.member.service;
|
||||
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.mjon.member.mapper.domain.MyMsgVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MemberService {
|
||||
|
||||
|
||||
RestResponse findAll();
|
||||
|
||||
RestResponse findAll2();
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.itn.mjonApi.mjon.member.service.impl;
|
||||
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.mjon.member.mapper.MyMsgMapper;
|
||||
import com.itn.mjonApi.mjon.member.mapper.domain.MyMsgVO;
|
||||
import com.itn.mjonApi.mjon.member.service.MemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MemberServiceImpl implements MemberService {
|
||||
|
||||
@Autowired
|
||||
MyMsgMapper myMsgMapper;
|
||||
|
||||
@Override
|
||||
public RestResponse findAll() {
|
||||
List<MyMsgVO> MyMsgListVO = myMsgMapper.findAll();
|
||||
return new RestResponse(HttpStatus.OK, "성공", MyMsgListVO, LocalDateTime.now());
|
||||
}
|
||||
@Override
|
||||
public RestResponse findAll2() {
|
||||
List<MyMsgVO> MyMsgListVO = myMsgMapper.findAll_2();
|
||||
return new RestResponse(HttpStatus.OK, "성공", MyMsgListVO, LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.itn.mjonApi.mjon.member.web;
|
||||
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.mjon.member.service.MemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class MemberController {
|
||||
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@GetMapping("/member/mymsg")
|
||||
public ResponseEntity<RestResponse> mymsg(){
|
||||
return ResponseEntity.ok(memberService.findAll());
|
||||
}
|
||||
|
||||
@GetMapping("/member/mymsg_2")
|
||||
public ResponseEntity<RestResponse> mymsg2(){
|
||||
return ResponseEntity.ok(memberService.findAll2());
|
||||
}
|
||||
|
||||
}
|
||||
11
src/main/resources/application-dev.properties
Normal file
11
src/main/resources/application-dev.properties
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
# DB INFO
|
||||
#spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://192.168.0.125:3306/mjon?serverTimezone=Asia/Seoul
|
||||
spring.datasource.username=mjonUr
|
||||
spring.datasource.password=mjon!@#$
|
||||
|
||||
|
||||
server.port=8088
|
||||
@ -1 +1,10 @@
|
||||
|
||||
|
||||
|
||||
spring.profiles.active=dev
|
||||
|
||||
|
||||
# mybatis setting
|
||||
mybatis.mapper-locations=classpath:mapper/**/*.xml
|
||||
# model camel case set
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
logging.level.jdbc.sqlonly=info
|
||||
|
||||
14
src/main/resources/mapper/MyMsgMapper.xml
Normal file
14
src/main/resources/mapper/MyMsgMapper.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.itn.mjonApi.mjon.member.mapper.MyMsgMapper">
|
||||
|
||||
<select id="findAll" resultType="com.itn.mjonApi.mjon.member.mapper.domain.MyMsgVO">
|
||||
SELECT
|
||||
*
|
||||
FROM MJ_MYMSG
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -1,13 +0,0 @@
|
||||
package com.itn.mjon_api;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class MjonApiApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user