Commit 403645c8 authored by 曹盼盼's avatar 曹盼盼

修改登录接口

parent 12fa0cb8
......@@ -36,12 +36,12 @@ public class MobileLoginParam {
private String code;
/**
* 注册类型为2-手机验证登录时使用:手机号
* 账号或手机号
*/
private String phoneNo;
/**
* 注册类型为2-手机验证登录时使用:验证
*
*/
private String verifyCode;
}
\ No newline at end of file
......@@ -15,4 +15,5 @@ public interface RegUnitInfoMapper extends BaseMapper<RegUnitInfo> {
List<RegUnitInfo> userData(String phone);
RegUnitInfo userDataINfo(String adminLoginName,String adminLoginPwd);
}
......@@ -4,8 +4,82 @@
<select id="userData" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitInfo">
SELECT *
FROM tz_flc_reg_unit_info WHERE admin_tel=#{phone}
SELECT
sequence_nbr,
name,
unit_code,
unit_code_type,
unit_type,
unit_type_code,
management_unit,
management_unit_id,
region_code,
country,
province,
city,
district,
stree,
community,
address,
longitude,
latitude,
industry_name,
legal_person,
legal_person_tel,
contact_person,
contact_person_tel,
admin_name,
admin_login_name,
admin_login_pwd,
admin_tel,
admin_id_number,
state,
admin_user_id,
amos_company_seq,
rec_user_id,
rec_user_name,
rec_date,
is_delete,
unit_code_type_name,
admin_id_card_photo
FROM tz_flc_reg_unit_info WHERE admin_tel=#{phone}
</select>
<select id="userDataINfo" resultType="com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitInfo">
SELECT
sequence_nbr,
name,
unit_code,
unit_code_type,
unit_type,
unit_type_code,
management_unit,
management_unit_id,
region_code,
country,
province,
city,
district,
stree,
community,
address,
longitude,
latitude,
industry_name,
legal_person,
legal_person_tel,
contact_person,
contact_person_tel,
admin_name,
admin_tel,
admin_id_number,
amos_company_seq,
unit_code_type_name,
admin_id_card_photo
FROM tz_flc_reg_unit_info WHERE admin_login_name=#{adminLoginName} AND admin_login_pwd=#{adminLoginPwd}
</select>
</mapper>
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.yeejoin.amos.boot.module.tzs.api.common.MobileLoginParam;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.TzsAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Map;
@RestController
@Api(tags = "tzs小程序接口")
@RequestMapping(value = "/tzs-app")
......@@ -41,4 +42,16 @@ public class TzsAppController {
public ResponseModel<Object> getEquipInfoBySuperviseCode(String supervisoryCode) {
return ResponseHelper.buildResponse(appService.getEquipInfoBySuperviseCode(supervisoryCode));
}
/**
* 登录
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping(value = "/mobile/login")
@ApiOperation(httpMethod = "POST", value = "小程序登录", notes = "小程序登录")
public ResponseModel<Map<String, Object>> login(@RequestBody MobileLoginParam param) {
return ResponseHelper.buildResponse(appService.login(param));
}
}
......@@ -7,13 +7,21 @@ import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.yeejoin.amos.boot.biz.common.utils.QRCodeUtil;
import com.yeejoin.amos.boot.module.tzs.api.common.CommonException;
import com.yeejoin.amos.boot.module.tzs.api.common.MobileLoginParam;
import com.yeejoin.amos.boot.module.tzs.api.dto.*;
import com.yeejoin.amos.boot.module.tzs.api.entity.*;
import com.yeejoin.amos.boot.module.tzs.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitInfo;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.RegUnitInfoMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.ibatis.builder.MapperBuilderAssistant;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,6 +30,7 @@ import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -32,6 +41,7 @@ import java.lang.reflect.Field;
import java.util.*;
@Service
@Slf4j
public class TzsAppService {
@Autowired
DesignInfoService designInfoService;
......@@ -95,6 +105,19 @@ public class TzsAppService {
@Value("${minio.url.path}")
String minioPath;
@Autowired
private RegUnitInfoMapper regUnitInfoMapper;
/**
* 产品appkey
*/
private static final String appKey="AMOS_STUDIO";
/**
* 产品product
*/
private static final String product="AMOS_STUDIO_WEB";
private final int successsCode = 200;
public Map<String, Object> getEquipmentInfo(String record){
Map<String, Object> map = new HashMap();
......@@ -304,4 +327,43 @@ public class TzsAppService {
CategoryOtherInfo categoryOtherInfo = categoryOtherInfoMapper.selectOne(new QueryWrapper<CategoryOtherInfo>().eq("SUPERVISORY_CODE", supervisoryCode));
return ObjectUtils.isEmpty(categoryOtherInfo) ? null : getEquipmentInfo(categoryOtherInfo.getRecord());
}
public Map<String, Object> login(MobileLoginParam param){
Map<String, Object> result = new LinkedHashMap<>();
IdPasswordAuthModel idPasswordAuthModel = new IdPasswordAuthModel();
idPasswordAuthModel.setLoginId(param.getPhoneNo());
idPasswordAuthModel.setPassword(param.getVerifyCode());
FeignClientResult<Map<String, String>> idpassword = new FeignClientResult<>();
RequestContext.setToken("");
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
try {
idpassword = Privilege.authClient.idpassword(idPasswordAuthModel);
} catch (Exception e) {
e.printStackTrace();
}
if (idpassword.getStatus() != successsCode) {
log.error("调用平台手机号验证码登录失败:{}", idpassword.getDevMessage());
String message = idpassword.getMessage();
if (StringUtils.isEmpty(message)) {
message = "账号已被禁用,请联系管理员";
}
throw new CommonException(600001, message);
}
HashMap<Object, Object> authInfo = new HashMap<>();// 设置authInfo信息
authInfo.put("token", idpassword.getResult().get("token"));
authInfo.put("personId", idpassword.getResult().get("userId"));
authInfo.put("appKey", appKey);
authInfo.put("product", product);
result.put("authInfo", authInfo);
//业务查询
RegUnitInfo userInfo = regUnitInfoMapper.userDataINfo(param.getPhoneNo(),param.getVerifyCode());
result.put("userInfo", userInfo);
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment