mirror of
https://github.com/suhf/No1WMS.git
synced 2026-02-04 12:13:24 +09:00
#update
StockController.java StockDto.java StockMapper.xml StockMapper.java StockService.java
This commit is contained in:
@@ -1,20 +1,12 @@
|
|||||||
package com.no1.wms.stock;
|
package com.no1.wms.stock;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import com.no1.wms.stock.StockDto;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -56,7 +48,7 @@ public class StockController {
|
|||||||
|
|
||||||
// 재고 상세페이지
|
// 재고 상세페이지
|
||||||
@PostMapping("stock/read/{id}")
|
@PostMapping("stock/read/{id}")
|
||||||
public String read(@PathVariable UUID id, Model m) {
|
public String read(@PathVariable String id, Model m) {
|
||||||
//스톡서비스로 재고 상세페이지 출력 메서드 작성
|
//스톡서비스로 재고 상세페이지 출력 메서드 작성
|
||||||
StockDto dto = service.stockOne(id);
|
StockDto dto = service.stockOne(id);
|
||||||
m.addAttribute("dto", dto);
|
m.addAttribute("dto", dto);
|
||||||
@@ -66,10 +58,44 @@ public class StockController {
|
|||||||
|
|
||||||
// 수정 - 폼
|
// 수정 - 폼
|
||||||
@GetMapping("/stock/update/{id}")
|
@GetMapping("/stock/update/{id}")
|
||||||
public String update(@PathVariable UUID id, Model m) {
|
public String update(@PathVariable String id, Model m) {
|
||||||
// StockDto dto = service.updateStock();
|
StockDto dto = service.stockOne(id);
|
||||||
// m.addAttribute("dto", dto);
|
m.addAttribute("dto", dto);
|
||||||
return "stock/update";
|
return "stock/update";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 수정 프로세스
|
||||||
|
@PutMapping("/board/update_process")
|
||||||
|
@ResponseBody
|
||||||
|
public String updateProcess(StockDto dto) {
|
||||||
|
service.updateStock(dto);
|
||||||
|
return "redirect:list";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 생성 폼
|
||||||
|
@PostMapping("/stock/create")
|
||||||
|
public String create()
|
||||||
|
{
|
||||||
|
return "stock/create";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 생성 프로세스
|
||||||
|
@PostMapping("/stock/create_process")
|
||||||
|
@ResponseBody
|
||||||
|
public String createProcess(StockDto dto) {
|
||||||
|
service.createStock(dto);
|
||||||
|
return "redirect:list";// 글목록
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 삭제
|
||||||
|
@DeleteMapping("/stock/delete")
|
||||||
|
@ResponseBody
|
||||||
|
public int delete(String id) {
|
||||||
|
int i = service.deleteBoard(id);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.no1.wms.stock;
|
package com.no1.wms.stock;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class StockDto {
|
public class StockDto {
|
||||||
|
|
||||||
private UUID id;
|
private String id;
|
||||||
private int warehouse_id;
|
private int warehouse_id;
|
||||||
private int product_id;
|
private int product_id;
|
||||||
private int quantity;
|
private int quantity;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.no1.wms.stock;
|
package com.no1.wms.stock;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@@ -18,7 +17,10 @@ public interface StockMapper {
|
|||||||
|
|
||||||
int createStock(StockDto dto);
|
int createStock(StockDto dto);
|
||||||
|
|
||||||
StockDto stockOne(UUID id);
|
StockDto stockOne(String id);
|
||||||
|
|
||||||
|
int deleteStock(String id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
package com.no1.wms.stock;
|
package com.no1.wms.stock;
|
||||||
|
|
||||||
import java.io.Console;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class StockService {
|
public class StockService {
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -40,7 +38,7 @@ public class StockService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public StockDto stockOne(UUID id) {
|
public StockDto stockOne(String id) {
|
||||||
return mapper.stockOne(id);
|
return mapper.stockOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,4 +51,9 @@ public class StockService {
|
|||||||
public int updateStock(StockDto dto) {
|
public int updateStock(StockDto dto) {
|
||||||
return mapper.updateStock(dto);
|
return mapper.updateStock(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int deleteBoard(String id) {
|
||||||
|
return mapper.deleteStock(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
order by id desc limit #{start}, #{perPage}
|
order by id desc limit #{start}, #{perPage}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="stockOne" parameterType="UUID" resultType="com.no1.wms.stock.StockDto">
|
<select id="stockOne" parameterType="String" resultType="com.no1.wms.stock.StockDto">
|
||||||
selct * from stock where id = #{id}
|
selct * from stock where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<!-- select -->
|
<!-- select -->
|
||||||
@@ -44,8 +44,14 @@
|
|||||||
|
|
||||||
<!-- insert -->
|
<!-- insert -->
|
||||||
<insert id="createStock" parameterType="com.no1.wms.stock.StockDto">
|
<insert id="createStock" parameterType="com.no1.wms.stock.StockDto">
|
||||||
insert into stock (id, quantity, activation)
|
insert into stock (id, warehouse_id, product_id, quantity, activation)
|
||||||
values (#{dto.id}, #{dto.quantity}, 1)
|
values (#{dto.id}, #{dto.warehouse_id}, #{dto.product_id}, #{dto.quantity}, 1)
|
||||||
</insert>
|
</insert>
|
||||||
<!-- insert -->
|
<!-- insert -->
|
||||||
|
|
||||||
|
<!-- delete -->
|
||||||
|
<delete id="deleteStock" parameterType="String">
|
||||||
|
delete from stock where no = #{id}
|
||||||
|
</delete>
|
||||||
|
<!-- delete -->
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user