From b82403d06437a59fcd4f7424157874bf6f12e20e Mon Sep 17 00:00:00 2001 From: Suh Date: Tue, 9 Jan 2024 13:08:26 +0900 Subject: [PATCH] =?UTF-8?q?mybatis=20join=20=EA=B4=80=EB=A0=A8=ED=95=9C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/authority/AuthorityController.java | 44 +++-- .../com/no1/wms/authority/AuthorityDto.java | 48 +++-- .../no1/wms/authority/AuthorityMapper.java | 7 + .../no1/wms/authority/AuthorityService.java | 21 ++- .../resources/mappers/AuthorityMapper.xml | 55 ++++++ src/main/resources/static/dev/authority.css | 4 + .../static/dev/authority_list_dev.html | 135 +++++++------- .../WEB-INF/views/authority/create_group.jsp | 169 ++++++++++++++++++ .../webapp/WEB-INF/views/authority/list.jsp | 125 +++++++++++++ 9 files changed, 516 insertions(+), 92 deletions(-) create mode 100644 src/main/webapp/WEB-INF/views/authority/create_group.jsp create mode 100644 src/main/webapp/WEB-INF/views/authority/list.jsp diff --git a/src/main/java/com/no1/wms/authority/AuthorityController.java b/src/main/java/com/no1/wms/authority/AuthorityController.java index fbba874..cccdc84 100644 --- a/src/main/java/com/no1/wms/authority/AuthorityController.java +++ b/src/main/java/com/no1/wms/authority/AuthorityController.java @@ -1,36 +1,48 @@ package com.no1.wms.authority; +import com.google.gson.Gson; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; +import java.util.List; import java.util.UUID; @Controller +@RequestMapping("/authority") public class AuthorityController { @Autowired AuthorityService authorityService; + private static final int PER_PAGE = 10; - - @GetMapping("/test/tt") - public ModelAndView test(ModelAndView mav, AuthorityDto d){ - d.setId("94690a18-a933-11ee-b9dd-0242ac110006"); - AuthorityDto dto = authorityService.selectById(d); - - System.out.println(dto.getName()); - - mav.setViewName("test/testlayout"); + @GetMapping("/list") + public ModelAndView list(ModelAndView mav, @RequestParam(defaultValue = "") String search, @RequestParam(defaultValue = "0") int start){ + List list = authorityService.selectAll(search, start, PER_PAGE); + for(int i=0; i < list.size(); ++i){ + System.out.println(list.get(i)); + } + mav.addObject("list", list); + mav.setViewName("/authority/list"); return mav; } - @GetMapping("/tt") - public ModelAndView test2(ModelAndView mav){ - //AuthorityDto dto = authorityService.selectById("94690a18-a933-11ee-b9dd-0242ac110006"); + @GetMapping("/create") + public String create(){ + return "/authority/create_group"; - //System.out.println(dto.getName()); + } - mav.setViewName("test/testlayout"); - return mav; + @PostMapping("/checkNameDuplicate") + @ResponseBody + public String checkNameDuplicate(@RequestParam String name, Gson gson){ + int count = authorityService.selectByName(name); + return gson.toJson(count); + } + @PostMapping("/create_process") + @ResponseBody + public String createProcess(AuthorityDto dto, Gson gson){ + int result = authorityService.insert(dto); + return gson.toJson(result); } } diff --git a/src/main/java/com/no1/wms/authority/AuthorityDto.java b/src/main/java/com/no1/wms/authority/AuthorityDto.java index b925d9c..08dc59e 100644 --- a/src/main/java/com/no1/wms/authority/AuthorityDto.java +++ b/src/main/java/com/no1/wms/authority/AuthorityDto.java @@ -1,30 +1,52 @@ package com.no1.wms.authority; +import com.no1.wms.account.AccountDto; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import org.apache.ibatis.type.Alias; import java.util.UUID; @Data +@Builder +@NoArgsConstructor @AllArgsConstructor @Alias("AuthorityDto") public class AuthorityDto { + private String id; private String name; - private Integer account; - private Integer authority; - private Integer productCategory; - private Integer product; - private Integer prices; - private Integer vendor; - private Integer warehouse; - private Integer stock; - private Integer planIn; - private Integer productIn; - private Integer productOut; - private Integer board; + + @Builder.Default + private Integer account = 0; + @Builder.Default + private Integer authority = 0; + @Builder.Default + private Integer productCategory = 0; + @Builder.Default + private Integer product = 0; + @Builder.Default + private Integer prices = 0; + @Builder.Default + private Integer vendor = 0; + @Builder.Default + private Integer warehouse = 0; + @Builder.Default + private Integer stock = 0; + @Builder.Default + private Integer planIn = 0; + @Builder.Default + private Integer productIn = 0; + @Builder.Default + private Integer productOut = 0; + @Builder.Default + private Integer board = 0; + + private AccountDto accountDto; + + 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 index 5d8cec1..b423572 100644 --- a/src/main/java/com/no1/wms/authority/AuthorityMapper.java +++ b/src/main/java/com/no1/wms/authority/AuthorityMapper.java @@ -3,10 +3,17 @@ package com.no1.wms.authority; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; +import java.util.List; +import java.util.Map; import java.util.UUID; @Repository @Mapper public interface AuthorityMapper { AuthorityDto selectById(AuthorityDto id); + int selectByName(String name); + + int insert(AuthorityDto dto); + + List selectAll(Map m); } diff --git a/src/main/java/com/no1/wms/authority/AuthorityService.java b/src/main/java/com/no1/wms/authority/AuthorityService.java index 854a0cc..99a735f 100644 --- a/src/main/java/com/no1/wms/authority/AuthorityService.java +++ b/src/main/java/com/no1/wms/authority/AuthorityService.java @@ -4,7 +4,9 @@ package com.no1.wms.authority; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.UUID; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @Service public class AuthorityService { @@ -14,4 +16,21 @@ public class AuthorityService { public AuthorityDto selectById(AuthorityDto dto){ return mapper.selectById(dto); } + + public List selectAll(String search, int start, int perPage){ + HashMap map = new HashMap(); + map.put("search", search); + map.put("start", start); + map.put("perPage", perPage); + + return mapper.selectAll(map); + } + + public int selectByName(String name){ + return mapper.selectByName(name); + } + + public int insert(AuthorityDto dto){ + return mapper.insert(dto); + } } diff --git a/src/main/resources/mappers/AuthorityMapper.xml b/src/main/resources/mappers/AuthorityMapper.xml index 58a4923..41d6d02 100644 --- a/src/main/resources/mappers/AuthorityMapper.xml +++ b/src/main/resources/mappers/AuthorityMapper.xml @@ -3,7 +3,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into authority + ( + id, name, account, authority, product_category, + product, prices, vendor, warehouse, stock, plan_in, + product_in, product_out, board, activation, is_group_authority) + VALUES ( + UUID(), #{name}, #{account}, + #{authority}, #{productCategory}, + #{product},#{prices},#{vendor}, + #{warehouse},#{stock}, #{planIn}, + #{productIn},#{productOut},#{board}, + #{activation}, #{isGroupAuthority} + ) + + \ No newline at end of file diff --git a/src/main/resources/static/dev/authority.css b/src/main/resources/static/dev/authority.css index 6624f7b..cf08d4f 100644 --- a/src/main/resources/static/dev/authority.css +++ b/src/main/resources/static/dev/authority.css @@ -3,4 +3,8 @@ } .tab-pane{ background-color: rgb(208, 208, 208); +} + +.form-check{ + display: inline!important; } \ No newline at end of file diff --git a/src/main/resources/static/dev/authority_list_dev.html b/src/main/resources/static/dev/authority_list_dev.html index 1758653..ffa5c9c 100644 --- a/src/main/resources/static/dev/authority_list_dev.html +++ b/src/main/resources/static/dev/authority_list_dev.html @@ -187,9 +187,6 @@ */ $(function() { $("#div_personal_search").hide(); - $("#search_btn").on("click", function () { - $("select[name='search_select'] option:selected").val(); - }); $(".nav-item button").on("click", function(obj){ const selectedButtonId = $(obj.currentTarget).attr('id'); if(selectedButtonId === 'home-tab'){ @@ -201,6 +198,19 @@ } }); }); + + function onSearch(isPersonalSearch){ + let jsonData = {}; + if(isPersonalSearch){ + jsonData.searchOption = $("select[name='search_select'] option:selected").val(); + jsonData.searchValue = $("#search_personal_input").val(); + + }else{ + jsonData.searchValue = $("#search_group_input").val(); + } + + console.log(JSON.stringify(jsonData)); + }
@@ -212,70 +222,71 @@
-
-
-
-
-
- - -
-
- - -
+
+
+
+
+
+
+ +
-
-
-
-
- - - - - - - - - -
번호권한 명
1사장 권한
2관리자 권한
3사원 권한
-
-
- - - - - - - - - -
번호id이름권한 명
1230112김이박사장 권한
2230112김이박사장 권한
3230112김이박사장 권한
-
-
+
+ + +
+
+
+
+
+
+ + + + + + + + + +
번호ID사용자 명권한 명
1230112김이박사장 권한
2230112김이박사장 권한
3230112김이박사장 권한
+
+
+ + + + + + + + + +
번호권한 명
1사장 권한
2관리자 권한
3사원 권한
+
+
-
+
diff --git a/src/main/webapp/WEB-INF/views/authority/create_group.jsp b/src/main/webapp/WEB-INF/views/authority/create_group.jsp new file mode 100644 index 0000000..0365a10 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/authority/create_group.jsp @@ -0,0 +1,169 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + +
+
+
+

권한 추가

+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ 권한명 +
+
+ + +
+ +
+
+
+ + + + + +
+
+
+
+
+ +
+
+
+
diff --git a/src/main/webapp/WEB-INF/views/authority/list.jsp b/src/main/webapp/WEB-INF/views/authority/list.jsp new file mode 100644 index 0000000..ffd2da8 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/authority/list.jsp @@ -0,0 +1,125 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> + + + +
+
+
+
+

그룹 권한 관리

+
+
+
+
+
+
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + +
사번사용자 명권한 명활성 여부
${dto.accountDto.employeeNumber}${dto.accountDto.name}${dto.name}${dto.activation}
+
+
+ + + + + + + + + +
번호권한 명
1사장 권한
2관리자 권한
3사원 권한
+
+ +
+
+
+
+ +
+
+
\ No newline at end of file