package com.feiqu.web.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;
import com.alibaba.fastjson.JSON;
import com.feiqu.common.base.BaseResult;
import com.feiqu.common.enums.*;
import com.feiqu.common.utils.DESUtils;
import com.feiqu.common.utils.SpringUtils;
import com.feiqu.framwork.constant.CommonConstant;
import com.feiqu.framwork.constant.IconUrlConfig;
import com.feiqu.framwork.support.cache.CacheManager;
import com.feiqu.framwork.util.CommonUtils;
import com.feiqu.framwork.util.CookieUtil;
import com.feiqu.framwork.util.SpringContextUtil;
import com.feiqu.framwork.util.WebUtil;
import com.feiqu.framwork.web.base.BaseController;
import com.feiqu.system.model.*;
import com.feiqu.system.pojo.cache.FqUserCache;
import com.feiqu.system.pojo.response.MessageUserDetail;
import com.feiqu.system.pojo.response.SimThoughtDTO;
import com.feiqu.system.pojo.response.ThoughtWithUser;
import com.feiqu.system.service.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.jeesuite.cache.command.RedisString;
import com.jeesuite.cache.redis.JedisProviderFactory;
import com.jeesuite.filesystem.FileSystemClient;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailException;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import redis.clients.jedis.JedisCommands;
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.*;
/**
* @author cwd
* @create 2017-09-16:19
**/
@Controller
@RequestMapping("u")
public class UserController extends BaseController {
private static Logger logger = LoggerFactory.getLogger(UserController.class);
/*@Autowired
FSProviderSpringFacade provider;*/
@Autowired
private ThoughtService thoughtService;
@Autowired
private ArticleService articleService;
@Autowired
private WebUtil webUtil;
@Autowired
private CMessageService messageService;
@Autowired
private UploadImgRecordService uploadImgRecordService;
@Autowired
private JavaMailSenderImpl mailSender;
@Autowired
private UserActivateService userActivateService;
@Autowired
private UserFollowService userFollowService;
@Autowired
private FqUserService userService;
@Autowired
private FqThirdPartyService fqThirdPartyService;
@Autowired
private FqLabelService fqLabelService;
@Autowired
private FqVisitRecordService visitRecordService;
@Autowired
private FqCollectService fqCollectService;
//支付方式
@Resource
private FqUserPayWayService fqUserPayWayService;
@GetMapping("upLevel")
public String upLevel(Model model){
FqUserCache fqUserCache = getCurrentUser();
int month = DateUtil.thisMonth()+1;
int lastMonth = month == 1? 12 : month-1;
JedisCommands commands = JedisProviderFactory.getJedisCommands(null);
Double score = commands.zscore(CommonConstant.FQ_ACTIVE_USER_SORT+month,fqUserCache.getId().toString());
Double lastMonthScore = commands.zscore(CommonConstant.FQ_ACTIVE_USER_SORT+lastMonth,fqUserCache.getId().toString());
Double totolScore = (score == null?0:score)+(lastMonthScore==null?0:lastMonthScore);
model.addAttribute("totolScore",totolScore);
return "/user/upLevel";
}
@PostMapping("upLevel")
@ResponseBody
public BaseResult upLevelGo(){
BaseResult result = new BaseResult();
try {
FqUserCache fqUserCache = getCurrentUser();
if(fqUserCache == null){
result.setResult(ResultEnum.USER_NOT_LOGIN);
return result;
}
int originLevel = fqUserCache.getLevel() == null?1:fqUserCache.getLevel();
int needActiveNum = 0;
switch (originLevel){
case 1:needActiveNum = 300;break;
case 2:needActiveNum = 800;break;
case 3:needActiveNum = 1500;break;
case 4:needActiveNum = 3000;break;
default:needActiveNum = 300;break;
}
int month = DateUtil.thisMonth()+1;
int lastMonth = month == 1? 12 : month-1;
JedisCommands commands = JedisProviderFactory.getJedisCommands(null);
Double score = commands.zscore(CommonConstant.FQ_ACTIVE_USER_SORT+month,fqUserCache.getId().toString());
Double lastMonthScore = commands.zscore(CommonConstant.FQ_ACTIVE_USER_SORT+lastMonth,fqUserCache.getId().toString());
Double totolScore = (score == null?0:score)+(lastMonthScore==null?0:lastMonthScore);
if(totolScore < needActiveNum){
result.setResult(ResultEnum.PARAM_ERROR);
result.setMessage("活跃度不足");
return result;
}
FqUser toUpdate = new FqUser();
toUpdate.setId(fqUserCache.getId());
toUpdate.setLevel(originLevel+1);
userService.updateByPrimaryKeySelective(toUpdate);
CacheManager.refreshUserCacheByUid(fqUserCache.getId());
commands.zadd(CommonConstant.FQ_ACTIVE_USER_SORT+month,totolScore.intValue()-needActiveNum,fqUserCache.getId().toString());
result.setData(originLevel+1);
} catch (Exception e) {
result.setResult(ResultEnum.FAIL);
logger.error("升级报错",e);
}finally {
JedisProviderFactory.getJedisProvider(null).release();
}
return result;
}
@RequestMapping("/manage")
public String manage(Model model){
FqUserCache fqUserCache = getCurrentUser();
if(fqUserCache == null){
return USER_LOGIN_REDIRECT_URL;
}
if(fqUserCache.getRole() != 1){
return GENERAL_ERROR_URL;
}
return "/user/manage";
}
@RequestMapping("/manage/list")
@ResponseBody
public Object list(Integer page){
BaseResult result = new BaseResult();
try {
PageHelper.startPage(page,CommonConstant.DEAULT_PAGE_SIZE);
FqUserExample example = new FqUserExample();
example.setOrderByClause("create_time desc");
List<FqUser> users = userService.selectByExample(example);
PageInfo pageInfo = new PageInfo(users);
result.setData(pageInfo);
} catch (Exception e) {
logger.error("用户分页出错",e);
result.setCode("1");
result.setMessage("用户分页出错");
}
return result;
}
@RequestMapping("/manage/changeStatus")
@ResponseBody
public Object changeStatus(Integer userId,Integer status){
BaseResult result = new BaseResult();
try {
FqUserCache currentUser = getCurrentUser();
if(currentUser == null){
result.setResult(ResultEnum.USER_NOT_LOGIN);
return result;
}
if(
没有合适的资源?快使用搜索试试~ 我知道了~
feiqu-opensource-master.zip
共787个文件
java:396个
html:93个
gif:76个
0 下载量 47 浏览量
2022-12-11
09:45:08
上传
评论
收藏 6.99MB ZIP 举报
温馨提示
此项目使用了hutool工具类作支撑,参考了 zheng项目以及 ruoyi的项目,页面ui使用了layui,集成了阿里云oss(支持前端和后端上传)、七牛云,支持代码自动生成,支持数据库读写分离,减去了70%的工作量,让你更多的精力放在写业务代码的过程中。这个项目还可以用来给你们公司做前端展示页面,也是非常方便的。
资源推荐
资源详情
资源评论
收起资源包目录
feiqu-opensource-master.zip (787个子文件)
bootstrap.min.css 118KB
layui.css 68KB
thinker-md.vendor.css 50KB
font-awesome.css 37KB
font-awesome.min.css 30KB
simditor.min.css 25KB
quill.bubble.css 25KB
quill.snow.css 24KB
common.css 19KB
common.min.css 16KB
layim.css 15KB
layer.css 14KB
layui.mobile.css 10KB
quill.core.css 9KB
laydate.css 7KB
code.css 1KB
thinker-md.user.css 259B
api-doc.css 218B
ip2region.db 6.52MB
fontawesome-webfont.eot 162KB
fontawesome-webfont.eot 59KB
iconfont.eot 40KB
gly-halflings-regular.eot 20KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
level-help.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
loading-1.gif 701B
.gitignore 247B
共 787 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
m0_72731342
- 粉丝: 2
- 资源: 1832
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功