admin
2022-01-28 cd7767932dddeaf6d9c73a83d4a9b38f0341b77f
bug修复
30个文件已修改
6个文件已添加
1828 ■■■■ 已修改文件
src/main/java/com/yeshi/buwan/controller/TestController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/admin/api/ConfigController.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/api/ApiControllerV2.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/api/ApiControllerV3.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/api/ClientEventController.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/CommentParser.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/UserParser.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/dao/system/DetailSystemConfigDao.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/dao/user/UserDPContentWatchStatisticDao.java 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/domain/user/UserDPContentWatchStatistic.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/filter/RequestFilter.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/DetailSystemConfigService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/SMSServiceImpl.java 72 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/SearchService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/UserService.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/ad/DeviceAdStrategyServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/user/UserDPContentWatchStatisticServiceImpl.java 166 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/inter/SMSService.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/inter/user/UserDPContentWatchStatisticService.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/FileUtil.java 702 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/JuHe/VideoResourceUtil.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/video/VideoDetailUtil.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/consumer.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/env-pro/kafka_log.properties 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/env-pro/logback.xml 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/fenqu.html 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/systemcanshu.html 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/CopyTest.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/DES.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/EmailTest.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/GeneralTest.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/StatisticTest.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/video/VideoResourcePlayVersionTest.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/video/VideoResourceVersionTest.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/vip/VIPTest.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/TestController.java
@@ -11,6 +11,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.TimeUtil;
import javax.annotation.Resource;
import java.io.PrintWriter;
@@ -55,6 +56,17 @@
    }
    @RequestMapping("getTime")
    public void getTime(PrintWriter out) {
        long time = System.currentTimeMillis();
        String str = TimeUtil.getGernalTime(time, "yyyyMMdd HH:mm:ss");
        out.print(String.format("time: %s  format:%s", time + "", str));
    }
    @RequestMapping("searchAlbum")
    public void searchAlbum(String key, PrintWriter out) {
        SearchService.SearchResult result = searchService.searchAlbum(0, key, null, 1, 20, false);
src/main/java/com/yeshi/buwan/controller/admin/api/ConfigController.java
@@ -28,9 +28,14 @@
    private EHCacheManager ehCacheManager;
    @RequestMapping("configList")
    public void configList(Long detailSystemId, String key, PrintWriter out) {
    public void configList(Long detailSystemId, String key, String type, PrintWriter out) {
        key = StringUtil.isNullOrEmpty(key) ? "" : key.trim();
        List<DetailSystemConfig> list = configService.listConfig(detailSystemId, key);
        List<DetailSystemConfig> list = null;
        if ("value".equalsIgnoreCase(type)) {
            list = configService.listConfigByValue(detailSystemId, key);
        } else {
            list = configService.listConfig(detailSystemId, key);
        }
        JSONObject json = new JSONObject();
        json.put("code", "0");
        JSONArray listJson = new JSONArray(list);
src/main/java/com/yeshi/buwan/controller/api/ApiControllerV2.java
@@ -314,6 +314,8 @@
            userParser.sendVerifyCode(acceptData, request, out);
        } else if (method.equalsIgnoreCase("register")) {
            userParser.register(acceptData, request, out);
        } else if (method.equalsIgnoreCase("phoneLogin")) {
            userParser.phoneLogin(acceptData, request, out);
        } else if (method.equalsIgnoreCase("login")) {
            userParser.login(acceptData, request, out);
        } else if (method.equalsIgnoreCase("updateLoginUserInfo")) {
@@ -336,6 +338,9 @@
            commentParser.bindWX(acceptData, request, out);
        } else if (method.equalsIgnoreCase("allowOneKeyLogin")) {
            commentParser.allowOneKeyLogin(acceptData, request, out);
        } else if (method.equalsIgnoreCase("sendSMSCode")) {
            //短信发送
            userParser.sendSMSCode(acceptData, request, out);
        }
        out.close();
    }
src/main/java/com/yeshi/buwan/controller/api/ApiControllerV3.java
@@ -283,6 +283,8 @@
            userParser.register(acceptData, request, out);
        } else if (method.equalsIgnoreCase("login")) {
            userParser.login(acceptData, request, out);
        }else if (method.equalsIgnoreCase("phoneLogin")) {
            userParser.phoneLogin(acceptData, request, out);
        } else if (method.equalsIgnoreCase("updateLoginUserInfo")) {
            userParser.updateLoginUserInfo(acceptData, request, out);
        } else if (method.equalsIgnoreCase("getLoginUserInfo")) {
src/main/java/com/yeshi/buwan/controller/api/ClientEventController.java
New file
@@ -0,0 +1,64 @@
package com.yeshi.buwan.controller.api;
import com.yeshi.buwan.service.inter.user.UserDPContentWatchStatisticService;
import com.yeshi.buwan.util.JsonUtilV2;
import com.yeshi.buwan.util.RedisManager;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.vo.AcceptData;
import org.apache.zookeeper.Login;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yeshi.utils.annotation.RequestSerializableByKey;
import javax.annotation.Resource;
/**
 * @author hxh
 * @description 客户端事件收集
 * @date 15:36 2021/12/28
 * @return
 **/
@Controller
@RequestMapping("api/v2/event")
public class ClientEventController {
    Logger logger = LoggerFactory.getLogger(ClientEventController.class);
    @Resource
    private UserDPContentWatchStatisticService userDPContentWatchStatisticService;
    ///阅读新闻
    @RequestMapping("readNews")
    @ResponseBody
    public String readNews(AcceptData acceptData, String LoginUid) {
        logger.info("readNews:{},{},{}", acceptData.getDetailSystem().getId(), userDPContentWatchStatisticService.getIdentityId(acceptData), LoginUid);
        userDPContentWatchStatisticService.readNews(acceptData, LoginUid);
        return JsonUtilV2.loadTrueJson("");
    }
    ///沉浸式视频播放
    @RequestSerializableByKey(key = "#acceptData.Package+'-'+#acceptData.device+'-'+#acceptData.utdId")
    @RequestMapping("playDrawVideo")
    @ResponseBody
    public String playDrawVideo(AcceptData acceptData, String Source, String From, boolean Finish, String LoginUid) {
        logger.info("playDrawVideo:{},{},{},{},{},{}", acceptData.getDetailSystem().getId(), userDPContentWatchStatisticService.getIdentityId(acceptData), Source, From, Finish, LoginUid);
        userDPContentWatchStatisticService.playDrawVideo(acceptData, LoginUid);
        return JsonUtilV2.loadTrueJson("");
    }
    ///小说阅读
    @RequestMapping("readNovel")
    @ResponseBody
    public String readNovel(AcceptData acceptData, long Duration, String LoginUid) {
        logger.info("readNovel:{},{},{},{}", acceptData.getDetailSystem().getId(), userDPContentWatchStatisticService.getIdentityId(acceptData), Duration, LoginUid);
        userDPContentWatchStatisticService.readNovel(acceptData, Duration, LoginUid);
        return JsonUtilV2.loadTrueJson("");
    }
}
src/main/java/com/yeshi/buwan/controller/parser/CommentParser.java
@@ -403,14 +403,18 @@
        } catch (SMSException e) {
            e.printStackTrace();
            out.print(JsonUtil.loadFalseJson(e.getMessage()));
            logger.error("发送验证码出错:phone-{} msg-{}",phone,e.getMessage(),e);
            return;
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseJson("短信发送出错,请稍后再试"));
            logger.error("发送验证码出错:phone-{} msg-{}",phone,e.getMessage(),e);
            return;
        }
        out.print(JsonUtil.loadTrueJson(""));
    }
    public void getVideoCommentList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        String videoId = request.getParameter("VideoId");
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java
@@ -16,12 +16,15 @@
import com.google.gson.reflect.TypeToken;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.domain.recommend.FloatAD;
import com.yeshi.buwan.domain.user.UserDPContentWatchStatistic;
import com.yeshi.buwan.dto.config.ADShieldIPConfig;
import com.yeshi.buwan.dto.log.BaseLog;
import com.yeshi.buwan.log.LogHelper;
import com.yeshi.buwan.service.imp.SystemService;
import com.yeshi.buwan.service.inter.ad.FloatADService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import com.yeshi.buwan.service.inter.user.UserDPContentWatchStatisticService;
import com.yeshi.buwan.service.manager.APPManager;
import com.yeshi.buwan.service.manager.IPManager;
import com.yeshi.buwan.util.IPUtil;
import com.yeshi.buwan.util.StringUtil;
@@ -56,6 +59,12 @@
    @Resource
    private SystemConfigService systemConfigService;
    @Resource
    private UserDPContentWatchStatisticService userDPContentWatchStatisticService;
    @Resource
    private APPManager appManager;
    public ADConfig getAdShowType(String key, String channel, int version, Map<String, String> map) {
@@ -194,6 +203,14 @@
                }
            }
        }
        //是否为内容阅读用户
        boolean isDPUser = false;
        try {
            isDPUser = userDPContentWatchStatisticService.isDPUser(acceptData);
        } catch (Exception e) {
        }
        //广告全部屏蔽区域
        String shieldAdLocationInfo = map.get("shield_ad_ip_location");
        boolean hiddenAll = shieldAllAd(acceptData.getChannel(), acceptData.getVersion(), shieldAdLocationInfo, ip);
@@ -212,10 +229,11 @@
            splashConfig = null;
        //开屏
        ad.put("splash", splash);
        adNew.put("splash", gson.toJson(splashConfig));
        if (!isDPUser)
            adNew.put("splash", gson.toJson(splashConfig));
        ADConfig adConfig = null;
            ADConfig adConfig = null;
        //视频前贴
        adConfig = getAdShowType("ad_play_video_pre", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
@@ -227,13 +245,15 @@
        if (hiddenAll)
            adConfig = null;
        ad.put("exitApp", adConfig == null ? "" : adConfig.getType());
        adNew.put("exitApp", gson.toJson(adConfig));
        if (!isDPUser)
            adNew.put("exitApp", gson.toJson(adConfig));
        //全屏广告控制
        adConfig = getAdShowType("ad_video_detail_full_video", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        ad.put("videoDetailFullVideo", adConfig == null ? "" : adConfig.getType());
        adNew.put("videoDetailFullVideo", gson.toJson(adConfig));
        if (!isDPUser)
            adNew.put("videoDetailFullVideo", gson.toJson(adConfig));
        //搜索页广告控制
        adConfig = getAdShowType("ad_video_search", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
@@ -257,14 +277,15 @@
        adConfig = getAdShowType("home_ad_interstitial", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        adNew.put("homeInterstitial", gson.toJson(adConfig));
        if (!isDPUser)
            adNew.put("homeInterstitial", gson.toJson(adConfig));
        //应用退出全屏
        adConfig = getAdShowType("ad_exit_app_fullvideo", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        adNew.put("exitAppFullvideo", gson.toJson(adConfig));
        if (!isDPUser)
            adNew.put("exitAppFullvideo", gson.toJson(adConfig));
        //其他广告
@@ -300,6 +321,19 @@
        //注销
        data.put("unRegisterLink", map.get("unregister_link"));
        data.put("aboutUsLink", map.get("about_us_link"));
        data.put("feedBackLink", map.get("feed_back_link"));
        data.put("helpLink", map.get("help_link"));
        //是否正在上线
        boolean onLine = false;
        try {
            onLine = appManager.isOnline(acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel());
        } catch (Exception e) {
        }
        data.put("onLining", onLine);
        out.print(JsonUtil.loadTrueJson(data.toString()));
    }
src/main/java/com/yeshi/buwan/controller/parser/UserParser.java
@@ -15,8 +15,10 @@
import com.yeshi.buwan.dto.search.SolrShortVideoSearchFilter;
import com.yeshi.buwan.dto.search.SolrVideoSearchFilter;
import com.yeshi.buwan.dto.user.LoginInfoDto;
import com.yeshi.buwan.exception.SMSException;
import com.yeshi.buwan.exception.user.LoginUserException;
import com.yeshi.buwan.exception.user.RegisterUserException;
import com.yeshi.buwan.service.inter.SMSService;
import com.yeshi.buwan.videos.pptv.PPTVUtil;
import com.yeshi.buwan.service.imp.*;
import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService;
@@ -95,6 +97,9 @@
    @Resource
    private RedisManager redisManager;
    @Resource
    private SMSService smsService;
    public void getUid(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
@@ -721,7 +726,7 @@
    //新版热门搜索
    public void getHotSearchNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        DetailSystemConfig config = configService.getConfigByKey("hot_search",  acceptData.getDetailSystem(), acceptData.getVersion());
        DetailSystemConfig config = configService.getConfigByKey("hot_search", acceptData.getDetailSystem(), acceptData.getVersion());
        if (config == null) {
            out.print(JsonUtil.loadFalseJson("无内容"));
            return;
@@ -1168,13 +1173,41 @@
            content = title;
        }
        boolean isS = MailSenderUtil.sendEmail(account, "ysyz17784739772@126.com", "weikou2014", title,
        boolean isS = MailSenderUtil.sendEmail(account, "app_yzm_zc@163.com", "KZKSRTEMDWEQRAQR", title,
                content);
        // }
        // }).start();
        out.print(JsonUtil.loadTrueJson("验证码发送成功"));
    }
    public void sendSMSCode(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        String phone = request.getParameter("phone");
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseJson("电话号码不能为空"));
            return;
        }
        if (!StringUtil.isMobile(phone)) {
            out.print(JsonUtil.loadFalseJson("电话号码格式不正确"));
            return;
        }
        try {
            smsService.sendLoginVCode(phone, 6,acceptData.getDetailSystem().getId(),acceptData.getVersion());
        } catch (SMSException e) {
            e.printStackTrace();
            out.print(JsonUtil.loadFalseJson(e.getMessage()));
            return;
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseJson("短信发送出错,请稍后再试"));
            return;
        }
        out.print(JsonUtil.loadTrueJson(""));
    }
    /**
     * 登录
@@ -1213,6 +1246,64 @@
        }
    }
    /**
     * 登录
     *
     * @param request
     * @param out
     */
    public void phoneLogin(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        String account = request.getParameter("phone");// 邮箱
        String vcode = request.getParameter("code");// 密码
        if (StringUtil.isNullOrEmpty(account)) {
            out.print(JsonUtil.loadFalseJson("请上传手机号"));
            return;
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseJson("请上传验证码"));
            return;
        }
        if (!smsService.verifyLoginVCode(account, vcode,acceptData.getDetailSystem().getId(),acceptData.getVersion())) {
            out.print(JsonUtil.loadFalseJson("验证码错误"));
            return;
        }
        LoginInfoDto loginInfoDto = new LoginInfoDto();
        loginInfoDto.setLoginType(LoginUser.LOGIN_TYPE_PHONE);
        loginInfoDto.setSystemId(acceptData.getDetailSystem().getSystem().getId());
        loginInfoDto.setPhone(account);
        loginInfoDto.setSmsCode(vcode);
        loginInfoDto.setIpInfo(IPUtil.getRemotIP(request) + ":" + request.getRemotePort());
        try {
            LoginUser user = userService.login(loginInfoDto);
            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(user)));
        } catch (LoginUserException e) {
            //用户不存在
            if (e.getCode() == LoginUserException.CODE_NO_USER) {
                //注册用户
                try {
                    userService.register(loginInfoDto);
                    //注册成功,开始登录
                    try {
                        LoginUser user = userService.login(loginInfoDto);
                        out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(user)));
                    } catch (LoginUserException e2) {
                        out.print(JsonUtil.loadFalseJson("登录出错,请稍后再试"));
                    }
                } catch (RegisterUserException e1) {
                    e1.printStackTrace();
                    out.print(JsonUtil.loadFalseJson("登录出错,请稍后再试"));
                }
            } else {
                out.print(JsonUtil.loadFalseJson(e.getMessage()));
            }
        }
    }
    /**
     * 更改用户信息
     *
src/main/java/com/yeshi/buwan/dao/system/DetailSystemConfigDao.java
@@ -35,4 +35,10 @@
        return list("from DetailSystemConfig c where c.systemId=? and c.beizhu like ?", new BigInteger( systemId+""), "%" + searchKey + "%");
    }
    public List<DetailSystemConfig> listByValue(Long systemId, String searchKey) {
        return list("from DetailSystemConfig c where c.systemId=? and c.value like ?", new BigInteger( systemId+""), "%" + searchKey + "%");
    }
}
src/main/java/com/yeshi/buwan/dao/user/UserDPContentWatchStatisticDao.java
New file
@@ -0,0 +1,114 @@
package com.yeshi.buwan.dao.user;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Repository;
import java.util.List;
import com.yeshi.buwan.domain.user.UserDPContentWatchStatistic;
import com.yeshi.buwan.dao.base.MongodbBaseDao;
import java.lang.Long;
import java.util.Date;
import java.lang.String;
import java.util.ArrayList;
@Repository
public class UserDPContentWatchStatisticDao extends MongodbBaseDao<UserDPContentWatchStatistic>{
  public void updateSelective(UserDPContentWatchStatistic bean) {
        Query query = new Query();
        Update update=new Update();
        query.addCriteria(Criteria.where("id").is(bean.getId()));
        if(bean.getDetailSystemId() != null) {
            update.set("detailSystemId", bean.getDetailSystemId());
        }
        if(bean.getDevice() != null) {
            update.set("device", bean.getDevice());
        }
        if(bean.getLoginUid() != null) {
            update.set("loginUid", bean.getLoginUid());
        }
        if(bean.getNovelDuration() != null) {
            update.set("novelDuration", bean.getNovelDuration());
        }
        if(bean.getDrawVideoNum() != null) {
            update.set("drawVideoNum", bean.getDrawVideoNum());
        }
        if(bean.getNewsNum() != null) {
            update.set("newsNum", bean.getNewsNum());
        }
        if(bean.getCreateTime() != null) {
            update.set("createTime", bean.getCreateTime());
        }
        update.set("updateTime", new Date());
        update(query, update);
  }
  public List<UserDPContentWatchStatistic> list(DaoQuery daoQuery){
        Query query=getQuery(daoQuery);
        if(daoQuery.sortList!=null&&daoQuery.sortList.size()>0){
            query.with(new Sort(daoQuery.sortList));
        }
        query.skip(daoQuery.start);
        query.limit(daoQuery.count);
        return findList(query);
  }
  public long count(DaoQuery daoQuery){
        Query query=getQuery(daoQuery);
        return count(query);
  }
    private Query getQuery(DaoQuery daoQuery){
          List<Criteria> andList=new ArrayList<>();
               if(daoQuery.detailSystemId!=null){
                    andList.add(Criteria.where("detailSystemId").is(daoQuery.detailSystemId));
               }
               if(daoQuery.device!=null){
                    andList.add(Criteria.where("device").is(daoQuery.device));
               }
               if(daoQuery.loginUid!=null){
                    andList.add(Criteria.where("loginUid").is(daoQuery.loginUid));
               }
               if(daoQuery.novelDuration!=null){
                    andList.add(Criteria.where("novelDuration").is(daoQuery.novelDuration));
               }
               if(daoQuery.drawVideoNum!=null){
                    andList.add(Criteria.where("drawVideoNum").is(daoQuery.drawVideoNum));
               }
               if(daoQuery.newsNum!=null){
                    andList.add(Criteria.where("newsNum").is(daoQuery.newsNum));
               }
               if(daoQuery.minCreateTime!=null){
                    andList.add(Criteria.where("createTime").gte(daoQuery.minCreateTime));
               }
               if(daoQuery.maxCreateTime!=null){
                    andList.add(Criteria.where("createTime").lt(daoQuery.maxCreateTime));
               }
          Query query=new Query();
          Criteria[]  ands=new Criteria[andList.size()];
          andList.toArray(ands);
          if(ands.length>0){
              query.addCriteria(new Criteria().andOperator(ands));
          }
          return query;
    }
  public static class DaoQuery{
        public String detailSystemId;
        public String device;
        public String loginUid;
        public Long novelDuration;
        public Long drawVideoNum;
        public Long newsNum;
        public Date minCreateTime;
        public Date maxCreateTime;
        public int start;
        public int count;
        public List<Sort.Order> sortList;
  }
}
src/main/java/com/yeshi/buwan/domain/user/UserDPContentWatchStatistic.java
New file
@@ -0,0 +1,110 @@
package com.yeshi.buwan.domain.user;
import com.yeshi.buwan.util.StringUtil;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
/**
 * @author hxh
 * @title: UserDPContentWatchStatristic
 * @description: 统计用户DP观看内容
 * @date 2021/12/29 17:49
 */
@Document(collection = "userDPContentWatchStatristic")
public class UserDPContentWatchStatistic {
    @Id
    private String id;
    private String detailSystemId;
    private String device;
    private String loginUid;
    //阅读小说时间
    private Long novelDuration;
    //小视频阅读数量
    private Long drawVideoNum;
    //新闻阅读数量
    private Long newsNum;
    private Date createTime;
    private Date updateTime;
    public static String createId(String detailSystemId, String device) {
        return detailSystemId + "-" + StringUtil.Md5(device);
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getDetailSystemId() {
        return detailSystemId;
    }
    public void setDetailSystemId(String detailSystemId) {
        this.detailSystemId = detailSystemId;
    }
    public String getDevice() {
        return device;
    }
    public void setDevice(String device) {
        this.device = device;
    }
    public String getLoginUid() {
        return loginUid;
    }
    public void setLoginUid(String loginUid) {
        this.loginUid = loginUid;
    }
    public Long getNovelDuration() {
        return novelDuration;
    }
    public void setNovelDuration(Long novelDuration) {
        this.novelDuration = novelDuration;
    }
    public Long getDrawVideoNum() {
        return drawVideoNum;
    }
    public void setDrawVideoNum(Long drawVideoNum) {
        this.drawVideoNum = drawVideoNum;
    }
    public Long getNewsNum() {
        return newsNum;
    }
    public void setNewsNum(Long newsNum) {
        this.newsNum = newsNum;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
src/main/java/com/yeshi/buwan/filter/RequestFilter.java
@@ -25,6 +25,7 @@
        HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
        String contentType = httpRequest.getContentType();
        if (contentType != null && contentType.contains("multipart/form-data")) {
            httpRequest.setCharacterEncoding("UTF-8");
            MultipartResolver resolver = new CommonsMultipartResolver(httpRequest.getSession().getServletContext());
            MultipartHttpServletRequest multipartRequest = resolver.resolveMultipart(httpRequest);
            // 将转化后的 request 放入过滤链中
src/main/java/com/yeshi/buwan/service/imp/DetailSystemConfigService.java
@@ -36,6 +36,10 @@
        return configDao.list(systemId, key);
    }
    public List<DetailSystemConfig> listConfigByValue(Long systemId, String value) {
        return configDao.listByValue(systemId, value);
    }
    @Cacheable(value = "configCache", key = "'getConfigAsMap-'+#system.id+'-'+#version")
    public Map<String, String> getConfigAsMap(DetailSystem system, int version) {
        Map<String, String> map = new HashMap<String, String>();
src/main/java/com/yeshi/buwan/service/imp/SMSServiceImpl.java
@@ -4,6 +4,7 @@
import com.yeshi.buwan.dto.config.TencentSMSConfig;
import com.yeshi.buwan.exception.SMSException;
import com.yeshi.buwan.service.inter.SMSService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import com.yeshi.buwan.util.Constant;
import com.yeshi.buwan.util.RedisKeyEnum;
import com.yeshi.buwan.util.RedisManager;
@@ -19,21 +20,14 @@
    @Resource
    private RedisManager redisManager;
    @Override
    public void sendBindVCode(String uid, String phone, int codeLength) throws SMSException {
        String limitKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLIMIT, uid + "");
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 0);
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(limitKey)))
            throw new SMSException(1001, "请过60秒再试");
    @Resource
    private DetailSystemConfigService detailSystemConfigService;
    private void sendSMSCode(String phone, String msg) throws SMSException {
        String msgCode = StringUtil.getNumberVerifyCode(codeLength);
        TencentSMSConfig tencentSMSConfig = Constant.tencentSMSConfig;
        // 验证码模板
        String msg = tencentSMSConfig.getContentBind().replace("[签名]", tencentSMSConfig.getSign()).replace("[验证码]",
                msgCode);
        SmsSingleSenderResult result = TencentSMSUtil.sendSingleMsg(Integer.parseInt(tencentSMSConfig.getAppId()), tencentSMSConfig.getAppKey(), phone, msg);
        if (result == null)
            throw new SMSException(2, "短信发送失败");
@@ -42,6 +36,23 @@
        } else if (result.result != 0) {// 发送失败
            throw new SMSException(result.result, "短信发送失败");
        }
    }
    @Override
    public void sendBindVCode(String uid, String phone, int codeLength) throws SMSException {
        String limitKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLIMIT, uid + "");
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 0);
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(limitKey)))
            throw new SMSException(1001, "请过60秒再试");
        String msgCode = StringUtil.getNumberVerifyCode(codeLength);
        // 验证码模板
        TencentSMSConfig tencentSMSConfig = Constant.tencentSMSConfig;
        String msg = tencentSMSConfig.getContentBind().replace("[签名]", tencentSMSConfig.getSign()).replace("[验证码]",
                msgCode);
        sendSMSCode(phone, msg);
        //保存验证码
        redisManager.cacheCommonString(key, msgCode, 60 * 5);
        //60s后再发送
@@ -58,4 +69,45 @@
        }
        return false;
    }
    @Override
    public void sendLoginVCode(String phone, int codeLength, String detailSystemId, int version) throws SMSException {
        String limitKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLIMIT, phone);
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 1);
        if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(limitKey)))
            throw new SMSException(1001, "请过60秒再试");
        String msgCode = StringUtil.getNumberVerifyCode(codeLength);
        // 验证码模板
        TencentSMSConfig tencentSMSConfig = Constant.tencentSMSConfig;
        String msg = tencentSMSConfig.getContentBind().replace("[签名]", detailSystemConfigService.getConfigValueByKey("tencent_sms_sign", detailSystemId, version)).replace("[验证码]",
                msgCode);
        sendSMSCode(phone, msg);
        //保存验证码
        redisManager.cacheCommonString(key, msgCode, 60 * 5);
        //60s后再发送
        redisManager.cacheCommonString(limitKey, "1", 60);
    }
    @Override
    public boolean verifyLoginVCode(String phone, String code, String detailSystemId, int version) {
        String value = detailSystemConfigService.getConfigValueByKey("test_phone_account", detailSystemId, version);
//测试账号
        if (value != null) {
            if (phone.equalsIgnoreCase(value.split("#")[0]) && code.equalsIgnoreCase(value.split("#")[1])) {
                return true;
            }
        }
        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSVCode, phone + "-" + 1);
        String cacheCode = redisManager.getCommonString(key);
        if (cacheCode != null && cacheCode.equalsIgnoreCase(code)) {
            redisManager.removeCommonString(key);
            return true;
        }
        return false;
    }
}
src/main/java/com/yeshi/buwan/service/imp/SearchService.java
@@ -448,7 +448,7 @@
            sh.setUser(user);
        }
        searchDao.create(sh);
//        searchDao.create(sh);
        // 查询数据库
        //专辑数量
src/main/java/com/yeshi/buwan/service/imp/UserService.java
@@ -12,6 +12,7 @@
import com.yeshi.buwan.exception.user.LoginUserException;
import com.yeshi.buwan.exception.user.RegisterUserException;
import com.yeshi.buwan.service.inter.LoginUserService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.cache.annotation.Cacheable;
@@ -47,11 +48,22 @@
    @Resource
    private LoginUserService loginUserService;
    @Resource
    private SystemConfigService systemConfigService;
    // 用户操作
    public List<UserInfo> getUserList(int system, int page) {
        return userDao.list("from UserInfo u where u.system.id=? order by u.createtime desc",
                (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{system + ""});
    }
    //设置昵称
    public void setNickName(Long uid, String nickName) {
        LoginUser update = new LoginUser();
        update.setId(uid + "");
        update.setName(nickName);
        loginUserDao.updateSelective(update);
    }
    // 获取用户数量
@@ -344,7 +356,7 @@
                loginUser = new LoginUser();
                loginUser.setLoginType(LoginUser.LOGIN_TYPE_PHONE);
                loginUser.setName(null);
                loginUser.setName(dto.getNickName());
                loginUser.setPhone(dto.getPhone());
                loginUserExtra = new LoginUserExtra();
@@ -366,8 +378,10 @@
        loginUser.setId(uid + "");
        if (StringUtil.isNullOrEmpty(loginUser.getName())) {
            //TODO 昵称前缀
//            systemConfigService.getConfigValueByKeyCache("");
            //设置默认用户昵称
            String nickName = "无名氏";
            String nickName = "ID_" + uid;
            LoginUser update = new LoginUser();
            update.setId(uid + "");
            update.setName(nickName);
src/main/java/com/yeshi/buwan/service/imp/ad/DeviceAdStrategyServiceImpl.java
@@ -3,13 +3,17 @@
import com.yeshi.buwan.dao.ad.DeviceAdStrategyDao;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.ad.DeviceAdStrategy;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.domain.user.UserDPContentWatchStatistic;
import com.yeshi.buwan.service.imp.DetailSystemConfigService;
import com.yeshi.buwan.service.imp.VideoInfoService;
import com.yeshi.buwan.service.inter.ad.DeviceAdStrategyService;
import com.yeshi.buwan.service.inter.user.UserDPContentWatchStatisticService;
import com.yeshi.buwan.service.inter.vip.VIPService;
import com.yeshi.buwan.util.RedisManager;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.TimeUtil;
import com.yeshi.buwan.vo.AcceptData;
import com.yeshi.buwan.vo.video.VideoDetailVO;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
@@ -34,6 +38,9 @@
    @Resource
    private DetailSystemConfigService detailSystemConfigService;
    @Resource
    private UserDPContentWatchStatisticService userDPContentWatchStatisticService;
    private DeviceAdStrategy init(String id, String deviceId, String detailSystemId) {
        DeviceAdStrategy strategy = new DeviceAdStrategy();
@@ -97,7 +104,7 @@
            strategy = init(id, deviceId, detailSystemId);
        }
        long now = System.currentTimeMillis();
        return loadAdWeight(new VideoDetailVO.VideoAdInfo(strategy.getDetailPVAExpireTime() < now, strategy.getDetailFSAExpireTime() < now), detailSystemId, version, channel);
        return filterData(loadAdWeight(new VideoDetailVO.VideoAdInfo(strategy.getDetailPVAExpireTime() < now, strategy.getDetailFSAExpireTime() < now), detailSystemId, version, channel), detailSystemId, deviceId);
    }
@@ -128,7 +135,7 @@
        }
        long now = System.currentTimeMillis();
        return loadAdWeight(new VideoDetailVO.VideoAdInfo(strategy.getDetailShortVideoPVAExpireTime() < now, strategy.getDetailShortVideoFSAExpireTime() < now), detailSystemId, version, channel);
        return filterData(loadAdWeight(new VideoDetailVO.VideoAdInfo(strategy.getDetailShortVideoPVAExpireTime() < now, strategy.getDetailShortVideoFSAExpireTime() < now), detailSystemId, version, channel), detailSystemId, deviceId);
    }
    @Override
@@ -145,9 +152,29 @@
                videoAdInfo.setFullVideo(videoAdInfo.isFullVideo() && shortVideo.isFullVideo());
            }
        }
        return filterData(videoAdInfo, detailSystemId, deviceId);
    }
    private VideoDetailVO.VideoAdInfo filterData(VideoDetailVO.VideoAdInfo videoAdInfo, String detailSystemId, String deviceId) {
        DetailSystem ds = new DetailSystem();
        ds.setId(detailSystemId);
        if (videoAdInfo != null) {
            AcceptData acceptData = new AcceptData();
            acceptData.setUtdId(deviceId);
            acceptData.setDetailSystem(ds);
            boolean isDPUser = userDPContentWatchStatisticService.isDPUser(acceptData);
            if (isDPUser) {
                videoAdInfo.setFullVideo(false);
                videoAdInfo.setPlayVideo(false);
            }
        }
        return videoAdInfo;
    }
    @Override
    public void setVideoDetailAdStrategy(String deviceId, String detailSystemId, Long fsaExpireTime, Long pvaExpireTime) {
        if (StringUtil.isNullOrEmpty(deviceId) || StringUtil.isNullOrEmpty(detailSystemId)) {
src/main/java/com/yeshi/buwan/service/imp/user/UserDPContentWatchStatisticServiceImpl.java
New file
@@ -0,0 +1,166 @@
package com.yeshi.buwan.service.imp.user;
import com.yeshi.buwan.dao.user.UserDPContentWatchStatisticDao;
import com.yeshi.buwan.domain.user.UserDPContentWatchStatistic;
import com.yeshi.buwan.service.inter.user.UserDPContentWatchStatisticService;
import com.yeshi.buwan.util.RedisManager;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.TimeUtil;
import com.yeshi.buwan.vo.AcceptData;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
/**
 * @author hxh
 * @title: UserDPContentWatchStatisticServiceImpl
 * @description: TODO
 * @date 2021/12/29 18:04
 */
@Service
public class UserDPContentWatchStatisticServiceImpl implements UserDPContentWatchStatisticService {
    @Resource
    private UserDPContentWatchStatisticDao userDPContentWatchStatisticDao;
    @Resource
    private RedisManager redisManager;
    private String getRedisKeyPrefix(AcceptData acceptData) {
        return String.format("dpevent-%s-", getIdentityId(acceptData));
    }
    private UserDPContentWatchStatistic getBaseBean(AcceptData acceptData, String loginUid) {
        UserDPContentWatchStatistic statistic = new UserDPContentWatchStatistic();
        statistic.setId(getIdentityId(acceptData));
        statistic.setDetailSystemId(acceptData.getDetailSystem().getId());
        String device = acceptData.getUtdId();
        if (StringUtil.isNullOrEmpty(device)) {
            device = acceptData.getDevice();
        }
        statistic.setDevice(device);
        statistic.setLoginUid(loginUid);
        return statistic;
    }
    //增加小说阅读时长
    private void addNovelDuration(AcceptData acceptData, String loginUid, long ds) {
        UserDPContentWatchStatistic statistic = getBaseBean(acceptData, loginUid);
        UserDPContentWatchStatistic old = userDPContentWatchStatisticDao.get(statistic.getId());
        if (old == null) {
            statistic.setNovelDuration(ds);
            statistic.setCreateTime(new Date());
            userDPContentWatchStatisticDao.save(statistic);
        } else {
            if (old.getNovelDuration() == null) {
                statistic.setNovelDuration(ds);
            } else {
                statistic.setNovelDuration(ds + old.getNovelDuration());
            }
            userDPContentWatchStatisticDao.updateSelective(statistic);
        }
    }
    @Override
    public void readNovel(AcceptData acceptData, long duration, String loginUid) {
        long ds = duration / 1000;
        //获取今日是否已经上传了
        String key = getRedisKeyPrefix(acceptData) + "novel-" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd");
        String old = redisManager.getCommonString(key);
        if (StringUtil.isNullOrEmpty(old)) {
            //增加阅读时长
            addNovelDuration(acceptData, loginUid, ds);
            //今日首次添加
            redisManager.cacheCommonString(key, ds + "", 60 * 60 * 24);
        } else {
            //不是今日首次添加
            if (ds - Long.parseLong(old) > 0) {
                addNovelDuration(acceptData, loginUid, ds - Long.parseLong(old));
                //增加阅读时长
                redisManager.cacheCommonString(key, ds + "", 60 * 60 * 24);
            }
        }
    }
    @Override
    public void playDrawVideo(AcceptData acceptData, String loginUid) {
        UserDPContentWatchStatistic statistic = getBaseBean(acceptData, loginUid);
        UserDPContentWatchStatistic old = userDPContentWatchStatisticDao.get(statistic.getId());
        if (old == null) {
            statistic.setCreateTime(new Date());
            statistic.setDrawVideoNum(1L);
            userDPContentWatchStatisticDao.save(statistic);
        } else {
            if (old.getDrawVideoNum() == null) {
                statistic.setDrawVideoNum(1L);
            } else {
                statistic.setDrawVideoNum(1L + old.getDrawVideoNum());
            }
            userDPContentWatchStatisticDao.updateSelective(statistic);
        }
    }
    @Override
    public void readNews(AcceptData acceptData, String loginUid) {
        UserDPContentWatchStatistic statistic = getBaseBean(acceptData, loginUid);
        UserDPContentWatchStatistic old = userDPContentWatchStatisticDao.get(statistic.getId());
        if (old == null) {
            statistic.setCreateTime(new Date());
            statistic.setNewsNum(1L);
            userDPContentWatchStatisticDao.save(statistic);
        } else {
            if (old.getNewsNum() == null) {
                statistic.setNewsNum(1L);
            } else {
                statistic.setNewsNum(1L + old.getNewsNum());
            }
            userDPContentWatchStatisticDao.updateSelective(statistic);
        }
    }
    @Override
    public String getIdentityId(AcceptData acceptData) {
        String device = acceptData.getUtdId();
        if (StringUtil.isNullOrEmpty(device)) {
            device = acceptData.getDevice();
        }
        if (StringUtil.isNullOrEmpty(device)) {
            return null;
        }
        return UserDPContentWatchStatistic.createId(acceptData.getDetailSystem().getId(), device);
    }
    @Override
    public boolean isDPUser(AcceptData acceptData) {
        String id = getIdentityId(acceptData);
        if (StringUtil.isNullOrEmpty(id)) {
            return false;
        }
        UserDPContentWatchStatistic bean = userDPContentWatchStatisticDao.get(id);
        if (bean == null) {
            return false;
        }
        //新闻阅读数量
        if (bean.getNewsNum() != null && bean.getNewsNum() >=1) {
            return true;
        }
        //短视频阅读数量
        if (bean.getDrawVideoNum() != null && bean.getDrawVideoNum() >= 5) {
            return true;
        }
        //小说阅读数量
        if (bean.getNovelDuration() != null && bean.getNovelDuration() >= 60) {
            return true;
        }
        return false;
    }
}
src/main/java/com/yeshi/buwan/service/inter/SMSService.java
@@ -22,4 +22,26 @@
     * @return
     */
    public boolean verifyBindVCode(String phone, String code);
    /**
     * @return void
     * @author hxh
     * @description 发送登录验证码
     * @date 11:33 2022/1/13
     * @param: phone
     * @param: codeLength
     **/
    public void sendLoginVCode(String phone, int codeLength,String detailSystemId,int version) throws SMSException;
    /**
     * @return boolean
     * @author hxh
     * @description /验证登录验证码
     * @date 11:33 2022/1/13
     * @param: phone
     * @param: code
     **/
    public boolean verifyLoginVCode(String phone, String code,String detailSystemId,int version);
}
src/main/java/com/yeshi/buwan/service/inter/user/UserDPContentWatchStatisticService.java
New file
@@ -0,0 +1,54 @@
package com.yeshi.buwan.service.inter.user;
import com.yeshi.buwan.vo.AcceptData;
/**
 * @author hxh
 * @title: UserDPContentWatchStatisticService
 * @description: TODO
 * @date 2021/12/29 18:03
 */
public interface UserDPContentWatchStatisticService {
    /**
     * @return void
     * @author hxh
     * @description 阅读小说
     * @date 18:06 2021/12/29
     * @param: acceptData
     * @param: duration
     **/
    public void readNovel(AcceptData acceptData, long duration, String loginUid);
    /**
     * @return void
     * @author hxh
     * @description 观看视频
     * @date 18:07 2021/12/29
     * @param: acceptData
     **/
    public void playDrawVideo(AcceptData acceptData, String loginUid);
    /**
     * @return void
     * @author hxh
     * @description 阅读新闻
     * @date 18:08 2021/12/29
     * @param: acceptData
     **/
    public void readNews(AcceptData acceptData, String loginUid);
    public String getIdentityId(AcceptData acceptData);
    /**
     * @author hxh
     * @description 是否为看内容的用户
     * @date 18:40 2021/12/29
     * @param: acceptData
     * @return boolean
     **/
    public boolean isDPUser(AcceptData acceptData);
}
src/main/java/com/yeshi/buwan/util/FileUtil.java
@@ -13,10 +13,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -34,403 +31,408 @@
//文件处理
@Entity
public class FileUtil {
    public final static int TYPE_PICTURE_CLASS = 1;// 分类图标文件夹
    public final static int TYPE_PICTURE_HOME_AD = 2;// 广告图片
    public final static int TYPE_PICTURE_VIDEO = 3;// 视频图片文件
    public final static int TYPE_PICTURE_STAR = 4;// 明星头像
    @Id
    @GeneratedValue
    public final static int TYPE_VIDEO = 5;// 视频文件
    public final static String PROJECT_NAME = "BuWan";
    public final static int TYPE_PICTURE_CLASS = 1;// 分类图标文件夹
    public final static int TYPE_PICTURE_HOME_AD = 2;// 广告图片
    public final static int TYPE_PICTURE_VIDEO = 3;// 视频图片文件
    public final static int TYPE_PICTURE_STAR = 4;// 明星头像
    @Id
    @GeneratedValue
    public final static int TYPE_VIDEO = 5;// 视频文件
    public final static String PROJECT_NAME = "BuWan";
    /**
     * 上传头像
     *
     * @param type
     * @param request
     * @return
     */
    public List<String> getFile(int type, HttpServletRequest request) throws Exception {
        List<String> resltList = new ArrayList<String>();
        DiskFileItemFactory factory = new DiskFileItemFactory();
        // 获取文件需要上传到的路径
        String path = request.getRealPath("/upload");
    /**
     * 上传头像
     *
     * @param type
     * @param request
     * @return
     */
    public List<String> getFile(int type, HttpServletRequest request) throws Exception {
        List<String> resltList = new ArrayList<String>();
        DiskFileItemFactory factory = new DiskFileItemFactory();
        // 获取文件需要上传到的路径
        String path = request.getRealPath("/upload");
        // 如果没以下两行设置的话,上传大的 文件 会占用 很多内存,
        // 设置暂时存放的 存储室 , 这个存储室,可以和 最终存储文件 的目录不同
        /**
         * 原理 它是先存到 暂时存储室,然后在真正写到 对应目录的硬盘上, 按理来说 当上传一个文件时,其实是上传了两份,第一个是以 .tem
         * 格式的 然后再将其真正写到 对应目录的硬盘上
         */
        factory.setRepository(new File(path));
        // 设置 缓存的大小,当上传文件的容量超过该缓存时,直接放到 暂时存储室
        factory.setSizeThreshold(1024 * 1024);
        // 如果没以下两行设置的话,上传大的 文件 会占用 很多内存,
        // 设置暂时存放的 存储室 , 这个存储室,可以和 最终存储文件 的目录不同
        /**
         * 原理 它是先存到 暂时存储室,然后在真正写到 对应目录的硬盘上, 按理来说 当上传一个文件时,其实是上传了两份,第一个是以 .tem
         * 格式的 然后再将其真正写到 对应目录的硬盘上
         */
        factory.setRepository(new File(path));
        // 设置 缓存的大小,当上传文件的容量超过该缓存时,直接放到 暂时存储室
        factory.setSizeThreshold(1024 * 1024);
        // 高水平的API文件上传处理
        ServletFileUpload upload = new ServletFileUpload(factory);
        // 高水平的API文件上传处理
        ServletFileUpload upload = new ServletFileUpload(factory);
        try {
            // 可以上传多个文件
            List<FileItem> list = (List<FileItem>) upload.parseRequest(request);
        try {
            // 可以上传多个文件
            List<FileItem> list = (List<FileItem>) upload.parseRequest(request);
            for (FileItem item : list) {
                // 获取表单的属性名字
                String name = item.getFieldName();
            for (FileItem item : list) {
                // 获取表单的属性名字
                String name = item.getFieldName();
                // 如果获取的 表单信息是普通的 文本 信息
                if (item.isFormField()) {
                // 如果获取的 表单信息是普通的 文本 信息
                if (item.isFormField()) {
                }
                // 对传入的非 简单的字符串进行处理 ,比如说二进制的 图片,电影这些
                else {
                    /**
                     * 以下三步,主要获取 上传文件的名字
                     */
                    // 获取路径名
                    String value = item.getName();
                    // 索引到最后一个反斜杠
                    int start = value.lastIndexOf("\\");
                    // 截取 上传文件的 字符串名字,加1是 去掉反斜杠,
                    String filename = value.substring(start + 1);
                }
                // 对传入的非 简单的字符串进行处理 ,比如说二进制的 图片,电影这些
                else {
                    /**
                     * 以下三步,主要获取 上传文件的名字
                     */
                    // 获取路径名
                    String value = item.getName();
                    // 索引到最后一个反斜杠
                    int start = value.lastIndexOf("\\");
                    // 截取 上传文件的 字符串名字,加1是 去掉反斜杠,
                    String filename = value.substring(start + 1);
                    request.setAttribute(name, filename);
                    request.setAttribute(name, filename);
                    File file = new File(path);
                    File file = new File(path);
                    if (!file.exists())
                        file.mkdirs();
                    if (!file.exists())
                        file.mkdirs();
                    File f = new File(createFile(type, path), filename);
                    File f = new File(createFile(type, path), filename);
                    resltList.add(f.getPath().split("webapps")[1]);
                    resltList.add(f.getPath().split("webapps")[1]);
                    OutputStream out = new FileOutputStream(f);
                    OutputStream out = new FileOutputStream(f);
                    InputStream in = item.getInputStream();
                    InputStream in = item.getInputStream();
                    int length = 0;
                    byte[] buf = new byte[1024];
                    int length = 0;
                    byte[] buf = new byte[1024];
                    LogUtil.i("获取上传文件的总共的容量:" + item.getSize());
                    LogUtil.i("获取上传文件的总共的容量:" + item.getSize());
                    // in.read(buf) 每次读到的数据存放在 buf 数组中
                    while ((length = in.read(buf)) != -1) {
                        // 在 buf 数组中 取出数据 写到 (输出流)磁盘上
                        out.write(buf, 0, length);
                    }
                    // in.read(buf) 每次读到的数据存放在 buf 数组中
                    while ((length = in.read(buf)) != -1) {
                        // 在 buf 数组中 取出数据 写到 (输出流)磁盘上
                        out.write(buf, 0, length);
                    }
                    in.close();
                    out.close();
                }
            }
                    in.close();
                    out.close();
                }
            }
        } catch (FileUploadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return resltList;
    }
        } catch (FileUploadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return resltList;
    }
    public Map<String, String> getTextAndFile(int type, HttpServletRequest request) throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        DiskFileItemFactory factory = new DiskFileItemFactory();
    public Map<String, String> getTextAndFile(int type, HttpServletRequest request) throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        DiskFileItemFactory factory = new DiskFileItemFactory();
        // 获取文件需要上传到的路径
        String path = request.getRealPath("/upload");
        // 获取文件需要上传到的路径
        String path = request.getRealPath("/upload");
        // 如果没以下两行设置的话,上传大的 文件 会占用 很多内存,
        // 设置暂时存放的 存储室 , 这个存储室,可以和 最终存储文件 的目录不同
        /**
         * 原理 它是先存到 暂时存储室,然后在真正写到 对应目录的硬盘上, 按理来说 当上传一个文件时,其实是上传了两份,第一个是以 .tem
         * 格式的 然后再将其真正写到 对应目录的硬盘上
         */
        factory.setRepository(new File(path));
        // 设置 缓存的大小,当上传文件的容量超过该缓存时,直接放到 暂时存储室
        factory.setSizeThreshold(1024 * 1024);
        // 如果没以下两行设置的话,上传大的 文件 会占用 很多内存,
        // 设置暂时存放的 存储室 , 这个存储室,可以和 最终存储文件 的目录不同
        /**
         * 原理 它是先存到 暂时存储室,然后在真正写到 对应目录的硬盘上, 按理来说 当上传一个文件时,其实是上传了两份,第一个是以 .tem
         * 格式的 然后再将其真正写到 对应目录的硬盘上
         */
        factory.setRepository(new File(path));
        // 设置 缓存的大小,当上传文件的容量超过该缓存时,直接放到 暂时存储室
        factory.setSizeThreshold(1024 * 1024);
        // 高水平的API文件上传处理
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setHeaderEncoding("UTF-8");
        // 高水平的API文件上传处理
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setHeaderEncoding("UTF-8");
        // 可以上传多个文件
        List<FileItem> list = (List<FileItem>) upload.parseRequest(request);
        for (FileItem item : list) {
            // 获取表单的属性名字
            String name = item.getFieldName();
        // 可以上传多个文件
        List<FileItem> list = (List<FileItem>) upload.parseRequest(request);
        for (FileItem item : list) {
            // 获取表单的属性名字
            String name = item.getFieldName();
            // 如果获取的 表单信息是普通的 文本 信息
            if (item.isFormField()) {
                // String value = new String(item.getString().getBytes(),
                // "UTF-8");
                map.put(name, item.getString("UTF-8"));
            }
            // 对传入的非 简单的字符串进行处理 ,比如说二进制的 图片,电影这些
            else {
                /**
                 * 以下三步,主要获取 上传文件的名字
                 */
                // 获取路径名
                String value = item.getName();
                if (StringUtil.isNullOrEmpty(value))
                    continue;
                // 索引到最后一个反斜杠
                int start = value.lastIndexOf("\\");
                // .需要转义
                String end = value.split("\\.")[1];
                // 截取 上传文件的 字符串名字,加1是 去掉反斜杠,
                String filename = "";
                if (value.contains(".") && value.length() > 2) {
                    filename = System.currentTimeMillis() + (int) (Math.random() * 10000) + "." + end;
                    request.setAttribute(name, filename);
                }
                File file = new File(path);
            // 如果获取的 表单信息是普通的 文本 信息
            if (item.isFormField()) {
                // String value = new String(item.getString().getBytes(),
                // "UTF-8");
                map.put(name, item.getString("UTF-8"));
            }
            // 对传入的非 简单的字符串进行处理 ,比如说二进制的 图片,电影这些
            else {
                /**
                 * 以下三步,主要获取 上传文件的名字
                 */
                // 获取路径名
                String value = item.getName();
                if (StringUtil.isNullOrEmpty(value))
                    continue;
                // 索引到最后一个反斜杠
                int start = value.lastIndexOf("\\");
                // .需要转义
                String end = value.split("\\.")[1];
                // 截取 上传文件的 字符串名字,加1是 去掉反斜杠,
                String filename = "";
                if (value.contains(".") && value.length() > 2) {
                    filename = System.currentTimeMillis() + (int) (Math.random() * 10000) + "." + end;
                    request.setAttribute(name, filename);
                }
                File file = new File(path);
                if (!file.exists())
                    file.mkdirs();
                if (!file.exists())
                    file.mkdirs();
                String createFile = createFile(type, path);
                File f = new File(createFile, filename);
                String createFile = createFile(type, path);
                File f = new File(createFile, filename);
                String fileName = createFile.split(PROJECT_NAME)[1] + File.separator + filename;
                fileName = fileName.replace("\\", "/");
                map.put(name, fileName);
                String fileName = createFile.split(PROJECT_NAME)[1] + File.separator + filename;
                fileName = fileName.replace("\\", "/");
                map.put(name, fileName);
                OutputStream out = new FileOutputStream(f);
                OutputStream out = new FileOutputStream(f);
                InputStream in = item.getInputStream();
                InputStream in = item.getInputStream();
                int length = 0;
                byte[] buf = new byte[1024];
                int length = 0;
                byte[] buf = new byte[1024];
                LogUtil.i("获取上传文件的总共的容量:" + item.getSize());
                LogUtil.i("获取上传文件的总共的容量:" + item.getSize());
                // in.read(buf) 每次读到的数据存放在 buf 数组中
                while ((length = in.read(buf)) != -1) {
                    // 在 buf 数组中 取出数据 写到 (输出流)磁盘上
                    out.write(buf, 0, length);
                }
                // in.read(buf) 每次读到的数据存放在 buf 数组中
                while ((length = in.read(buf)) != -1) {
                    // 在 buf 数组中 取出数据 写到 (输出流)磁盘上
                    out.write(buf, 0, length);
                }
                in.close();
                out.close();
            }
        }
                in.close();
                out.close();
            }
        }
        return map;
    }
        return map;
    }
    // 创建文件夹
    private String createFile(int type, String path) {
        if (type == TYPE_PICTURE_CLASS)// 分类图片
        {
            File f = new File(path, "class");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_PICTURE_HOME_AD)// 首页广告图片
        {
            File f = new File(path, "ad");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_PICTURE_STAR)// 明星头像
        {
            File ff = new File(path, "star");
            if (!ff.exists())
                ff.mkdirs();
            File f = new File(ff.getPath(), "picture");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_PICTURE_VIDEO)// 视频封面
        {
            File ff = new File(path, "juhe");
            if (!ff.exists())
                ff.mkdirs();
            File f = new File(ff.getPath(), "picture");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_VIDEO)// 视频封面
        {
            File ff = new File(path, "juhe");
            if (!ff.exists())
                ff.mkdirs();
            File f = new File(ff.getPath(), "juhe");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        }
        return "";
    // 创建文件夹
    private String createFile(int type, String path) {
        if (type == TYPE_PICTURE_CLASS)// 分类图片
        {
            File f = new File(path, "class");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_PICTURE_HOME_AD)// 首页广告图片
        {
            File f = new File(path, "ad");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_PICTURE_STAR)// 明星头像
        {
            File ff = new File(path, "star");
            if (!ff.exists())
                ff.mkdirs();
            File f = new File(ff.getPath(), "picture");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_PICTURE_VIDEO)// 视频封面
        {
            File ff = new File(path, "juhe");
            if (!ff.exists())
                ff.mkdirs();
            File f = new File(ff.getPath(), "picture");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else if (type == TYPE_VIDEO)// 视频封面
        {
            File ff = new File(path, "juhe");
            if (!ff.exists())
                ff.mkdirs();
            File f = new File(ff.getPath(), "juhe");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        }
        return "";
    }
    }
    public static String getAbsolutePathWithProjectName(HttpServletRequest request, String path) {
        return "http://" + request.getLocalAddr() + ":" + request.getLocalPort() + path;
    }
    public static String getAbsolutePathWithProjectName(HttpServletRequest request, String path) {
        return "http://" + request.getLocalAddr() + ":" + request.getLocalPort() + path;
    }
    public static void downFile(String urlStr, String filePath) throws MalformedURLException {
        // 下载网络文件
        int bytesum = 0;
        int byteread = 0;
    public static void downFile(String urlStr, String filePath) throws MalformedURLException {
        // 下载网络文件
        int bytesum = 0;
        int byteread = 0;
        URL url = new URL(urlStr);
        URL url = new URL(urlStr);
        try {
            URLConnection conn = url.openConnection();
            InputStream inStream = conn.getInputStream();
            FileOutputStream fs = new FileOutputStream(filePath);
        try {
            URLConnection conn = url.openConnection();
            InputStream inStream = conn.getInputStream();
            FileOutputStream fs = new FileOutputStream(filePath);
            byte[] buffer = new byte[1204];
            while ((byteread = inStream.read(buffer)) != -1) {
                bytesum += byteread;
                LogUtil.i(bytesum);
                fs.write(buffer, 0, byteread);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
            byte[] buffer = new byte[1204];
            while ((byteread = inStream.read(buffer)) != -1) {
                bytesum += byteread;
                LogUtil.i(bytesum);
                fs.write(buffer, 0, byteread);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    // 复制文件
    public static boolean copyFile(String fileFrom, String fileTo) {
        try {
            File f = new File(fileTo);
            if (!f.exists())
                f.createNewFile();
    // 复制文件
    public static boolean copyFile(String fileFrom, String fileTo) {
        try {
            File f = new File(fileTo);
            if (!f.exists())
                f.createNewFile();
            FileInputStream in = new java.io.FileInputStream(fileFrom);
            FileOutputStream out = new FileOutputStream(fileTo);
            byte[] bt = new byte[1024];
            int count;
            while ((count = in.read(bt)) > 0) {
                out.write(bt, 0, count);
            }
            in.close();
            out.close();
            return true;
        } catch (IOException ex) {
            return false;
        }
    }
            FileInputStream in = new java.io.FileInputStream(fileFrom);
            FileOutputStream out = new FileOutputStream(fileTo);
            byte[] bt = new byte[1024];
            int count;
            while ((count = in.read(bt)) > 0) {
                out.write(bt, 0, count);
            }
            in.close();
            out.close();
            return true;
        } catch (IOException ex) {
            return false;
        }
    }
    public static boolean save(String ht, String path) throws IOException {
        try {
            File f = new File(path);
            if (!f.exists())
                f.createNewFile();
            FileWriter writer;
            writer = new FileWriter(path);
            writer.write(ht);
            writer.flush();
            writer.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    public static boolean save(String ht, String path) throws IOException {
        try {
            File f = new File(path);
            if (!f.exists())
                f.createNewFile();
            FileWriter writer;
            writer = new FileWriter(path);
            writer.write(ht);
            writer.flush();
            writer.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    public static List<FileName> reNameFile(String dir, String path) {
        if (dir.endsWith("/"))
            dir = dir.substring(0, dir.length() - 1);
        VideoManager manager = new VideoManager();
        List<FileName> list = new ArrayList<FileName>();
        if (!StringUtil.isNullOrEmpty(dir))
            if (StringUtil.isNullOrEmpty(path)) {// 获取文件夹下面的所有文件
                File f = new File(dir);
                File[] fileList = f.listFiles();
                if (fileList.length > 0) {
                    String[] sts = fileList[0].getPath().split("\\.");
    public static List<FileName> reNameFile(String dir, String path) {
        if (dir.endsWith("/"))
            dir = dir.substring(0, dir.length() - 1);
        VideoManager manager = new VideoManager();
        List<FileName> list = new ArrayList<FileName>();
        if (!StringUtil.isNullOrEmpty(dir))
            if (StringUtil.isNullOrEmpty(path)) {// 获取文件夹下面的所有文件
                File f = new File(dir);
                File[] fileList = f.listFiles();
                if (fileList.length > 0) {
                    String[] sts = fileList[0].getPath().split("\\.");
                    for (int i = 0; i < fileList.length; i++) {
                        String[] files = fileList[i].getPath().split("/");
                        FileName name = new FileName();
                        name.setNewName(
                                dir + "/" + manager.getVideoPathName(sts[sts.length - 1], files[files.length - 1]));
                        name.setOldName(files[files.length - 1]);
                        list.add(name);
                        fileList[i].renameTo(new File(list.get(i).getNewName()));
                        LogUtil.i(name.getOldName());
                        LogUtil.i(name.getNewName());
                    }
                }
            } else {// 获取某一个文件
                String[] sts = path.split("\\.");
                String newPath = dir + "/" + manager.getVideoPathName(sts[sts.length - 1], path);
                new File(dir + "/" + path).renameTo(new File(newPath));
                FileName name = new FileName();
                name.setNewName(newPath);
                name.setOldName(path);
                list.add(name);
            }
        return list;
    }
                    for (int i = 0; i < fileList.length; i++) {
                        String[] files = fileList[i].getPath().split("/");
                        FileName name = new FileName();
                        name.setNewName(
                                dir + "/" + manager.getVideoPathName(sts[sts.length - 1], files[files.length - 1]));
                        name.setOldName(files[files.length - 1]);
                        list.add(name);
                        fileList[i].renameTo(new File(list.get(i).getNewName()));
                        LogUtil.i(name.getOldName());
                        LogUtil.i(name.getNewName());
                    }
                }
            } else {// 获取某一个文件
                String[] sts = path.split("\\.");
                String newPath = dir + "/" + manager.getVideoPathName(sts[sts.length - 1], path);
                new File(dir + "/" + path).renameTo(new File(newPath));
                FileName name = new FileName();
                name.setNewName(newPath);
                name.setOldName(path);
                list.add(name);
            }
        return list;
    }
    public static List<String> readText(String filepath) throws IOException {
        List<String> list = new ArrayList<String>();
        // String path = "C:/Users/Administrator/Desktop/乐视云/1234.txt";// 相对路径
        File filename = new File(filepath);
        BufferedReader bufread = new BufferedReader(new FileReader(filename));
        String read;
        while ((read = bufread.readLine()) != null) {
            LogUtil.i(read);
            list.add(read);
            // readStr = (readStr + read);
        }
        // LogUtil.i("读取配置文件信息:" + readStr);
        return list;
    }
    public static List<String> readText(String filepath) throws IOException {
        List<String> list = new ArrayList<String>();
        // String path = "C:/Users/Administrator/Desktop/乐视云/1234.txt";// 相对路径
        File filename = new File(filepath);
        BufferedReader bufread = new BufferedReader(new FileReader(filename));
        String read;
        while ((read = bufread.readLine()) != null) {
            LogUtil.i(read);
            list.add(read);
            // readStr = (readStr + read);
        }
        // LogUtil.i("读取配置文件信息:" + readStr);
        return list;
    }
    public static String readTxt(String filepath) throws IOException {
        String result = "";
        File filename = new File(filepath);
        BufferedReader bufread = new BufferedReader(new FileReader(filename));
        String read;
        while ((read = bufread.readLine()) != null) {
            LogUtil.i(read);
            result += read;
            // readStr = (readStr + read);
        }
        // LogUtil.i("读取配置文件信息:" + readStr);
        return result;
    }
    public static String readTxt(String filepath) throws IOException {
        String result = "";
        File filename = new File(filepath);
        BufferedReader bufread = new BufferedReader(new FileReader(filename));
        String read;
        while ((read = bufread.readLine()) != null) {
            LogUtil.i(read);
            result += read;
            // readStr = (readStr + read);
        }
        // LogUtil.i("读取配置文件信息:" + readStr);
        return result;
    }
    public static String saveAsFile(InputStream inputStream, String path) throws IOException {
        if (!new File(path).exists()) {
            new File(path).createNewFile();
        }
    public static String saveAsFile(InputStream inputStream, String path) throws IOException {
        if (!new File(path).exists()) {
            new File(path).createNewFile();
        }
        FileOutputStream fileOut = new FileOutputStream(new File(path));
        byte[] buf = new byte[1024 * 8];
        while (true) {
            int read = 0;
            if (inputStream != null) {
                read = inputStream.read(buf);
            }
            if (read == -1) {
                break;
            }
            fileOut.write(buf, 0, read);
        }
        fileOut.close();
        return path;
    }
        FileOutputStream fileOut = new FileOutputStream(new File(path));
        byte[] buf = new byte[1024 * 8];
        while (true) {
            int read = 0;
            if (inputStream != null) {
                read = inputStream.read(buf);
            }
            if (read == -1) {
                break;
            }
            fileOut.write(buf, 0, read);
        }
        fileOut.close();
        return path;
    }
    public static String getCacheDir() {
    public static String getCacheDir() {
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            File f = new File("D:/cache");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else {
            File f = new File("/usr/local/cache");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        }
    }
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            File f = new File("D:/cache");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        } else {
            File f = new File("/usr/local/cache");
            if (!f.exists())
                f.mkdirs();
            return f.getPath();
        }
    }
}
src/main/java/com/yeshi/buwan/util/JuHe/VideoResourceUtil.java
@@ -27,6 +27,8 @@
////            ridList.add("24");
//            ridList.add("25");
//        }
        ridList.remove(25+"");
        ridList.remove(28+"");
        List<Long> ids = new ArrayList<>();
        if (ridList != null) {
            for (String id : ridList) {
src/main/java/com/yeshi/buwan/util/video/VideoDetailUtil.java
@@ -374,16 +374,17 @@
            //韩剧
            if ("48".equalsIgnoreCase(acceptData.getDetailSystem().getId())) {
                //正在上线
                if (appManager.isOnline(acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel())) {
                    //需要原生播放器
                    if (oldId != null && oldId.startsWith("native_")) {
                        if (playUrl.getPlayType() == 1) {
                            //原生播放器播放
                            playUrl.setPlayType(2);
                            playUrl.setUrl("https://jx.parwix.com:4433/player/?url=" + playUrl.getUrl());
                        }
                    }
                }
                //TODO 上线的时候开启,防止误操作
//                if (appManager.isOnline(acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel())) {
//                    //需要原生播放器
//                    if (oldId != null && oldId.startsWith("native_")) {
//                        if (playUrl.getPlayType() == 1) {
//                            //原生播放器播放
//                            playUrl.setPlayType(2);
//                            playUrl.setUrl("https://jx.parwix.com:4433/player/?url=" + playUrl.getUrl());
//                        }
//                    }
//                }
            }
        }
src/main/resources/consumer.xml
@@ -15,4 +15,7 @@
    <dubbo:annotation package="com"/>
</beans>
src/main/resources/env-pro/kafka_log.properties
@@ -1,6 +1,7 @@
log.config.kafka.isSend=true
log.config.kafka.bootstrapServers= 172.16.16.38:9092,172.16.16.38:9093,172.16.16.38:9094
log.config.kafka.topic=    log_buwan_search_key
log.config.kafka.bootstrapServers=172.16.16.38:9092,172.16.16.38:9093,172.16.16.38:9094
log.config.kafka.topic=log_buwan_search_key
log.config.kafka.topic_dp=log_buwan_dp_watch
log.config.kafka.batchSize=5
log.config.kafka.lingerMs=1000
log.config.kafka.compressionType=gzip
src/main/resources/env-pro/logback.xml
@@ -201,6 +201,29 @@
    </appender>
    <appender name="KAFKA_DP_LOG" class="com.yeshi.buwan.log.KafkaAppender">
        <!-- encoder必须配置, 日志格式 -->
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <!--<pattern>-->
            <!--%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %highlight(%-5level) %green([%thread]) %boldMagenta(%logger{10}) - %cyan(%msg%n)-->
            <!--</pattern>-->
            <!--为了便于分析将日志数据转为json格式-->
            <pattern>${log.pattern}</pattern>
            <!-- 控制台也要使用UTF-8,不要使用GBK,否则会中文乱码 -->
            <charset>UTF-8</charset>
        </encoder>
        <bootstrapServers>${log.config.kafka.bootstrapServers}</bootstrapServers>
        <topic>${log.config.kafka.topic_dp}</topic>
        <batchSize>${log.config.kafka.batchSize}</batchSize>
        <lingerMs>${log.config.kafka.lingerMs}</lingerMs>
        <compressionType>${log.config.kafka.compressionType}</compressionType>
        <retries>${log.config.kafka.retries}</retries>
        <maxRequestSize>${log.config.kafka.maxRequestSize}</maxRequestSize>
        <isSend>${log.config.kafka.isSend}</isSend>
    </appender>
    <!--name表示为哪一个logger指定层级和输出的方式
       additivity表示叠加祖先的输出方式(默认为true,会叠加),所以com.lxc.o2o以及其子类都会输出在控制台中,因为这个logger继承了root中的appender
       level表示级别大于等于${log.level}的信息才会输出,输出方式为配置的appender,
@@ -319,6 +342,9 @@
        <appender-ref ref="KAFKA_APPLE_PAY"></appender-ref>
    </logger>
    <logger name="com.yeshi.buwan.controller.api.ClientEventController" level="INFO" additivity="false">
        <appender-ref ref="KAFKA_DP_LOG"></appender-ref>
    </logger>
src/main/webapp/admin/new/fenqu.html
@@ -762,17 +762,11 @@
                        shade: 0.8,
                        area: ['400px', '300px'],
                        yes: function (index) {
                            var arr = new Array();
                            $(".check-item:checked").each(function () {
                                var vid = $(this).attr("key");
                                arr.push(vid);
                            });
                            if (arr.length == 0) {
                                layer.msg("请先选择数据");
                                return false;
                            }
                            var ids = getCheckedItems();
                            if (ids.length < 1)
                                layer.msg("未选择视频");
                            var type = $("#dialog-chooselink .addType option:selected").val();
                            addTop(arr, type);
                            addTop(ids, type);
                            layer.close(index);
                            $(".check-item").prop("checked", false);
                        },
@@ -861,6 +855,7 @@
    });
    function addTop(arr, tid) {
        console.log("选中的视频ID:",arr);
        $.ajax({
            type: "post",
            url: "api/top/addTop",
src/main/webapp/admin/new/systemcanshu.html
@@ -30,6 +30,13 @@
                    </select>
                </div>
                <div class="col-lg-2">
                    <select name="select" class="form-control search search-type col-lg-2">
                        <option value="name" >按名称</option>
                        <option value="value" >按内容</option>
                    </select>
                </div>
                <div class="form-group search  col-lg-2" role="search" style="display: flex;">
                    <input type="text" class="form-control search" id="kw" style="width: 200px;" placeholder="请输入名称">
                    <button type="button" class="btn btn-default search-button" v-on:click="requestData">搜索
@@ -87,7 +94,8 @@
                requestData: function () {
                    $.post("api/config/configList", {
                        detailSystemId: $(".detailsystem").val(),
                        key: $("#kw").val()
                        key: $("#kw").val(),
                        type: $(".search-type").val()
                    }, function (data) {
                        if (data.code == 0) {
                            app.configs = data.configList;
src/test/java/com/hxh/spring/test/CopyTest.java
New file
@@ -0,0 +1,75 @@
package com.hxh.spring.test;
import com.yeshi.buwan.util.FileUtil;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
/**
 * @author hxh
 * @title: CopyTest
 * @description: TODO
 * @date 2022/1/5 15:56
 */
public class CopyTest {
    private static Set<String> getFileNames(String path) throws Exception {
        Set<String> sets = new HashSet<>();
        Scanner scanner = new Scanner(new FileInputStream(new File(path)));
        while (scanner.hasNextLine()) {
            sets.add(scanner.nextLine().trim());
        }
        scanner.close();
        return sets;
    }
    private static void copyLayout() throws Exception {
        Set<String> sets = getFileNames("C:\\Users\\Administrator\\Desktop\\新建文件夹 (3)\\layout.txt");
        String fromBaseDir = "D:\\workspace\\Android\\buwan\\old\\HanJuPlayer\\app\\res\\layout\\";
        String toBaseDir = "C:\\Users\\Administrator\\Downloads\\android\\ZhiBo\\app\\src\\main\\res\\layout\\";
        String type = ".xml";
        for (String name : sets) {
            FileUtil.copyFile(fromBaseDir + name + type, toBaseDir + name + type);
        }
    }
    private static void copyImage() throws Exception {
        Set<String> sets = getFileNames("C:\\Users\\Administrator\\Desktop\\新建文件夹 (3)\\drawable-xhdpi.txt");
        String fromBaseDir = "D:\\workspace\\Android\\buwan\\old\\HanJuPlayer\\app\\res\\drawable-xhdpi\\";
        String toBaseDir = "C:\\Users\\Administrator\\Downloads\\android\\ZhiBo\\app\\src\\main\\res\\drawable-xhdpi\\";
        String type = ".png";
        for (String name : sets) {
            FileUtil.copyFile(fromBaseDir + name + type, toBaseDir + name + type);
        }
    }
    private static void copyDrawable() throws Exception {
        Set<String> sets = getFileNames("C:\\Users\\Administrator\\Desktop\\新建文件夹 (3)\\drawable.txt");
        String fromBaseDir = "D:\\workspace\\Android\\buwan\\old\\HanJuPlayer\\app\\res\\drawable\\";
        String toBaseDir = "C:\\Users\\Administrator\\Downloads\\android\\ZhiBo\\app\\src\\main\\res\\drawable\\";
        String type = ".xml";
        for (String name : sets) {
            FileUtil.copyFile(fromBaseDir + name + type, toBaseDir + name + type);
        }
    }
    public static void main(String[] args) throws Exception {
        copyImage();
    }
}
src/test/java/com/hxh/spring/test/DES.java
@@ -9,7 +9,7 @@
public class DES {
    @org.junit.Test
    public void test1() {
        String st = "iDp+mknN2urZPWPAdmBTv1ME3YqW7QwsJH0zD9ebFH7kI5NtvSWSUq+Ngejm2MTGCkhiX7yXdRJgFDtIiyss77y1IW+a/txfPE+VQcR2JLpRsDic0lo8750mRvs9KyFs/RUdIo0u450gt3T4FlOrTM7Ixnci60xM+BWcfp15HoAml/8cPPY8u/SGFTfIFyhzLsxtcjMd8b+FzbFfwuETBXu/C26qQAanyQCxbGu2BV3HJSKdqLUFDPWE5ppCsUvTBtCnYaPS8GvolmgRhY/6VCHf7SAOyFd5QD4msVoPGl+n3cXkKAHWHiwdRNNImL9eYgV+2UbFpQ0SaUuuI19XnQ==";
        String st = "iDp+mknN2uptRUo51EW28wcdP2q0yp6iFgzTe1sLzcs/jyg32plI0rWA5ixujhGdNWb8QJY1JUs=";
        System.out.println(DESUtil.decode(st));
    }
src/test/java/com/hxh/spring/test/EmailTest.java
@@ -6,8 +6,8 @@
    @org.junit.Test
    public void test() {
        for (int i = 0; i < 3; i++) {
            boolean isS = MailSenderUtil.sendEmail("2780501319@qq.com", "ysyz17784739772@126.com", "weikou2014",
        for (int i = 0; i < 1; i++) {
            boolean isS = MailSenderUtil.sendEmail("1101184511@qq.com", "app_yzm_zc@163.com", "KZKSRTEMDWEQRAQR",
                    "布丸社区注册验证码:" + 123, "布丸社区注册验证码:" + 123);
        }
    }
src/test/java/com/hxh/spring/test/GeneralTest.java
@@ -4,6 +4,7 @@
import com.yeshi.buwan.dao.live.TVLiveProgramResourceDao;
import com.yeshi.buwan.dao.video.VideoResourceVersionMapDao;
import com.yeshi.buwan.domain.live.TVLiveProgramResource;
import com.yeshi.buwan.domain.user.UserDPContentWatchStatistic;
import com.yeshi.buwan.domain.video.StarInfo;
import com.yeshi.buwan.domain.video.VideoResourceVersionMap;
import com.yeshi.buwan.service.inter.video.VideoResourceVersionMapService;
@@ -85,10 +86,10 @@
    @org.junit.Test
    public void createDao() {
        MongoDBDaoData.Builder builder = new MongoDBDaoData.Builder();
        builder.setBaseDaoClass(mongoBaseDao).setDaoPackageName(packageBaseName + ".dao.live");
        builder.setEntityClass(TVLiveProgramResource.class);
        builder.setBaseDaoClass(mongoBaseDao).setDaoPackageName(packageBaseName + ".dao.user");
        builder.setEntityClass(UserDPContentWatchStatistic.class);
        try {
            SpringComponentGenerater.createMongoDao(builder.create(), PROJECT_PATH + "\\src\\main\\java\\com\\yeshi\\buwan\\dao\\live\\");
            SpringComponentGenerater.createMongoDao(builder.create(), PROJECT_PATH + "\\src\\main\\java\\com\\yeshi\\buwan\\dao\\user\\");
        } catch (Exception e) {
            e.printStackTrace();
        }
src/test/java/com/hxh/spring/test/StatisticTest.java
@@ -8,7 +8,16 @@
import com.yeshi.buwan.service.imp.StatisticsService;
import com.yeshi.buwan.util.BeanUtil;
import com.yeshi.buwan.util.news.SouGouParser;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import javax.annotation.Resource;
@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
@ContextConfiguration(locations = {"classpath:spring.xml"})
@WebAppConfiguration
public class StatisticTest {
    // @Test
    public void updateSouGou() {// SouGouParser
@@ -36,9 +45,12 @@
    }
    @Resource
    private StatisticsService statisticsService;
    @Test
    public void playStatistics() {
        final StatisticsService statisticsService = (StatisticsService) BeanUtil.getBean("statisticsService");
        statisticsService.categoryPlayStatistic();
    }
src/test/java/com/hxh/spring/test/video/VideoResourcePlayVersionTest.java
@@ -155,6 +155,23 @@
    @Test
    public void addZhiBoAndroid() {
        String[] resourceIds = null;
        resourceIds = new String[]{"13", "20", "17", "19", "21", "22", "24", "26", "27"};
        for (String rid : resourceIds) {
            try {
                videoResourcePlayVersionMapService.add(new VideoResourcePlayVersionMap("50", 1, rid, null));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    @Test
    public void listValid() {
        List<String> resourceIds = videoResourcePlayVersionMapService.listResourceId("43", 105, null);
        System.out.println(resourceIds);
src/test/java/com/hxh/spring/test/video/VideoResourceVersionTest.java
@@ -132,6 +132,31 @@
    }
    @Test
    public void addZhiBoAndroid() {
        String[] resourceIds = null;
        resourceIds = new String[]{"13", "20", "17", "19", "21", "22", "24", "26", "27"};
        for (String rid : resourceIds) {
            try {
                videoResourceVersionMapService.add(new VideoResourceVersionMap("50", 1, rid, null));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
//        resourceIds = new String[]{"25"};
//        for (String rid : resourceIds) {
//            try {
//                videoResourceVersionMapService.add(new VideoResourceVersionMap("47", 1, rid, "meizu"));
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
    }
    @Test
    public void listValid() {
        List<String> resourceIds = videoResourceVersionMapService.listResourceId("43", 105, null);
src/test/java/com/hxh/spring/test/vip/VIPTest.java
@@ -7,6 +7,8 @@
import com.yeshi.buwan.exception.vip.VIPException;
import com.yeshi.buwan.exception.vip.VideoBuyRecordException;
import com.yeshi.buwan.job.OrderJob;
import com.yeshi.buwan.util.user.VipUtil;
import com.yeshi.buwan.util.vip.VIPOrderUtil;
import com.yeshi.buwan.videos.pptv.PPTVVipManager;
import com.yeshi.buwan.service.inter.order.OrderService;
import com.yeshi.buwan.service.inter.vip.VIPPriceService;
@@ -19,15 +21,20 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.yeshi.utils.alipay.AlipayH5PayUtil;
import org.yeshi.utils.wx.WXPayV3Util;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
@ContextConfiguration(locations = {"classpath:spring.xml"})
@WebAppConfiguration
//@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
//@ContextConfiguration(locations = {"classpath:spring.xml"})
//@WebAppConfiguration
public class VIPTest {
    @Resource
@@ -234,6 +241,54 @@
        }
    }
    @Test
    public void refoundWX() {
        //退款
        try {
            Scanner scanner = new Scanner(new FileInputStream(new File("C:\\Users\\Administrator\\Desktop\\wx退款订单.txt")));
            while (scanner.hasNextLine()) {
                String st = scanner.nextLine();
                String[] sts = st.split(" ");
                String line = "";
                line += "buwan_vip_" + sts[0] + ",";
                line += sts[1] + ",";
                line += "影视大全VIP权益终止退回,";
                line += "buwan_vip_" + sts[0];
                System.out.println(line);
            }
            scanner.close();
        } catch (Exception e) {
        }
    }
    @Test
    public void refoundAlipay() {
        //退款
        try {
            Scanner scanner = new Scanner(new FileInputStream(new File("C:\\Users\\Administrator\\Desktop\\退款\\alipay.txt")));
            while (scanner.hasNextLine()) {
                String st = scanner.nextLine();
                String[] sts = st.split(" ");
                String id = sts[0];
                String money = sts[1];
                String orderId = VIPOrderUtil.getOutOrderNo(OrderType.vip, id);
                AlipayH5PayUtil.refund(VipUtil.getAlipayApp(), orderId, null, new BigDecimal(money), orderId);
            }
            scanner.close();
        } catch (Exception e) {
        }
    }
    //
}