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 java.io.IOException;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
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.ShoufeirenyuanEntity;
import com.entity.view.ShoufeirenyuanView;
import com.service.ShoufeirenyuanService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 收费人员
* 后端接口
* @author
* @email
* @date 2022-02-16 20:15:07
*/
@RestController
@RequestMapping("/shoufeirenyuan")
public class ShoufeirenyuanController {
@Autowired
private ShoufeirenyuanService shoufeirenyuanService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
ShoufeirenyuanEntity user = shoufeirenyuanService.selectOne(new EntityWrapper<ShoufeirenyuanEntity>().eq("shoufeizhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"shoufeirenyuan", "收费人员" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody ShoufeirenyuanEntity shoufeirenyuan){
//ValidatorUtils.validateEntity(shoufeirenyuan);
ShoufeirenyuanEntity user = shoufeirenyuanService.selectOne(new EntityWrapper<ShoufeirenyuanEntity>().eq("shoufeizhanghao", shoufeirenyuan.getShoufeizhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
shoufeirenyuan.setId(uId);
shoufeirenyuanService.insert(shoufeirenyuan);
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");
ShoufeirenyuanEntity user = shoufeirenyuanService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
ShoufeirenyuanEntity user = shoufeirenyuanService.selectOne(new EntityWrapper<ShoufeirenyuanEntity>().eq("shoufeizhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
shoufeirenyuanService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,ShoufeirenyuanEntity shoufeirenyuan,
HttpServletRequest request){
EntityWrapper<ShoufeirenyuanEntity> ew = new EntityWrapper<ShoufeirenyuanEntity>();
PageUtils page = shoufeirenyuanService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shoufeirenyuan), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ShoufeirenyuanEntity shoufeirenyuan,
HttpServletRequest request){
EntityWrapper<ShoufeirenyuanEntity> ew = new EntityWrapper<ShoufeirenyuanEntity>();
PageUtils page = shoufeirenyuanService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shoufeirenyuan), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( ShoufeirenyuanEntity shoufeirenyuan){
EntityWrapper<ShoufeirenyuanEntity> ew = new EntityWrapper<ShoufeirenyuanEntity>();
ew.allEq(MPUtil.allEQMapPre( shoufeirenyuan, "shoufeirenyuan"));
return R.ok().put("data", shoufeirenyuanService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(ShoufeirenyuanEntity shoufeirenyuan){
EntityWrapper< ShoufeirenyuanEntity> ew = new EntityWrapper< ShoufeirenyuanEntity>();
ew.allEq(MPUtil.allEQMapPre( shoufeirenyuan, "shoufeirenyuan"));
ShoufeirenyuanView shoufeirenyuanView = shoufeirenyuanService.selectView(ew);
return R.ok("查询收费人员成功").put("data", shoufeirenyuanView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
ShoufeirenyuanEntity shoufeirenyuan = shoufeirenyuanService.selectById(id);
return R.ok().put("data", shoufeirenyuan);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
ShoufeirenyuanEntity shoufeirenyuan = shoufeirenyuanService.selectById(id);
return R.ok().put("data", shoufeirenyuan);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShoufeirenyuanEntity shoufeirenyuan, HttpServletRequest request){
shoufeirenyuan.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(shoufeirenyuan);
ShoufeirenyuanEntity user = shoufeirenyuanService.selectOne(new EntityWrapper<ShoufeirenyuanEntity>().eq("shoufeizhanghao", shoufeirenyuan.getShoufeizhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
shoufeirenyuan.setId(new Date().getTime());
shoufeirenyuanService.insert(shoufeirenyuan);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ShoufeirenyuanEntity shoufeirenyuan, HttpServletRequest request){
shoufeirenyuan.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(shoufeirenyuan);
ShoufeirenyuanEntity user = shoufeirenyuanService.selectOne(new EntityWrapper<ShoufeirenyuanEntity>().eq("shoufeizhanghao", shoufeirenyuan.getShoufeizhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
shoufeirenyuan.setId(new Date().getTime());
shoufeirenyuanService.insert(shoufeirenyuan);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShoufeirenyuanEntity shoufeirenyuan, HttpServletRequest request){
//ValidatorUtils.validateEntity(shoufeirenyuan);
shoufeirenyuanService.updateById(shoufeirenyuan);//全部更新
return R.ok();
}
/**
* 删除
风月歌
- 粉丝: 1811
- 资源: 5159
最新资源
- 全桥变器,可以实现零电压开关和零电流开关ZVS和ZCS 波形好,和仿真详细对应说明
- 三相桥式全控整流器及其详细的说明等
- No.825 基于S7-200 PLC和组态王自动扶梯控制系统 带解释的梯形图程序,接线图原理图图纸,io分配,组态画面
- STM32+AD7124+热电偶方案+Pt100冷端补偿解析工程源码,源码包含Pt100、NTC热敏、热电偶处理驱动源码, 支持热电偶类型T、J、E、N、K、B、如果用于别的R、S 8种类型,并有Pt
- 暂态稳定性仿真分析 基于MATLAB Simulink的单机无穷大系统 可仿真、分析不同故障切除时间下,三相短路、两相短路接地、两相短路、单相接地短路故障状态下的暂态稳定性 可任意调节故障切除时间
- 带负载转矩前馈补偿的永磁同步电机FOC 1.采用滑模负载转矩观测器,可快速准确观测到负载转矩 赠送龙伯格负载转矩观测器用于对比分析 2.将观测到的负载转矩用作前馈补偿,可提高系统抗负载扰动能力;
- 双边工作自动裁断机全套设计资料100%好用.zip
- 基于STM32F4核心板的经典项目程序,远比网上搜索的开发板例程更有价值,历时2年时间打造 适合学生学习,工程师提高技术等等 项目内容为:用stm32f407单片机核心板和gy-91模块做一个功能
- 基于FAST与MATLAB SIMULINK联合仿真模型非线性风力发电机的PID独立变桨和统一变桨控制下仿真模型+参考文献,对于5WM非线性风机风机进行控制 链接simulink的scope出转速对比
- 永磁同步电机调速控制软件工程PMSM,该工程主要基于DSP28335硬件控制平台,两电平IPM模块主回路,DSP控制器控制, 配过压和过流保护,小功率电机调速控制,工程软件配注释,提供对应硬件原理图
- 汇川MD500E变频器开发方案 源码+解析, MD500E代码方案和解析文档+仿真资料 资料全 包含pmsm的foc控制算法,电阻、电感、磁链等参数的辩识算法,死区补偿算法过调制处理算法
- 超值福利 关键词:场景生成 缩减 微网优化调度,综合能源优化,matlab cplex等优化程序,全部打包带走,神经网络光伏预测,可提供优化学习资料 火火 运行环境:matlab 欢迎咨询
- Java项目:基于servlet+jsp+tomcat实现的网上点餐系统分享给需要的同学【完整源码+数据库】
- droop下垂并网控制,采用电压电流双环spwm控制.2018b版本
- 西门子1200PLC控制加KPT1200触摸屏,污水处理厂自控项目实例,含一台200SMART200加触摸屏泵站程序画面 内涵全套电气控制图纸 改建成已运行项目,所有应用均经过实际验证 应用包括
- 全套S7-1200一拖三恒压供水程序样例+PID样例+触摸屏样例 34 1、此程序采用S7-1200PLC和KTP1000PN触摸屏人机执行PID控制变频器实现恒压供水. 包括plc程序,触摸屏
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈