package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.ZixunshiEntity;
import com.entity.view.ZixunshiView;
import com.service.ZixunshiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 咨询师
* 后端接口
* @author
* @email
* @date 2021-01-08 11:11:36
*/
@RestController
@RequestMapping("/zixunshi")
public class ZixunshiController {
@Autowired
private ZixunshiService zixunshiService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
ZixunshiEntity user = zixunshiService.selectOne(new EntityWrapper<ZixunshiEntity>().eq("zhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"zixunshi", "管理员" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody ZixunshiEntity zixunshi){
//ValidatorUtils.validateEntity(zixunshi);
ZixunshiEntity user = zixunshiService.selectOne(new EntityWrapper<ZixunshiEntity>().eq("zhanghao", zixunshi.getZhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
zixunshi.setId(uId);
zixunshiService.insert(zixunshi);
return R.ok();
}
/**
* 退出
*/
@RequestMapping("/logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
ZixunshiEntity user = zixunshiService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
ZixunshiEntity user = zixunshiService.selectOne(new EntityWrapper<ZixunshiEntity>().eq("zhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
zixunshiService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ZixunshiEntity zixunshi, HttpServletRequest request){
EntityWrapper<ZixunshiEntity> ew = new EntityWrapper<ZixunshiEntity>();
PageUtils page = zixunshiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zixunshi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ZixunshiEntity zixunshi, HttpServletRequest request){
EntityWrapper<ZixunshiEntity> ew = new EntityWrapper<ZixunshiEntity>();
PageUtils page = zixunshiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, zixunshi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( ZixunshiEntity zixunshi){
EntityWrapper<ZixunshiEntity> ew = new EntityWrapper<ZixunshiEntity>();
ew.allEq(MPUtil.allEQMapPre( zixunshi, "zixunshi"));
return R.ok().put("data", zixunshiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(ZixunshiEntity zixunshi){
EntityWrapper< ZixunshiEntity> ew = new EntityWrapper< ZixunshiEntity>();
ew.allEq(MPUtil.allEQMapPre( zixunshi, "zixunshi"));
ZixunshiView zixunshiView = zixunshiService.selectView(ew);
return R.ok("查询咨询师成功").put("data", zixunshiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
ZixunshiEntity zixunshi = zixunshiService.selectById(id);
return R.ok().put("data", zixunshi);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
ZixunshiEntity zixunshi = zixunshiService.selectById(id);
return R.ok().put("data", zixunshi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ZixunshiEntity zixunshi, HttpServletRequest request){
zixunshi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(zixunshi);
ZixunshiEntity user = zixunshiService.selectOne(new EntityWrapper<ZixunshiEntity>().eq("zhanghao", zixunshi.getZhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
zixunshi.setId(new Date().getTime());
zixunshiService.insert(zixunshi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ZixunshiEntity zixunshi, HttpServletRequest request){
zixunshi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(zixunshi);
ZixunshiEntity user = zixunshiService.selectOne(new EntityWrapper<ZixunshiEntity>().eq("zhanghao", zixunshi.getZhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
zixunshi.setId(new Date().getTime());
zixunshiService.insert(zixunshi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ZixunshiEntity zixunshi, HttpServletRequest request){
//ValidatorUtils.validateEntity(zixunshi);
zixunshiService.updateById(zixunshi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
zixunshiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("rem
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM的心理咨询管理管理系统拥有三个角色:学生用户、咨询师、管理员.zip (147个子文件)
ZixunshiController.java 8KB
XueshengController.java 8KB
CommonController.java 8KB
CeshijieguoController.java 7KB
DiscusswenzhangxinxiController.java 7KB
CeshixinxiController.java 7KB
YuyuexinxiController.java 7KB
WenzhangxinxiController.java 7KB
StoreupController.java 7KB
CeshitimuController.java 6KB
DiscusszixunshiController.java 6KB
MessagesController.java 6KB
MPUtil.java 5KB
CeshixinxiEntity.java 5KB
UserController.java 5KB
CeshitimuEntity.java 4KB
YuyuexinxiEntity.java 4KB
CeshijieguoEntity.java 4KB
CeshixinxiModel.java 4KB
CeshixinxiVO.java 4KB
ZixunshiEntity.java 4KB
BaiduUtil.java 4KB
WenzhangxinxiEntity.java 3KB
XueshengEntity.java 3KB
CeshitimuModel.java 3KB
CeshitimuVO.java 3KB
AuthorizationInterceptor.java 3KB
ConfigController.java 3KB
YuyuexinxiModel.java 3KB
CeshijieguoModel.java 3KB
StoreupEntity.java 3KB
FileController.java 3KB
YuyuexinxiVO.java 3KB
CeshijieguoVO.java 3KB
DiscusswenzhangxinxiEntity.java 3KB
DiscusszixunshiEntity.java 3KB
MessagesEntity.java 3KB
Query.java 3KB
ZixunshiModel.java 2KB
TokenServiceImpl.java 2KB
ZixunshiVO.java 2KB
WenzhangxinxiModel.java 2KB
XueshengModel.java 2KB
DiscusswenzhangxinxiServiceImpl.java 2KB
WenzhangxinxiVO.java 2KB
TokenEntity.java 2KB
XueshengVO.java 2KB
DiscusszixunshiServiceImpl.java 2KB
WenzhangxinxiServiceImpl.java 2KB
CeshijieguoServiceImpl.java 2KB
YuyuexinxiServiceImpl.java 2KB
CeshixinxiServiceImpl.java 2KB
PageUtils.java 2KB
CeshitimuServiceImpl.java 2KB
ZixunshiServiceImpl.java 2KB
MessagesServiceImpl.java 2KB
XueshengServiceImpl.java 2KB
StoreupServiceImpl.java 2KB
StoreupModel.java 2KB
StoreupVO.java 2KB
DiscusswenzhangxinxiModel.java 1KB
MessagesModel.java 1KB
DiscusszixunshiModel.java 1KB
UserServiceImpl.java 1KB
DiscusswenzhangxinxiVO.java 1KB
DiscusszixunshiVO.java 1KB
MessagesVO.java 1KB
CommonServiceImpl.java 1KB
UserEntity.java 1KB
DiscusswenzhangxinxiService.java 1KB
SpringContextUtils.java 1KB
DiscusswenzhangxinxiDao.java 1KB
ValidatorUtils.java 1KB
DiscusszixunshiService.java 1KB
DiscusszixunshiDao.java 1022B
SQLFilter.java 1019B
WenzhangxinxiService.java 1018B
DiscusswenzhangxinxiView.java 991B
CeshijieguoService.java 990B
WenzhangxinxiDao.java 986B
YuyuexinxiService.java 976B
CeshixinxiService.java 976B
HttpClientUtils.java 971B
CeshitimuService.java 962B
CeshijieguoDao.java 956B
MessagesService.java 945B
ZixunshiService.java 945B
DiscusszixunshiView.java 943B
XueshengService.java 942B
YuyuexinxiDao.java 941B
CeshixinxiDao.java 941B
StoreupService.java 931B
CeshitimuDao.java 926B
ConfigServiceImpl.java 925B
WenzhangxinxiView.java 919B
ZixunshiDao.java 908B
MessagesDao.java 908B
XueshengDao.java 905B
CeshijieguoView.java 901B
StoreupDao.java 893B
共 147 条
- 1
- 2
资源评论
- Lynne06302024-05-14感谢资源主的分享,很值得参考学习,资源价值较高,支持!
博士僧小星
- 粉丝: 1931
- 资源: 5896
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功