mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	增加 OAuth2 客户端
This commit is contained in:
		@@ -0,0 +1,74 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.auth;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.convert.auth.OAuth2ClientConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.auth.OAuth2ClientDO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.service.auth.OAuth2ClientService;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiImplicitParam;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
 | 
			
		||||
@Api(tags = "管理后台 - OAuth2 客户端")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/system/oauth2-client")
 | 
			
		||||
@Validated
 | 
			
		||||
public class OAuth2ClientController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private OAuth2ClientService oAuth2ClientService;
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/create")
 | 
			
		||||
    @ApiOperation("创建 OAuth2 客户端")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:oauth2-client:create')")
 | 
			
		||||
    public CommonResult<Long> createOAuth2Client(@Valid @RequestBody OAuth2ClientCreateReqVO createReqVO) {
 | 
			
		||||
        return success(oAuth2ClientService.createOAuth2Client(createReqVO));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PutMapping("/update")
 | 
			
		||||
    @ApiOperation("更新 OAuth2 客户端")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:oauth2-client:update')")
 | 
			
		||||
    public CommonResult<Boolean> updateOAuth2Client(@Valid @RequestBody OAuth2ClientUpdateReqVO updateReqVO) {
 | 
			
		||||
        oAuth2ClientService.updateOAuth2Client(updateReqVO);
 | 
			
		||||
        return success(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @DeleteMapping("/delete")
 | 
			
		||||
    @ApiOperation("删除 OAuth2 客户端")
 | 
			
		||||
    @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:oauth2-client:delete')")
 | 
			
		||||
    public CommonResult<Boolean> deleteOAuth2Client(@RequestParam("id") Long id) {
 | 
			
		||||
        oAuth2ClientService.deleteOAuth2Client(id);
 | 
			
		||||
        return success(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/get")
 | 
			
		||||
    @ApiOperation("获得 OAuth2 客户端")
 | 
			
		||||
    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:oauth2-client:query')")
 | 
			
		||||
    public CommonResult<OAuth2ClientRespVO> getOAuth2Client(@RequestParam("id") Long id) {
 | 
			
		||||
        OAuth2ClientDO oAuth2Client = oAuth2ClientService.getOAuth2Client(id);
 | 
			
		||||
        return success(OAuth2ClientConvert.INSTANCE.convert(oAuth2Client));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/page")
 | 
			
		||||
    @ApiOperation("获得OAuth2 客户端分页")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:oauth2-client:query')")
 | 
			
		||||
    public CommonResult<PageResult<OAuth2ClientRespVO>> getOAuth2ClientPage(@Valid OAuth2ClientPageReqVO pageVO) {
 | 
			
		||||
        PageResult<OAuth2ClientDO> pageResult = oAuth2ClientService.getOAuth2ClientPage(pageVO);
 | 
			
		||||
        return success(OAuth2ClientConvert.INSTANCE.convertPage(pageResult));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,51 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.client;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* OAuth2 客户端 Base VO,提供给添加、修改、详细的子 VO 使用
 | 
			
		||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
 | 
			
		||||
*/
 | 
			
		||||
@Data
 | 
			
		||||
public class OAuth2ClientBaseVO {
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "客户端编号", required = true)
 | 
			
		||||
    @NotNull(message = "客户端编号不能为空")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "客户端密钥", required = true)
 | 
			
		||||
    @NotNull(message = "客户端密钥不能为空")
 | 
			
		||||
    private String secret;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "应用名", required = true)
 | 
			
		||||
    @NotNull(message = "应用名不能为空")
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "应用图标", required = true)
 | 
			
		||||
    @NotNull(message = "应用图标不能为空")
 | 
			
		||||
    private String logo;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "应用描述")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "状态", required = true)
 | 
			
		||||
    @NotNull(message = "状态不能为空")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "访问令牌的有效期", required = true)
 | 
			
		||||
    @NotNull(message = "访问令牌的有效期不能为空")
 | 
			
		||||
    private Integer accessTokenValiditySeconds;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "刷新令牌的有效期", required = true)
 | 
			
		||||
    @NotNull(message = "刷新令牌的有效期不能为空")
 | 
			
		||||
    private Integer refreshTokenValiditySeconds;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "可重定向的 URI 地址", required = true)
 | 
			
		||||
    @NotNull(message = "可重定向的 URI 地址不能为空")
 | 
			
		||||
    private List<String> redirectUris;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.client;
 | 
			
		||||
 | 
			
		||||
import lombok.*;
 | 
			
		||||
import io.swagger.annotations.*;
 | 
			
		||||
 | 
			
		||||
@ApiModel("管理后台 - OAuth2 客户端创建 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ToString(callSuper = true)
 | 
			
		||||
public class OAuth2ClientCreateReqVO extends OAuth2ClientBaseVO {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.client;
 | 
			
		||||
 | 
			
		||||
import lombok.*;
 | 
			
		||||
import io.swagger.annotations.*;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
 | 
			
		||||
 | 
			
		||||
@ApiModel("管理后台 - OAuth2 客户端分页 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ToString(callSuper = true)
 | 
			
		||||
public class OAuth2ClientPageReqVO extends PageParam {
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "应用名")
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "状态")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.client;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import io.swagger.annotations.ApiModelProperty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import lombok.ToString;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
@ApiModel("管理后台 - OAuth2 客户端 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ToString(callSuper = true)
 | 
			
		||||
public class OAuth2ClientRespVO extends OAuth2ClientBaseVO {
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "创建时间", required = true)
 | 
			
		||||
    private Date createTime;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,14 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.auth.vo.client;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiModel;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import lombok.ToString;
 | 
			
		||||
 | 
			
		||||
@ApiModel("管理后台 - OAuth2 客户端更新 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ToString(callSuper = true)
 | 
			
		||||
public class OAuth2ClientUpdateReqVO extends OAuth2ClientBaseVO {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,33 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.convert.auth;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.auth.OAuth2ClientDO;
 | 
			
		||||
import org.mapstruct.Mapper;
 | 
			
		||||
import org.mapstruct.factory.Mappers;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * OAuth2 客户端 Convert
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface OAuth2ClientConvert {
 | 
			
		||||
 | 
			
		||||
    OAuth2ClientConvert INSTANCE = Mappers.getMapper(OAuth2ClientConvert.class);
 | 
			
		||||
 | 
			
		||||
    OAuth2ClientDO convert(OAuth2ClientCreateReqVO bean);
 | 
			
		||||
 | 
			
		||||
    OAuth2ClientDO convert(OAuth2ClientUpdateReqVO bean);
 | 
			
		||||
 | 
			
		||||
    OAuth2ClientRespVO convert(OAuth2ClientDO bean);
 | 
			
		||||
 | 
			
		||||
    List<OAuth2ClientRespVO> convertList(List<OAuth2ClientDO> list);
 | 
			
		||||
 | 
			
		||||
    PageResult<OAuth2ClientRespVO> convertPage(PageResult<OAuth2ClientDO> page);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.system.dal.dataobject.auth;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.IdType;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableField;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableId;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableName;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import lombok.experimental.Accessors;
 | 
			
		||||
@@ -18,7 +21,7 @@ import java.util.List;
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@TableName("system_oauth2_application")
 | 
			
		||||
@TableName(value = "system_oauth2_client", autoResultMap = true)
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@@ -29,7 +32,7 @@ public class OAuth2ClientDO extends BaseDO {
 | 
			
		||||
     *
 | 
			
		||||
     * 由于 SQL Server 在存储 String 主键有点问题,所以暂时使用 Long 类型
 | 
			
		||||
     */
 | 
			
		||||
    @TableId
 | 
			
		||||
    @TableId(type = IdType.INPUT)
 | 
			
		||||
    private Long id;
 | 
			
		||||
    /**
 | 
			
		||||
     * 客户端密钥
 | 
			
		||||
@@ -64,6 +67,7 @@ public class OAuth2ClientDO extends BaseDO {
 | 
			
		||||
    /**
 | 
			
		||||
     * 可重定向的 URI 地址
 | 
			
		||||
     */
 | 
			
		||||
    @TableField(typeHandler = JacksonTypeHandler.class)
 | 
			
		||||
    private List<String> redirectUris;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,25 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.dal.mysql.auth;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.auth.OAuth2ClientDO;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * OAuth2 客户端 Mapper
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface OAuth2ClientMapper extends BaseMapperX<OAuth2ClientDO> {
 | 
			
		||||
 | 
			
		||||
    default PageResult<OAuth2ClientDO> selectPage(OAuth2ClientPageReqVO reqVO) {
 | 
			
		||||
        return selectPage(reqVO, new LambdaQueryWrapperX<OAuth2ClientDO>()
 | 
			
		||||
                .likeIfPresent(OAuth2ClientDO::getName, reqVO.getName())
 | 
			
		||||
                .eqIfPresent(OAuth2ClientDO::getStatus, reqVO.getStatus())
 | 
			
		||||
                .orderByDesc(OAuth2ClientDO::getId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,13 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.service.auth;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.auth.OAuth2ClientDO;
 | 
			
		||||
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * OAuth2.0 Client Service 接口
 | 
			
		||||
 *
 | 
			
		||||
@@ -11,6 +17,44 @@ import cn.iocoder.yudao.module.system.dal.dataobject.auth.OAuth2ClientDO;
 | 
			
		||||
 */
 | 
			
		||||
public interface OAuth2ClientService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 创建OAuth2 客户端
 | 
			
		||||
     *
 | 
			
		||||
     * @param createReqVO 创建信息
 | 
			
		||||
     * @return 编号
 | 
			
		||||
     */
 | 
			
		||||
    Long createOAuth2Client(@Valid OAuth2ClientCreateReqVO createReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新OAuth2 客户端
 | 
			
		||||
     *
 | 
			
		||||
     * @param updateReqVO 更新信息
 | 
			
		||||
     */
 | 
			
		||||
    void updateOAuth2Client(@Valid OAuth2ClientUpdateReqVO updateReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除OAuth2 客户端
 | 
			
		||||
     *
 | 
			
		||||
     * @param id 编号
 | 
			
		||||
     */
 | 
			
		||||
    void deleteOAuth2Client(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得OAuth2 客户端
 | 
			
		||||
     *
 | 
			
		||||
     * @param id 编号
 | 
			
		||||
     * @return OAuth2 客户端
 | 
			
		||||
     */
 | 
			
		||||
    OAuth2ClientDO getOAuth2Client(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得OAuth2 客户端分页
 | 
			
		||||
     *
 | 
			
		||||
     * @param pageReqVO 分页查询
 | 
			
		||||
     * @return OAuth2 客户端分页
 | 
			
		||||
     */
 | 
			
		||||
    PageResult<OAuth2ClientDO> getOAuth2ClientPage(OAuth2ClientPageReqVO pageReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 从缓存中,校验客户端是否合法
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,19 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.service.auth;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.client.OAuth2ClientUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.convert.auth.OAuth2ClientConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.auth.OAuth2ClientDO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.mysql.auth.OAuth2ClientMapper;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
			
		||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.OAUTH2_CLIENT_NOT_EXISTS;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * OAuth2.0 Client Service 实现类
 | 
			
		||||
 *
 | 
			
		||||
@@ -11,6 +22,51 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
@Service
 | 
			
		||||
public class OAuth2ClientServiceImpl implements OAuth2ClientService {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private OAuth2ClientMapper oauth2ClientMapper;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Long createOAuth2Client(OAuth2ClientCreateReqVO createReqVO) {
 | 
			
		||||
        // 插入
 | 
			
		||||
        OAuth2ClientDO oAuth2Client = OAuth2ClientConvert.INSTANCE.convert(createReqVO);
 | 
			
		||||
        oauth2ClientMapper.insert(oAuth2Client);
 | 
			
		||||
        // 返回
 | 
			
		||||
        return oAuth2Client.getId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void updateOAuth2Client(OAuth2ClientUpdateReqVO updateReqVO) {
 | 
			
		||||
        // 校验存在
 | 
			
		||||
        this.validateOAuth2ClientExists(updateReqVO.getId());
 | 
			
		||||
        // 更新
 | 
			
		||||
        OAuth2ClientDO updateObj = OAuth2ClientConvert.INSTANCE.convert(updateReqVO);
 | 
			
		||||
        oauth2ClientMapper.updateById(updateObj);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void deleteOAuth2Client(Long id) {
 | 
			
		||||
        // 校验存在
 | 
			
		||||
        this.validateOAuth2ClientExists(id);
 | 
			
		||||
        // 删除
 | 
			
		||||
        oauth2ClientMapper.deleteById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void validateOAuth2ClientExists(Long id) {
 | 
			
		||||
        if (oauth2ClientMapper.selectById(id) == null) {
 | 
			
		||||
            throw exception(OAUTH2_CLIENT_NOT_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public OAuth2ClientDO getOAuth2Client(Long id) {
 | 
			
		||||
        return oauth2ClientMapper.selectById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public PageResult<OAuth2ClientDO> getOAuth2ClientPage(OAuth2ClientPageReqVO pageReqVO) {
 | 
			
		||||
        return oauth2ClientMapper.selectPage(pageReqVO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public OAuth2ClientDO validOAuthClientFromCache(Long id) {
 | 
			
		||||
        return new OAuth2ClientDO().setId(id)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user