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.GongyingshangEntity;
import com.entity.view.GongyingshangView;
import com.service.GongyingshangService;
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 2021-02-22 14:49:31
*/
@RestController
@RequestMapping("/gongyingshang")
public class GongyingshangController {
@Autowired
private GongyingshangService gongyingshangService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
GongyingshangEntity user = gongyingshangService.selectOne(new EntityWrapper<GongyingshangEntity>().eq("gongyingshangzhanghao", username));
if(user==null || !user.getMima().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(), username,"gongyingshang", "供应商" );
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@RequestMapping("/register")
public R register(@RequestBody GongyingshangEntity gongyingshang){
//ValidatorUtils.validateEntity(gongyingshang);
GongyingshangEntity user = gongyingshangService.selectOne(new EntityWrapper<GongyingshangEntity>().eq("gongyingshangzhanghao", gongyingshang.getGongyingshangzhanghao()));
if(user!=null) {
return R.error("注册用户已存在");
}
Long uId = new Date().getTime();
gongyingshang.setId(uId);
gongyingshangService.insert(gongyingshang);
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");
GongyingshangEntity user = gongyingshangService.selectById(id);
return R.ok().put("data", user);
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
GongyingshangEntity user = gongyingshangService.selectOne(new EntityWrapper<GongyingshangEntity>().eq("gongyingshangzhanghao", username));
if(user==null) {
return R.error("账号不存在");
}
user.setMima("123456");
gongyingshangService.updateById(user);
return R.ok("密码已重置为:123456");
}
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,GongyingshangEntity gongyingshang, HttpServletRequest request){
EntityWrapper<GongyingshangEntity> ew = new EntityWrapper<GongyingshangEntity>();
PageUtils page = gongyingshangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, gongyingshang), params), params));
request.setAttribute("data", page);
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,GongyingshangEntity gongyingshang, HttpServletRequest request){
EntityWrapper<GongyingshangEntity> ew = new EntityWrapper<GongyingshangEntity>();
PageUtils page = gongyingshangService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, gongyingshang), params), params));
request.setAttribute("data", page);
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( GongyingshangEntity gongyingshang){
EntityWrapper<GongyingshangEntity> ew = new EntityWrapper<GongyingshangEntity>();
ew.allEq(MPUtil.allEQMapPre( gongyingshang, "gongyingshang"));
return R.ok().put("data", gongyingshangService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(GongyingshangEntity gongyingshang){
EntityWrapper< GongyingshangEntity> ew = new EntityWrapper< GongyingshangEntity>();
ew.allEq(MPUtil.allEQMapPre( gongyingshang, "gongyingshang"));
GongyingshangView gongyingshangView = gongyingshangService.selectView(ew);
return R.ok("查询供应商成功").put("data", gongyingshangView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
GongyingshangEntity gongyingshang = gongyingshangService.selectById(id);
return R.ok().put("data", gongyingshang);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
GongyingshangEntity gongyingshang = gongyingshangService.selectById(id);
return R.ok().put("data", gongyingshang);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody GongyingshangEntity gongyingshang, HttpServletRequest request){
gongyingshang.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(gongyingshang);
GongyingshangEntity user = gongyingshangService.selectOne(new EntityWrapper<GongyingshangEntity>().eq("gongyingshangzhanghao", gongyingshang.getGongyingshangzhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
gongyingshang.setId(new Date().getTime());
gongyingshangService.insert(gongyingshang);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody GongyingshangEntity gongyingshang, HttpServletRequest request){
gongyingshang.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(gongyingshang);
GongyingshangEntity user = gongyingshangService.selectOne(new EntityWrapper<GongyingshangEntity>().eq("gongyingshangzhanghao", gongyingshang.getGongyingshangzhanghao()));
if(user!=null) {
return R.error("用户已存在");
}
gongyingshang.setId(new Date().getTime());
gongyingshangService.insert(gongyingshang);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody GongyingshangEntity gongyingshang, HttpServletRequest request){
//ValidatorUtils.validateEntity(gongyingshang);
gongyingshangService.updateById(gongyingshang);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
gongyi
Java徐师兄
- 粉丝: 1590
- 资源: 2309
最新资源
- COMSOL光学模型:魔角光子晶体激光器(能带,模式,参数化几何建模,激光,图中只放了一个例子)
- 锂离子电池热失控仿真,COMSOL热失控仿真,不同温度条件导致的电池热失控分析,方形电池热失控
- C#联合halcon源码 CAD测量比对 CAD图纸 测量 海康相机 通常测量规则的物体,通过找边,找圆,求线线交点,点到线的距离,很容易测量尺寸 这个源码的测量物体是不规则的,很多凸凹的地方都需要
- 基于MATLAB的图像拼接系统带GUI界面,支持彩色图片拼接,保存拼接结果图等
- #车辆动力学 #ABS汽车防抱死制动系统仿真 《汽车防抱死制动系统仿真》 内容包括:Matlab源程序+word讲解文档 汽车防抱死制动系统(ABS)可在汽车制动过程中自动控制和调节车轮制动力,防止制
- 基于cruise的混合动力商用车仿真,P2并联混动仿真模型可实现并联混动汽车动力性经济性仿真 1.模型通过cruise simulink联合仿真,策略通过MATLAB Simulink搭建逻辑门限控制
- 源荷不确定性 考虑源荷随机特征的热电联供微网优化matlab 王锐的《含可再生能源的热电联供型微网经济运行优化》 由风电机组、光伏电池、燃料电池、余热锅炉、燃气锅炉、蓄电池以及热电负荷构成的热电联供型
- C#基于GDI+的点集数据可视化与交互操作, 1)读取点线数据文件 2)绘图展示 3)自动编码(算法) 4)放大缩小全图查看 5)点击点进行绘制线段, 6)分类图层管理 7)绘制完成,保存绘制结果
- Qt+OpenCV通用视觉框架全套源码 Qt+OpenCV通用视觉框架全套源码 工具可扩展 除了opencv和相机sdk的dll,其它所有算法均无封装,可以根据自己需要补充自己的工具 基于 Q
- 电动汽车模型的各模块的Simulink模型,包括驾驶员模块,整车控制器模块,电机模块,变速器模块,主减速器模块,车轮模块,车速模块以及BMS模块 附有说明文档,文档详细的描述了模型的建模过程及功能
- 利用ReliefF算法对分类特征变量做特征重要性排序,实现特征选择 通过重要性排序图,选择重要的特征变量,以期实现数据降维的目的 程序直接替数据就可以用,程序内有注释,方便学习和使用 程序语言为
- AirPower-javascript
- libhv-websocket
- STM32F103C8T6单片机开发的步进电机控制,可实现步数加方向控制包括C#上位机程序,程序源码注释详细,非常实用,适合单片机开发人员和上位机开发人员
- pdfh5-javascript
- wmproxy-websocket
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈