update:动画rss界面新增【番剧计划】入口,以及是否今日更新提示

This commit is contained in:
Yutousama 2022-07-10 17:02:48 +08:00
parent fe7f7997a8
commit 6b8932c86f
11 changed files with 638 additions and 43 deletions

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ToolsApplication {
public static final String version="1.4.5";
public static final String version="1.4.6";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);

View File

@ -9,6 +9,7 @@ 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 org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@ -17,13 +18,12 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
@Controller
public class AnimationController {
@Resource
BangumiListDao listDao;
@Resource
BangumiItemDao itemDao;
BangumiService bangumiService;
@ResponseBody
@RequestMapping(value = "/anim/rss/data.do", method = RequestMethod.GET)
@ -41,11 +41,7 @@ public class AnimationController {
items = new AnimationData().bangumiList(page,type,team, keys);
}
JSONObject json = new JSONObject();
if (items != null) {
json.put("data", items);
} else {
json.put("data", new JSONArray());
}
json.put("data", Objects.requireNonNullElseGet(items, JSONArray::new));
json.put("count", 999);
json.put("code", 0);
json.put("msg", "ok");
@ -58,7 +54,7 @@ public class AnimationController {
BangumiList bangumiList = new BangumiList();
bangumiList.setTitle(title);
bangumiList.setStatus(1);
int i = listDao.insert(bangumiList);
int i = bangumiService.addBangumiList(bangumiList);
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
@ -71,16 +67,13 @@ public class AnimationController {
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", "ok");
json.put("data", JSON.toJSON(listDao.selectByExample(new BangumiListExample())));
json.put("data", JSON.toJSON(bangumiService.getAllBangumiList()));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/type/del.do", method = RequestMethod.POST)
public String delType(int id){
BangumiItemExample example=new BangumiItemExample();
example.createCriteria().andBidEqualTo(id+"");
itemDao.deleteByExample(example);
int i=listDao.deleteByPrimaryKey(id);
int i=bangumiService.removeBangumiType(id);
JSONObject json=new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "删除失败" : "删除成功");
@ -89,15 +82,22 @@ public class AnimationController {
@ResponseBody
@RequestMapping(value = "/anim/rss/add.do", method = RequestMethod.POST)
public String addAnimationRss(String title, String author, String categories, String titleKey, String bid) {
public String addAnimationRss(String bgmId,String title, String author, String categories, String titleKey, String bid) {
int id=0;
if(!StringUtils.isEmpty(bgmId)){
try {
id=Integer.parseInt(bgmId.trim());
}catch (Exception ignored){}
}
BangumiItem item = new BangumiItem();
item.setBgmid(id);
item.setTitle(title);
item.setAuthor(author);
item.setCategories(categories);
item.setTitlekey(titleKey);
item.setBid(bid);
item.setEnable(1);
int i = itemDao.insert(item);
int i = bangumiService.addBangumiItem(item);
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
@ -108,17 +108,15 @@ public class AnimationController {
@RequestMapping(value = "/anim/rss/list.do", method = RequestMethod.GET)
public String getAnimationRssList(String type) {
JSONObject json = new JSONObject();
BangumiItemExample example=new BangumiItemExample();
example.createCriteria().andBidEqualTo(type);
json.put("code", 0);
json.put("msg", "ok");
json.put("data", JSON.toJSON(itemDao.selectByExample(example)));
json.put("data", JSON.toJSON(bangumiService.getBangumiItemList(type)));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/rss/del.do", method = RequestMethod.POST)
public String delAnimation(int id){
int i=itemDao.deleteByPrimaryKey(id);
int i=bangumiService.removeBangumiItem(id);
JSONObject json=new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "删除失败" : "删除成功");
@ -126,9 +124,12 @@ public class AnimationController {
}
@ResponseBody
@RequestMapping(value = "/anim/rss/edit.do",method = RequestMethod.POST)
public JSONObject editAnimation(int id,String title, String author, String categories, String titleKey,String enable){
public JSONObject editAnimation(int id,int bgmId,String title, String author, String categories, String titleKey,String enable){
JSONObject json=new JSONObject();
BangumiItem item =itemDao.selectByPrimaryKey(id);
BangumiItem item =bangumiService.getBangumiItem(id);
if(bgmId!=0){
item.setBgmid(bgmId);
}
if(!StringUtils.isEmpty(title)){
item.setTitle(title);
}
@ -144,7 +145,7 @@ public class AnimationController {
if(!StringUtils.isEmpty(enable)){
item.setEnable(Integer.parseInt(enable));
}
int i=itemDao.updateByPrimaryKey(item);
int i=bangumiService.updateBangumiItem(item);
if(i>0){
json.put("msg","操作成功");
}else{
@ -157,7 +158,7 @@ public class AnimationController {
@RequestMapping(value = "/anim/client/get.do", method = RequestMethod.GET)
public String clientApi(){
AnimationData animationData=new AnimationData();
List<BangumiItem> list=itemDao.selectByExample(new BangumiItemExample());
List<BangumiItem> list=bangumiService.getAllBangumiItemList();
for (BangumiItem item : list) {
item.setCategories(animationData.nameToValue(item.getCategories(),false)+"");
item.setAuthor(animationData.nameToValue(item.getAuthor(),true)+"");

View File

@ -11,6 +11,8 @@ import lombok.Data;
public class BangumiItem implements Serializable {
private Integer id;
private Integer bgmid;
private String bid;
private String categories;
@ -19,6 +21,8 @@ public class BangumiItem implements Serializable {
private String title;
private boolean isUpdate=false;
/**
* 标题过滤词
*/

View File

@ -164,6 +164,66 @@ public class BangumiItemExample {
return (Criteria) this;
}
public Criteria andBgmidIsNull() {
addCriterion("bgmId is null");
return (Criteria) this;
}
public Criteria andBgmidIsNotNull() {
addCriterion("bgmId is not null");
return (Criteria) this;
}
public Criteria andBgmidEqualTo(Integer value) {
addCriterion("bgmId =", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidNotEqualTo(Integer value) {
addCriterion("bgmId <>", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidGreaterThan(Integer value) {
addCriterion("bgmId >", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidGreaterThanOrEqualTo(Integer value) {
addCriterion("bgmId >=", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidLessThan(Integer value) {
addCriterion("bgmId <", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidLessThanOrEqualTo(Integer value) {
addCriterion("bgmId <=", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidIn(List<Integer> values) {
addCriterion("bgmId in", values, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidNotIn(List<Integer> values) {
addCriterion("bgmId not in", values, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidBetween(Integer value1, Integer value2) {
addCriterion("bgmId between", value1, value2, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidNotBetween(Integer value1, Integer value2) {
addCriterion("bgmId not between", value1, value2, "bgmid");
return (Criteria) this;
}
public Criteria andBidIsNull() {
addCriterion("bid is null");
return (Criteria) this;

View File

@ -0,0 +1,98 @@
package com.yutou.tools.services;
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.Tools;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service("BangumiService")
public class BangumiServiceImpl implements BangumiService {
@Resource
BangumiListDao listDao;
@Resource
BangumiItemDao itemDao;
@Override
public int addBangumiList(BangumiList... list) {
for (BangumiList bangumiList : list) {
if (listDao.insert(bangumiList) <= 0) {
return 0;
}
}
return 1;
}
@Override
public int addBangumiItem(BangumiItem... list) {
for (BangumiItem item : list) {
if (itemDao.insert(item) <= 0) {
return 0;
}
}
return 1;
}
@Override
public int updateBangumiItem(BangumiItem item) {
return itemDao.updateByPrimaryKey(item);
}
@Override
public int removeBangumiItem(int id) {
return itemDao.deleteByPrimaryKey(id);
}
@Override
public int removeBangumiType(int id) {
BangumiItemExample example = new BangumiItemExample();
example.createCriteria().andBidEqualTo(id + "");
itemDao.deleteByExample(example);
return listDao.deleteByPrimaryKey(id);
}
@Override
public BangumiItem getBangumiItem(int id) {
return itemDao.selectByPrimaryKey(id);
}
@Override
public List<BangumiItem> getBangumiItemList(String type) {
BangumiItemExample example = new BangumiItemExample();
example.createCriteria().andBidEqualTo(type);
List<BangumiItem> items = itemDao.selectByExample(example);
for (BangumiItem item : items) {
if(item.getEnable()==0){
continue;
}
JSONObject bangumi=BangumiTools.getBangumiInfoSmall(item.getBgmid());
int day=Tools.getWeekDay();
if (day == 0) {
day = 7;
}
if(bangumi.getInteger("air_weekday")==day) {
item.setUpdate(true);
}
}
return items;
}
@Override
public List<BangumiItem> getAllBangumiItemList() {
return itemDao.selectByExample(new BangumiItemExample());
}
@Override
public List<BangumiList> getAllBangumiList() {
return listDao.selectByExample(new BangumiListExample());
}
}

View File

@ -0,0 +1,20 @@
package com.yutou.tools.services.interfaces;
import com.yutou.tools.mybatis.model.BangumiItem;
import com.yutou.tools.mybatis.model.BangumiList;
import org.springframework.stereotype.Service;
import java.util.List;
public interface BangumiService {
int addBangumiList(BangumiList... list);
int addBangumiItem(BangumiItem... list);
int updateBangumiItem(BangumiItem item);
int removeBangumiItem(int id);
int removeBangumiType(int id);
BangumiItem getBangumiItem(int id);
List<BangumiItem> getBangumiItemList(String type);
List<BangumiItem> getAllBangumiItemList();
List<BangumiList> getAllBangumiList();
}

View File

@ -0,0 +1,359 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.utils.StringUtils;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class BangumiTools {
private static final String url = "https://api.bgm.tv/";
private static final String toDayBangumi = url + "calendar";
private static final String BangumiInfo = url + "subject/%s?responseGroup=large";
private static final String BangumiInfoSmall = url + "subject/%s?responseGroup=small";
private static final String SearchBangumi = url + "search/subject/%s?responseGroup=large&type=2";
/**
* 获取番剧列表
*
* @param day 周几-1为全部,非1~7范围则为当天
* @return 当日数据
*/
public static JSONObject getBangumi(int day) {
String str = HttpTools.get(toDayBangumi);
JSONArray main = JSON.parseArray(str);
if (day == -1) {
JSONObject json = new JSONObject();
json.put("bangumi", main);
return json;
}
if (day < 1 || day > 7) {
day=Tools.getWeekDay();
if (day == 0) {
day = 7;
}
}
if (main != null) {
for (Object o : main) {
JSONObject json = (JSONObject) o;
if (json.getJSONObject("weekday").getInteger("id") == day) {
return json;
}
}
}
return null;
}
/**
* 获取番剧详细信息
*
* @param id 剧集id
* @return 详细信息
*/
public static JSONObject getBangumiInfo(int id) {
String str = HttpTools.get(String.format(BangumiInfo, id + ""));
return JSON.parseObject(str);
}
/**
* 获取番剧简略信息
*
* @param id 剧集id
* @return 详细信息
*/
public static JSONObject getBangumiInfoSmall(int id) {
String str = HttpTools.get(String.format(BangumiInfoSmall, id + ""));
return JSON.parseObject(str);
}
public static JSONArray getPeople(int id) {
/**
* Actor 演员
* Composer 作曲家
* Director 导演
* GuestStar 特邀明星
* Producer 制片人
* Writer 编剧
*/
JSONArray people = new JSONArray();
JSONObject bangumi = getBangumiInfo(id);
JSONArray crt = bangumi.getJSONArray("crt");
if(crt!=null) {
for (Object o : crt) {
JSONObject item = (JSONObject) o;
JSONObject pel = new JSONObject();
pel.put("Name", item.getString("name_cn"));
pel.put("Role", item.getString("role_name"));
pel.put("Type", "Actor");
people.add(pel);
}
}
crt = bangumi.getJSONArray("staff");
if(crt!=null) {
for (Object o : crt) {
JSONObject item = (JSONObject) o;
JSONObject pel = new JSONObject();
pel.put("Name", item.getString("name_cn"));
String jobsName="";
for (Object _jobs : item.getJSONArray("jobs")) {
jobsName+=_jobs+"";
}
jobsName=jobsName.substring(0,jobsName.length()-1);
pel.put("Role", jobsName);
pel.put("Type", "");
if (jobsName.contains("导演")) {
pel.put("Type", "Director");
} else if (jobsName.contains("脚本")) {
pel.put("Type", "DirectorDirector");
}
people.add(pel);
}
}
return people;
}
/**
* 搜索番剧
*
* @param key 关键词
* @return 详细信息
*/
public static JSONObject search(String key) {
String str = HttpTools.get(String.format(SearchBangumi, URLEncoder.encode(key, StandardCharsets.UTF_8)));
return JSON.parseObject(str);
}
/**
* 获取下一集播放日期
*
* @param id 番剧id
* @return 日期
*/
public static String getPlayNextTime(int id) {
JSONObject info = getBangumiInfo(id);
JSONArray eps = info.getJSONArray("eps");
String toDayTime = Tools.getToDayTime();
for (Object o : eps) {
JSONObject ep = (JSONObject) o;
String time = ep.getString("airdate");
try {
if (new SimpleDateFormat("yyyy-MM-dd").parse(time).getTime() >=
new SimpleDateFormat("yyyy-MM-dd").parse(toDayTime).getTime()) {
return time;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
}
/**
* 格式化字符串输出番剧详细信息
*
* @param id 番剧id
* @return 详细内容
*/
public static List<String> reportBangumiInfo(int id) {
List<String> bangumiList = new ArrayList<>();
JSONObject json = getBangumiInfo(id);
if (json.containsKey("code")) {
bangumiList.add("error = " + json.toJSONString());
return bangumiList;
}
JSONArray eps = json.getJSONArray("eps");
JSONArray crts = json.getJSONArray("crt");
JSONArray staffs = json.getJSONArray("staff");
StringBuilder builder = new StringBuilder();
builder.append("<img ").append(json.getJSONObject("images").getString("large")).append(" /img>").append("\n");
builder.append("标题:").append(json.getString("name_cn")).append("\n");
builder.append("日文标题:").append(json.getString("name")).append("\n");
builder.append("首播时间:").append(json.getString("air_date")).append("\n");
builder.append("每周").append(json.getInteger("air_weekday")).append("放送").append("\n");
builder.append("Bangumi地址:").append(json.getString("url")).append("\n");
builder.append("Bangumi评分:").append(json.getJSONObject("rating").getFloat("score")).append("\n");
builder.append("预计放送集数:").append(json.getInteger("eps_count")).append("\n");
if (eps != null) {
builder.append("已放送集:").append("\n");
for (Object o : eps) {
JSONObject ep = (JSONObject) o;
if (ep.getString("status").equals("Air")) {
builder.append("· 第").append(ep.getInteger("sort")).append("话:");
builder.append(ep.getString("name"));
builder.append("[").append(ep.getString("name_cn")).append("]").append("\n");
builder.append("播放日期:").append(ep.getString("airdate")).append(";\n");
builder.append("播放时长:").append(ep.getString("duration")).append(";\n");
builder.append("单集介绍:").append(ep.getString("desc"));
builder.append("\n\n");
} else {
builder.append("下一话:");
builder.append("").append(ep.getInteger("sort")).append("话:");
builder.append("播放日期:").append(ep.getString("airdate")).append("\n\n");
break;
}
}
}
if (crts != null) {
builder.append("角色介绍:").append("\n");
for (Object o : crts) {
JSONObject crt = (JSONObject) o;
JSONObject info = crt.getJSONObject("info");
builder.append(crt.getString("role_name")).append(":");
builder.append(crt.getString("name"));
builder.append("(").append(crt.getString("name_cn")).append(")").append(" ");
builder.append("CV:").append(crt.getJSONArray("actors").getJSONObject(0).getString("name"));
builder.append("(").append(info.getString("gender")).append(")");
builder.append("\n");
}
}
Map<String, List<JSONObject>> map = new HashMap<>();
for (Object o : staffs) {
JSONObject staff = (JSONObject) o;
for (Object jobs : staff.getJSONArray("jobs")) {
String job = (String) jobs;
List<JSONObject> list;
if (!map.containsKey(job)) {
list = new ArrayList<>();
} else {
list = map.get(job);
}
list.add(staff);
map.put(job, list);
}
}
if (!map.isEmpty()) {
builder.append("staff:").append("\n");
for (String key : map.keySet()) {
builder.append(key).append(":");
for (JSONObject staff : map.get(key)) {
builder.append(staff.getString("name_cn"));
builder.append("(").append(staff.getString("name")).append(")");
builder.append("");
}
builder.append("\n");
}
}
bangumiList.add(builder.toString());
return bangumiList;
}
/**
* 格式化输出新番列表
*
* @return 新番信息
*/
public static String reportBangumiList() {
try {
JSONObject json = getBangumi(-1);
StringBuilder builder = new StringBuilder();
assert json != null;
JSONArray array = json.getJSONArray("bangumi");
for (Object o : array) {
JSONObject data = (JSONObject) o;
JSONObject weekday = data.getJSONObject("weekday");
JSONArray items = data.getJSONArray("items");
builder.append(weekday.getString("cn")).append("(").append(weekday.getString("ja")).append(")");
builder.append(":").append("\n");
reportBangumi(builder, items, false);
builder.append("\n");
}
return builder.toString();
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
private static void reportBangumi(StringBuilder builder, JSONArray items, boolean reportEp) {
int epIndex = 0;
String epName = "N/A";
for (Object oj : items) {
JSONObject item = (JSONObject) oj;
builder.append("[").append(item.getInteger("id")).append("]");
builder.append(StringUtils.isEmpty(item.getString("name_cn"))
? item.getString("name") : item.getString("name_cn"));
if (!reportEp) {
builder.append("\n");
continue;
}
JSONObject info = getBangumiInfo(item.getInteger("id"));
if (info.get("eps") == null) {
continue;
}
JSONArray eps = info.getJSONArray("eps");
for (Object oe : eps) {
JSONObject ep = (JSONObject) oe;
if (ep.getString("status").equals("Air")) {
epIndex = ep.getInteger("sort");
epName = ep.getString("name");
} else {
break;
}
}
builder.append("").append(epIndex).append("话:");
builder.append(epName);
builder.append("\n");
}
}
/**
* 格式化字符串输出今日播放番剧列表
*
* @return 番剧列表
*/
public static String reportToDayBangumi() {
String toDayTime = Tools.getToDayTime();
if (!toDayTime.equals(RedisTools.get("reportToDayBangumi"))) {
RedisTools.set("reportToDayBangumi", toDayTime);
StringBuilder builder = new StringBuilder();
JSONObject toDay = getBangumi(0);
if (toDay == null) {
builder.append("今天没有任何番剧放送~");
} else {
JSONObject weekday = toDay.getJSONObject("weekday");
JSONArray items = toDay.getJSONArray("items");
builder.append("今日 ").append(weekday.get("cn")).append("(").append(weekday.get("ja")).append(")");
builder.append(" 放送列表:").append("\n");
reportBangumi(builder, items, true);
}
RedisTools.set("toDayBangumi", builder.toString());
return builder.toString();
} else {
System.out.println("error ");
return RedisTools.get("toDayBangumi");
}
}
/**
* 格式化字符串输出搜索动画
*
* @param key 关键词
* @return 详细内容
*/
public static List<String> reportSearchBangumi(String key) {
List<String> bangumiList = new ArrayList<>();
JSONObject main = search(key);
if (main.getInteger("results") > 0) {
JSONArray list = main.getJSONArray("list");
Collections.reverse(list);
for (Object _items : list) {
JSONObject items= (JSONObject) _items;
bangumiList.addAll(reportBangumiInfo(items.getInteger("id")));
}
return bangumiList;
} else {
bangumiList.add("搜索不到任何内容:" + key);
return bangumiList;
}
}
public static void main(String[] args) {
JSONObject toDay = getBangumiInfoSmall(371396);
System.out.println(toDay);
}
}

View File

@ -463,4 +463,11 @@ public class Tools {
return "";
}
public static int getWeekDay() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(new Date());
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
}
}

View File

@ -3,6 +3,7 @@
<mapper namespace="com.yutou.tools.mybatis.dao.BangumiItemDao">
<resultMap id="BaseResultMap" type="com.yutou.tools.mybatis.model.BangumiItem">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="bgmId" jdbcType="INTEGER" property="bgmid" />
<result column="bid" jdbcType="VARCHAR" property="bid" />
<result column="categories" jdbcType="VARCHAR" property="categories" />
<result column="author" jdbcType="VARCHAR" property="author" />
@ -69,7 +70,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, bid, categories, author, title, titleKey, `enable`
id, bgmId, bid, categories, author, title, titleKey, `enable`
</sql>
<select id="selectByExample" parameterType="com.yutou.tools.mybatis.model.BangumiItemExample" resultMap="BaseResultMap">
select
@ -102,16 +103,19 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.BangumiItem" useGeneratedKeys="true">
insert into bangumi_item (bid, categories, author,
title, titleKey, `enable`
)
values (#{bid,jdbcType=VARCHAR}, #{categories,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR},
#{title,jdbcType=VARCHAR}, #{titlekey,jdbcType=VARCHAR}, #{enable,jdbcType=INTEGER}
)
insert into bangumi_item (bgmId, bid, categories,
author, title, titleKey,
`enable`)
values (#{bgmid,jdbcType=INTEGER}, #{bid,jdbcType=VARCHAR}, #{categories,jdbcType=VARCHAR},
#{author,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{titlekey,jdbcType=VARCHAR},
#{enable,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.BangumiItem" useGeneratedKeys="true">
insert into bangumi_item
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bgmid != null">
bgmId,
</if>
<if test="bid != null">
bid,
</if>
@ -132,6 +136,9 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bgmid != null">
#{bgmid,jdbcType=INTEGER},
</if>
<if test="bid != null">
#{bid,jdbcType=VARCHAR},
</if>
@ -164,6 +171,9 @@
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.bgmid != null">
bgmId = #{record.bgmid,jdbcType=INTEGER},
</if>
<if test="record.bid != null">
bid = #{record.bid,jdbcType=VARCHAR},
</if>
@ -190,6 +200,7 @@
<update id="updateByExample" parameterType="map">
update bangumi_item
set id = #{record.id,jdbcType=INTEGER},
bgmId = #{record.bgmid,jdbcType=INTEGER},
bid = #{record.bid,jdbcType=VARCHAR},
categories = #{record.categories,jdbcType=VARCHAR},
author = #{record.author,jdbcType=VARCHAR},
@ -203,6 +214,9 @@
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.tools.mybatis.model.BangumiItem">
update bangumi_item
<set>
<if test="bgmid != null">
bgmId = #{bgmid,jdbcType=INTEGER},
</if>
<if test="bid != null">
bid = #{bid,jdbcType=VARCHAR},
</if>
@ -226,7 +240,8 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.yutou.tools.mybatis.model.BangumiItem">
update bangumi_item
set bid = #{bid,jdbcType=VARCHAR},
set bgmId = #{bgmid,jdbcType=INTEGER},
bid = #{bid,jdbcType=VARCHAR},
categories = #{categories,jdbcType=VARCHAR},
author = #{author,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},

View File

@ -24,16 +24,16 @@
$('#header').load("/html/header.html");
$('#footer').load("/html/footer.html");
var loadId = layer.load();
let loadId = layer.load();
$.get('/anim/meta/get.do', function (json) {
layer.close(loadId)
layui.use('tree', function () {
var tree = layui.tree;
let tree = layui.tree;
tree.render({
elem: '#animmeta',
data: json,
click: function (obj) {
var url="https://bgm.tv/subject_search/"+encodeURIComponent(obj.data.title)+"?cat=2"
let url="https://bgm.tv/subject_search/"+encodeURIComponent(obj.data.title)+"?cat=2"
layer.prompt({
title: "设置元数据:"+'<a href='+url+' target="_blank">查询</a>',
value: ''

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="zh">
<head>
<meta charset="utf-8">
@ -169,6 +169,7 @@
</script>
<script type="text/html" id="listTools">
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="src">原地址</a>
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="bgm_src">番剧计划</a>
<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>
@ -181,6 +182,15 @@
value="{{d.id}}"></div>
{{# }}}
</script>
<script type="text/html" id="animUpdateState">
{{# if(d.update==1){}}
<div><input type="checkbox" name="update" lay-text="今天更新|不更新" lay-filter="stateCheckbox" lay-skin="switch"
value="{{d.id}}" checked disabled></div>
{{# } else { }}
<div><input type="checkbox" name="update" lay-text="今天更新|不更新" lay-filter="stateCheckbox" lay-skin="switch"
value="{{d.id}}" disabled></div>
{{# }}}
</script>
<script>
$('#header').load("/html/header.html");
$('#footer').load("/html/footer.html");
@ -216,12 +226,14 @@
, url: '/anim/rss/list.do?type=' + tabid
, page: true
, cols: [[
{field: "id", title: "id", width: 80, sort: true, fixed: 'left'}
{field: "id", title: "id", width: 60, sort: true, fixed: 'left'}
, {field: 'bgmid', title: 'bgmId', width: 80, edit: 'text'}
, {field: 'title', title: '标题', edit: 'text'}
, {field: 'categories', title: '类型', width: 80}
, {field: 'author', title: '字幕组', width: 100}
, {field: 'titlekey', title: '搜索关键词', edit: 'text'}
, {field: 'titlekey', title: '搜索关键词', width: 200, edit: 'text'}
, {field: 'enable', title: '状态', width: 80, templet: '#animState'}
, {field: 'update', title: '更新', width: 110, templet: '#animUpdateState'}
, {field: "right", toolbar: '#listTools'}
]]
});
@ -234,6 +246,8 @@
let data = {}
if (type === 'title') {
data = {id: id, title: value}
} else if (type === 'bgmid') {
data = {id: id, bgmId: value}
} else {
data = {id: id, titleKey: value}
}
@ -293,6 +307,8 @@
})
} else if (obj.event === 'src') {
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)
}
})
table.on('tool(rssTools)', function (obj) {
@ -306,19 +322,22 @@
option += '<option>' + i + '</option>'
}
}
let html = '<form class="layui-form">名字:<div class="layui-form-item"><textarea class="layui-textarea" id="rss_value">'+data.title+'</textarea> 季度:<select lay-search lay-verify="required" id="rss_select">'+option+'</select></div></form>'
let html = '<form class="layui-form">名字:<div class="layui-form-item"><textarea class="layui-textarea" id="rss_value" onblur="setTitle(this)">' + data.title + '</textarea> 季度:<select lay-search lay-verify="required" id="rss_select">' + option + '</select> <a id="bgmUrl" href="javascript:;" target="_blank">bgmId:</a><input class="layui-input" id="bgmId"/></div></form>'
layer.open({
type: 0,
area: ['500px', '600px'],
title: '订阅这个RSS结果,并加入到第' + tabid + '个分类中',
content: html,
success:function (){
success: function () {
form.render('select');
},
yes: function (index, elem) {
let value=$('#rss_value')[0].value+'/Season '+$('#rss_select')[0].value
let value = $('#rss_value')[0].value + '/Season ' + $('#rss_select')[0].value
let bgmId = $('#bgmId')[0].value
$.post("/anim/rss/add.do", {
title: value
, bgmId: bgmId
, author: data.author
, categories: data.categories[0]
, titleKey: $('#title').val()
@ -376,6 +395,10 @@
$('#search').click(function () {
searchClick()
})
$('#searchBgmId').click(function () {
let url = "https://bgm.tv/subject_search/" + encodeURIComponent($('#title')[0].value) + "?cat=2"
window.open(url)
})
function searchClick() {
rssList.reload({
@ -387,8 +410,16 @@
})
}
});
function setTitle(_this) {
let url = "https://bgm.tv/subject_search/" + encodeURIComponent(_this.value) + "?cat=2"
console.log(url)
$('#bgmUrl')[0].href = url;
}
//let js="" ; $('#team option').each(function() { let value=$(this).val(); let text=$(this).text(); js+='{"'+value+'":"'+text+'"},'})
</script>
</body>