From 2864bb89d4b76ec636ea3290ea352a1da86311ea Mon Sep 17 00:00:00 2001 From: Suh Date: Tue, 2 Jan 2024 17:10:05 +0900 Subject: [PATCH] =?UTF-8?q?mybatis=20=EC=84=B8=ED=8C=85=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++- src/main/java/com/no1/wms/WmsApplication.java | 1 + .../wms/authority/AuthorityController.java | 26 +++++++++++++++++ .../com/no1/wms/authority/AuthorityDto.java | 29 +++++++++++++++++++ .../no1/wms/authority/AuthorityMapper.java | 11 +++++++ .../no1/wms/authority/AuthorityService.java | 17 +++++++++++ .../java/com/no1/wms/base/BaseController.java | 12 ++++++++ .../com/no1/wms/login/LoginController.java | 15 ++++++++++ src/main/java/com/no1/wms/utils/Utils.java | 7 +++++ src/main/resources/application.properties | 12 ++++++++ .../resources/mappers/AuthorityMapper.xml | 9 ++++++ src/main/resources/static/hello.html | 10 +++++++ src/main/webapp/WEB-INF/views/base/hello.jsp | 11 +++++++ src/main/webapp/WEB-INF/views/test/kkk.jsp | 11 +++++++ 14 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/no1/wms/authority/AuthorityController.java create mode 100644 src/main/java/com/no1/wms/authority/AuthorityDto.java create mode 100644 src/main/java/com/no1/wms/authority/AuthorityMapper.java create mode 100644 src/main/java/com/no1/wms/authority/AuthorityService.java create mode 100644 src/main/java/com/no1/wms/base/BaseController.java create mode 100644 src/main/java/com/no1/wms/login/LoginController.java create mode 100644 src/main/java/com/no1/wms/utils/Utils.java create mode 100644 src/main/resources/mappers/AuthorityMapper.xml create mode 100644 src/main/resources/static/hello.html create mode 100644 src/main/webapp/WEB-INF/views/base/hello.jsp create mode 100644 src/main/webapp/WEB-INF/views/test/kkk.jsp diff --git a/build.gradle b/build.gradle index e847d59..f408293 100644 --- a/build.gradle +++ b/build.gradle @@ -29,10 +29,12 @@ dependencies { developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'org.mariadb.jdbc:mariadb-java-client' annotationProcessor 'org.projectlombok:lombok' + implementation group: 'org.glassfish.web', name: 'jakarta.servlet.jsp.jstl', version: '2.0.0' + implementation 'org.apache.tomcat.embed:tomcat-embed-jasper' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3' -} +} tasks.named('test') { useJUnitPlatform() } diff --git a/src/main/java/com/no1/wms/WmsApplication.java b/src/main/java/com/no1/wms/WmsApplication.java index 78b801e..0e9daee 100644 --- a/src/main/java/com/no1/wms/WmsApplication.java +++ b/src/main/java/com/no1/wms/WmsApplication.java @@ -1,5 +1,6 @@ package com.no1.wms; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/src/main/java/com/no1/wms/authority/AuthorityController.java b/src/main/java/com/no1/wms/authority/AuthorityController.java new file mode 100644 index 0000000..9bd1704 --- /dev/null +++ b/src/main/java/com/no1/wms/authority/AuthorityController.java @@ -0,0 +1,26 @@ +package com.no1.wms.authority; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.servlet.ModelAndView; + +import java.util.UUID; + +@Controller +public class AuthorityController { + @Autowired + AuthorityService authorityService; + + + @GetMapping("/test") + public ModelAndView test(ModelAndView mav){ + AuthorityDto dto = authorityService.selectById("94690a18-a933-11ee-b9dd-0242ac110006"); + + System.out.println(dto.getName()); + + mav.setViewName("test/kkk"); + return mav; + } + +} diff --git a/src/main/java/com/no1/wms/authority/AuthorityDto.java b/src/main/java/com/no1/wms/authority/AuthorityDto.java new file mode 100644 index 0000000..d118ce3 --- /dev/null +++ b/src/main/java/com/no1/wms/authority/AuthorityDto.java @@ -0,0 +1,29 @@ +package com.no1.wms.authority; + +import lombok.AllArgsConstructor; +import lombok.Data; +import org.apache.ibatis.type.Alias; + +import java.util.UUID; + +@Data +@AllArgsConstructor +@Alias("AuthorityDto") +public class AuthorityDto { + private UUID id; + private String name; + private int account; + private int authority; + private int productCategory; + private int product; + private int prices; + private int vendor; + private int warehouse; + private int stock; + private int planIn; + private int productIn; + private int productOut; + private int board; + private boolean activation; + private boolean isGroupAuthority; +} diff --git a/src/main/java/com/no1/wms/authority/AuthorityMapper.java b/src/main/java/com/no1/wms/authority/AuthorityMapper.java new file mode 100644 index 0000000..212457a --- /dev/null +++ b/src/main/java/com/no1/wms/authority/AuthorityMapper.java @@ -0,0 +1,11 @@ +package com.no1.wms.authority; + +import org.apache.ibatis.annotations.Mapper; + +import java.util.UUID; + + +@Mapper +public interface AuthorityMapper { + AuthorityDto selectById(String id); +} diff --git a/src/main/java/com/no1/wms/authority/AuthorityService.java b/src/main/java/com/no1/wms/authority/AuthorityService.java new file mode 100644 index 0000000..a95ebf1 --- /dev/null +++ b/src/main/java/com/no1/wms/authority/AuthorityService.java @@ -0,0 +1,17 @@ +package com.no1.wms.authority; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.UUID; + +@Service +public class AuthorityService { + + @Autowired + AuthorityMapper mapper; + public AuthorityDto selectById(String id){ + return mapper.selectById(id); + } +} diff --git a/src/main/java/com/no1/wms/base/BaseController.java b/src/main/java/com/no1/wms/base/BaseController.java new file mode 100644 index 0000000..ffc5173 --- /dev/null +++ b/src/main/java/com/no1/wms/base/BaseController.java @@ -0,0 +1,12 @@ +package com.no1.wms.base; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class BaseController { + @GetMapping("/") + public String base(){ + return "base/hello"; + } +} diff --git a/src/main/java/com/no1/wms/login/LoginController.java b/src/main/java/com/no1/wms/login/LoginController.java new file mode 100644 index 0000000..d536a04 --- /dev/null +++ b/src/main/java/com/no1/wms/login/LoginController.java @@ -0,0 +1,15 @@ +package com.no1.wms.login; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class LoginController { + @GetMapping("/login") + public ModelAndView login(ModelAndView mav){ + mav.setViewName("login"); + return mav; + } + +} diff --git a/src/main/java/com/no1/wms/utils/Utils.java b/src/main/java/com/no1/wms/utils/Utils.java new file mode 100644 index 0000000..9cf385b --- /dev/null +++ b/src/main/java/com/no1/wms/utils/Utils.java @@ -0,0 +1,7 @@ +package com.no1.wms.utils; + +import java.util.UUID; + +public class Utils { + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b13789..9c0b826 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,13 @@ +#DB Datasource +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.datasource.url=jdbc:mariadb://summerneko.com:43306/wms +spring.datasource.username=client +spring.datasource.password=no1wms +# Mapper Xml Location +mybatis.mapper-locations=classpath:mappers/*.xml +mybatis.type-aliases-package=com.no1.wms + +# jsp +spring.mvc.view.prefix=/WEB-INF/views/ +spring.mvc.view.suffix=.jsp \ No newline at end of file diff --git a/src/main/resources/mappers/AuthorityMapper.xml b/src/main/resources/mappers/AuthorityMapper.xml new file mode 100644 index 0000000..58a4923 --- /dev/null +++ b/src/main/resources/mappers/AuthorityMapper.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/hello.html b/src/main/resources/static/hello.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/src/main/resources/static/hello.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/base/hello.jsp b/src/main/webapp/WEB-INF/views/base/hello.jsp new file mode 100644 index 0000000..f12087e --- /dev/null +++ b/src/main/webapp/WEB-INF/views/base/hello.jsp @@ -0,0 +1,11 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + Title + + +kkkkkk + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/test/kkk.jsp b/src/main/webapp/WEB-INF/views/test/kkk.jsp new file mode 100644 index 0000000..25ee7f3 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/test/kkk.jsp @@ -0,0 +1,11 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + Title + + +kkkkk 성공 + + \ No newline at end of file