| | |
| | | package com.moral.controller; |
| | | |
| | | import com.moral.Webinterceptor.WebInterceptor; |
| | | import com.moral.common.util.BeanUtils; |
| | | import com.moral.common.webAnno.UserLoginToken; |
| | | import com.moral.entity.AreaNames; |
| | | import com.moral.entity.Organization; |
| | | import com.moral.service.AccountService; |
| | | import com.moral.service.DictionaryDataService; |
| | | import com.moral.service.OrganizationService; |
| | | import com.moral.service.WebTokenService; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | @Resource |
| | | DictionaryDataService dictionaryDataService; |
| | | OrganizationService organizationService; |
| | | @Resource |
| | | WebTokenService webTokenService; |
| | | |
| | | @RequestMapping("login") |
| | | public Map<String, Object> login(HttpServletRequest request){ |
| | |
| | | Object orgId = resultMap.get("orgId"); |
| | | if (resultMap.get("orgId") != null && resultMap.get("orgId") instanceof Integer) { |
| | | StringBuilder areaNamesBuilder = new StringBuilder("中国"); |
| | | //判断是否为本公司开发者 |
| | | if (!((Integer) orgId).equals(dictionaryDataService.querySupperOrgId())) { |
| | | //不是本公司开发者则获取用户所属地区 |
| | | Organization organization = organizationService.getOrganizationById((Integer) orgId); |
| | | if (organization.getAreaNames() != null) { |
| | | Map<String, String> areaNameMap = BeanUtils.beanToMap(organization.getAreaNames()); |
| | |
| | | resultMap.put("mapAreaCode", mapAreaCode.toString()); |
| | | } |
| | | resultMap.put("mapPath", areaNamesBuilder.toString()); |
| | | String accountId= String.valueOf(resultMap.get("accountId")); |
| | | resultMap.put("token",webTokenService.getToken(accountId)); |
| | | } |
| | | } |
| | | request.getSession().setAttribute(WebInterceptor.SESSION_KEY,resultMap); |
| | | return resultMap; |
| | | } |
| | | |
| | | @RequestMapping("add") |
| | | @UserLoginToken |
| | | @GetMapping("test") |
| | | public String add(){ |
| | | return "123123"; |
| | | return "test success!"; |
| | | } |
| | | } |