[Spring][쇼핑몰 프로젝트][13] 작가등록 기능 구현 -1

https://kimvampa.tistory.com/155
This commit is contained in:
SeoJin Kim
2021-02-08 08:28:02 +09:00
parent 93d980be61
commit b0e5639227
16 changed files with 388 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
package com.vam.mapper;
import com.vam.model.AuthorVO;
public interface AuthorMapper {
/* 작가 등록 */
public void authorEnroll(AuthorVO author);
}

View File

@@ -0,0 +1,91 @@
package com.vam.model;
import java.util.Date;
public class AuthorVO {
/* 작가 아이디 */
private int authorId;
/* 작가 이름 */
private String authorName;
/* 국가 id */
private String nationId;
/* 작가 국가 */
private String nationName;
/* 작가 소개 */
private String authorIntro;
/*등록 날짜*/
private Date regDate;
/* 수정 날짜 */
private Date updateDate;
public int getAuthorId() {
return authorId;
}
public void setAuthorId(int authorId) {
this.authorId = authorId;
}
public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public String getNationId() {
return nationId;
}
public void setNationId(String nationId) {
this.nationId = nationId;
}
public String getNationName() {
return nationName;
}
public void setNationName(String nationName) {
this.nationName = nationName;
}
public String getAuthorIntro() {
return authorIntro;
}
public void setAuthorIntro(String authorIntro) {
this.authorIntro = authorIntro;
}
public Date getRegDate() {
return regDate;
}
public void setRegDate(Date regDate) {
this.regDate = regDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
@Override
public String toString() {
return "AuthorVO [authorId=" + authorId + ", authorName=" + authorName + ", nationId=" + nationId
+ ", nationName=" + nationName + ", authorIntro=" + authorIntro + ", regDate=" + regDate
+ ", updateDate=" + updateDate + "]";
}
}

View File

@@ -0,0 +1,10 @@
package com.vam.service;
import com.vam.model.AuthorVO;
public interface AuthorService {
/* 작가 등록 */
public void authorEnroll(AuthorVO author) throws Exception;
}

View File

@@ -0,0 +1,22 @@
package com.vam.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vam.mapper.AuthorMapper;
import com.vam.model.AuthorVO;
@Service
public class AuthorServiceImpl implements AuthorService {
@Autowired
AuthorMapper authorMapper;
@Override
public void authorEnroll(AuthorVO author) throws Exception {
authorMapper.authorEnroll(author);
}
}

View 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.vam.mapper.AuthorMapper">
<!-- 작가 등록 -->
<insert id="authorEnroll">
insert into vam_author(authorName, nationId, authorIntro) values(#{authorName}, #{nationId}, #{authorIntro} )
</insert>
</mapper>

View File

@@ -0,0 +1,32 @@
package com.vam.mapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.vam.model.AuthorVO;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
public class AuthorMapperTests {
@Autowired
private AuthorMapper mapper;
/* 작가 등록 테스트 */
@Test
public void authorEnroll() throws Exception{
AuthorVO author = new AuthorVO();
author.setNationId("01");
author.setAuthorName("테스트");
author.setAuthorIntro("테스트 소개");
mapper.authorEnroll(author);
}
}

View 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.vam.mapper.AuthorMapper">
<!-- 작가 등록 -->
<insert id="authorEnroll">
insert into vam_author(authorName, nationId, authorIntro) values(#{authorName}, #{nationId}, #{authorIntro} )
</insert>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Fri Feb 05 03:32:23 KST 2021
#Mon Feb 08 06:13:16 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa
m2e.projectName=VamPa
groupId=com.vam

View File

@@ -0,0 +1,10 @@
package com.vam.mapper;
import com.vam.model.AuthorVO;
public interface AuthorMapper {
/* 작가 등록 */
public void authorEnroll(AuthorVO author);
}

View File

@@ -0,0 +1,91 @@
package com.vam.model;
import java.util.Date;
public class AuthorVO {
/* 작가 아이디 */
private int authorId;
/* 작가 이름 */
private String authorName;
/* 국가 id */
private String nationId;
/* 작가 국가 */
private String nationName;
/* 작가 소개 */
private String authorIntro;
/*등록 날짜*/
private Date regDate;
/* 수정 날짜 */
private Date updateDate;
public int getAuthorId() {
return authorId;
}
public void setAuthorId(int authorId) {
this.authorId = authorId;
}
public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public String getNationId() {
return nationId;
}
public void setNationId(String nationId) {
this.nationId = nationId;
}
public String getNationName() {
return nationName;
}
public void setNationName(String nationName) {
this.nationName = nationName;
}
public String getAuthorIntro() {
return authorIntro;
}
public void setAuthorIntro(String authorIntro) {
this.authorIntro = authorIntro;
}
public Date getRegDate() {
return regDate;
}
public void setRegDate(Date regDate) {
this.regDate = regDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
@Override
public String toString() {
return "AuthorVO [authorId=" + authorId + ", authorName=" + authorName + ", nationId=" + nationId
+ ", nationName=" + nationName + ", authorIntro=" + authorIntro + ", regDate=" + regDate
+ ", updateDate=" + updateDate + "]";
}
}

View File

@@ -0,0 +1,10 @@
package com.vam.service;
import com.vam.model.AuthorVO;
public interface AuthorService {
/* 작가 등록 */
public void authorEnroll(AuthorVO author) throws Exception;
}

View File

@@ -0,0 +1,22 @@
package com.vam.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vam.mapper.AuthorMapper;
import com.vam.model.AuthorVO;
@Service
public class AuthorServiceImpl implements AuthorService {
@Autowired
AuthorMapper authorMapper;
@Override
public void authorEnroll(AuthorVO author) throws Exception {
authorMapper.authorEnroll(author);
}
}

View 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.vam.mapper.AuthorMapper">
<!-- 작가 등록 -->
<insert id="authorEnroll">
insert into vam_author(authorName, nationId, authorIntro) values(#{authorName}, #{nationId}, #{authorIntro} )
</insert>
</mapper>

View File

@@ -0,0 +1,32 @@
package com.vam.mapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.vam.model.AuthorVO;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
public class AuthorMapperTests {
@Autowired
private AuthorMapper mapper;
/* 작가 등록 테스트 */
@Test
public void authorEnroll() throws Exception{
AuthorVO author = new AuthorVO();
author.setNationId("01");
author.setAuthorName("테스트");
author.setAuthorIntro("테스트 소개");
mapper.authorEnroll(author);
}
}

View 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.vam.mapper.AuthorMapper">
<!-- 작가 등록 -->
<insert id="authorEnroll">
insert into vam_author(authorName, nationId, authorIntro) values(#{authorName}, #{nationId}, #{authorIntro} )
</insert>
</mapper>

View File

@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Fri Feb 05 03:32:24 KST 2021
#Mon Feb 08 06:13:18 KST 2021
m2e.projectLocation=C\:\\Users\\sjinj\\git\\Blog_Project\\VamPa_MySQL
m2e.projectName=VamPa_MySQL
groupId=com.vam