package com.controller;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.annotation.IgnoreAuth;
import com.entity.JingliEntity;
import com.entity.ShenshuEntity;
import com.service.JingliService;
import com.service.ShenshuService;
import com.service.TokenService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.XuanshouEntity;
import com.service.XuanshouService;
import com.utils.PageUtils;
import com.utils.R;
/**
* 人员表
* 后端接口
* @author
* @email
* @date 2021-03-02
*/
@RestController
@Controller
@RequestMapping("/xuanshou")
public class XuanshouController {
private static final Logger logger = LoggerFactory.getLogger(XuanshouController.class);
@Autowired
private XuanshouService xuanshouService;
@Autowired
private JingliService jingliService;
@Autowired
private ShenshuService shenshuService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String role, HttpServletRequest request) {
XuanshouEntity user = xuanshouService.selectOne(new EntityWrapper<XuanshouEntity>().eq("account", username));
if(user != null){
if(!user.getRole().equals(role)){
return R.error("权限不正常");
}
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),user.getName(), "users", user.getRole());
return R.ok().put("token", token);
}else{
return R.error("账号或密码或权限不对");
}
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
XuanshouEntity user = xuanshouService.selectById(id);
return R.ok().put("data", user);
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody XuanshouEntity user){
// ValidatorUtils.validateEntity(user);
if(xuanshouService.selectOne(new EntityWrapper<XuanshouEntity>().eq("account", user.getAccount())) !=null) {
return R.error("选手或教练已存在");
}
xuanshouService.insert(user);
return R.ok();
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
XuanshouEntity user = xuanshouService.selectOne(new EntityWrapper<XuanshouEntity>().eq("account", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
xuanshouService.update(user,null);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",page方法");
Object role = request.getSession().getAttribute("role");
PageUtils page = null;
if(role.equals("选手") || role.equals("教练")){
params.put("yh",request.getSession().getAttribute("userId"));
params.put("qx",role);
page = xuanshouService.queryPage(params);
}else if(role.equals("经理")) {
Integer userId = (Integer) request.getSession().getAttribute("userId");
JingliEntity jingliEntity = jingliService.selectById(userId);
if(jingliEntity == null){
return R.error();
}
params.put("jlbTypes", jingliEntity.getJlbTypes());
page = xuanshouService.queryPage(params);
}else{
page = xuanshouService.queryPage(params);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("Controller:"+this.getClass().getName()+",info方法");
XuanshouEntity xuanshou = xuanshouService.selectById(id);
if(xuanshou!=null){
return R.ok().put("data", xuanshou);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@IgnoreAuth
@RequestMapping("/save")
public R save(@RequestBody XuanshouEntity xuanshou, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",save");
Wrapper<XuanshouEntity> queryWrapper = new EntityWrapper<XuanshouEntity>()
.eq("name", xuanshou.getName())
.eq("account", xuanshou.getAccount())
.eq("jlb_types", xuanshou.getJlbTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
XuanshouEntity xuanshouEntity = xuanshouService.selectOne(queryWrapper);
if("".equals(xuanshou.getImgPhoto()) || "null".equals(xuanshou.getImgPhoto())){
xuanshou.setImgPhoto(null);
}
if(xuanshouEntity==null){
xuanshou.setZtTypes(1);
xuanshouService.insert(xuanshou);
return R.ok();
}else {
return R.error(511,"数据重复,请从新输入");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody XuanshouEntity xuanshou, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",update");
//根据字段查询是否有相同数据
Wrapper<XuanshouEntity> queryWrapper = new EntityWrapper<XuanshouEntity>()
.notIn("id",xuanshou.getId())
.eq("name", xuanshou.getName())
.eq("account", xuanshou.getAccount())
.eq("jlb_types", xuanshou.getJlbTypes())
.eq("role", xuanshou.getRole())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
XuanshouEntity xuanshouEntity = xuanshouService.selectOne(queryWrapper);
if("".equals(xuanshou.getImgPhoto()) || "null".equals(xuanshou.getImgPhoto())){
xuanshou.setImgPhoto(null);
}
if(xuanshouEntity==null){
xuanshouService.updateById(xuanshou);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 同意
*/
@RequestMapping("/consent")
public R consent(@RequestBody Integer ids){
ShenshuEntity shenshu = shenshuService.selectById(ids);
if(shenshu==null){
return R.error();
}
XuanshouEntity xuanshou = xuanshouService.selectById(shenshu.getXsTypes());
if(xuanshou == null){
return R.error();
}
if(xuanshou.getZtTypes() == 1){
return R.error("您已经同意过了,请不要重复按同意按钮");
}
xuanshou.setZtTypes(1);
xuanshouService.updateById(xuanshou);
return R.ok();
}
/**
* 同意转会
*/
@RequestMapping("/consentTransfer")
public R consentTransfer(@RequestBody Integer ids){
ShenshuEnt
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
JSP+SSM项目-电子竞技管理平台的Java毕业设计(源码+说明+演示视频+数据库).zip 【项目技术】 开发语言:Java 框架:ssm 架构:B/S 数据库:mysql 【实现功能】 人员信息管理,经理信息管理,奖惩信息管理,俱乐部管理,申请信息管理等
资源推荐
资源详情
资源评论
收起资源包目录
JSP+SSM项目-电子竞技管理平台的Java毕业设计(源码+说明+演示视频+数据库).zip (868个子文件)
style.css 835KB
bootstrap4.2.1.min.css 150KB
bootstrap.min.css 141KB
bootstrap.css 120KB
bootstrap.min.css 118KB
material-design-iconic-font.min.css 93KB
animate.css 68KB
style.css 66KB
style.default.css 66KB
linea-icon.css 46KB
ueditor.css 44KB
font-awesome.min.css 38KB
ueditor.min.css 34KB
font-awesome.min.css 30KB
jquery.treetable.theme.default.css 25KB
lightgallery.css 25KB
animate.css 23KB
styles.css 23KB
entypo-icon.css 23KB
all.css 21KB
font-awesome.css 21KB
video-js.css 21KB
image.css 19KB
jquery.idealforms.css 17KB
themify-icons.css 16KB
themify-icons.css 16KB
jquery.dataTables.min.css 15KB
video.css 15KB
attachment.css 15KB
square.min.css 14KB
simple-line-icons.css 14KB
all.css 13KB
dropzone.css 11KB
video-js.min.css 11KB
bootstrap-switch.css 11KB
bootstrap-datetimepicker.min.css 11KB
extra-pages.css 11KB
ladda.min.css 10KB
filter.css 9KB
tooltipster.css 9KB
pe-icon-7-stroke.css 9KB
awesome-bootstrap-checkbox.css 9KB
calendar.css 9KB
responsive.css 8KB
laydate.css 8KB
shCoreDefault.css 7KB
pe-icon-7-styles.css 7KB
css.css 7KB
social.css 7KB
jquery-jvectormap.css 6KB
clockface.css 6KB
jquery.steps.css 6KB
dripicon.css 5KB
weather-icons.min.css 5KB
footable.core.css 5KB
jquery.toast.min.css 5KB
dataTables.bootstrap4.min.css 5KB
datepicker.css 5KB
tabelizer.min.css 5KB
datepicker.css 5KB
datepicker.css 5KB
footable.standalone.css 5KB
signin.css 5KB
media.css 5KB
slidebars.css 4KB
skin-select.css 4KB
datepicker.css 4KB
scrawl.css 4KB
DT_bootstrap.css 4KB
datepicker.css 4KB
bootstrap-timepicker.css 3KB
green.css 3KB
yellow.css 3KB
red.css 3KB
blue.css 3KB
violet.css 3KB
codemirror.css 3KB
owl.carousel.min.css 3KB
bootstrap-colorpicker.css 3KB
maki-icons.css 3KB
jquery.treeview.css 3KB
profile.css 3KB
charts.css 3KB
jquery.searchableSelect.css 3KB
background.css 2KB
bootstrap-wysihtml5.css 2KB
awwwards.css 2KB
jquery.stepy.css 2KB
responsive-table.css 2KB
emotion.css 2KB
dialogbase.css 2KB
jquery.pnotify.default.css 2KB
music.css 2KB
demo.css 1KB
acc-wizard.min.css 1KB
jquery.easy-pie-chart.css 1KB
pace-theme-center-simple.css 1KB
uploader.css 1KB
edittable.css 1KB
editor.css 1KB
共 868 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
岛上程序猿
- 粉丝: 5247
- 资源: 4176
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 如何在Python中实现圣诞树的弹性碰撞效果
- 实变函数与测度论中的Cantor三分集和Lebesgue测度概念解析
- jQuery制作的3D冰块立方时钟动态特效源码.zip
- CSS 基础介绍.pdf
- LabVIEW中三维图片控件的使用及其编程技术
- LabVIEW环境下功能型快速原型的设计与测试
- Windows 7 技术指南:NI软硬件兼容性及性能提升
- shufflenet模型-python训练识别塑料玩具价格等级-不含数据集图片-含逐行注释和说明文档.zip
- shufflenet模型-基于卷积神经网络识别废铁价格水平-不含数据集图片-含逐行注释和说明文档.zip
- dangbeimarket_5.0.7_314_znds.apk
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功