package com.newfiber.api.pc.service.impl; import com.newfiber.api.pc.dao.SysMenuJurisdictionDao; import com.newfiber.api.pc.dao.Sys_MenusDao; import com.newfiber.api.pc.model.entity.MenuJurisdiction; import com.newfiber.api.pc.model.zhz.Menu; import com.newfiber.api.pc.service.DataMenuJurisdictionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Date; import java.util.List; @Service @Transactional(rollbackFor = Exception.class) public class DataMenuJurisdictionServiceImpl implements DataMenuJurisdictionService { @Autowired private SysMenuJurisdictionDao MenuJurisdictionDao; @Override public int addMenuJurisdiction(String Menu_No, String Jurisdiction_No) throws Exception { List<MenuJurisdiction> menuJurisdictions = new ArrayList<>(); MenuJurisdiction menuJurisdiction=new MenuJurisdiction(); menuJurisdiction.setJurisdictionNo(Jurisdiction_No); MenuJurisdictionDao.deleteDataMenuJu(menuJurisdiction); String [] menuNo=Menu_No.split(","); for(int i=0;i<menuNo.length;i++){ MenuJurisdiction newJur = new MenuJurisdiction(); newJur.setJurisdictionNo(Jurisdiction_No); newJur.setCreateTime(new Date()); newJur.setMenuNo(menuNo[i]); menuJurisdictions.add(newJur); } MenuJurisdictionDao.addMenu(menuJurisdictions); return 0; } @Override public List<Menu> selectMenusByJurs(List<String> list) { if(list == null || list.size() <= 0){ return new ArrayList<>(); } String jurs = "'" + String.join("','", list) + "'"; return MenuJurisdictionDao.selectMenusByJurs(jurs); } }