| | |
| | | import com.matrix.core.constance.SystemErrorCode; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.RSAUtils; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.core.tools.*; |
| | | import com.matrix.core.web.BaseAction; |
| | | import com.matrix.system.common.authority.DefaultAuthorityManager; |
| | | import com.matrix.system.common.authority.strategy.AccountPasswordLogin; |
| | | import com.matrix.system.common.authority.strategy.LoginStrategy; |
| | | import com.matrix.system.common.authority.strategy.ScanQrCodeLogin; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.dao.ProjExceptionDao; |
| | | import com.matrix.system.common.dto.WebLoginDto; |
| | | import com.matrix.system.common.service.SysUsersService; |
| | | import com.matrix.system.hive.dao.SysShopInfoDao; |
| | | import com.matrix.system.hive.statistics.StatisticsBusinessDataJob; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.security.Key; |
| | | import java.util.Map; |
| | |
| | | StatisticsBusinessDataJob sjobp; |
| | | @RequestMapping(value = "/job") |
| | | public @ResponseBody String job() { |
| | | sjobp.executeExt2(); |
| | | //sjobp.executeExt2(); |
| | | return "1"; |
| | | } |
| | | |
| | |
| | | * |
| | | * 登录验证 |
| | | * @author:姜友瑶 |
| | | * @param user |
| | | * @return 返回类型 AjaxResult |
| | | * @date 2016年8月30日 |
| | | */ |
| | | @RequestMapping(value = "/dologin") |
| | | public @ResponseBody AjaxResult dologin(SysUsers user) { |
| | | long sqlStart = System.currentTimeMillis(); |
| | | decryptAccountAndPassword(user); |
| | | LoginStrategy apLogin = new AccountPasswordLogin(user, sysUsersService); |
| | | public @ResponseBody AjaxResult dologin(WebLoginDto webLoginDto) { |
| | | |
| | | user = authorityManager.login(apLogin); |
| | | long sqlStart = System.currentTimeMillis(); |
| | | SysUsers user=null; |
| | | if(WebLoginDto.ACCOUNT_LOGIN.equals(webLoginDto.getLoginType())){ |
| | | user= decryptAccountAndPassword(webLoginDto); |
| | | LoginStrategy apLogin = new AccountPasswordLogin(user, sysUsersService); |
| | | user = authorityManager.login(apLogin); |
| | | }else { |
| | | ScanQrCodeLogin apLogin = new ScanQrCodeLogin( sysUsersService,webLoginDto.getLoginQrCodeKey()); |
| | | user = authorityManager.login(apLogin); |
| | | } |
| | | |
| | | |
| | | if(user.getShopId()!=null){ |
| | |
| | | * @author JIANGYOUYAO |
| | | * @email 935090232@qq.com |
| | | * @date 2017年12月11日 |
| | | * @param user |
| | | */ |
| | | private void decryptAccountAndPassword(SysUsers user) { |
| | | private SysUsers decryptAccountAndPassword(WebLoginDto webLoginDto) { |
| | | |
| | | String privateKey = WebUtil.getSessionAttribute(MatrixConstance.PRIVATE_KEY); |
| | | if (StringUtils.isBlank(privateKey)) { |
| | | throw new GlobleException(SystemErrorCode.REQUEST_INVALID); |
| | | } |
| | | |
| | | SysUsers user=new SysUsers(); |
| | | try { |
| | | // 账号解密 |
| | | byte[] acccountData = RSAUtils.decryptByPrivateKey(user.getSuAccount(), privateKey); |
| | | byte[] acccountData = RSAUtils.decryptByPrivateKey(webLoginDto.getSuAccount(), privateKey); |
| | | user.setSuAccount(new String(acccountData)); |
| | | // 密码解密 |
| | | byte[] passWordData = RSAUtils.decryptByPrivateKey(user.getSuPassword(), privateKey); |
| | | byte[] passWordData = RSAUtils.decryptByPrivateKey(webLoginDto.getSuPassword(), privateKey); |
| | | user.setSuPassword(new String(passWordData)); |
| | | |
| | | } catch (Exception e) { |
| | | LogUtil.error("用户账号密码解密失败", e); |
| | | throw new GlobleException(SystemErrorCode.LOGIN_FAIL); |
| | | } |
| | | |
| | | return user; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 移动端登录 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/doHiveMobilelogin") |
| | | public @ResponseBody AjaxResult doHiveMobilelogin(SysUsers user) { |
| | | long sqlStart = System.currentTimeMillis(); |
| | | decryptAccountAndPassword(user); |
| | | LoginStrategy apLogin = new AccountPasswordLogin(user, sysUsersService); |
| | | user = authorityManager.login(apLogin); |
| | | // 获取该账户的岗位信息,并判断是否为店长 |
| | | if(user.getShopId()!=null){ |
| | | user.setShopName(sysShopInfoDao.selectById(user.getShopId()).getShopName()); |
| | | } |
| | | |
| | | AjaxResult result = new AjaxResult(); |
| | | authorityManager.initUserPower(result); |
| | | result.setStatus(AjaxResult.STATUS_SUCCESS); |
| | | LogUtil.info("#用户登录成功 账号={}#", user.getSuAccount()); |
| | | switch (user.getSuUserType()) { |
| | | // 企业管理员 |
| | | case AppConstance.USER_TYPE_ADMIN: |
| | | result.setPage(HIVE_MOBILE_REDIRECT_INDEX); |
| | | break; |
| | | // 企业用户 |
| | | case AppConstance.USER_TYPE_EMPLOYEE: |
| | | result.setPage(HIVE_MOBILE_REDIRECT_INDEX); |
| | | break; |
| | | default:// 不能识别的用户 |
| | | result.setPage("common/redirect/404"); |
| | | } |
| | | long endStart = System.currentTimeMillis(); |
| | | LogUtil.info("本次登录耗时#{}毫秒", (endStart-sqlStart)+""); |
| | | return result; |
| | | } |
| | | |
| | | @GetMapping(value = "/hiveMobileLoginOut") |
| | | public String hiveMobileLoginOut() { |
| | | authorityManager.getLoginOut(); |
| | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | |
| | | |
| | | /** |
| | | * 官网联系我们通知 |
| | | */ |
| | | @RequestMapping(value = "/gwLinkUs") |
| | | public @ResponseBody |
| | | AjaxResult gwLinkUs(@RequestBody Map<String , Object> param) { |
| | | |
| | | String title = "hive新客户在官网提交联系请求"; |
| | | String content = "hive=>name:" + param.get("name") + " tel:" + param.get("tel") ; |
| | | DingDingRobotUtil.sendLink("https://oapi.dingtalk.com/robot/send?access_token=62bb902f0e3945f0ece31306b99abae043fc69a66da0ef04d89fd20bf58d88d8", content, title, "", "www.baidu.com"); |
| | | |
| | | return AjaxResult.buildSuccessInstance("提交成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |