登陆接口+统一返回的接口

This commit is contained in:
kuang.yife 2023-12-10 12:59:38 +08:00
parent f607e2b9fa
commit 5b9ea18698
4 changed files with 209 additions and 9 deletions

View File

@ -1,12 +1,11 @@
package com.ruoyi.web.controller.app;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.web.request.LoginReq;
import com.ruoyi.web.response.LoginResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* <p>登陆相关接口</p>
@ -20,10 +19,9 @@ public class LoginController {
//密码登陆
@ResponseBody
@PostMapping(value = "/loginByPhone")
@ApiOperation(value = "手机号登陆")
public AjaxResult loginByPhone(){
return AjaxResult.success();
@ApiOperation(value = "手机号登陆", response = LoginReq.class)
public Result<LoginResp> loginByPhone(@RequestBody LoginReq loginReq){
return Result.success();
}
// 手机号验证码登陆

View File

@ -0,0 +1,24 @@
package com.ruoyi.web.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>登陆相关需要的参数</p>
* @author clunt
*/
@Data
@ApiModel(value = "App*登陆入参")
public class LoginReq {
@ApiModelProperty(value = "手机号", required = true)
private String mobile;
@ApiModelProperty(value = "验证码")
private String authCode;
@ApiModelProperty(value = "密码")
private String password;
}

View File

@ -0,0 +1,102 @@
package com.ruoyi.web.response;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "App*登陆响应参数")
public class LoginResp {
@ApiModelProperty(value = "用户id*妥善存储,后续调用需要传递")
private Long userId;
@ApiModelProperty(value = "用户手机号")
private String mobile;
/** 昵称 */
@ApiModelProperty(value = "昵称")
private String nickName;
/** 真实姓名 */
@ApiModelProperty(value = "真实姓名")
private String realName;
/** 性别: 0.未知 1.男 2.女 */
@ApiModelProperty(value = "性别: 0.未知 1.男 2.女")
private Long sex;
/** 出生年月 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "出生年月日")
private Date birthday;
/** 身高(单位cm) */
@ApiModelProperty(value = "身高(单位cm)")
private Long height;
/** 体重(单位KG) */
@ApiModelProperty(value = "体重(单位KG)")
private Long weight;
/** 学历 0.大专以下 1.大专 2.本科 3.研究生 4.博士 */
@ApiModelProperty(value = "学历 0.大专以下 1.大专 2.本科 3.研究生 4.博士")
private Long education;
/** 毕业院校 */
@ApiModelProperty(value = "毕业院校")
private String school;
/** 婚姻状况 0.未婚 1.离异 */
@ApiModelProperty(value = "婚姻状况 0.未婚 1.离异")
private Long marriage;
/** 职业 */
@ApiModelProperty(value = "职业")
private String job;
/** 收入(元/年) */
@ApiModelProperty(value = "收入(元/年)")
private Long income;
/** 籍贯 */
@ApiModelProperty(value = "籍贯")
private String nativePlace;
/** 省份 */
@ApiModelProperty(value = "省份")
private Long provinceId;
/** 城市 */
@ApiModelProperty(value = "城市")
private Long cityId;
/** 是否有房产 0.无房 1.有房 */
@ApiModelProperty(value = "是否有房产 0.无房 1.有房")
private Long houseProperty;
/** 是否有车 0.无车 1.有车 */
@ApiModelProperty(value = "是否有车 0.无车 1.有车")
private Long carProperty;
/** 自我介绍 */
@ApiModelProperty(value = "自我介绍")
private String selfIntroduce;
/** 家庭背景 */
@ApiModelProperty(value = "家庭背景")
private String familyBackground;
/** 业务爱好 */
@ApiModelProperty(value = "业务爱好")
private String hobby;
/** 择偶标准 */
@ApiModelProperty(value = "择偶标准")
private String choosingStandard;
}

View File

@ -0,0 +1,76 @@
package com.ruoyi.common.core.domain;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "统一返回参数")
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1084094914898698049L;
private static final String DEFAULT_ERROR_CODE = "999999";
private static final String DEFAULT_SUCCESS_CODE = "100000";
@ApiModelProperty("请求编码code为100000代表的是成功其他都是失败")
private String code;
@ApiModelProperty("返回的提示信息")
private String msg;
@ApiModelProperty("true 代表的是返回成功false代表的是返回失败")
private boolean success;
private T data;
@ApiModelProperty("请求的时间戳")
private String timestamp;
private Result() {
}
private Result(String code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
this.timestamp = DateUtil.now();
}
public static <T> Result<T> error() {
return error("999999", "未知异常,请联系管理员");
}
public static <T> Result<T> error(String msg) {
return error("999999", msg);
}
public static <T> Result<T> error(String code, String msg) {
Result result = new Result(code, msg, (Object)null);
result.setSuccess(false);
return result;
}
public static <T> Result<T> error(String code, T data, String msg) {
Result result = new Result(code, msg, data);
result.setSuccess(false);
return result;
}
public static <T> Result<T> success() {
return success(null, "操作成功!");
}
public static <T> Result<T> success(T data) {
return success(data, "操作成功!");
}
/** @deprecated */
public static <T> Result<T> success(String msg) {
return success(null, msg);
}
public static <T> Result<T> success(T data, String msg) {
Result result = new Result("100000", msg, data);
result.setSuccess(true);
return result;
}
}