package com.bonus.canteen.core.menu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.menu.entity.MenuDishesCook;
import com.bonus.canteen.core.menu.mapper.MenuDishesCookMapper;
import com.bonus.canteen.core.menu.service.MenuDishesCookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class MenuDishesCookServiceImpl extends ServiceImpl<MenuDishesCookMapper, MenuDishesCook> implements MenuDishesCookService {
   private static final Logger log = LoggerFactory.getLogger(MenuDishesCookServiceImpl.class);
//   @Autowired
//   @Lazy
//   private MenuDishesMapper menuDishesMapper;
//
//   public void addMenuDishesCook(MenuDishesCookAddDTO content) {
//      List<MenuDishesCook> cookList = ((MenuDishesCookMapper)this.baseMapper).selectList((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuDishesCook.class).eq(MenuDishesCook::getCookName, content.getCookName())).eq(MenuDishesCook::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
//      if (CollUtil.isNotEmpty(cookList)) {
//         throw new LeException(I18n.getMessage("menu_cook_name_repeat", new Object[0]));
//      } else {
//         String username = SecurityUtils.getUser().getUsername();
//         MenuDishesCook dishesCook = new MenuDishesCook();
//         BeanUtil.copyProperties(content, dishesCook, new String[0]);
//         dishesCook.setCrby(username);
//         dishesCook.setCookId(Id.next());
//         ((MenuDishesCookMapper)this.baseMapper).insert(dishesCook);
//      }
//   }
//
//   public Page<MenuDishesCookPageVO> getMenuDishesCookPage(String content) {
//      Map<String, JSONObject> contentMap = (Map)JSON.parseObject(content, Map.class);
//      Page<MenuDishesCook> page = QueryParseHelper.getPageFromContent(content, MenuDishesCook.class);
//      MenuDishesCookPageDTO dishesCookPageDTO = (MenuDishesCookPageDTO)((JSONObject)contentMap.get("object")).toJavaObject(MenuDishesCookPageDTO.class);
//      return ((MenuDishesCookMapper)this.baseMapper).selectAllList(page, dishesCookPageDTO, DelFlagEnum.DEL_FALSE.key());
//   }
//
//   public void editMenuDishesCook(MenuDishesCookEditDTO content) {
//      if (StringUtils.isNotBlank(content.getCookName())) {
//         List<MenuDishesCook> cookList = ((MenuDishesCookMapper)this.baseMapper).selectList((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuDishesCook.class).eq(MenuDishesCook::getCookName, content.getCookName())).eq(MenuDishesCook::getDelFlag, DelFlagEnum.DEL_FALSE.key())).ne(MenuDishesCook::getCookId, content.getCookId()));
//         if (!CollUtil.isEmpty(cookList)) {
//            throw new LeException(I18n.getMessage("menu_cook_name_repeat", new Object[0]));
//         }
//      }
//
//      String username = SecurityUtils.getUser().getUsername();
//      MenuDishesCook dishesCook = new MenuDishesCook();
//      BeanUtil.copyProperties(content, dishesCook, new String[0]);
//      dishesCook.setUpby(username);
//      ((MenuDishesCookMapper)this.baseMapper).update(dishesCook, (Wrapper)Wrappers.lambdaQuery(MenuDishesCook.class).eq(MenuDishesCook::getCookId, content.getCookId()));
//   }
//
//   public void removeByMaterialId(Long cookId) {
//      List<MenuDishes> menuDishesList = this.menuDishesMapper.selectList((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuDishes.class).eq(MenuDishes::getCookId, cookId)).eq(MenuDishes::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
//      if (menuDishesList != null && !menuDishesList.isEmpty()) {
//         throw new LeException(I18n.getMessage("menu_cook_use_del", new Object[0]));
//      } else {
//         ((MenuDishesCookMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)(new UpdateWrapper()).lambda().eq(MenuDishesCook::getCookId, cookId)).set(MenuDishesCook::getDelFlag, DelFlagEnum.DEL_TRUE.key()));
//      }
//   }


}
