update Categorys and Products and add Prices

This commit is contained in:
Kana
2024-01-12 09:53:33 +09:00
parent 660e581391
commit 735cf868cd
16 changed files with 721 additions and 123 deletions

View File

@@ -0,0 +1,91 @@
package com.no1.wms.price;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.no1.wms.category.CategoryDto;
@Controller
@RequestMapping("/price")
public class PriceController {
@Autowired
PriceService priceService;
@GetMapping("/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 = priceService.count(searchn, search);
int perPage = 15; // 한 페이지에 보일 글의 개수
int startRow = (page - 1) * perPage;
List<PriceDto> dto = priceService.priceList2(searchn, search, startRow ,perPage);
m.addAttribute("list", dto);
m.addAttribute("start", startRow + 1);
int pageNum = 5;//보여질 페이지 번호 수
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("searchn",searchn);
m.addAttribute("search",search);
m.addAttribute("begin", begin);
m.addAttribute("end", end);
m.addAttribute("pageNum", pageNum);
m.addAttribute("totalPages", totalPages);
m.addAttribute("p" , page);
return "/price/list";
}
// 생성 - 폼
@PostMapping("/create")
public String create() {
return "price/create";
}
// 생성 - Ajax
@PostMapping("/price/create_process")
@ResponseBody
public boolean createProcess(PriceDto dto) {
int i = priceService.createProcess(dto);
if (i == 1) {
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,32 @@
package com.no1.wms.price;
import java.util.Date;
import org.apache.ibatis.type.Alias;
import com.no1.wms.account.AccountDto;
import com.no1.wms.product.ProductDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Alias("PriceDto")
public class PriceDto {
private String id;//id
private String price;//가격
private Date registration_date;//등록날짜
private String manager_id;//담당자
private String product_id; //제품 아이디
private boolean activation;//활성화
private ProductDto productDto;
private AccountDto accountDto;
}

View File

@@ -0,0 +1,17 @@
package com.no1.wms.price;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import com.no1.wms.category.CategoryDto;
@Mapper
public interface PriceMapper {
List<PriceDto> priceList(Map<String, Object> m);
int count(Map<String, Object> m);//카운터
List<PriceDto> priceList2(Map<String, Object> m);//검색기능까지 포함
int createProcess(PriceDto dto);
}

View File

@@ -0,0 +1,56 @@
package com.no1.wms.price;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.no1.wms.category.CategoryDto;
import com.no1.wms.product.ProductDto;
@Service
public class PriceService {
@Autowired
PriceMapper mapper;
public List<PriceDto> priceList(int p){
int start = 0;
int count = 10;
Map m = new HashMap<String, Object>();
m.put("start", start);
m.put("count", count);
return mapper.priceList(m);
}
//페이징 카운터
public int count(int searchn, String search) {
Map<String,Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
return mapper.count(m);
}
public List<PriceDto> priceList2(int searchn, String search, int start, int perPage){
Map<String, Object> m = new HashMap<String, Object>();
m.put("searchn",searchn);
m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
return mapper.priceList2(m);
}
public int createProcess(PriceDto dto) {
return mapper.createProcess(dto);
}
}