Commit f773df39 authored by 曹盼盼's avatar 曹盼盼

新增微信小程序登录接口

parent c5d4f75d
package com.yeejoin.amos.boot.module.tzs.api.common;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @description: 公共实体
* @author: duanwei
**/
@Data
public class BaseEntity implements Serializable {
private static final long serialVersionUID = -5464322936854328207L;
@TableId(type = IdType.ID_WORKER)
private Long id;
/**
* 创建时间
*/
@TableField(value = "create_date", fill = FieldFill.INSERT)
private Date createDate;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private Date updateTime;
}
package com.yeejoin.amos.boot.module.tzs.api.common;
import com.yeejoin.amos.boot.module.tzs.api.enums.BaseExceptionEnum;
/**
* @Author cpp
* @Description基础异常类
* @Date 2023/4/23
*/
public class BaseException extends RuntimeException {
private static final long serialVersionUID = 194906846739586857L;
/**
* 错误码
*/
private int code;
/**
* 错误内容
*/
private String msg;
public BaseException(String msg) {
super(msg);
}
public BaseException(int code, String msg) {
super(msg);
this.code = code;
this.msg = msg;
}
public BaseException(BaseExceptionEnum baseExceptionEnum) {
super(baseExceptionEnum.getMsg());
this.msg = baseExceptionEnum.getMsg();
this.code = baseExceptionEnum.getCode();
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.yeejoin.amos.boot.module.tzs.api.common;
import com.yeejoin.amos.boot.module.tzs.api.enums.CommonErrorEnum;
/**
* @description: 共同异常类
* @author: duanwei
* @create: 2019-08-28 20:07
**/
public class CommonException extends BaseException {
private static final long serialVersionUID = 194906846739586857L;
/**
* 错误码
*/
private int code;
/**
* 错误内容
*/
private String msg;
public CommonException(int code, String msg) {
super(msg);
this.code = code;
this.msg = msg;
}
public CommonException(CommonErrorEnum menuExceptionEnum) {
super(menuExceptionEnum.getMsg());
this.msg = menuExceptionEnum.getMsg();
this.code = menuExceptionEnum.getCode();
}
@Override
public int getCode() {
return code;
}
@Override
public void setCode(int code) {
this.code = code;
}
@Override
public String getMsg() {
return msg;
}
@Override
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.yeejoin.amos.boot.module.tzs.api.common;
import org.springframework.util.Assert;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
/**
* IO流拓展工具类,补充IOUtils新版本中废弃的closeQuietly
*
* @author King
* @since 2018/12/27 17:56
*/
public class ExtendedIOUtils {
public static void flush(Flushable... resources) throws IOException {
Assert.noNullElements(resources, "resources invalid");
int length = resources.length;
for (int i = 0; i < length; ++i) {
Flushable resource = resources[i];
if (resource != null) {
resource.flush();
}
}
}
public static void closeQuietly(Closeable... resources) {
int length = resources.length;
for (int i = 0; i < length; ++i) {
Closeable resource = resources[i];
if (resource != null) {
try {
resource.close();
} catch (IOException e) {
//ignore exception
}
}
}
}
}
package com.yeejoin.amos.boot.module.tzs.api.common;
import java.util.HashMap;
import java.util.Map;
/**
* @Description: 全局单机缓存
* @Author: duanwei
* @Date: 2020/6/30
*/
public class GlobalCache {
/**
* 全局请求头
*/
public static Map<String, String> header = new HashMap<>();
/**
* 依赖参数容器
*/
public static Map<String, String> paramMap = new HashMap<>(1000);
}
package com.yeejoin.amos.boot.module.tzs.api.common;
import lombok.Data;
/**
* @Author cpp
* @Description
* @Date 2023/4/23
*/
@Data
public class MobileLoginParam {
/**
* 注册类型:1-微信授权快捷登录;2-手机验证登录
*/
private int registerType;
/**
* 是否需要需要短信验证: true-验证; false-不验证
*/
private Boolean isNeedVerify;
/**
* 注册类型为1时使用:微信用户数据字段1,根据1、2进行数据解密,计算出手机号
*/
private String encryptedData;
/**
* 注册类型为1时使用:微信用户数据字段2,根据1、2进行数据解密,计算出手机号
*/
private String iv;
/**
*注册类型为1时使用:微信用户数据字段3,根据1、2、3进行数据解密,计算出手机号
*/
private String code;
/**
* 注册类型为2-手机验证登录时使用:手机号
*/
private String phoneNo;
/**
* 注册类型为2-手机验证登录时使用:验证码
*/
private String verifyCode;
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.api.common;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 字符串工具类
*
* @author as-youjun
*/
public class StringUtil {
private static Pattern NOT_ZERO_AT_THE_END = Pattern.compile("[1-9](\\d*[1-9])?");
private static Pattern numericPattern = Pattern.compile("-?[0-9]+\\.?[0-9]*");
private static Pattern NUMBER_PATTERN = Pattern.compile("-?[0-9]+(\\.[0-9]+)?");
/**
* 判断对象是否为空
*
* @param str
* @return
*/
public static boolean isNotEmpty(Object str) {
boolean flag = true;
if (str != null && !"".equals(str)) {
if (str.toString().length() > 0) {
flag = true;
}
} else {
flag = false;
}
return flag;
}
/***************************************************************************
* repeat - 通过源字符串重复生成N次组成新的字符串。
*
* @param src
* - 源字符串 例如: 空格(" "), 星号("*"), "浙江" 等等...
* @param num
* - 重复生成次数
* @return 返回已生成的重复字符串
* @version 1.0 (2006.10.10) Wilson Lin
**************************************************************************/
public static String repeat(String src, int num) {
StringBuffer s = new StringBuffer();
for (int i = 0; i < num; i++) {
s.append(src);
}
return s.toString();
}
/**
* 判断是否数字表示
*
* @param str 源字符串
* @return 是否数字的标志
*/
public static boolean isNumeric(String str) {
// 该正则表达式可以匹配所有的数字 包括负数
String bigStr;
try {
bigStr = new BigDecimal(str).toString();
} catch (Exception e) {
return false;//异常 说明包含非数字。
}
Matcher isNum = NUMBER_PATTERN.matcher(bigStr); // matcher是全匹配
if (!isNum.matches()) {
return false;
}
return true;
}
public static int toInt(String s) {
if (s != null && !"".equals(s.trim())) {
try {
return Integer.parseInt(s);
} catch (Exception e) {
return 0;
}
}
return 0;
}
public static boolean isEmpty(Collection collection) {
return collection == null || collection.isEmpty();
}
public static boolean isNotEmpty(Collection collection) {
return collection != null && collection.size() > 0;
}
public static boolean isEmpty(Map map) {
return map == null || map.isEmpty();
}
/**
* 截取前后都不是0的数字字符串
* <p>
* 12010102 => 12010102 12010100 => 120101 ab1201100b => 12011
*
* @param str
* @return
*/
public static String delEndZero(String str) {
Matcher mat = NOT_ZERO_AT_THE_END.matcher(str);
boolean rs = mat.find();
if (rs) {
return mat.group(0);
}
return null;
}
/**
* <pre>
* 移除字符串后面的0
* </pre>
*
* @param s
* @return
*/
public static String removeSufixZero(String s) {
if (s == null) {
return "";
}
while (s.endsWith("0")) {
if ("0".equals(s)) {
s = "";
break;
}
s = s.substring(0, s.length() - 1);
}
return s;
}
public static String transforCode(String code) {
if (code.endsWith("0000000")) {
code = code.substring(0, 1);
} else if (code.endsWith("000000")) {
code = code.substring(0, 2);
} else if (code.endsWith("0000")) {
code = code.substring(0, 4);
} else if (code.endsWith("00")) {
code = code.substring(0, 6);
}
return code;
}
}
package com.yeejoin.amos.boot.module.tzs.api.enums;
/**
* @description: 基础枚举类
**/
public enum BaseExceptionEnum {
/**
* 请求成功
*/
SUCCESS(0, "请求成功"),
/**
* 系统繁忙
*/
SYSTEM_BUSY(100, "系统繁忙"),
/**
* 请求超时
*/
REQUEST_TIME_OUT(300, "请求超时"),
/**
* 参数错误
*/
PARAMETER_ERROR(400, "参数错误"),
/**
* 网络异常
*/
NETWORK_ERROR(404, "网络异常"),
/**
* 数据不存在
*/
DATA_NOT_EXISTS(600, "数据不存在"),
/**
* 无权访问
*/
ACCESSDENIED_ERROR(501, "无权访问"),
/**
* 请求已经过期
*/
REQUEST_EXPIRATION(406, "请求已经过期"),
/**
* 请求失败
*/
REQUEST_ERROR(407, "请求失败"),
/**
* 未知错误
*/
FAILURE(999, "未知错误");
private Integer code;
private String msg;
BaseExceptionEnum(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.yeejoin.amos.boot.module.tzs.api.enums;
/**
* 通用错误码,code编码:10000000-10000999
*
* @author King
* @since 2018/12/14 10:30
*/
public enum CommonErrorEnum {
/**
* 服务器核心数据丢失
*/
SERVER_KEY_DATA_MISSING(10000000, "服务器核心数据丢失"),
/**
* 服务器数据查询错误
*/
SERVER_DATA_QUERY_ERROR(10000001, "服务器数据查询错误"),
/**
* 主键查询主键无效
*/
QUERY_PRIMARY_INVALID(10000002, "主键查询主键无效"),
/**
* 主键查询主键无效
*/
QUERY_ONE_PARAM_INVALID(10000003, "唯一性查询参数无效"),
/**
* 序列化异常
*/
SERIALIZATION_EXCEPTION(10000004, "序列化异常"),
/**
* 反序列化异常
*/
DESERIALIZATION_EXCEPTION(10000005, "反序列化异常"),
/**
* 入参无效
*/
PARAM_INVALID(10000006, "入参无效"),
/**
* 核心字段无效
*/
CRUCIAL_FIELD_INVALID(10000007, "核心字段无效"),
/**
* 解压缩异常
*/
DECOMPRESS_EXCEPTION(10000008, "解压缩异常"),
/**
* 缓存查询key值无效
*/
CACHE_QUERY_KEY_INVALID(10000009, "缓存查询key值无效"),
/**
* 缓存失效
*/
CACHE_LOSE_EFFICACY(10000010, "缓存失效"),
/**
* 未知错误
*/
UNKNOWN(10000999, "未知错误");
private Integer code;
private String msg;
CommonErrorEnum(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.yeejoin.amos.boot.module.tzs.api.enums;
/**
* @author shg
* 人员审核状态-2020年底 驻场开发
*/
public enum PersonCheckStatus {
UN_REGISTER("未注册", 0),
WAIT_REGISTER("待审核", 1),
CHECK_REJECT("审核拒绝", 2),
CHECK_PASS("分包商审核通过", 3),
INITED("项目审核通过", 4),
DONE("初始化完成", 5);
private String name;
private int status;
PersonCheckStatus(String name, int status) {
this.name = name;
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
package com.yeejoin.amos.boot.module.tzs.api.enums;
/**
* @author DELL
* 手机登录类型: 2020年底 驻场开发
*/
public enum PhoneRegisterTypeEum {
WX("微信授权快捷登录",1),
PHONE_VERIFY("手机验证登录",2);
private String name;
private int code;
PhoneRegisterTypeEum(String name,int code){
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.api.service;
import com.yeejoin.amos.boot.module.tzs.api.common.MobileLoginParam;
import java.util.Map;
public interface ISafetyService {
/**
* app 登陆
*
* @param param MobileLoginParam.class
* @return Map<String, Object>
*/
Map<String, Object> loginFromApp(MobileLoginParam param);
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.tzs.api.service;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @description:
* @author: duanwei
* @date: 2020-07-02 12:11
**/
public interface SmallProService {
/**
* 统一提供小程序Token
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
*
* @return
*/
String getSmallProToken();
/**
* 统一产生第三方页面二维码
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
*
* @param access_token 接口调用凭证
* @param scene 传递的参数
* 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
String getSmallProQrCode(String access_token, String scene, String page, Long width, Boolean auto_color,
JSONObject line_color, Boolean is_hyaline);
/**
* 统一产生第三方页面二维码
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/qr-code.html
*
* @param access_token 接口调用凭证
* @param scene 传递的参数
* 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用
* urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加
* /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
* @param width 二维码的宽度,单位 px,最小 280px,最大 1280px
* @param auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
* @param line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如
* {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @param is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
* @return
*/
byte[] getSmallProQrCodeByte(String access_token, String scene, String page, Long width, Boolean auto_color,
JSONObject line_color, Boolean is_hyaline);
/**
* 小程序二维码请求-文件流
*
* @param access_token
* @param scene
* @param page
* @param width
* @param auto_color
* @param line_color
* @param is_hyaline
* @param response
* @param fileName
* @param fileType
*/
void getSmallProQrCodeResponse(String access_token, String scene, String page, Long width, Boolean auto_color,
JSONObject line_color, Boolean is_hyaline, HttpServletResponse response, String fileName, String fileType);
/**
* code转session
*
* @param code
* @return
*/
JSONObject getCode2Session(String code);
/**
* 获取sessionKey
*
* @param code
* @return
*/
String getSessionKey(String code);
/**
* 获取openId
*
* @param code
* @return
*/
String getOpenId(String code);
/**
* 获取电话号码
* @param session_key
* @param encryptedData
* @param iv
* @return
*/
String getPhoneNumber(String session_key, String encryptedData, String iv);
/* *//**
* 微信消息通知推送
* @param
*//*
void sendWeChatUpcomingMessage(List<String> openIds, String template, List<String> message) ;*/
String getName();
}
package com.yeejoin.amos.boot.module.tzs.api.vo;
import lombok.Data;
import org.apache.http.client.methods.CloseableHttpResponse;
import java.io.InputStream;
/**
* @description: http封装响应对象
* @author: duanwei
* @create: 2019-08-08 13:30
**/
@Data
public class ResponeVo {
int code;
CloseableHttpResponse response;
String content;
byte[] inStream;
InputStream inputStream;
}
package com.yeejoin.amos.boot.module.tzs.api.vo;
import lombok.Data;
/**
* @description:
* @author: duanwei
* @date: 2020-07-02 12:12
**/
@Data
public class SmallProQrCodeVo {
/**
* 数据类型 (MIME Type)
*/
private String contentType;
/**
* byte数据 微信生成的二维码
*/
private byte[] buffer;
/**
* 错误码
*/
private Integer errCode;
/**
* 错误信息
*/
private String errMsg;
}
package com.yeejoin.amos.boot.module.tzs.api.vo;
import lombok.Data;
/**
* @description:
* @author: duanwei
* @date: 2020-07-02 12:12
**/
@Data
public class SmallProTokenVo {
private String access_token;
private Integer expires_in;
private Integer errcode;
private String errmsg;
}
package com.yeejoin.amos.boot.module.tzs.flc.api.feign; package com.yeejoin.amos.boot.module.tzs.flc.api.feign;
import com.yeejoin.amos.boot.biz.common.feign.FeignConfiguration; import com.yeejoin.amos.boot.biz.common.feign.FeignConfiguration;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.VerifyCodeAuthModel;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
@FeignClient(value = "AMOS-API-PRIVILEGE",configuration = {FeignConfiguration.class}) import java.awt.*;
@FeignClient(value = "AMOS-API-PRIVILEGE", configuration = {FeignConfiguration.class})
public interface PrivilegeFeginService { public interface PrivilegeFeginService {
@RequestMapping(value = "/privilege/v1/agencyuser/me", method = RequestMethod.GET) @RequestMapping(value = "/privilege/v1/agencyuser/me", method = RequestMethod.GET)
...@@ -28,4 +38,12 @@ public interface PrivilegeFeginService { ...@@ -28,4 +38,12 @@ public interface PrivilegeFeginService {
//获取行政区划树 //获取行政区划树
@RequestMapping(value = "systemctl/v1/region/tree", method = RequestMethod.GET) @RequestMapping(value = "systemctl/v1/region/tree", method = RequestMethod.GET)
FeignClientResult getTree(); FeignClientResult getTree();
/**
* 手机号验证码登录
*/
@RequestMapping(value = "/privilege/v1/auth/mobile/verifycode", method = RequestMethod.POST)
FeignClientResult mobileVerifyCode(@RequestBody VerifyCodeAuthModel model) throws InnerInvokException;
} }
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.mapper; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitInfo; import com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitInfo;
import java.util.List;
/** /**
* 单位注册信息表 Mapper 接口 * 单位注册信息表 Mapper 接口
* *
...@@ -11,4 +13,6 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitInfo; ...@@ -11,4 +13,6 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.entity.RegUnitInfo;
*/ */
public interface RegUnitInfoMapper extends BaseMapper<RegUnitInfo> { public interface RegUnitInfoMapper extends BaseMapper<RegUnitInfo> {
List<RegUnitInfo> userData(String phone);
} }
...@@ -2,4 +2,10 @@ ...@@ -2,4 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.flc.api.mapper.RegUnitInfoMapper"> <mapper namespace="com.yeejoin.amos.boot.module.tzs.flc.api.mapper.RegUnitInfoMapper">
<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>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.tzs.biz.config; package com.yeejoin.amos.boot.module.tzs.biz.config;
import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.annotation.DbType;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import freemarker.template.utility.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
......
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.tzs.api.common.MobileLoginParam;
import com.yeejoin.amos.boot.module.tzs.api.service.ISafetyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
/**
* @Author cpp
* @Description
* @Date 2023/4/23
*/
@RestController
@RequestMapping(value = "/safe")
@Api(tags = "微信程序登录api")
public class SafetyController extends BaseController {
@Autowired
private ISafetyService iSafetyService;
@ApiOperation(value = "移动端登录", notes = "移动端登录")
@PostMapping(value = "/mobile/login")
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
public Object loginFromApp(@RequestBody MobileLoginParam param) {
buildRequestContext();
return iSafetyService.loginFromApp(param);
}
protected void buildRequestContext() {
String token = getToken();
String product = getProduct();
String appKey = getAppKey();
RequestContext.setToken(token);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
}
}
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