|  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemMenuBiz; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.dao.business.CompanyMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Company; | 
|---|
|  |  |  | import com.doumee.dao.system.dto.UpdateSystemMenuSortDTO; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemMenu; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.dao.system.vo.SystemMenuListVO; | 
|---|
|  |  |  | import com.doumee.dao.system.vo.SystemMenuNodeVO; | 
|---|
|  |  |  | import com.doumee.service.business.CompanyService; | 
|---|
|  |  |  | import com.doumee.service.system.SystemMenuService; | 
|---|
|  |  |  | import com.doumee.service.system.SystemUserService; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class SystemMenuBizImpl implements SystemMenuBiz { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemMenuService systemMenuService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CompanyService companyService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemUserService systemUserService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(SystemMenu systemMenu) { | 
|---|
|  |  |  | 
|---|
|  |  |  | public List<SystemMenuNodeVO> findTree (Integer userId,Integer type) { | 
|---|
|  |  |  | SystemMenu queryDto = new SystemMenu(); | 
|---|
|  |  |  | queryDto.setDeleted(Boolean.FALSE); | 
|---|
|  |  |  | List<SystemMenu> menus = systemMenuService.findByUserId(userId,type); | 
|---|
|  |  |  | List<SystemMenu> menus = new ArrayList<SystemMenu>(); | 
|---|
|  |  |  | List<SystemMenuNodeVO> rootNodes = new ArrayList<>(); | 
|---|
|  |  |  | menus = systemMenuService.findByUserId(userId,type); | 
|---|
|  |  |  | if(type.equals(Constants.ONE)){ | 
|---|
|  |  |  | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | Company company = companyService.findById(loginUserInfo.getCompanyId()); | 
|---|
|  |  |  | if(Objects.isNull(company)){ | 
|---|
|  |  |  | return rootNodes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | SystemUser systemUser = systemUserService.findById(userId); | 
|---|
|  |  |  | if(Objects.isNull(systemUser)){ | 
|---|
|  |  |  | return rootNodes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(company.getUsername().equals(systemUser.getUsername())){ | 
|---|
|  |  |  | SystemMenu systemMenu = new SystemMenu(); | 
|---|
|  |  |  | systemMenu.setType(type); | 
|---|
|  |  |  | systemMenu.setDeleted(Boolean.FALSE); | 
|---|
|  |  |  | menus = systemMenuService.findList(systemMenu); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 添加根菜单 | 
|---|
|  |  |  | for (SystemMenu menu : menus) { | 
|---|
|  |  |  | if (menu.getParentId() == null) { | 
|---|