| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class MenuUserService { |
| | |
| | | return mapper.selectList(query); |
| | | } |
| | | |
| | | public void addList(List<MenuUser> menuList) { |
| | | public void addList(int userId, List<MenuUser> menuList) { |
| | | //校验是否存在,存在则剔除 |
| | | List<MenuUser> existsList = getList(userId); |
| | | List<Integer> existsIdList = existsList.stream().map(menuUser -> menuUser.getId()).collect(Collectors.toList()); |
| | | for (MenuUser menuUser : menuList) { |
| | | Integer id = menuUser.getId(); |
| | | if(existsIdList.contains(id)){ |
| | | menuList.remove(menuUser); |
| | | } |
| | | } |
| | | mapper.insertBatchSomeColumn(menuList); |
| | | } |
| | | |