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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
技术选型 【后端】:Java 【框架】:ssm 【前端】:vue/jsp 【JDK版本】:JDK1.8 【服务器】:tomcat7+ 【数据库】:mysql 5.7+ 包含:项目源码、数据库脚本等,该项目源码可作为毕设使用。 项目都经过严格调试,确保可以运行! 具体项目介绍可查看博主文章 扫描图片二维码可免费代写开题报告
资源推荐
资源详情
资源评论
收起资源包目录
ssm2048电子竞技管理平台的设计与实现+jsp.zip (867个子文件)
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
共 867 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
Java码库
- 粉丝: 2116
- 资源: 6100
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 技术资料分享STM32F10xx46-Errata-CH-V2很好的技术资料.zip
- 技术资料分享STM32F10xx8B-Errata-CH-V6很好的技术资料.zip
- project(1).zip
- 技术资料分享STM32F10x-StdPeriph-Driver-3.5.0(中文版)很好的技术资料.zip
- 【Unity粒子特效插件】Particle Dynamic Magic 2: Decal, Spline, AI Particl
- Screenshot_20241109_202536_com.huawei.himovie.jpg
- Screenshot_20241109_202550_com.huawei.photos.jpg
- 技术资料分享STM32F2技术培训-灵活的静态存储控制器-FSMC很好的技术资料.zip
- 技术资料分享stm32-FSMC机制很好的技术资料.zip
- 期末大作业c语言期末大作业源代码(图书信息管理系统)含详细文档说明(高分项目)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功