Commit 8f301dcf authored by terrfly's avatar terrfly
Browse files

添加接口示例;

parent 336278be
......@@ -20,6 +20,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeequan.jeepay.core.model.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
......@@ -39,6 +41,7 @@ import java.util.Date;
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_isv_info")
@ApiModel
public class IsvInfo extends BaseModel implements Serializable {
//gw
......@@ -51,62 +54,74 @@ public class IsvInfo extends BaseModel implements Serializable {
/**
* 服务商号
*/
@ApiModelProperty(value = "服务商号")
@TableId(value = "isv_no", type = IdType.INPUT)
private String isvNo;
/**
* 服务商名称
*/
@ApiModelProperty(value = "服务商名称")
private String isvName;
/**
* 服务商简称
*/
@ApiModelProperty(value = "服务商简称")
private String isvShortName;
/**
* 联系人姓名
*/
@ApiModelProperty(value = "联系人姓名")
private String contactName;
/**
* 联系人手机号
*/
@ApiModelProperty(value = "联系人手机号")
private String contactTel;
/**
* 联系人邮箱
*/
@ApiModelProperty(value = "联系人邮箱")
private String contactEmail;
/**
* 状态: 0-停用, 1-正常
*/
@ApiModelProperty(value = "状态: 0-停用, 1-正常")
private Byte state;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
/**
* 创建者用户ID
*/
@ApiModelProperty(value = "创建者用户ID")
private Long createdUid;
/**
* 创建者姓名
*/
@ApiModelProperty(value = "创建者姓名")
private String createdBy;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createdAt;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private Date updatedAt;
......
/*
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* 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.jeequan.jeepay.core.model;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/*
* 接口返回对象
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/6/8 16:35
*/
@Data
@ApiModel
public class ApiPageRes<M> extends ApiRes {
/** 数据对象 **/
@ApiModelProperty(value = "业务数据")
private PageBean<M> data;
/** 业务处理成功, 封装分页数据, 仅返回必要参数 **/
public static <M> ApiPageRes<M> pages(IPage<M> iPage){
PageBean<M> innerPage = new PageBean<>();
innerPage.setRecords(iPage.getRecords()); //记录明细
innerPage.setTotal(iPage.getTotal()); //总条数
innerPage.setCurrent(iPage.getCurrent()); //当前页码
innerPage.setHasNext( iPage.getPages() > iPage.getCurrent()); //是否有下一页
ApiPageRes result = new ApiPageRes();
result.setData(innerPage);
result.setCode(ApiCodeEnum.SUCCESS.getCode());
result.setMsg(ApiCodeEnum.SUCCESS.getMsg());
return result;
}
@Data
@ApiModel
public static class PageBean<M> {
/** 数据列表 */
@ApiModelProperty(value = "数据列表")
private List<M> records;
/** 总数量 */
@ApiModelProperty(value = "总数量")
private Long total;
/** 当前页码 */
@ApiModelProperty(value = "当前页码")
private Long current;
/** 是否包含下一页, true:包含 ,false: 不包含 */
@ApiModelProperty(value = "是否包含下一页, true:包含 ,false: 不包含")
private boolean hasNext;
}
}
......@@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.utils.JeepayKit;
import com.jeequan.jeepay.core.utils.JsonKit;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
......@@ -35,6 +36,7 @@ import java.io.Serializable;
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiRes<T> implements Serializable {
/** 业务响应码 **/
......@@ -82,13 +84,13 @@ public class ApiRes<T> implements Serializable {
}
/** 业务处理成功, 封装分页数据, 仅返回必要参数 **/
public static ApiRes page(IPage iPage){
public static <T> ApiRes<ApiPageRes.PageBean<T>> page(IPage<T> iPage){
JSONObject result = new JSONObject();
result.put("records", iPage.getRecords()); //记录明细
result.put("total", iPage.getTotal()); //总条数
result.put("current", iPage.getCurrent()); //当前页码
result.put("hasNext", iPage.getPages() > iPage.getCurrent() ); //是否有下一页
ApiPageRes.PageBean<T> result = new ApiPageRes.PageBean<>();
result.setRecords(iPage.getRecords()); //记录明细
result.setTotal(iPage.getTotal()); //总条数
result.setCurrent(iPage.getCurrent()); //当前页码
result.setHasNext( iPage.getPages() > iPage.getCurrent()); //是否有下一页
return ok(result);
}
......@@ -106,4 +108,5 @@ public class ApiRes<T> implements Serializable {
return new ApiRes(ApiCodeEnum.CUSTOM_FAIL.getCode(), customMsg, null, null);
}
}
......@@ -27,6 +27,10 @@ import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.mgr.service.AuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -40,6 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
* @site https://www.jeequan.com
* @date 2021/6/8 17:09
*/
@Api(tags = "认证模块")
@RestController
@RequestMapping("/api/anon/auth")
public class AuthController extends CommonCtrl {
......@@ -47,11 +52,17 @@ public class AuthController extends CommonCtrl {
@Autowired private AuthService authService;
/** 用户信息认证 获取iToken **/
@ApiOperation("登录认证")
@ApiImplicitParams({
@ApiImplicitParam(name = "ia", value = "用户名 i account, 需要base64处理", required = true),
@ApiImplicitParam(name = "ip", value = "密码 i passport, 需要base64处理", required = true),
@ApiImplicitParam(name = "vc", value = "证码 vercode, 需要base64处理", required = true),
@ApiImplicitParam(name = "vt", value = "验证码token, vercode token , 需要base64处理", required = true)
})
@RequestMapping(value = "/validate", method = RequestMethod.POST)
@MethodLog(remark = "登录认证")
public ApiRes validate() throws BizException {
String account = Base64.decodeStr(getValStringRequired("ia")); //用户名 i account, 已做base64处理
String ipassport = Base64.decodeStr(getValStringRequired("ip")); //密码 i passport, 已做base64处理
String vercode = Base64.decodeStr(getValStringRequired("vc")); //验证码 vercode, 已做base64处理
......
......@@ -23,9 +23,14 @@ import com.jeequan.jeepay.components.mq.vender.IMQSender;
import com.jeequan.jeepay.core.aop.MethodLog;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.entity.IsvInfo;
import com.jeequan.jeepay.core.model.ApiPageRes;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.IsvInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -41,6 +46,7 @@ import org.springframework.web.bind.annotation.RestController;
* @site https://www.jeequan.com
* @date 2021-06-07 07:15
*/
@Api(tags = "服务商管理")
@RestController
@RequestMapping("/api/isvInfo")
public class IsvInfoController extends CommonCtrl {
......@@ -53,9 +59,13 @@ public class IsvInfoController extends CommonCtrl {
* @date: 2021/6/7 16:12
* @describe: 查询服务商信息列表
*/
@ApiOperation("服务商列表")
@ApiImplicitParams({
@ApiImplicitParam(name= "isvNo", value = "服务商编号")
})
@PreAuthorize("hasAuthority('ENT_ISV_LIST')")
@RequestMapping(value="", method = RequestMethod.GET)
public ApiRes list() {
public ApiPageRes<IsvInfo> list() {
IsvInfo isvInfo = getObject(IsvInfo.class);
LambdaQueryWrapper<IsvInfo> wrapper = IsvInfo.gw();
if (StringUtils.isNotEmpty(isvInfo.getIsvNo())) {
......@@ -70,7 +80,7 @@ public class IsvInfoController extends CommonCtrl {
wrapper.orderByDesc(IsvInfo::getCreatedAt);
IPage<IsvInfo> pages = isvInfoService.page(getIPage(true), wrapper);
return ApiRes.page(pages);
return ApiPageRes.pages(pages);
}
/**
......
Supports Markdown
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