mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-05 04:03:45 +09:00
#수정
stock.list.jsp StockMapper.xml #추가 stock.create.jsp WarehouseController.java WarehouseDto.java WarehouseMapper.java WarehouseMapper.xml WarehouseService.java
This commit is contained in:
101
src/main/java/com/no1/wms/warehouse/WarehouseController.java
Normal file
101
src/main/java/com/no1/wms/warehouse/WarehouseController.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@Slf4j
|
||||
public class WarehouseController {
|
||||
|
||||
@Autowired
|
||||
WarehouseService service;
|
||||
|
||||
// 재고 리스트 출력
|
||||
@GetMapping("warehouse/list")
|
||||
public String list(@RequestParam(name = "searchn", defaultValue = "0") int searchn,
|
||||
@RequestParam(name = "search", defaultValue = "") String search,
|
||||
@RequestParam(name = "p", defaultValue = "1") int page, Model m) {
|
||||
int count = service.count(searchn, search);
|
||||
|
||||
int perPage = 10; // 한 페이지에 보일 글의 갯수
|
||||
int startRow = (page - 1) * perPage;
|
||||
|
||||
//스톡서비스로 재고 리스트 출력 메서트 작성
|
||||
List<Object> dto = service.list(searchn, search, perPage);
|
||||
m.addAttribute("list", dto);
|
||||
|
||||
int pageNum = 4;//보여질 페이지 번호 수
|
||||
int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수
|
||||
|
||||
int begin = (page - 1) / pageNum * pageNum + 1;
|
||||
int end = begin + pageNum - 1;
|
||||
if (end > totalPages) {
|
||||
end = totalPages;
|
||||
}
|
||||
m.addAttribute("begin", begin);
|
||||
m.addAttribute("end", end);
|
||||
m.addAttribute("pageNum", pageNum);
|
||||
m.addAttribute("totalPages", totalPages);
|
||||
|
||||
return "warehouse/list";
|
||||
}
|
||||
|
||||
|
||||
// 재고 상세페이지
|
||||
@PostMapping("warehouse/read/{id}")
|
||||
public String read(@PathVariable String id, Model m) {
|
||||
//스톡서비스로 재고 상세페이지 출력 메서드 작성
|
||||
WarehouseDto dto = service.warehouseOne(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "warehouse/read/";
|
||||
}
|
||||
|
||||
|
||||
// 수정 - 폼
|
||||
@GetMapping("/warehouse/update/{id}")
|
||||
public String update(@PathVariable String id, Model m) {
|
||||
WarehouseDto dto = service.warehouseOne(id);
|
||||
m.addAttribute("dto", dto);
|
||||
return "warehouse/update";
|
||||
}
|
||||
|
||||
|
||||
// 수정 프로세스
|
||||
@PutMapping("/warehouse/update_process")
|
||||
@ResponseBody
|
||||
public String updateProcess(WarehouseDto dto) {
|
||||
service.updateWarehouse(dto);
|
||||
return "redirect:list";
|
||||
}
|
||||
|
||||
|
||||
// 생성 폼
|
||||
@GetMapping("/warehouse/create")
|
||||
public String create()
|
||||
{
|
||||
return "stock/create";
|
||||
}
|
||||
|
||||
|
||||
// 생성 프로세스
|
||||
@PostMapping("/warehouse/create_process")
|
||||
@ResponseBody
|
||||
public String createProcess(WarehouseDto dto) {
|
||||
service.createWarehouse(dto);
|
||||
return "redirect:list";// 글목록
|
||||
}
|
||||
|
||||
|
||||
// 삭제
|
||||
@DeleteMapping("/warehouse/delete")
|
||||
@ResponseBody
|
||||
public int delete(String id) {
|
||||
int i = service.deleteWarehouse(id);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/no1/wms/warehouse/WarehouseDto.java
Normal file
15
src/main/java/com/no1/wms/warehouse/WarehouseDto.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WarehouseDto {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private int capacity;
|
||||
private int current_capacity;
|
||||
private String manager_id;
|
||||
private String address;
|
||||
private boolean activation;
|
||||
}
|
||||
26
src/main/java/com/no1/wms/warehouse/WarehouseMapper.java
Normal file
26
src/main/java/com/no1/wms/warehouse/WarehouseMapper.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface WarehouseMapper {
|
||||
|
||||
int count(Map<String, Object> m);//검색 글 갯수
|
||||
|
||||
List<Object> list(Map<String, Object> m);
|
||||
|
||||
int updateWarehouse(WarehouseDto dto);
|
||||
|
||||
int createWarehouse(WarehouseDto dto);
|
||||
|
||||
WarehouseDto warehouseOne(String id);
|
||||
|
||||
int deleteWarehouse(String id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
61
src/main/java/com/no1/wms/warehouse/WarehouseService.java
Normal file
61
src/main/java/com/no1/wms/warehouse/WarehouseService.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package com.no1.wms.warehouse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class WarehouseService {
|
||||
@Autowired
|
||||
WarehouseMapper mapper;
|
||||
|
||||
public int count(int searchn, String search) {
|
||||
|
||||
System.out.println(searchn+search);
|
||||
|
||||
Map<String,Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", 0);
|
||||
m.put("perPage", 10000);
|
||||
return mapper.count(m);
|
||||
}
|
||||
|
||||
|
||||
public List<Object> list(int searchn, String search, int start){
|
||||
|
||||
System.out.println(searchn+search);
|
||||
|
||||
Map<String, Object> m = new HashMap<String, Object>();
|
||||
m.put("searchn",searchn);
|
||||
m.put("search", search);
|
||||
m.put("start", start);
|
||||
m.put("perPage", 10);
|
||||
|
||||
return mapper.list(m);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public WarehouseDto warehouseOne(String id) {
|
||||
return mapper.warehouseOne(id);
|
||||
}
|
||||
|
||||
|
||||
public int createWarehouse(WarehouseDto dto) {
|
||||
return mapper.createWarehouse(dto);
|
||||
}
|
||||
|
||||
|
||||
public int updateWarehouse(WarehouseDto dto) {
|
||||
return mapper.updateWarehouse(dto);
|
||||
}
|
||||
|
||||
|
||||
public int deleteWarehouse(String id) {
|
||||
return mapper.deleteWarehouse(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user