| | |
| | | |
| | | @GetMapping("getProductList") |
| | | public Result<List<XhProductModel>> getProductList(Long shipId, Integer productType) { |
| | | if(productType==2){ |
| | | shipId =null; |
| | | if (productType == 2) { |
| | | shipId = null; |
| | | } |
| | | List<XhProductModel> list = xhProductModelService.getProductList(shipId, productType - 1); |
| | | if(productType == 5){ |
| | | List<XhProductModel> list2 = xhProductModelService.getProductList(shipId, productType - 2); |
| | | if (productType == 5) { |
| | | List<XhProductModel> list2 = xhProductModelService.getProductList(shipId, productType - 2); |
| | | list.addAll(list2); |
| | | } |
| | | return Result.ok(list); |
| | |
| | | public Result insert(@RequestBody XhProductModel xhProductModel) { |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(xhProductModel, AddGroup.class, DefaultGroup.class); |
| | | |
| | | Integer no = xhProductModelService.getNo(xhProductModel.getPid(), xhProductModel.getProductType()); |
| | | if (xhProductModel.getSort() == null || xhProductModel.getSort() < no) { |
| | | xhProductModel.setSort(no + 1); |
| | | } |
| | | if (xhProductModel.getProductType().equals("2")) { |
| | | Long id = UUIDUtil.generateId(); |
| | | xhProductModel.setId(id); |
| | | xhProductModel.setShipId(id); |
| | | |
| | | ParamData data = new ParamData(); |
| | | data.setShipId(id); |
| | | data.setProductId(id); |
| | | |
| | | paramDataService.insert(data); |
| | | } |
| | | xhProductModel.setNamePath(xhProductModel.getNamePath() + "," + xhProductModel.getName()); |
| | | xhProductModelService.insert(xhProductModel); |
| | | ParamData data = new ParamData(); |
| | | data.setShipId(xhProductModel.getShipId()); |
| | | data.setProductId(xhProductModel.getId()); |
| | | paramDataService.insert(data); |
| | | Map<Long, XhProductModel> imgMap = new HashMap<>(); |
| | | imgMap = (Map<Long, XhProductModel>) CacheUtils.get("sysImgCache", "sysImgCache"); |
| | | imgMap.put(xhProductModel.getId(), xhProductModel); |
| | | xhProductModelService.insertProduct(xhProductModel); |
| | | return Result.ok(); |
| | | } |
| | | |
| | |
| | | public Result update(@RequestBody XhProductModel xhProductModel) { |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(xhProductModel, UpdateGroup.class, DefaultGroup.class); |
| | | xhProductModelService.update(xhProductModel); |
| | | Map<Long, XhProductModel> imgMap = new HashMap<>(); |
| | | imgMap = (Map<Long, XhProductModel>) CacheUtils.get("sysImgCache", "sysImgCache"); |
| | | imgMap.put(xhProductModel.getId(), xhProductModel); |
| | | |
| | | xhProductModelService.updateProduct(xhProductModel); |
| | | return Result.ok(); |
| | | } |
| | | |
| | |
| | | imgMap = (Map<Long, XhProductModel>) CacheUtils.get("sysImgCache", "sysImgCache"); |
| | | for (Long id : ids) { |
| | | Long[] list = xhProductModelService.getByPid(id); |
| | | if (list.length > 0){ |
| | | if (list.length > 0) { |
| | | this.deleteByProduct(list); |
| | | } |
| | | imgMap.remove(id); |