[add]支持其他平台通过ApiKey调用系统相关接口
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.UserApiKey;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface UserApiKeyMapper {
|
||||
|
||||
@SelectKey(statement = "SELECT LAST_INSERT_ID() AS id", keyProperty = "id", before = false, resultType = Integer.class)
|
||||
@Insert("INSERT INTO wvp_user_api_key (user_id, app, api_key, expired_at, remark, enable, create_time, update_time) VALUES" +
|
||||
"(#{userId}, #{app}, #{apiKey}, #{expiredAt}, #{remark}, #{enable}, #{createTime}, #{updateTime})")
|
||||
int add(UserApiKey userApiKey);
|
||||
|
||||
@Update(value = {"<script>" +
|
||||
"UPDATE wvp_user_api_key " +
|
||||
"SET update_time = #{updateTime} " +
|
||||
"<if test=\"app != null\">, app = #{app}</if>" +
|
||||
"<if test=\"apiKey != null\">, api_key = #{apiKey}</if>" +
|
||||
"<if test=\"expiredAt != null\">, expired_at = #{expiredAt}</if>" +
|
||||
"<if test=\"remark != null\">, username = #{remark}</if>" +
|
||||
"<if test=\"enable != null\">, enable = #{enable}</if>" +
|
||||
"WHERE id = #{id}" +
|
||||
" </script>"})
|
||||
int update(UserApiKey userApiKey);
|
||||
|
||||
@Update("UPDATE wvp_user_api_key SET enable = true WHERE id = #{id}")
|
||||
int enable(@Param("id") int id);
|
||||
|
||||
@Update("UPDATE wvp_user_api_key SET enable = false WHERE id = #{id}")
|
||||
int disable(@Param("id") int id);
|
||||
|
||||
@Update("UPDATE wvp_user_api_key SET api_key = #{apiKey} WHERE id = #{id}")
|
||||
int apiKey(@Param("id") int id, @Param("apiKey") String apiKey);
|
||||
|
||||
@Update("UPDATE wvp_user_api_key SET remark = #{remark} WHERE id = #{id}")
|
||||
int remark(@Param("id") int id, @Param("remark") String remark);
|
||||
|
||||
@Delete("DELETE FROM wvp_user_api_key WHERE id = #{id}")
|
||||
int delete(@Param("id") int id);
|
||||
|
||||
@Select("SELECT uak.id, uak.user_id, uak.app, uak.api_key, uak.expired_at, uak.remark, uak.enable, uak.create_time, uak.update_time, u.username AS username FROM wvp_user_api_key uak LEFT JOIN wvp_user u on u.id = uak.user_id WHERE uak.id = #{id}")
|
||||
UserApiKey selectById(@Param("id") int id);
|
||||
|
||||
@Select("SELECT uak.id, uak.user_id, uak.app, uak.api_key, uak.expired_at, uak.remark, uak.enable, uak.create_time, uak.update_time, u.username AS username FROM wvp_user_api_key uak LEFT JOIN wvp_user u on u.id = uak.user_id WHERE uak.api_key = #{apiKey}")
|
||||
UserApiKey selectByApiKey(@Param("apiKey") String apiKey);
|
||||
|
||||
@Select("SELECT uak.id, uak.user_id, uak.app, uak.api_key, uak.expired_at, uak.remark, uak.enable, uak.create_time, uak.update_time, u.username AS username FROM wvp_user_api_key uak LEFT JOIN wvp_user u on u.id = uak.user_id")
|
||||
List<UserApiKey> selectAll();
|
||||
|
||||
@Select("SELECT uak.id, uak.user_id, uak.app, uak.api_key, uak.expired_at, uak.remark, uak.enable, uak.create_time, uak.update_time, u.username AS username FROM wvp_user_api_key uak LEFT JOIN wvp_user u on u.id = uak.user_id")
|
||||
List<UserApiKey> getUserApiKeys();
|
||||
|
||||
@Select("SELECT COUNT(0) FROM wvp_user_api_key WHERE api_key = #{apiKey}")
|
||||
boolean isApiKeyExists(@Param("apiKey") String apiKey);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.genersoft.iot.vmp.storager.dao.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
@Schema(description = "用户ApiKey信息")
|
||||
public class UserApiKey implements Serializable {
|
||||
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
@Schema(description = "Id")
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 用户Id
|
||||
*/
|
||||
@Schema(description = "用户Id")
|
||||
private int userId;
|
||||
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
@Schema(description = "应用名")
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* ApiKey
|
||||
*/
|
||||
@Schema(description = "ApiKey")
|
||||
private String apiKey;
|
||||
|
||||
/**
|
||||
* 过期时间(null=永不过期)
|
||||
*/
|
||||
@Schema(description = "过期时间(null=永不过期)")
|
||||
private String expiredAt;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
@Schema(description = "备注信息")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用")
|
||||
private boolean enable;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public void setApp(String app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getExpiredAt() {
|
||||
return expiredAt;
|
||||
}
|
||||
|
||||
public void setExpiredAt(String expiredAt) {
|
||||
this.expiredAt = expiredAt;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public void setEnable(boolean enable) {
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(String updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user