old mode 100755
new mode 100644
| File was renamed from service-api/src/main/java/com/java110/api/listener/login/AdminLoginPropertyListener.java |
| | |
| | | /* |
| | | * Copyright 2017-2021 吴学文 and java110 team. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package com.java110.api.listener.login; |
| | | package com.java110.user.cmd.login; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.api.listener.AbstractServiceApiDataFlowListener; |
| | | import com.java110.core.annotation.Java110Listener; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.event.service.api.ServiceDataFlowEvent; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.AuthenticationFactory; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.store.StoreUserDto; |
| | |
| | | import com.java110.po.userLogin.UserLoginPo; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.constant.ServiceCodeConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.exception.SMOException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 用户注册 侦听 |
| | | * Created by wuxw on 2018/5/18. |
| | | */ |
| | | @Java110Listener("adminLoginPropertyListener") |
| | | public class AdminLoginPropertyListener extends AbstractServiceApiDataFlowListener { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(AdminLoginPropertyListener.class); |
| | | |
| | | @Java110Cmd(serviceCode = "login.adminLoginProperty") |
| | | public class AdminLoginPropertyCmd extends Cmd { |
| | | |
| | | @Autowired |
| | | private IUserLoginInnerServiceSMO userLoginInnerServiceSMOImpl; |
| | |
| | | private IStoreInnerServiceSMO storeInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public String getServiceCode() { |
| | | return ServiceCodeConstant.SERVICE_CODE_ADMIN_LOGIN_PROPERTY; |
| | | } |
| | | |
| | | @Override |
| | | public HttpMethod getHttpMethod() { |
| | | return HttpMethod.POST; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int getOrder() { |
| | | return 0; |
| | | } |
| | | |
| | | private void validate(JSONObject reqJson) { |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | Assert.hasKeyAndValue(reqJson, "username", "未包含需要登录的用户名"); |
| | | Assert.hasKeyAndValue(reqJson, "userId", "未包含需要登录的用户ID"); |
| | | Assert.hasKeyAndValue(reqJson, "curPasswd", "未包含当前用户的密码"); |
| | | Assert.hasKeyAndValue(reqJson, "curUserName", "未包含当前用户的用户名"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param event |
| | | */ |
| | | @Override |
| | | public void soService(ServiceDataFlowEvent event) { |
| | | //获取数据上下文对象 |
| | | DataFlowContext dataFlowContext = event.getDataFlowContext(); |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | ResponseEntity<String> responseEntity = null; |
| | | JSONObject paramIn = JSONObject.parseObject(dataFlowContext.getReqData()); |
| | | validate(paramIn); |
| | | |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserName(paramIn.getString("curUserName")); |
| | | userDto.setPassword(paramIn.getString("curPasswd")); |
| | | userDto.setUserName(reqJson.getString("curUserName")); |
| | | userDto.setPassword(reqJson.getString("curPasswd")); |
| | | List<UserDto> userDtos = userInnerServiceSMOImpl.getUsers(userDto); |
| | | |
| | | if (userDtos == null || userDtos.size() < 1) { |
| | | dataFlowContext.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_UNAUTHORIZED, "用户或密码错误")); |
| | | context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_UNAUTHORIZED, "用户或密码错误")); |
| | | return; |
| | | } |
| | | |
| | |
| | | List<StoreUserDto> storeUserDtos = storeInnerServiceSMOImpl.getStoreUserInfo(storeUserDto); |
| | | |
| | | if (storeUserDtos == null || storeUserDtos.size() < 1) { |
| | | dataFlowContext.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_UNAUTHORIZED, "当前用户不是运营团队 不能免登录")); |
| | | context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_UNAUTHORIZED, "当前用户不是运营团队 不能免登录")); |
| | | return; |
| | | } |
| | | |
| | | // 校验 需要登录的物业账号是否存在 |
| | | userDto = new UserDto(); |
| | | userDto.setUserId(paramIn.getString("userId")); |
| | | userDto.setUserName(paramIn.getString("username")); |
| | | userDto.setUserId(reqJson.getString("userId")); |
| | | userDto.setUserName(reqJson.getString("username")); |
| | | userDtos = userInnerServiceSMOImpl.getUsers(userDto); |
| | | |
| | | Assert.listOnlyOne(userDtos, "物业账号不存在"); |
| | |
| | | storeUserDtos = storeInnerServiceSMOImpl.getStoreUserInfo(storeUserDto); |
| | | |
| | | if (storeUserDtos == null || storeUserDtos.size() < 1) { |
| | | dataFlowContext.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_UNAUTHORIZED, "需要免密登录的账号不是物业账号")); |
| | | context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_UNAUTHORIZED, "需要免密登录的账号不是物业账号")); |
| | | return; |
| | | } |
| | | |
| | |
| | | userLoginPo.setUserName(userInfo.getString("userName")); |
| | | userLoginInnerServiceSMOImpl.saveUserLogin(userLoginPo); |
| | | responseEntity = new ResponseEntity<String>(userInfo.toJSONString(), HttpStatus.OK); |
| | | dataFlowContext.setResponseEntity(responseEntity); |
| | | context.setResponseEntity(responseEntity); |
| | | } catch (Exception e) { |
| | | logger.error("登录异常:", e); |
| | | throw new SMOException(ResponseConstant.RESULT_CODE_INNER_ERROR, "系统内部错误,请联系管理员"); |
| | | } |
| | | } |
| | | |
| | | } |