| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Optional;
|
| | | import java.util.Set;
|
| | |
|
| | | import static com.moral.common.bean.Constants.IS_DELETE_FALSE;
|
| | | import static com.moral.common.bean.Constants.IS_DELETE_TRUE;
|
| | | import static com.moral.common.util.ResourceUtil.getValue;
|
| | | import static org.apache.commons.lang3.StringUtils.isNumeric;
|
| | | import static org.springframework.util.ObjectUtils.isEmpty;
|
| | |
|
| | | import java.util.*;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.util.CollectionUtils;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
|
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.moral.common.bean.Constants;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.Crypto;
|
| | | import com.moral.common.util.ResourceUtil;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.Account;
|
| | | import com.moral.entity.Menu;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.entity.Role;
|
| | | import com.moral.mapper.AccountMapper;
|
| | | import com.moral.mapper.MenuMapper;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.OrganizationService;
|
| | |
| | | public class AccountServiceImpl implements AccountService {
|
| | | @Resource
|
| | | private BCryptPasswordEncoder encoder;
|
| | |
|
| | | @Resource
|
| | | private AccountMapper accountMapper;
|
| | |
|
| | |
| | | account.setPassword(parameters.get("password").toString());
|
| | | return account;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getOrganizationIdByAccountId(String id) {
|
| | | Integer accountId = Integer.parseInt(id);
|
| | | Map<String, Object> map = accountMapper.getOrganizationIdByAccountId(accountId);
|
| | | return map;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Account> getAccountList(String accountName) {
|
| | | List<Account> accountList = accountMapper.getAccountList(accountName);
|
| | | return accountList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Role> getRolesByAccountName(String accountName) {
|
| | | List<Role> roleList = accountMapper.getRolesByAccountName(accountName);
|
| | | return roleList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getMenuListsByAccountName(String accountName) {
|
| | | List<Menu> menuList=accountMapper.getParentMenuListsByAccountName(accountName);
|
| | | String email=accountMapper.getEmailByAccountName(accountName);
|
| | | Map<String,Object> mapList=new LinkedHashMap<>();
|
| | | Map<String,Object> appMap=new LinkedHashMap<>();
|
| | | appMap.put("name","七星瓢虫环境监测");
|
| | | appMap.put("description","七星瓢虫环境监测后台配置中心");
|
| | | mapList.put("app",appMap);
|
| | | Map<String,Object> userMap=new LinkedHashMap<>();
|
| | | userMap.put("name",accountName);
|
| | | userMap.put("avatar","./assets/img/zorro.svg");
|
| | | userMap.put("email",email);
|
| | | mapList.put("user",userMap);
|
| | | Map<String,Object> navigationMap=new LinkedHashMap<>();
|
| | | Map<String,Object> navigationChildMap=new LinkedHashMap<>();
|
| | | navigationChildMap.put("text","工作台");
|
| | | navigationChildMap.put("link", "/dashboard/workplace");
|
| | | navigationChildMap.put("icon","icon-speedometer");
|
| | | navigationChildMap.put("translate","dashboard_workplace");
|
| | | List<Map> navigationChildList=new ArrayList<>();
|
| | | navigationChildList.add(navigationChildMap);
|
| | | navigationMap.put("text","主导航");
|
| | | navigationMap.put("translate","main_navigation");
|
| | | navigationMap.put("group",true);
|
| | | navigationMap.put("children",navigationChildList);
|
| | | Map<String,Object> systemMap=new LinkedHashMap<>();
|
| | | systemMap.put("text","系统模块");
|
| | | systemMap.put("group",true);
|
| | | List<Map> systemList=new ArrayList<>();
|
| | | if(!CollectionUtils.isEmpty(menuList)){
|
| | | for(Menu m:menuList){
|
| | | Map<String,Object> systemChildMap=new LinkedHashMap<>();
|
| | | systemChildMap.put("text",m.getMenuName());
|
| | | systemChildMap.put("icon",m.getMenuIcon());
|
| | | List<Menu> childMenuLists=accountMapper.getChildMenuIdsByAccountName(accountName,m.getId());
|
| | | List<Map> systemSonList=new ArrayList<>();
|
| | | if(!CollectionUtils.isEmpty(childMenuLists)){
|
| | | for(Menu childMenu:childMenuLists){
|
| | | Map<String,Object> systemSonMap=new LinkedHashMap<>();
|
| | | systemSonMap.put("text",childMenu.getMenuName());
|
| | | systemSonMap.put("link",childMenu.getMenuUrl());
|
| | | systemSonList.add(systemSonMap);
|
| | | }
|
| | | }
|
| | | systemChildMap.put("children",systemSonList);
|
| | | systemList.add(systemChildMap);
|
| | | }
|
| | | }
|
| | | systemMap.put("children",systemList);
|
| | | List<Map> list=new ArrayList<>();
|
| | | list.add(navigationMap);
|
| | | list.add(systemMap);
|
| | | mapList.put("menu",list);
|
| | | return mapList;
|
| | | }
|
| | |
|
| | | }
|