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.MPUtil;
import com.utils.CommonUtil;
/**
* 供应商
* 后端接口
* @author
* @email
* @date 2020-11-05 22:50:30
*/
@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("zhanghao", 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("zhanghao", gongyingshang.getZhanghao()));
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("zhanghao", 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") String id){
GongyingshangEntity gongyingshang = gongyingshangService.selectById(id);
return R.ok().put("data", gongyingshang);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String 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("zhanghao", gongyingshang.getZhanghao()));
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("zhanghao", gongyingshang.getZhanghao()));
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){
gongyingshangService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM的便利店信息管理系统源码.zip (825个子文件)
GongyingshangController.class 10KB
YuangongController.class 10KB
CommonController.class 10KB
GongyingshangshangpinController.class 8KB
JinhuoxinxiController.class 8KB
LiaotianhuifuController.class 8KB
LiaotianxinxiController.class 8KB
TousuxinxiController.class 8KB
ShangpinleixingController.class 8KB
XiaoshoutongjiController.class 8KB
ShangpinxinxiController.class 8KB
MPUtil.class 7KB
UserController.class 6KB
GongyingshangshangpinEntity.class 5KB
JinhuoxinxiEntity.class 5KB
TokenServiceImpl.class 4KB
FileController.class 4KB
ShangpinxinxiEntity.class 4KB
BaiduUtil.class 4KB
GongyingshangshangpinServiceImpl.class 4KB
ShangpinleixingServiceImpl.class 4KB
XiaoshoutongjiServiceImpl.class 4KB
GongyingshangServiceImpl.class 4KB
ShangpinxinxiServiceImpl.class 4KB
LiaotianxinxiServiceImpl.class 4KB
LiaotianhuifuServiceImpl.class 4KB
JinhuoxinxiServiceImpl.class 4KB
TousuxinxiServiceImpl.class 4KB
YuangongServiceImpl.class 4KB
ConfigController.class 4KB
TousuxinxiEntity.class 3KB
AuthorizationInterceptor.class 3KB
GongyingshangEntity.class 3KB
YuangongEntity.class 3KB
XiaoshoutongjiEntity.class 3KB
LiaotianxinxiEntity.class 3KB
LiaotianhuifuEntity.class 3KB
Query.class 3KB
GongyingshangshangpinModel.class 3KB
GongyingshangshangpinVO.class 3KB
UserServiceImpl.class 3KB
PageUtils.class 3KB
JinhuoxinxiModel.class 3KB
TokenEntity.class 3KB
JinhuoxinxiVO.class 3KB
ShangpinxinxiModel.class 2KB
ShangpinxinxiVO.class 2KB
ShangpinleixingEntity.class 2KB
CommonServiceImpl.class 2KB
R.class 2KB
GongyingshangshangpinService.class 2KB
GongyingshangshangpinDao.class 2KB
UserEntity.class 2KB
ValidatorUtils.class 2KB
TousuxinxiModel.class 2KB
SpringContextUtils.class 2KB
TousuxinxiVO.class 2KB
ShangpinleixingService.class 2KB
XiaoshoutongjiService.class 2KB
ShangpinxinxiService.class 2KB
LiaotianxinxiService.class 2KB
GongyingshangService.class 2KB
LiaotianhuifuService.class 2KB
ShangpinleixingDao.class 2KB
XiaoshoutongjiDao.class 2KB
JinhuoxinxiService.class 2KB
ShangpinxinxiDao.class 2KB
LiaotianhuifuDao.class 2KB
LiaotianxinxiDao.class 2KB
GongyingshangDao.class 2KB
XiaoshoutongjiModel.class 2KB
TousuxinxiService.class 2KB
XiaoshoutongjiVO.class 2KB
HttpClientUtils.class 2KB
JinhuoxinxiDao.class 2KB
YuangongService.class 2KB
TousuxinxiDao.class 2KB
ConfigServiceImpl.class 2KB
YuangongDao.class 2KB
TypeEnum.class 1KB
GongyingshangModel.class 1KB
GongyingshangVO.class 1KB
YuangongModel.class 1KB
YuangongVO.class 1KB
LiaotianhuifuModel.class 1KB
LiaotianxinxiModel.class 1KB
LiaotianhuifuVO.class 1KB
LiaotianxinxiVO.class 1KB
JQPageInfo.class 1KB
EIException.class 1KB
ConfigEntity.class 1KB
SQLFilter.class 1KB
GongyingshangshangpinView.class 1KB
ShangpinleixingView.class 1KB
XiaoshoutongjiView.class 1KB
LiaotianhuifuView.class 1KB
GongyingshangView.class 1KB
LiaotianxinxiView.class 1KB
ShangpinxinxiView.class 1KB
JinhuoxinxiView.class 1KB
共 825 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
老歪不歪
- 粉丝: 44
- 资源: 4368
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功