| | |
| | | package com.sandu.ximon.admin.service; |
| | | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.Group; |
| | | import com.sandu.ximon.dao.domain.Groups; |
| | | import com.sandu.ximon.dao.mapper.GroupMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class GroupService extends BaseServiceImpl<GroupMapper, Group> { |
| | | public class GroupService extends BaseServiceImpl<GroupMapper, Groups> { |
| | | |
| | | public void addGroup(String name) { |
| | | Group group = new Group(); |
| | | private final GroupMapper groupMapper; |
| | | |
| | | public boolean addGroup(String name) { |
| | | Groups group = new Groups(); |
| | | group.setUserId(SecurityUtils.getUserId()); |
| | | group.setName(name); |
| | | group.setCount(null); |
| | | save(group); |
| | | |
| | | // group.setCount(null); |
| | | return save(group); |
| | | } |
| | | //给灯杆设置分组在灯杆那边 |
| | | |
| | | public void updateGroup(String name,Long id) { |
| | | Group group = new Group(); |
| | | //给灯杆设置分组在灯杆那边 |
| | | |
| | | public boolean updateGroup(Long id,String name) { |
| | | Groups byId = getById(id); |
| | | if(byId==null){ |
| | | throw new BusinessException("未找到该分组"); |
| | | } |
| | | Groups group = new Groups(); |
| | | //group.setUserId(SecurityUtils.getUserId()); |
| | | group.setId(id); |
| | | group.setName(name); |
| | | //group.setCount(null); |
| | | updateById(group); |
| | | |
| | | return updateById(group); |
| | | } |
| | | |
| | | public boolean deleteGroup(Long id){ |
| | | Groups byId = getById(id); |
| | | if(byId==null){ |
| | | throw new BusinessException("未找到该分组"); |
| | | } |
| | | return removeById(id); |
| | | } |
| | | |
| | | public List<Groups> groupList(){ |
| | | return groupMapper.groupList(SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | |
| | | } |