Commit d59c4e73 authored by Quxl's avatar Quxl

x

parent bde89778
......@@ -26,12 +26,12 @@ public class S_logs implements java.io.Serializable {
@Column(columnDefinition="varchar(255) COMMENT '连接前缀'")
private String prefix;
@Column(columnDefinition="varchar(255) COMMENT '访问连接地址'")
private String path;
@Column(columnDefinition="varchar(255) COMMENT '客户端IP'")
private String ip;
@Column(columnDefinition="text COMMENT '访问连接地址'")
private String path;
@Column(columnDefinition="longtext COMMENT '请求内容'")
private String content;
......@@ -74,14 +74,6 @@ public class S_logs implements java.io.Serializable {
return prefix;
}
public void setPath(String path) {
this.path = path;
}
public String getPath() {
return path;
}
public void setIp(String ip) {
this.ip = ip;
}
......@@ -90,6 +82,14 @@ public class S_logs implements java.io.Serializable {
return ip;
}
public void setPath(String path) {
this.path = path;
}
public String getPath() {
return path;
}
public void setContent(String content) {
this.content = content;
}
......
......@@ -17,10 +17,10 @@ public class S_logs_error implements java.io.Serializable {
@Column(columnDefinition="int(10)")
private Integer id;
@Column(columnDefinition="varchar(255)")
@Column(columnDefinition="text")
private String path;
@Column(columnDefinition="varchar(255)")
@Column(columnDefinition="text")
private String title;
@Column(columnDefinition="longtext")
......
package com.egolm.xplayer.bean;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;
@Entity(name="t_licence")
public class T_licence implements java.io.Serializable {
......
package com.egolm.xplayer.bean;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;
@Entity(name="t_video")
public class T_video implements java.io.Serializable {
......@@ -38,7 +41,7 @@ public class T_video implements java.io.Serializable {
private Integer is_free;
@Column(columnDefinition="int(1) COMMENT '是否显示 0否 1是'")
private Integer is_show;
private Integer is_sales;
@Column(columnDefinition="int(1) COMMENT '影片来源 0管理员添加 1电影节导入'")
private Integer source;
......@@ -117,12 +120,12 @@ public class T_video implements java.io.Serializable {
return is_free;
}
public void setIs_show(Integer is_show) {
this.is_show = is_show;
public void setIs_sales(Integer is_sales) {
this.is_sales = is_sales;
}
public Integer getIs_show() {
return is_show;
public Integer getIs_sales() {
return is_sales;
}
public void setSource(Integer source) {
......
package com.egolm.xplayer.bean;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
@Entity(name="t_video_img")
public class T_video_img implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(columnDefinition="int(10) COMMENT '图片ID'")
private Integer id;
@Column(columnDefinition="int(10) COMMENT '视频ID'")
private Integer video_id;
@Column(columnDefinition="int(10) COMMENT '视频源ID'")
private Integer video_source_id;
@Column(columnDefinition="int(1) COMMENT '1封面 2海报 3详情'")
private Integer type;
@Column(columnDefinition="varchar(255) COMMENT '图片地址'")
private String path;
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setVideo_id(Integer video_id) {
this.video_id = video_id;
}
public Integer getVideo_id() {
return video_id;
}
public void setVideo_source_id(Integer video_source_id) {
this.video_source_id = video_source_id;
}
public Integer getVideo_source_id() {
return video_source_id;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getType() {
return type;
}
public void setPath(String path) {
this.path = path;
}
public String getPath() {
return path;
}
}
package com.egolm.xplayer.bean;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
@Entity(name="x_country")
public class X_country implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(columnDefinition="int(10)")
private Integer id;
@Column(columnDefinition="varchar(255)")
private String cn_name;
@Column(columnDefinition="varchar(255)")
private String en_name;
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setCn_name(String cn_name) {
this.cn_name = cn_name;
}
public String getCn_name() {
return cn_name;
}
public void setEn_name(String en_name) {
this.en_name = en_name;
}
public String getEn_name() {
return en_name;
}
}
package com.egolm.xplayer.bean;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
@Entity(name="x_language")
public class X_language implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(columnDefinition="int(10)")
private Integer id;
@Column(columnDefinition="varchar(255)")
private String cn_name;
@Column(columnDefinition="varchar(255)")
private String en_name;
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setCn_name(String cn_name) {
this.cn_name = cn_name;
}
public String getCn_name() {
return cn_name;
}
public void setEn_name(String en_name) {
this.en_name = en_name;
}
public String getEn_name() {
return en_name;
}
}
package com.egolm.xplayer.bean;
import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Id;
@Entity(name="x_type")
public class X_type implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(columnDefinition="int(10)")
private Integer id;
@Column(columnDefinition="varchar(255)")
private String cn_name;
@Column(columnDefinition="varchar(255)")
private String en_name;
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setCn_name(String cn_name) {
this.cn_name = cn_name;
}
public String getCn_name() {
return cn_name;
}
public void setEn_name(String en_name) {
this.en_name = en_name;
}
public String getEn_name() {
return en_name;
}
}
package com.egolm.xplayer.bean.model;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity(name="t_video")
public class T_video_model implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(columnDefinition="int(10) COMMENT '视频ID '")
private Integer id;
@Column(columnDefinition="varchar(255) COMMENT '视频名称'")
private String name;
@Column(columnDefinition="varchar(255) COMMENT '一句话简介'")
private String desc;
@Column(columnDefinition="longtext COMMENT '剧情简介'")
private String profiles;
@Column(columnDefinition="int(4) COMMENT '年份'")
private Integer year;
@Column(columnDefinition="varchar(255) COMMENT '国家'")
private String country;
@Column(columnDefinition="int(1) COMMENT '是否免费 0否 1是'")
private Integer is_free;
@Column(columnDefinition="decimal(10,2)")
private BigDecimal base_score;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getProfiles() {
return profiles;
}
public void setProfiles(String profiles) {
this.profiles = profiles;
}
public Integer getYear() {
return year;
}
public void setYear(Integer year) {
this.year = year;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Integer getIs_free() {
return is_free;
}
public void setIs_free(Integer is_free) {
this.is_free = is_free;
}
public BigDecimal getBase_score() {
return base_score;
}
public void setBase_score(BigDecimal base_score) {
this.base_score = base_score;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
......@@ -21,6 +21,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.egolm.common.StringUtil;
import com.egolm.xplayer.config.interceptor.AdminLoginInterceptor;
import com.egolm.xplayer.config.interceptor.LogInterceptor;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -30,9 +31,13 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
private LogInterceptor logInterceptor;
@Autowired
private AdminLoginInterceptor adminInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(logInterceptor).addPathPatterns("/**").excludePathPatterns("/*.html").excludePathPatterns("/assets/**");
registry.addInterceptor(adminInterceptor).addPathPatterns("/admin").excludePathPatterns("/admin/*.html").excludePathPatterns("/assets/**").excludePathPatterns("/admin/doLogin");
}
@Override
......
package com.egolm.xplayer.config.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.xplayer.config.XRException;
import com.egolm.xplayer.web.service.AdminTokenService;
@Component
public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
AdminTokenService adminTokenService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if(adminTokenService.getLoginBean() == null) {
throw new XRException("请登陆后再操作", 300);
}
return super.preHandle(request, response, handler);
}
}
......@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSON;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.web.ServletUtil;
import com.egolm.xplayer.bean.S_logs;
import com.egolm.xplayer.web.service.AdminTokenService;
import com.egolm.xplayer.web.service.UserTokenService;
@Component
......@@ -24,17 +25,22 @@ public class LogInterceptor extends HandlerInterceptorAdapter {
@Autowired
UserTokenService userTokenService;
@Autowired
AdminTokenService adminTokenService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
Date now = new Date();
String path = request.getRequestURI().replace(request.getContextPath(), "");
String prefix = path.split("/")[1];
Integer userId = userTokenService.getLoginId();
Integer adminId = adminTokenService.getLoginId();
String content = JSON.toJSONString(request.getParameterMap());
String ip = ServletUtil.remoteIp(request);
String user_agent = request.getHeader("User-Agent");
S_logs log = new S_logs();
log.setUser_id(userId);
log.setAdmin_id(adminId);
log.setCreate_time(now);
log.setContent(content);
log.setIp(ip);
......
package com.egolm.xplayer.web;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.xplayer.config.SqlWhere;
@Controller
@RequestMapping("mv")
public class MvController {
@Autowired
JdbcTemplate jdbcTemplate;
@ResponseBody
@RequestMapping("getMvList")
public Rjx getMvList(String keyword, String year, String[] country, String[] category, Page page) {
if(page == null) {
page = new Page();
}
Integer year_start = null;
Integer year_end = null;
if(StringUtil.isNotBlank(year) && !"全部".equals(year)) {
if(year.contains("-")) {
String[] years = year.split("-");
year_start = Integer.valueOf(years[0]);
year_end = Integer.valueOf(years[1]);
} else {
year_start = year_end = Integer.valueOf(year);
}
}
SqlWhere where = new SqlWhere().eq("is_show", 1).ge("year", year_start).le("year", year_end).lk(new String[]{"name"}, keyword);
String sql = "select * from t_video" + StringUtil.join(" and ", " where ", where.getStringList());
List<Map<String, Object>> list = jdbcTemplate.limit(sql, page, where.getObjectArray());
return Rjx.jsonOk().setData(list);
}
}
package com.egolm.xplayer.web.api;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.bean.Rjx;
import com.egolm.xplayer.bean.X_country;
import com.egolm.xplayer.bean.X_language;
import com.egolm.xplayer.web.service.CommonService;
@Controller
@RequestMapping("common")
public class CommonController {
@Autowired
CommonService common;
@ResponseBody
@PostMapping("getCountryList")
public Rjx getCountryList() {
List<X_country> countries = common.queryAll(X_country.class);
return Rjx.jsonOk().setData(countries);
}
@ResponseBody
@PostMapping("getLanguageList")
public Rjx getLanguageList() {
List<X_language> languages = common.queryAll(X_language.class);
return Rjx.jsonOk().setData(languages);
}
}
package com.egolm.xplayer.web.api.admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.xplayer.bean.T_admin;
import com.egolm.xplayer.web.service.AdminTokenService;
@Controller
@RequestMapping("admin")
public class AdminController {
@Autowired
private AdminTokenService tokenService;
@ResponseBody
@RequestMapping("doLogin")
public Rjx login(String username, String password) {
if(StringUtil.isBlank(username) || StringUtil.isBlank(password)) {
T_admin loginAdmin = tokenService.getLoginBean();
if(loginAdmin != null) {
return Rjx.jsonOk().setMessage("会话已存在");
} else {
return Rjx.jsonErr().setMessage("登陆失败:用户名或密码不能为空");
}
} else {
T_admin user = tokenService.doLogin();
if(user != null) {
return Rjx.jsonOk();
} else {
return Rjx.jsonErr().setMessage("登陆失败:用户名或密码错误");
}
}
}
@ResponseBody
@RequestMapping("getUpk")
public Rjx getUpk() {
Integer loginId = tokenService.getLoginId();
return Rjx.jsonOk().setData(loginId);
}
@ResponseBody
@RequestMapping("doLogout")
public Rjx logout() {
tokenService.doLogout();
return Rjx.jsonOk();
}
}
package com.egolm.xplayer.web;
package com.egolm.xplayer.web.api.admin;
import java.sql.Connection;
import java.sql.PreparedStatement;
......@@ -8,29 +8,92 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.xplayer.bean.T_video;
import com.egolm.xplayer.bean.T_video_source;
import com.egolm.xplayer.bean.model.T_video_model;
import com.egolm.xplayer.config.SqlWhere;
import com.egolm.xplayer.web.service.CommonService;
@Controller
@RequestMapping("admin/mvDownload")
public class MvDownloadController {
@RequestMapping("admin/video")
public class AdminVideoController {
@Autowired
JdbcTemplate jdbcTemplate;
public void initMv() {
@Autowired
CommonService common;
@ResponseBody
@PostMapping("getVideoList")
public Rjx getMvList(String keyword, Integer is_sales, Integer is_free, Page page) {
if(page == null) {
page = new Page();
}
SqlWhere where = new SqlWhere().eq("is_sales", is_sales).eq("is_free", is_free).lk(new String[]{"name"}, keyword);
String sql = "select * from t_video" + StringUtil.join(" and ", " where ", where.getStringList());
List<Map<String, Object>> list = jdbcTemplate.limit(sql, page, where.getObjectArray());
return Rjx.jsonOk().setData(list).setPage(page);
}
@ResponseBody
@PostMapping("saveVideoBase")
public Rjx saveVideoBase(T_video_model vm) {
if(vm.getId() != null) {
common.update(vm);
} else {
T_video video = new T_video();
BeanUtils.copyProperties(vm, video);
video.setIs_sales(0);
video.setCreate_time(new Date());
video.setSource(0);
common.save(vm);
}
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("doSalesUpdate")
public Rjx doSalesUpdate(Integer id) {
T_video vm = new T_video();
vm.setId(id);
vm.setIs_sales(1);
common.merge(vm);
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("doNotSalesUpdate")
public Rjx doNotSalesUpdate(Integer id) {
T_video vm = new T_video();
vm.setId(id);
vm.setIs_sales(0);
common.merge(vm);
return Rjx.jsonOk();
}
@ResponseBody
@PostMapping("doImport")
public Rjx doImport() {
List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from x_mvlist where upload_id is not null and upload_state = 2");
for(Map<String, Object> map : list) {
String name = (String)map.get("cn_name");
Integer is_show = 1;
Integer is_sales = 0;
String profiles = (String)map.get("intro");
String country = (String)map.get("film_country");
String upload_id = (String)map.get("upload_id");
......@@ -43,8 +106,8 @@ public class MvDownloadController {
String cover = null;
Integer source = 1;
String source_key = map.get("id") + "";
Object[] argArray = new Object[] {name, is_show, profiles, country, year, cover, source, source_key, source, source_key};
String sql = "insert into t_video (name, is_show, profiles, country, year, cover, source, source_key) select ?, ?, ?, ?, ?, ?, ?, ? from dual where not exists(select 1 from t_video where source = ? and source_key = ?)";
Object[] argArray = new Object[] {name, is_sales, profiles, country, year, cover, source, source_key, source, source_key};
String sql = "insert into t_video (name, is_sales, profiles, country, year, cover, source, source_key) select ?, ?, ?, ?, ?, ?, ?, ? from dual where not exists(select 1 from t_video where source = ? and source_key = ?)";
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
......@@ -64,6 +127,7 @@ public class MvDownloadController {
jdbcTemplate.save(vs);
}
}
return Rjx.jsonOk();
}
}
package com.egolm.xplayer.web;
package com.egolm.xplayer.web.api.player;
import java.util.Date;
import java.util.List;
......@@ -11,12 +11,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.xplayer.bean.T_licence_user;
import com.egolm.xplayer.bean.T_video;
import com.egolm.xplayer.bean.T_video_source;
import com.egolm.xplayer.config.AliyunUtil;
import com.egolm.xplayer.config.SqlWhere;
import com.egolm.xplayer.config.XRException;
import com.egolm.xplayer.web.service.CommonService;
import com.egolm.xplayer.web.service.UserTokenService;
......@@ -37,12 +40,27 @@ public class PlayerController {
@Autowired
CommonService common;
public Rjx getAuthCodeById(Integer id) {
T_video_source vs = common.queryById(id, T_video_source.class);
T_video video = common.queryById(vs.getVideo_id(), T_video.class);
String vid = vs.getPlay_key();
String authCode = null;
return Rjx.jsonOk().set("vid", vid).set("authCode", authCode).setData(video);
@ResponseBody
@RequestMapping("getMvList")
public Rjx getMvList(String keyword, String year, String[] country, String[] category, Page page) {
if(page == null) {
page = new Page();
}
Integer year_start = null;
Integer year_end = null;
if(StringUtil.isNotBlank(year) && !"全部".equals(year)) {
if(year.contains("-")) {
String[] years = year.split("-");
year_start = Integer.valueOf(years[0]);
year_end = Integer.valueOf(years[1]);
} else {
year_start = year_end = Integer.valueOf(year);
}
}
SqlWhere where = new SqlWhere().eq("is_sales", 1).ge("year", year_start).le("year", year_end).lk(new String[]{"name"}, keyword);
String sql = "select * from t_video" + StringUtil.join(" and ", " where ", where.getStringList());
List<Map<String, Object>> list = jdbcTemplate.limit(sql, page, where.getObjectArray());
return Rjx.jsonOk().setData(list);
}
@ResponseBody
......
package com.egolm.xplayer.web;
package com.egolm.xplayer.web.api.player;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -12,7 +12,7 @@ import com.egolm.xplayer.web.service.UserTokenService;
@Controller
@RequestMapping("user")
public class UserLoginController {
public class UserController {
@Autowired
private UserTokenService tokenService;
......@@ -22,8 +22,8 @@ public class UserLoginController {
@RequestMapping("doLogin")
public Rjx login(String username, String password) {
if(StringUtil.isBlank(username) || StringUtil.isBlank(password)) {
T_user loginAdmin = tokenService.getLoginBean();
if(loginAdmin != null) {
T_user loginUser = tokenService.getLoginBean();
if(loginUser != null) {
return Rjx.jsonOk().setMessage("会话已存在");
} else {
return Rjx.jsonErr().setMessage("登陆失败:用户名或密码不能为空");
......
package com.egolm.xplayer.web.service;
import com.egolm.xplayer.bean.T_admin;
public interface AdminTokenService {
String SESSION_LOGIN_TOKEN = "SESSION_ADMIN_LOGIN_TOKEN";
String COOKIE_LOGIN_TOKEN = "COOKIE_ADMIN_LOGIN_TOKEN";
T_admin getLoginBean();
Integer getLoginId();
T_admin doLogin();
void doLogout();
}
package com.egolm.xplayer.web.service.impl;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.xplayer.bean.T_admin;
import com.egolm.xplayer.config.WebMvcConfig;
import com.egolm.xplayer.config.XException;
import com.egolm.xplayer.web.service.AdminTokenService;
@Service
public class AdminTokenServiceImpl implements AdminTokenService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public T_admin getLoginBean() {
HttpSession session = WebMvcConfig.getSession();
return (T_admin)session.getAttribute(SESSION_LOGIN_TOKEN);
}
@Override
public Integer getLoginId() {
T_admin user = this.getLoginBean();
if(user != null) {
return user.getId();
}
return null;
}
@Override
public T_admin doLogin() {
HttpServletRequest request = WebMvcConfig.getRequest();
String username = request.getParameter("username");
String password = request.getParameter("password");
String pwdMd5Str = StringUtil.toMD5HexString(password);
try {
String sql = "select * from t_admin where username = ? and password = ?";
T_admin user = jdbcTemplate.queryForBean(sql, T_admin.class, username, pwdMd5Str);
HttpSession session = request.getSession();
session.setAttribute(SESSION_LOGIN_TOKEN, user);
Cookie cookie = WebMvcConfig.getOrCreateUUIDCookie(COOKIE_LOGIN_TOKEN, "/", 60*60*24*5, true);
if(cookie != null) {
jdbcTemplate.executeUpdate("update t_admin set token = ? where id = ?", cookie.getValue(), user.getId());
}
return user;
} catch (Exception e) {
throw new XException("用户名或密码错误", e);
}
}
@Override
public void doLogout() {
HttpSession session = WebMvcConfig.getSession();
session.removeAttribute(SESSION_LOGIN_TOKEN);
session.invalidate();
}
public static void main(String[] args) {
System.out.println(StringUtil.toMD5HexString("linkfern#2019"));
}
}
<!DOCTYPE html>
<html>
<head>
<title>LOGIN</title>
<link rel="icon" href="assets/favicon/favicon.ico" type="image/x-icon" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
* {margin:0px; padding:0px; border:0px;}
body {background:#f0f0f0;font-size:18px;}
input, button {outline:none; -webkit-tap-highlight-color:rgba(0,0,0,0); -webkit-user-modify:read-write-plaintext-only;}
.login_div {display: flex; justify-content:center; align-items:Center;}
.login_div table {display:none; padding:30px; background:#fff; border:1px solid #ccc; width:300px; margin-left:auto; margin-right:auto;}
.login_div table .title {border-bottom:1px dotted #ccc;padding-bottom:15px;width:100%;text-align: center;}
.login_div table .input_label {margin-top:15px;color:#888;}
.login_div table input {padding-left:10px; padding-right:10px; height:40px;line-height:40px; font-size:18px; width:270px; border:1px solid #ccc; border-radius:5px}
.login_div table button {border:1px solid #bbb; width:100%; height:40px; margin-top:30px;border-radius:5px; cursor: pointer;font-size:18px;}
input#password {letter-spacing:4px;}
#message {height:24px; color:red;font-size:16px;}
</style>
<script src="../assets/jquery/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<form action="#" autocomplete="off">
<div class="login_div">
<table>
<tr><td><div class="title">Login</div></td></tr>
<tr><td><div class="input_label">Username</div></td></tr>
<tr><td><input type="text" id="username" /></td></tr>
<tr><td><div class="input_label">Password</div></td></tr>
<tr><td><input type="password" id="password" /></td></tr>
<tr><td><button type="button" onclick="login();">Login</button></td></tr>
<tr><td height="24"><div id="message"></div></td></tr>
</table>
</div>
</form>
</body>
<script type="text/javascript" src="../assets/common.js"></script>
<script type="text/javascript">
function doLogin(args) {
$.ajax({
type: "post",
url: "doLogin",
cache: false,
data: args,
dataType: "json",
success: function(json) {
if(json.code == 200) {
window.location.href = "mvlist.html";
} else if(args && args.username){
$("#message").text(json.message);
$("#message").show();
$("#message").fadeOut(2000);
}
}
});
}
function login() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if(username) {
doLogin({username: username, password: password});
} else {
doLogin({});
}
}
$(function() {
$(".login_div").height(window.innerHeight);
$(window).resize(function() {
$(".login_div").height(window.innerHeight);
});
$("table").show();
$("html").keydown(function(e) {
if(e.keyCode==13) {
login();
}
});
doLogin({});
});
</script>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>影片档案管理</title>
<link rel="icon" href="assets/favicon/favicon.ico" type="image/x-icon" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.0.11/lib/theme-chalk/index.css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript" src="https://unpkg.com/element-ui@2.0.11/lib/index.js"></script>
<script type="text/javascript" src="../assets/jquery/jquery.min.js"></script>
</head>
<body>
<div id="app">
<el-form @submit.native.prevent="loadData" size="mini" :model="searchForm" :inline="true" class="demo-form-inline">
<el-form-item>
<el-select v-model="searchForm.is_free" placeholder="请选择是否免费" @change="loadData">
<el-option value=""></el-option>
<el-option v-for="item in isFreeArray" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-radio-group v-model="searchForm.is_sales" @change="loadData">
<el-radio-button v-for="item in isSalesArray" :label="item.value">{{item.label}}</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-input placeholder="请输入搜索内容" v-model="searchForm.keyword">
<el-button slot="append" icon="el-icon-search" @click="loadData"></el-button>
</el-input>
</el-form-item>
<el-form-item>
<el-button size="mini" type="primary" @click="loadData">检索</el-button>
</el-form-item>
</el-form>
<el-button size="mini" type="primary" @click="toAdd">新建视频档案</el-button>
<el-button size="mini" type="danger" @click="doImport">从电影节导入视频档案</el-button>
<el-button size="mini" type="primary" @click="toPlayer">到视频网站首页</el-button>
<div style="margin-top:15px;">
<el-table ref="configList" :data="tableData" stripe style="width:100%" border size="small">
<el-table-column label="名称">
<template scope="scope">
<a href="javascript:void(0);" @click="toEdit(scope.row)">{{scope.row.name}}</a>
</template>
</el-table-column>
<el-table-column prop="desc" label="简介"></el-table-column>
<el-table-column label="费用" width="100">
<template scope="scope">
<el-button round v-if="scope.row.is_free == 0" size="mini" type="danger">收费</el-button>
<el-button round v-if="scope.row.is_free == 1" size="mini" type="success">免费</el-button>
</template>
</el-table-column>
<el-table-column prop="year" label="年代"></el-table-column>
<el-table-column prop="country" label="国家"></el-table-column>
<el-table-column prop="base_score" label="基础分"></el-table-column>
<el-table-column width="230">
<template scope="scope">
<el-button type="primary" size="mini" @click="toLicenceManage">许可证管理</el-button>
<el-button type="primary" size="mini" @click="toVideoSourceManage">视频管理</el-button>
</template>
</el-table-column>
</el-table>
<div align="right">
<el-pagination
layout="total, prev, pager, next, sizes"
@size-change="changePageSize"
@current-change="changePageIndex"
:current-page="searchForm.index"
:page-sizes="[10, 20, 30, 40]"
:page-size="searchForm.limit"
:total="searchForm.total">
</el-pagination>
</div>
</div>
<el-dialog title="编辑" :visible.sync="videoFormVisible" style="width:1200px;margin:auto;" :close-on-press-escape="false" :close-on-click-modal="false">
<el-form>
<el-form-item label="档案名称" label-width="90px">
<el-input v-model="videoForm.name" placeholder="请输入档案名称"></el-input>
</el-form-item>
<el-form-item label="一句话简介" label-width="90px">
<el-input v-model="videoForm.desc" placeholder="请输入简短描述"></el-input>
</el-form-item>
<el-form-item label="国家" label-width="90px">
<el-select v-model="videoForm.country" filterable :filter-method="searchCountry" placeholder="请选择国家">
<el-option v-for="country in countryOptions" :key="country.id" :label="country.cn_name" :value="country.en_name">
<span style="float:left">{{country.en_name}}</span>
<span style="float:right">{{country.cn_name}}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="收费" label-width="90px">
<el-radio-group v-model="videoForm.is_free">
<el-radio-button v-for="item in isFreeArray" :label="item.value">{{item.label}}</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="年代/评分" label-width="90px">
<el-input v-model="videoForm.year" placeholder="例如:2019" style="width:49%;"></el-input>
<el-input v-model="videoForm.base_score" placeholder="基础分" style="width:50%;"></el-input>
</el-form-item>
<el-form-item label="视频简介" label-width="90px">
<el-input type="textarea" :rows="8" v-model="videoForm.profiles" resize="none" placeholder="请输视频简介"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size="mini" type="danger" v-if="videoForm.id && videoForm.is_sales != 1" @click="doSales">上架</el-button>
<el-button size="mini" type="danger" v-if="videoForm.id && videoForm.is_sales == 1" @click="doNotSales">下架</el-button>
<el-button size="mini" @click="videoFormVisible = false">关 闭</el-button>
<el-button size="mini" type="primary" @click="save">确 定</el-button>
</div>
</el-dialog>
</div>
<script type="text/javascript" src="../assets/common.js"></script>
<script type="text/javascript" src="../assets/js/adminLoginInterceptor.js"></script>
<script>
var vue = new Vue({
el:"#app",
data: {
videoFormVisible: false,
isFreeArray: [{value: 1, label: "免费视频"}, {value: 0, label: "收费视频"}],
isSalesArray: [{value: 1, label: "上架视频"}, {value: 0, label: "下架视频"}],
searchForm: {is_sales: 0, limit: 30, index: 1, total: 0},
videoForm: {},
tableData: [],
countries: [],
countryOptions: [],
},
methods: {
searchCountry(key) {
var scope = this;
if(key) {
setTimeout(() => {
scope.$set(scope.countryOptions);
scope.countryOptions = scope.countries.filter(item => {
return item.cn_name.toLowerCase().indexOf(key.toLowerCase()) > -1 || item.en_name.toLowerCase().indexOf(key.toLowerCase()) > -1;
});
}, 200);
} else {
scope.countryOptions = scope.countries;
}
},
loadData() {
var scope = this;
$.post("video/getVideoList", scope.searchForm, function(json) {
if(json.code == 200) {
scope.tableData = json.data;
scope.searchForm.total = json.page.total;
}
});
},
toAdd() {
this.videoFormVisible = true;
this.videoForm = {};
},
toEdit(row) {
this.videoFormVisible = true;
this.videoForm = row;
},
save() {
var scope = this;
$.post("video/saveVideoBase", scope.videoForm, function(json) {
if(json.code == 200) {
scope.videoFormVisible = false;
scope.videoForm = {};
scope.loadData();
}
});
},
doNotSales() {
var scope = this;
$.post("video/doNotSalesUpdate", {id: scope.videoForm.id}, function(json) {
if(json.code == 200) {
scope.videoFormVisible = false;
scope.videoForm = {};
scope.loadData();
}
});
},
doSales() {
var scope = this;
$.post("video/doSalesUpdate", {id: scope.videoForm.id}, function(json) {
scope.videoFormVisible = false;
scope.videoForm = {};
scope.loadData();
});
},
doImport() {
var scope = this;
this.$confirm("确定要从电影节导入视频码?", '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.post("video/doImport", function(json) {
if(json.code == 200) {
scope.loadData();
}
});
});
},
toPlayer() {
window.open("../mvlist.html");
},
toLicenceManage() {
var text = "此功能用于管理视频许可证书, 包括付费许可证. 点播券许可证, 及许可证已授权的所有用户";
var title = "功能尚未开发,敬请期待";
this.$alert(text, title, {
confirmButtonText: "确定",
});
},
toVideoSourceManage() {
var text = "此功能用于管理视频档案下全部视频(包括正片, 预告, 预览等), 图片(包括封面, 海报, 详情图等)";
var title = "功能尚未开发,敬请期待";
this.$alert(text, title, {
confirmButtonText: "确定",
});
},
changePageSize: function(val) {
this.searchForm.limit = val;
this.loadData();
},
changePageIndex: function(val) {
this.searchForm.index = val;
this.loadData();
}
},
mounted() {
var scope = this;
$.post($.getContextPath() + "/common/getCountryList", function(json) {
if(json.code == 200) {
scope.countries = json.data;
scope.countryOptions = json.data;
}
});
this.loadData();
}
});
</script>
</body>
</html>
\ No newline at end of file
$(document).ajaxSuccess(function(event, xhr, options) {
if(xhr.responseJSON && xhr.responseJSON.code == 300) {
var contextPath = $.getContextPath();
window.location.href = contextPath + "/admin/login.html";
}
});
$(document).ajaxError(function(event, xhr, options) {
if(xhr.responseJSON && xhr.responseJSON.code == 300) {
var contextPath = $.getContextPath();
window.location.href = contextPath + "/admin/login.html";
}
});
\ No newline at end of file
......@@ -96,7 +96,7 @@
scope.mvList = [];
}
$.ajax({
url: "mv/getMvList",
url: "player/getMvList",
data: scope.searchForm,
success: function(json) {
if(json.code == 200) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment