zuhu管理完善
This commit is contained in:
@@ -91,6 +91,7 @@ public class TenantController {
|
||||
public ResponseEntity<Map<String, Object>> addTenant(
|
||||
@Parameter(description = "租户信息", required = true)
|
||||
@RequestBody Tenant tenant) {
|
||||
tenant.setTenantCode("TENANT_ID_"+tenant.getTenantCode());
|
||||
tenant.setId(tenant.getTenantCode());
|
||||
Map<String, Object> result = tenantService.addTenant(tenant);
|
||||
Boolean success = (Boolean) result.get("success");
|
||||
|
||||
@@ -72,9 +72,14 @@ public class User implements Serializable {
|
||||
private String scenarioItem;
|
||||
|
||||
@Schema(description = "主角色")
|
||||
@TableField("role")
|
||||
@TableField("role_name")
|
||||
private String role;
|
||||
|
||||
@Schema(description = "主角色")
|
||||
@TableField("role_name")
|
||||
private String roleName;
|
||||
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@@ -168,8 +168,7 @@ public class TenantServiceImpl extends ServiceImpl<TenantMapper, Tenant> impleme
|
||||
}
|
||||
|
||||
// 生成UUID作为主键
|
||||
tenant.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
tenant.setCreateTime(LocalDateTime.now());
|
||||
tenant.setId(tenant.getTenantCode());
|
||||
tenant.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
// 设置默认状态为启用
|
||||
|
||||
@@ -56,7 +56,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
loginResponse.setToken(token);
|
||||
loginResponse.setLoginTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
loginResponse.setTenantId(user.getTenantId());
|
||||
loginResponse.setRoleName(user.getRole());
|
||||
loginResponse.setRoleName(user.getRoleName());
|
||||
loginResponse.setScenario(user.getScenario());
|
||||
|
||||
return loginResponse;
|
||||
|
||||
@@ -1,4 +1,97 @@
|
||||
package com.cst.douyi;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短视频平台 热门视频获取(合规公开接口版)
|
||||
* 支持:抖音开放平台/快手公开榜单/小红书公开热门等
|
||||
*
|
||||
* 申请平台开放平台权限
|
||||
* 抖音开放平台:https://open.douyin.com/
|
||||
* 快手开放平台:https://open.kuaishou.com/
|
||||
* 小红书开放平台:https://open.xiaohongshu.com/
|
||||
*开发控制台: https://developer.open-douyin.com/console?type=1
|
||||
*
|
||||
*/
|
||||
public class VideoHotUtil01 {
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
// ==================== 抖音公开热门视频(示例,替换为你自己的开放平台接口)====================
|
||||
// 注意:必须使用抖音开放平台申请的接口,不能用抓包的私有接口!
|
||||
private static final String DOUYIN_HOT_API =
|
||||
"https://open.douyin.com/api/douyin/v1/video/list?access_token=YOUR_TOKEN";
|
||||
|
||||
/**
|
||||
* 获取抖音热门视频(需要开放平台权限)
|
||||
*/
|
||||
public static List<HotVideo> getDouyinHotVideos() {
|
||||
List<HotVideo> list = new ArrayList<>();
|
||||
try {
|
||||
Request request = new Request.Builder()
|
||||
.url(DOUYIN_HOT_API)
|
||||
.addHeader("User-Agent", "Mozilla/5.0")
|
||||
.get()
|
||||
.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) return list;
|
||||
|
||||
JsonNode root = mapper.readTree(response.body().string());
|
||||
JsonNode videos = root.path("data").path("list");
|
||||
|
||||
// 解析视频
|
||||
for (JsonNode node : videos) {
|
||||
HotVideo video = new HotVideo();
|
||||
video.setTitle(node.path("title").asText());
|
||||
video.setPlayUrl(node.path("play_addr").path("url_list").get(0).asText());
|
||||
video.setCoverUrl(node.path("cover").path("url_list").get(0).asText());
|
||||
video.setLikeCount(node.path("like_count").asLong());
|
||||
video.setCreateTime(node.path("create_time").asLong());
|
||||
list.add(video);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// 视频实体类
|
||||
public static class HotVideo {
|
||||
private String title; // 标题
|
||||
private String playUrl; // 播放地址
|
||||
private String coverUrl; // 封面
|
||||
private long likeCount; // 点赞数
|
||||
private long createTime; // 发布时间
|
||||
|
||||
// getter + setter
|
||||
public String getTitle() {return title;}
|
||||
public void setTitle(String title) {this.title = title;}
|
||||
public String getPlayUrl() {return playUrl;}
|
||||
public void setPlayUrl(String playUrl) {this.playUrl = playUrl;}
|
||||
public String getCoverUrl() {return coverUrl;}
|
||||
public void setCoverUrl(String coverUrl) {this.coverUrl = coverUrl;}
|
||||
public long getLikeCount() {return likeCount;}
|
||||
public void setLikeCount(long likeCount) {this.likeCount = likeCount;}
|
||||
public long getCreateTime() {return createTime;}
|
||||
public void setCreateTime(long createTime) {this.createTime = createTime;}
|
||||
}
|
||||
|
||||
// 测试
|
||||
public static void main(String[] args) {
|
||||
List<HotVideo> videos = getDouyinHotVideos();
|
||||
for (HotVideo v : videos) {
|
||||
System.out.println("标题:" + v.getTitle());
|
||||
System.out.println("点赞:" + v.getLikeCount());
|
||||
System.out.println("播放地址:" + v.getPlayUrl());
|
||||
System.out.println("----------------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user