add:新增临时rss订阅地址
This commit is contained in:
parent
e17095cc7e
commit
88960372f5
@ -3,14 +3,11 @@ package com.yutou.tools.bangumi;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.yutou.tools.mybatis.dao.BangumiItemDao;
|
||||
import com.yutou.tools.mybatis.dao.BangumiListDao;
|
||||
import com.yutou.tools.mybatis.model.BangumiItem;
|
||||
import com.yutou.tools.mybatis.model.BangumiItemExample;
|
||||
import com.yutou.tools.mybatis.model.BangumiList;
|
||||
import com.yutou.tools.mybatis.model.BangumiListExample;
|
||||
import com.yutou.tools.services.interfaces.BangumiService;
|
||||
import com.yutou.tools.utils.BangumiTools;
|
||||
import com.yutou.tools.utils.RedisTools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -84,7 +81,20 @@ public class AnimationController {
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/anim/rss/add.do", method = RequestMethod.POST)
|
||||
public String addAnimationRss(String bgmId, String title, String author, String categories, String titleKey, String bid) {
|
||||
public JSONObject addAnimationRss(String bgmId, String title, String author, String categories, String titleKey, String bid) {
|
||||
int i = 0;
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
if ("-1".equals(bid)) {
|
||||
BangumiItem item = new BangumiItem();
|
||||
item.setId(-1);
|
||||
item.setTitle(title);
|
||||
item.setTitlekey(title.split("\\?")[1]);
|
||||
i = bangumiService.addBangumiItem(item);
|
||||
json.put("msg", i == 0 ? "添加失败" : "添加成功");
|
||||
return json;
|
||||
}
|
||||
|
||||
int id = 0;
|
||||
if (!StringUtils.isEmpty(bgmId)) {
|
||||
try {
|
||||
@ -100,11 +110,9 @@ public class AnimationController {
|
||||
item.setTitlekey(titleKey);
|
||||
item.setBid(bid);
|
||||
item.setEnable(1);
|
||||
int i = bangumiService.addBangumiItem(item);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
i = bangumiService.addBangumiItem(item);
|
||||
json.put("msg", i == 0 ? "添加失败" : "添加成功");
|
||||
return json.toJSONString();
|
||||
return json;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ -119,12 +127,18 @@ public class AnimationController {
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/anim/rss/del.do", method = RequestMethod.POST)
|
||||
public String delAnimation(int id) {
|
||||
int i = bangumiService.removeBangumiItem(id);
|
||||
public JSONObject delAnimation(String id) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("code", 0);
|
||||
if (id.startsWith("http")) {
|
||||
boolean tmpRss = RedisTools.list_remove("anim_tmp_rss", id);
|
||||
json.put("msg", tmpRss ? "删除成功" : "删除失败");
|
||||
return json;
|
||||
}
|
||||
int i = bangumiService.removeBangumiItem(Integer.parseInt(id));
|
||||
|
||||
json.put("msg", i == 0 ? "删除失败" : "删除成功");
|
||||
return json.toJSONString();
|
||||
return json;
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
|
@ -14,7 +14,9 @@ import com.yutou.tools.utils.Tools;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service("BangumiService")
|
||||
public class BangumiServiceImpl implements BangumiService {
|
||||
@ -36,7 +38,9 @@ public class BangumiServiceImpl implements BangumiService {
|
||||
@Override
|
||||
public int addBangumiItem(BangumiItem... list) {
|
||||
for (BangumiItem item : list) {
|
||||
if (itemDao.insert(item) <= 0) {
|
||||
if (item.getId().equals(-1)) {
|
||||
RedisTools.list_add("anim_tmp_rss",item.getTitle());
|
||||
} else if (itemDao.insert(item) <= 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -68,9 +72,20 @@ public class BangumiServiceImpl implements BangumiService {
|
||||
|
||||
@Override
|
||||
public List<BangumiItem> getBangumiItemList(String type) {
|
||||
List<BangumiItem> items;
|
||||
if ("-1".equals(type)) {
|
||||
Set<String> strings = RedisTools.list_get("anim_tmp_rss");
|
||||
items=new ArrayList<>();
|
||||
for (String string : strings) {
|
||||
BangumiItem item=new BangumiItem();;
|
||||
item.setTitle(string);
|
||||
items.add(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
BangumiItemExample example = new BangumiItemExample();
|
||||
example.createCriteria().andBidEqualTo(type);
|
||||
List<BangumiItem> items = itemDao.selectByExample(example);
|
||||
items = itemDao.selectByExample(example);
|
||||
for (BangumiItem item : items) {
|
||||
if (item.getEnable() == 0 || item.getBgmid() == 0) {
|
||||
continue;
|
||||
@ -93,15 +108,23 @@ public class BangumiServiceImpl implements BangumiService {
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private String getDay(int day) {
|
||||
switch (day) {
|
||||
case 1:return "一";
|
||||
case 2:return "二";
|
||||
case 3:return "三";
|
||||
case 4:return "四";
|
||||
case 5:return "五";
|
||||
case 6:return "六";
|
||||
default:return "日";
|
||||
case 1:
|
||||
return "一";
|
||||
case 2:
|
||||
return "二";
|
||||
case 3:
|
||||
return "三";
|
||||
case 4:
|
||||
return "四";
|
||||
case 5:
|
||||
return "五";
|
||||
case 6:
|
||||
return "六";
|
||||
default:
|
||||
return "日";
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,6 +135,11 @@ public class BangumiServiceImpl implements BangumiService {
|
||||
|
||||
@Override
|
||||
public List<BangumiList> getAllBangumiList() {
|
||||
return listDao.selectByExample(new BangumiListExample());
|
||||
List<BangumiList> list = listDao.selectByExample(new BangumiListExample());
|
||||
BangumiList bangumi = new BangumiList();
|
||||
bangumi.setTitle("临时RSS");
|
||||
bangumi.setId(-1);
|
||||
list.add(bangumi);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,11 @@
|
||||
<a class="layui-btn layui-btn-xs" lay-event="show">查看</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||
</script>
|
||||
<script type="text/html" id="RsslistTools">
|
||||
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="mikan">MiKan</a>
|
||||
<a class="layui-btn layui-btn-xs" lay-event="tmp_rss_show">查看</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="tmp_rss_del">删除</a>
|
||||
</script>
|
||||
<script type="text/html" id="animState">
|
||||
{{# if(d.enable==1){}}
|
||||
<div><input type="checkbox" name="state" lay-text="启用|关闭" lay-filter="stateCheckbox" lay-skin="switch"
|
||||
@ -202,7 +207,22 @@
|
||||
window.location.href = "/"
|
||||
}
|
||||
})
|
||||
|
||||
function addTmpRss(def) {
|
||||
layer.prompt({
|
||||
formType: 0,
|
||||
value: '',
|
||||
title: '请输入RSS地址'
|
||||
}, function(value, index, elem){
|
||||
$.post('/anim/rss/add.do',{
|
||||
title: value,
|
||||
bid:-1
|
||||
},function (json) {
|
||||
console.log(json)
|
||||
layer.msg(json.msg)
|
||||
layer.close(index);
|
||||
})
|
||||
});
|
||||
}
|
||||
layui.use(['layer', 'form', 'element', 'table', 'util'], function () {
|
||||
let layer = layui.layer
|
||||
, util = layui.util
|
||||
@ -220,24 +240,34 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.get("/anim/type/list.do", function (data) {
|
||||
let json = JSON.parse(data);
|
||||
if (json.code === 0) {
|
||||
for (let index = 0; index < json.data.length; index++) {
|
||||
const ret = json.data[index];
|
||||
let ret = json.data[index];
|
||||
let content;
|
||||
if(ret.id===-1){
|
||||
content='<button type="button" class="layui-btn layui-btn-xs" onclick="addTmpRss(this)">添加临时订阅地址</button>'
|
||||
}else{
|
||||
content=''
|
||||
}
|
||||
element.tabAdd('animType', {
|
||||
title: ret.title
|
||||
, content: '<table id="passwordlist' + ret.id + '" lay-filter="adminTable"></table>'
|
||||
, content: content+'<table id="passwordlist' + ret.id + '" lay-filter="adminTable"></table>'
|
||||
, id: ret.id
|
||||
})
|
||||
}
|
||||
element.on('tab(animType)', function (data) {
|
||||
tabid = $(this).attr('lay-id')
|
||||
table.render({
|
||||
elem: "#passwordlist" + tabid
|
||||
, url: '/anim/rss/list.do?type=' + tabid
|
||||
, page: true
|
||||
, cols: [[
|
||||
let cols;
|
||||
if(tabid==='-1'){
|
||||
cols=[[
|
||||
{field: 'title', title: '地址'}
|
||||
,{field: "right", toolbar: '#RsslistTools'}
|
||||
]]
|
||||
}else{
|
||||
cols=[[
|
||||
{field: "id", title: "id", width: 60, sort: true, fixed: 'left'}
|
||||
, {field: 'bgmid', title: 'bgmId', width: 80, edit: 'text'}
|
||||
, {field: 'title', title: '标题', edit: 'text'}
|
||||
@ -248,6 +278,12 @@
|
||||
, {field: 'update', title: '更新', width: 110, templet: '#animUpdateState'}
|
||||
, {field: "right", toolbar: '#listTools'}
|
||||
]]
|
||||
}
|
||||
table.render({
|
||||
elem: "#passwordlist" + tabid
|
||||
, url: '/anim/rss/list.do?type=' + tabid
|
||||
, page: true
|
||||
, cols: cols
|
||||
});
|
||||
})
|
||||
table.on('edit(adminTable)', function (obj) {
|
||||
@ -306,8 +342,7 @@
|
||||
, content: "删除操作无法回滚,是否确认删除:" + obj.data.title
|
||||
, btn: ['确认', '取消']
|
||||
, yes: function (index) {
|
||||
$.post('/anim/rss/del.do', {id: obj.data.id}, function (data) {
|
||||
let json = JSON.parse(data);
|
||||
$.post('/anim/rss/del.do', {id: obj.data.id}, function (json) {
|
||||
layer.msg(json.msg)
|
||||
layer.close(index)
|
||||
})
|
||||
@ -321,6 +356,15 @@
|
||||
window.open("https://share.dmhy.org/topics/list?keyword=" + encodeURI(obj.data.titlekey))
|
||||
} else if (obj.event === 'bgm_src') {
|
||||
window.open("https://bgm.tv/subject/" + obj.data.bgmid)
|
||||
} else if (obj.event==='mikan'){
|
||||
console.log(getParam('bangumiId',obj.data.title))
|
||||
window.open('https://mikanani.me/Home/Bangumi/'+getParam('bangumiId',obj.data.title)+'#'+getParam('subgroupid',obj.data.title))
|
||||
} else if (obj.event==='tmp_rss_show'){
|
||||
window.open(obj.data.title)
|
||||
} else if (obj.event==='tmp_rss_del'){
|
||||
$.post('/anim/rss/del.do', {id: obj.data.title}, function (json) {
|
||||
layer.msg(json.msg)
|
||||
})
|
||||
}
|
||||
})
|
||||
table.on('tool(rssTools)', function (obj) {
|
||||
@ -354,8 +398,7 @@
|
||||
, categories: data.categories[0]
|
||||
, titleKey: $('#title').val()
|
||||
, bid: tabid
|
||||
}, function (data) {
|
||||
let json = JSON.parse(data);
|
||||
}, function (json) {
|
||||
layer.msg(json.msg)
|
||||
layer.close(index)
|
||||
})
|
||||
@ -456,7 +499,6 @@
|
||||
|
||||
function setTitle(_this) {
|
||||
let url = "https://bgm.tv/subject_search/" + encodeURIComponent(_this.value) + "?cat=2"
|
||||
console.log(url)
|
||||
$('#bgmUrl')[0].href = url;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,10 @@ function Base64() {
|
||||
}
|
||||
}
|
||||
function getParam(name){
|
||||
let results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
||||
return getParam(name,window.location.href)
|
||||
}
|
||||
function getParam(name,url){
|
||||
let results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url);
|
||||
if (results == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user