public static TheLoaiSachUI convertToUI(TheLoaiSach theLoaiSach) { TheLoaiSachUI tLUI = new TheLoaiSachUI(); if (theLoaiSach != null) { tLUI.setMaTheLoai(theLoaiSach.getTenTheLoai()); tLUI.setTenTheLoai(theLoaiSach.getTenTheLoai()); } return tLUI; }
public static TheLoaiSach convertToTheLoaiSach(TheLoaiSachUI theLoaiSachUI) { TheLoaiSach tlS = new TheLoaiSach(); if (tlS != null) { tlS.setMaTheLoai(theLoaiSachUI.getMaTheLoai()); tlS.setTenTheLoai(theLoaiSachUI.getTenTheLoai()); } return tlS; }
@RequestMapping(value = "/sach/add", method = RequestMethod.GET) public String hienThiThemSach(Model model) { List<TheLoaiSach> theLoaiSachs = theLoaiSachService.timDanhMucTheLoaiSach(); List<TheLoaiSachUI> theLoaiSachUIs = new ArrayList<TheLoaiSachUI>(); if (theLoaiSachs.size() > 0) { for (TheLoaiSach theLoaiSach : theLoaiSachs) { TheLoaiSachUI tLSachUIL = new TheLoaiSachUI(); tLSachUIL.setMaTheLoai(theLoaiSach.getMaTheLoai()); tLSachUIL.setTenTheLoai(theLoaiSach.getTenTheLoai()); theLoaiSachUIs.add(tLSachUIL); } } SachUI sachUI = new SachUI(); sachUI.setMaSach(UUID.randomUUID().toString()); model.addAttribute("theLoaiUIs", theLoaiSachUIs); model.addAttribute("sachUI", sachUI); model.addAttribute("btnName", "Thêm Sách Mới"); return WebConstant.views.THEM_SACH; }