| @@ -1,9 +1,11 @@ | |||||
| package com.iformall.controller.sm; | package com.iformall.controller.sm; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.sm.SaveApiMenuDTO; | import com.iformall.domain.dto.sm.SaveApiMenuDTO; | ||||
| import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | ||||
| import com.iformall.domain.po.sm.ApiMenu; | import com.iformall.domain.po.sm.ApiMenu; | ||||
| import com.iformall.exception.BizException; | |||||
| import com.iformall.service.sm.ApiMenuService; | import com.iformall.service.sm.ApiMenuService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -24,6 +26,15 @@ public class ApiMenuController { | |||||
| return new ResultData(apiMenuService.pageApiMenu(ApiMenu, pageNum, pageSize)); | return new ResultData(apiMenuService.pageApiMenu(ApiMenu, pageNum, pageSize)); | ||||
| } | } | ||||
| @ApiOperation("单个查询api菜单") | |||||
| @GetMapping("/get") | |||||
| public ResultData getApiMenu(Long id) { | |||||
| if (id == null) { | |||||
| throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| return new ResultData(apiMenuService.getApiMenu(id)); | |||||
| } | |||||
| @ApiOperation("新增api菜单") | @ApiOperation("新增api菜单") | ||||
| @PostMapping("/save") | @PostMapping("/save") | ||||
| public ResultData saveApiMenu(@RequestBody SaveApiMenuDTO dto) { | public ResultData saveApiMenu(@RequestBody SaveApiMenuDTO dto) { | ||||
| @@ -37,4 +48,10 @@ public class ApiMenuController { | |||||
| apiMenuService.updateApiMenu(dto); | apiMenuService.updateApiMenu(dto); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("全查询父级api菜单") | |||||
| @GetMapping("/listParentMenu") | |||||
| public ResultData listParentMenu() { | |||||
| return new ResultData(apiMenuService.listParentMenu()); | |||||
| } | |||||
| } | } | ||||
| @@ -1,8 +1,10 @@ | |||||
| package com.iformall.controller.sm; | package com.iformall.controller.sm; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | ||||
| import com.iformall.domain.po.WxThirdPartyApi; | import com.iformall.domain.po.WxThirdPartyApi; | ||||
| import com.iformall.exception.BizException; | |||||
| import com.iformall.service.WxThirdPartyApiService; | import com.iformall.service.WxThirdPartyApiService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -23,6 +25,15 @@ public class ThirdPartyApiController { | |||||
| return new ResultData(thirdPartyApiService.pageThirdPartyApi(thirdPartyApi, pageNum, pageSize)); | return new ResultData(thirdPartyApiService.pageThirdPartyApi(thirdPartyApi, pageNum, pageSize)); | ||||
| } | } | ||||
| @ApiOperation("单个查询秘钥") | |||||
| @GetMapping("/get") | |||||
| public ResultData getThirdPartyApi(Long id) { | |||||
| if (id == null) { | |||||
| throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| return new ResultData(thirdPartyApiService.getThirdPartyApi(id)); | |||||
| } | |||||
| @ApiOperation("修改秘钥状态") | @ApiOperation("修改秘钥状态") | ||||
| @PostMapping("/updateStatus") | @PostMapping("/updateStatus") | ||||
| public ResultData updateThirdPartyApiStatus(@RequestBody UpdateThirdPartyApiStatusDTO dto) { | public ResultData updateThirdPartyApiStatus(@RequestBody UpdateThirdPartyApiStatusDTO dto) { | ||||
| @@ -13,4 +13,11 @@ public interface CommonConstants { | |||||
| */ | */ | ||||
| Integer FLAG_TRUE = 1; | Integer FLAG_TRUE = 1; | ||||
| Integer FLAG_FALSE = 0; | Integer FLAG_FALSE = 0; | ||||
| /** | |||||
| * 通用数字 | |||||
| */ | |||||
| int NUM_0 = 0; | |||||
| int NUM_1 = 1; | |||||
| int NUM_2 = 2; | |||||
| } | } | ||||
| @@ -12,7 +12,7 @@ import java.util.Date; | |||||
| @ApiModel(value = "新增API指南") | @ApiModel(value = "新增API指南") | ||||
| @Data | @Data | ||||
| public class SaveApiGuideDTO { | public class SaveApiGuideDTO { | ||||
| @ApiModelProperty("api名称") | |||||
| @ApiModelProperty("指南名称") | |||||
| private String name; | private String name; | ||||
| @ApiModelProperty("指南内容") | @ApiModelProperty("指南内容") | ||||
| private String content; | private String content; | ||||
| @@ -2,6 +2,7 @@ package com.iformall.domain.dto.sm; | |||||
| import com.iformall.common.CommonConstants; | import com.iformall.common.CommonConstants; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.sm.ApiDetail; | |||||
| import com.iformall.domain.po.sm.ApiMenu; | import com.iformall.domain.po.sm.ApiMenu; | ||||
| import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
| @@ -18,6 +19,26 @@ public class SaveApiMenuDTO { | |||||
| private Long parentId; | private Long parentId; | ||||
| @ApiModelProperty("状态(0:正常,1:锁定)") | @ApiModelProperty("状态(0:正常,1:锁定)") | ||||
| private Integer status; | private Integer status; | ||||
| @ApiModelProperty("是否付费(0:否,1:是)") | |||||
| private Integer chargeFlag; | |||||
| @ApiModelProperty("是否需用户授权(0:否,1:是)") | |||||
| private Integer authFlag; | |||||
| @ApiModelProperty("接口描述") | |||||
| private String description; | |||||
| @ApiModelProperty("平台地址") | |||||
| private String platformUrl; | |||||
| @ApiModelProperty("系统参数") | |||||
| private String publicParam; | |||||
| @ApiModelProperty("请求参数") | |||||
| private String requestParam; | |||||
| @ApiModelProperty("响应参数") | |||||
| private String responseParam; | |||||
| @ApiModelProperty("请求示例") | |||||
| private String requestSample; | |||||
| @ApiModelProperty("响应示例") | |||||
| private String responseSample; | |||||
| @ApiModelProperty("异常示例") | |||||
| private String exceptionSample; | |||||
| public static ApiMenu mapping(SaveApiMenuDTO dto) { | public static ApiMenu mapping(SaveApiMenuDTO dto) { | ||||
| ApiMenu apiMenu = new ApiMenu(); | ApiMenu apiMenu = new ApiMenu(); | ||||
| @@ -30,4 +51,24 @@ public class SaveApiMenuDTO { | |||||
| apiMenu.setDeleteFlag(CommonConstants.FLAG_FALSE); | apiMenu.setDeleteFlag(CommonConstants.FLAG_FALSE); | ||||
| return apiMenu; | return apiMenu; | ||||
| } | } | ||||
| public static ApiDetail mappingApiDetail(SaveApiMenuDTO dto, ApiMenu apiMenu) { | |||||
| ApiDetail apiDetail = new ApiDetail(); | |||||
| apiDetail.setId(IdWorker.get().nextId()); | |||||
| apiDetail.setCreateTime(new Date()); | |||||
| apiDetail.setUpdateTime(new Date()); | |||||
| apiDetail.setMenuId(apiMenu.getId()); | |||||
| apiDetail.setMenuName(apiMenu.getName()); | |||||
| apiDetail.setChargeFlag(dto.getChargeFlag()); | |||||
| apiDetail.setAuthFlag(dto.getAuthFlag()); | |||||
| apiDetail.setDescription(dto.getDescription()); | |||||
| apiDetail.setPlatformUrl(dto.getPlatformUrl()); | |||||
| apiDetail.setPublicParam(dto.getPublicParam()); | |||||
| apiDetail.setRequestParam(dto.getRequestParam()); | |||||
| apiDetail.setResponseParam(dto.getResponseParam()); | |||||
| apiDetail.setRequestSample(dto.getRequestSample()); | |||||
| apiDetail.setResponseSample(dto.getResponseSample()); | |||||
| apiDetail.setExceptionSample(dto.getExceptionSample()); | |||||
| return apiDetail; | |||||
| } | |||||
| } | } | ||||
| @@ -23,6 +23,7 @@ public class UpdateApiGuideDTO { | |||||
| public static ApiGuide mapping(UpdateApiGuideDTO dto) { | public static ApiGuide mapping(UpdateApiGuideDTO dto) { | ||||
| ApiGuide apiGuide = new ApiGuide(); | ApiGuide apiGuide = new ApiGuide(); | ||||
| apiGuide.setId(dto.getId()); | |||||
| apiGuide.setUpdateTime(new Date()); | apiGuide.setUpdateTime(new Date()); | ||||
| if (CommonConstants.STATUS_NORMAL.equals(dto.getStatus())) { | if (CommonConstants.STATUS_NORMAL.equals(dto.getStatus())) { | ||||
| apiGuide.setReleaseTime(new Date()); | apiGuide.setReleaseTime(new Date()); | ||||
| @@ -2,6 +2,7 @@ package com.iformall.domain.dto.sm; | |||||
| import com.iformall.common.CommonConstants; | import com.iformall.common.CommonConstants; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.sm.ApiDetail; | |||||
| import com.iformall.domain.po.sm.ApiMenu; | import com.iformall.domain.po.sm.ApiMenu; | ||||
| import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
| @@ -12,14 +13,36 @@ import java.util.Date; | |||||
| @ApiModel(value = "修改API菜单") | @ApiModel(value = "修改API菜单") | ||||
| @Data | @Data | ||||
| public class UpdateApiMenuDTO { | public class UpdateApiMenuDTO { | ||||
| @ApiModelProperty("id") | |||||
| @ApiModelProperty(value = "菜单id",required = true) | |||||
| private Long id; | private Long id; | ||||
| @ApiModelProperty(value = "详情id") | |||||
| private Long detailId; | |||||
| @ApiModelProperty("菜单名称") | @ApiModelProperty("菜单名称") | ||||
| private String name; | private String name; | ||||
| @ApiModelProperty("父菜单id") | @ApiModelProperty("父菜单id") | ||||
| private Long parentId; | private Long parentId; | ||||
| @ApiModelProperty("状态(0:正常,1:锁定)") | @ApiModelProperty("状态(0:正常,1:锁定)") | ||||
| private Integer status; | private Integer status; | ||||
| @ApiModelProperty("是否付费(0:否,1:是)") | |||||
| private Integer chargeFlag; | |||||
| @ApiModelProperty("是否需用户授权(0:否,1:是)") | |||||
| private Integer authFlag; | |||||
| @ApiModelProperty("接口描述") | |||||
| private String description; | |||||
| @ApiModelProperty("平台地址") | |||||
| private String platformUrl; | |||||
| @ApiModelProperty("系统参数") | |||||
| private String publicParam; | |||||
| @ApiModelProperty("请求参数") | |||||
| private String requestParam; | |||||
| @ApiModelProperty("响应参数") | |||||
| private String responseParam; | |||||
| @ApiModelProperty("请求示例") | |||||
| private String requestSample; | |||||
| @ApiModelProperty("响应示例") | |||||
| private String responseSample; | |||||
| @ApiModelProperty("异常示例") | |||||
| private String exceptionSample; | |||||
| public static ApiMenu mapping(UpdateApiMenuDTO dto) { | public static ApiMenu mapping(UpdateApiMenuDTO dto) { | ||||
| ApiMenu apiMenu = new ApiMenu(); | ApiMenu apiMenu = new ApiMenu(); | ||||
| @@ -30,4 +53,22 @@ public class UpdateApiMenuDTO { | |||||
| apiMenu.setStatus(dto.getStatus()); | apiMenu.setStatus(dto.getStatus()); | ||||
| return apiMenu; | return apiMenu; | ||||
| } | } | ||||
| public static ApiDetail mappingApiDetail(UpdateApiMenuDTO dto) { | |||||
| ApiDetail apiDetail = new ApiDetail(); | |||||
| apiDetail.setUpdateTime(new Date()); | |||||
| apiDetail.setMenuId(dto.getId()); | |||||
| apiDetail.setMenuName(dto.getName()); | |||||
| apiDetail.setChargeFlag(dto.getChargeFlag()); | |||||
| apiDetail.setAuthFlag(dto.getAuthFlag()); | |||||
| apiDetail.setDescription(dto.getDescription()); | |||||
| apiDetail.setPlatformUrl(dto.getPlatformUrl()); | |||||
| apiDetail.setPublicParam(dto.getPublicParam()); | |||||
| apiDetail.setRequestParam(dto.getRequestParam()); | |||||
| apiDetail.setResponseParam(dto.getResponseParam()); | |||||
| apiDetail.setRequestSample(dto.getRequestSample()); | |||||
| apiDetail.setResponseSample(dto.getResponseSample()); | |||||
| apiDetail.setExceptionSample(dto.getExceptionSample()); | |||||
| return apiDetail; | |||||
| } | |||||
| } | } | ||||
| @@ -44,12 +44,12 @@ public class ApiDetail implements Serializable { | |||||
| /** | /** | ||||
| * 是否付费(0:否,1:是) | * 是否付费(0:否,1:是) | ||||
| */ | */ | ||||
| private Byte chargeFlag; | |||||
| private Integer chargeFlag; | |||||
| /** | /** | ||||
| * 是否需用户授权(0:否,1:是) | * 是否需用户授权(0:否,1:是) | ||||
| */ | */ | ||||
| private Byte authFlag; | |||||
| private Integer authFlag; | |||||
| /** | /** | ||||
| * 描述 | * 描述 | ||||
| @@ -91,11 +91,6 @@ public class ApiDetail implements Serializable { | |||||
| */ | */ | ||||
| private String exceptionSample; | private String exceptionSample; | ||||
| /** | |||||
| * 状态(0:正常,1:锁定) | |||||
| */ | |||||
| private Byte status; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| } | } | ||||
| @@ -0,0 +1,48 @@ | |||||
| package com.iformall.domain.vo.sm; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| @ApiModel(value = "查询API菜单响应数据") | |||||
| @Data | |||||
| public class ApiMenuVO { | |||||
| @ApiModelProperty("菜单id") | |||||
| private Long id; | |||||
| @ApiModelProperty("创建时间") | |||||
| private Date createTime; | |||||
| @ApiModelProperty("修改时间") | |||||
| private Date updateTime; | |||||
| @ApiModelProperty("是否叶子节点(0:否,1:是)") | |||||
| private Integer leafFlag; | |||||
| @ApiModelProperty("菜单名称") | |||||
| private String name; | |||||
| @ApiModelProperty("父菜单id") | |||||
| private Long parentId; | |||||
| @ApiModelProperty("状态(0:正常,1:锁定)") | |||||
| private Integer status; | |||||
| @ApiModelProperty("详情id") | |||||
| private Long detailId; | |||||
| @ApiModelProperty("是否付费(0:否,1:是)") | |||||
| private Integer chargeFlag; | |||||
| @ApiModelProperty("是否需用户授权(0:否,1:是)") | |||||
| private Integer authFlag; | |||||
| @ApiModelProperty("接口描述") | |||||
| private String description; | |||||
| @ApiModelProperty("平台地址") | |||||
| private String platformUrl; | |||||
| @ApiModelProperty("系统参数") | |||||
| private String publicParam; | |||||
| @ApiModelProperty("请求参数") | |||||
| private String requestParam; | |||||
| @ApiModelProperty("响应参数") | |||||
| private String responseParam; | |||||
| @ApiModelProperty("请求示例") | |||||
| private String requestSample; | |||||
| @ApiModelProperty("响应示例") | |||||
| private String responseSample; | |||||
| @ApiModelProperty("异常示例") | |||||
| private String exceptionSample; | |||||
| } | |||||
| @@ -2,6 +2,7 @@ package com.iformall.mapper; | |||||
| import com.iformall.domain.po.sm.ApiMenu; | import com.iformall.domain.po.sm.ApiMenu; | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.iformall.domain.vo.sm.ApiMenuVO; | |||||
| import java.util.List; | import java.util.List; | ||||
| @@ -11,6 +12,10 @@ import java.util.List; | |||||
| public interface ApiMenuMapper extends BaseMapper<ApiMenu> { | public interface ApiMenuMapper extends BaseMapper<ApiMenu> { | ||||
| List<ApiMenu> listApiMenu(ApiMenu apiMenu); | List<ApiMenu> listApiMenu(ApiMenu apiMenu); | ||||
| List<ApiMenu> listParentMenu(); | |||||
| List<ApiMenuVO> listApiMenuAndDetail(ApiMenu apiMenu); | |||||
| } | } | ||||
| @@ -44,4 +44,6 @@ public interface WxThirdPartyApiService { | |||||
| * @param dto | * @param dto | ||||
| */ | */ | ||||
| void updateThirdPartyApiStatus(UpdateThirdPartyApiStatusDTO dto); | void updateThirdPartyApiStatus(UpdateThirdPartyApiStatusDTO dto); | ||||
| WxThirdPartyApi getThirdPartyApi(Long id); | |||||
| } | } | ||||
| @@ -19,6 +19,7 @@ import com.iformall.service.WxThirdPartyApiService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| import com.iformall.utils.sign.AppUtils; | import com.iformall.utils.sign.AppUtils; | ||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -94,6 +95,14 @@ public class WxThirdPartyApiServiceImpl implements WxThirdPartyApiService { | |||||
| .eq(WxThirdPartyApi::getId, dto.getId())); | .eq(WxThirdPartyApi::getId, dto.getId())); | ||||
| } | } | ||||
| @Override | |||||
| public WxThirdPartyApi getThirdPartyApi(Long id) { | |||||
| WxThirdPartyApi thirdPartyApi = new WxThirdPartyApi(); | |||||
| thirdPartyApi.setId(id); | |||||
| List<WxThirdPartyApi> vos = wxThirdPartyApiMapper.listThirdPartyApi(thirdPartyApi); | |||||
| return !CollectionUtils.isEmpty(vos) ? vos.get(0) : null; | |||||
| } | |||||
| /** | /** | ||||
| * 构建秘钥实体 | * 构建秘钥实体 | ||||
| * | * | ||||
| @@ -5,15 +5,22 @@ import com.iformall.domain.dto.sm.SaveApiMenuDTO; | |||||
| import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | ||||
| import com.iformall.domain.po.sm.ApiMenu; | import com.iformall.domain.po.sm.ApiMenu; | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import com.iformall.domain.vo.sm.ApiMenuVO; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * | * | ||||
| */ | */ | ||||
| public interface ApiMenuService extends IService<ApiMenu> { | public interface ApiMenuService extends IService<ApiMenu> { | ||||
| PageInfo<ApiMenu> pageApiMenu(ApiMenu apiMenu, Integer pageNum, Integer pageSize); | |||||
| PageInfo<ApiMenuVO> pageApiMenu(ApiMenu apiMenu, Integer pageNum, Integer pageSize); | |||||
| void saveApiMenu(SaveApiMenuDTO dto); | void saveApiMenu(SaveApiMenuDTO dto); | ||||
| void updateApiMenu(UpdateApiMenuDTO dto); | void updateApiMenu(UpdateApiMenuDTO dto); | ||||
| List<ApiMenu> listParentMenu(); | |||||
| ApiMenuVO getApiMenu(Long id); | |||||
| } | } | ||||
| @@ -1,15 +1,24 @@ | |||||
| package com.iformall.service.sm.impl; | package com.iformall.service.sm.impl; | ||||
| import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.CommonConstants; | |||||
| import com.iformall.domain.dto.sm.SaveApiMenuDTO; | import com.iformall.domain.dto.sm.SaveApiMenuDTO; | ||||
| import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | ||||
| import com.iformall.domain.po.sm.ApiDetail; | |||||
| import com.iformall.domain.po.sm.ApiMenu; | import com.iformall.domain.po.sm.ApiMenu; | ||||
| import com.iformall.domain.vo.sm.ApiMenuVO; | |||||
| import com.iformall.mapper.ApiDetailMapper; | |||||
| import com.iformall.service.sm.ApiMenuService; | import com.iformall.service.sm.ApiMenuService; | ||||
| import com.iformall.mapper.ApiMenuMapper; | import com.iformall.mapper.ApiMenuMapper; | ||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * | * | ||||
| @@ -19,22 +28,53 @@ public class ApiMenuServiceImpl extends ServiceImpl<ApiMenuMapper, ApiMenu> impl | |||||
| @Autowired | @Autowired | ||||
| private ApiMenuMapper apiMenuMapper; | private ApiMenuMapper apiMenuMapper; | ||||
| @Autowired | |||||
| private ApiDetailMapper apiDetailMapper; | |||||
| @Override | |||||
| public PageInfo<ApiMenuVO> pageApiMenu(ApiMenu apiMenu, Integer pageNum, Integer pageSize) { | |||||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> apiMenuMapper.listApiMenuAndDetail(apiMenu)); | |||||
| } | |||||
| @Override | @Override | ||||
| public PageInfo<ApiMenu> pageApiMenu(ApiMenu apiMenu, Integer pageNum, Integer pageSize) { | |||||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> apiMenuMapper.listApiMenu(apiMenu)); | |||||
| public ApiMenuVO getApiMenu(Long id) { | |||||
| ApiMenu apiMenu = new ApiMenu(); | |||||
| apiMenu.setId(id); | |||||
| List<ApiMenuVO> vos = apiMenuMapper.listApiMenuAndDetail(apiMenu); | |||||
| return !CollectionUtils.isEmpty(vos) ? vos.get(0) : null; | |||||
| } | } | ||||
| @Transactional(rollbackFor = Exception.class) | |||||
| @Override | @Override | ||||
| public void saveApiMenu(SaveApiMenuDTO dto) { | public void saveApiMenu(SaveApiMenuDTO dto) { | ||||
| // 保存菜单信息 | |||||
| ApiMenu apiMenu = SaveApiMenuDTO.mapping(dto); | ApiMenu apiMenu = SaveApiMenuDTO.mapping(dto); | ||||
| apiMenuMapper.insert(apiMenu); | apiMenuMapper.insert(apiMenu); | ||||
| if (CommonConstants.NUM_0 != dto.getParentId()) { | |||||
| // 保存菜单详情信息 | |||||
| ApiDetail apiDetail = SaveApiMenuDTO.mappingApiDetail(dto, apiMenu); | |||||
| apiDetailMapper.insert(apiDetail); | |||||
| } | |||||
| } | } | ||||
| @Transactional(rollbackFor = Exception.class) | |||||
| @Override | @Override | ||||
| public void updateApiMenu(UpdateApiMenuDTO dto) { | public void updateApiMenu(UpdateApiMenuDTO dto) { | ||||
| // 修改菜单信息 | |||||
| ApiMenu apiMenu = UpdateApiMenuDTO.mapping(dto); | ApiMenu apiMenu = UpdateApiMenuDTO.mapping(dto); | ||||
| apiMenuMapper.updateById(apiMenu); | apiMenuMapper.updateById(apiMenu); | ||||
| if (CommonConstants.NUM_0 != dto.getParentId()) { | |||||
| // 修改菜单详情信息 | |||||
| ApiDetail apiDetail = UpdateApiMenuDTO.mappingApiDetail(dto); | |||||
| apiDetailMapper.update(apiDetail, new LambdaUpdateWrapper<ApiDetail>().eq(ApiDetail::getMenuId, dto.getId())); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public List<ApiMenu> listParentMenu() { | |||||
| return apiMenuMapper.listParentMenu(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -20,7 +20,6 @@ | |||||
| <result property="requestSample" column="request_sample" jdbcType="VARCHAR"/> | <result property="requestSample" column="request_sample" jdbcType="VARCHAR"/> | ||||
| <result property="responseSample" column="response_sample" jdbcType="VARCHAR"/> | <result property="responseSample" column="response_sample" jdbcType="VARCHAR"/> | ||||
| <result property="exceptionSample" column="exception_sample" jdbcType="VARCHAR"/> | <result property="exceptionSample" column="exception_sample" jdbcType="VARCHAR"/> | ||||
| <result property="status" column="status" jdbcType="TINYINT"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="Base_Column_List"> | <sql id="Base_Column_List"> | ||||
| @@ -28,7 +27,6 @@ | |||||
| menu_id,menu_name,charge_flag, | menu_id,menu_name,charge_flag, | ||||
| auth_flag,description,platform_url, | auth_flag,description,platform_url, | ||||
| public_param,request_param,response_param, | public_param,request_param,response_param, | ||||
| request_sample,response_sample,exception_sample, | |||||
| status | |||||
| request_sample,response_sample,exception_sample | |||||
| </sql> | </sql> | ||||
| </mapper> | </mapper> | ||||
| @@ -16,31 +16,67 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="Base_Column_List"> | <sql id="Base_Column_List"> | ||||
| id,create_time,update_time, | |||||
| name,parent_id,status, | |||||
| leaf_flag,delete_flag | |||||
| m.id,m.create_time,m.update_time, | |||||
| m.name,m.parent_id,m.status, | |||||
| m.leaf_flag,m.delete_flag | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| WHERE 1 = 1 | WHERE 1 = 1 | ||||
| AND m.delete_flag = 0 | |||||
| <if test=" null != id "> | <if test=" null != id "> | ||||
| and `id` = #{id} | |||||
| AND m.`id` = #{id} | |||||
| </if> | </if> | ||||
| <if test=" null != parentId and '' != parentId "> | <if test=" null != parentId and '' != parentId "> | ||||
| and `parent_id` = #{parentId} | |||||
| AND m.`parent_id` = #{parentId} | |||||
| </if> | </if> | ||||
| <if test=" null != name and '' != name "> | <if test=" null != name and '' != name "> | ||||
| and `name` = #{name} | |||||
| AND m.`name` = #{name} | |||||
| </if> | </if> | ||||
| <if test=" null != status "> | <if test=" null != status "> | ||||
| and `status = #{status} | |||||
| AND m.`status = #{status} | |||||
| </if> | </if> | ||||
| </sql> | </sql> | ||||
| <select id="listApiMenu" resultType="com.iformall.domain.po.sm.ApiMenu"> | <select id="listApiMenu" resultType="com.iformall.domain.po.sm.ApiMenu"> | ||||
| SELECT | SELECT | ||||
| <include refid="Base_Column_List"/> | <include refid="Base_Column_List"/> | ||||
| FROM api_menu | |||||
| FROM api_menu m | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| <select id="listParentMenu" resultType="com.iformall.domain.po.sm.ApiMenu"> | |||||
| SELECT | |||||
| <include refid="Base_Column_List"/> | |||||
| FROM | |||||
| api_menu m | |||||
| WHERE | |||||
| m.delete_flag = 0 | |||||
| AND m.parent_id = 0 | |||||
| </select> | |||||
| <select id="listApiMenuAndDetail" resultType="com.iformall.domain.vo.sm.ApiMenuVO"> | |||||
| SELECT | |||||
| m.id, | |||||
| m.create_time AS createTime, | |||||
| m.update_time AS updateTime, | |||||
| m.leaf_flag AS leafFlag, | |||||
| m.`name` AS `name`, | |||||
| m.parent_id AS parentId, | |||||
| m.`status` AS `status`, | |||||
| d.id AS detailId, | |||||
| d.charge_flag AS chargeFlag, | |||||
| d.auth_flag AS authFlag, | |||||
| d.description AS description, | |||||
| d.platform_url AS platformUrl, | |||||
| d.public_param AS publicParam, | |||||
| d.request_param AS requestParam, | |||||
| d.response_param AS responseParam, | |||||
| d.request_sample AS requestSample, | |||||
| d.response_sample AS responseSample, | |||||
| d.exception_sample AS exception_sample | |||||
| FROM | |||||
| api_menu m | |||||
| LEFT JOIN api_detail d ON m.id = d.menu_id | |||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||
| @@ -91,6 +91,6 @@ | |||||
| SELECT | SELECT | ||||
| <include refid="allColumns"/> | <include refid="allColumns"/> | ||||
| FROM wx_third_party_api | FROM wx_third_party_api | ||||
| <include refid="generalWhereConditions"></include> | |||||
| <include refid="generalWhereConditions"/> | |||||
| </select> | </select> | ||||
| </mapper> | </mapper> | ||||