package com.xiaoyuanbang.order.controller;
import com.xiaoyuanbang.model.Order;
import com.xiaoyuanbang.order.service.OrderService;
import com.xiaoyuanbang.common.entity.PageResult;
import com.xiaoyuanbang.common.entity.Result;
import com.xiaoyuanbang.common.entity.StatusCode;
import com.xiaoyuanbang.model.User;
import com.xiaoyuanbang.user.service.UserService;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import com.xiaoyuanbang.common.util.JwtUtil;
import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
import java.util.*;
/**
* 控制器层
*
* @author Administrator
*/
@RestController
@CrossOrigin
@RequestMapping("/order")
public class OrderController {
@Autowired
private OrderService orderService;
@Autowired
private HttpServletRequest request;
@Autowired
// private RestTemplate restTemplate;
private UserService userService;
@Autowired
private JwtUtil jwtUtil;
/**
* 查询全部数据
*
* @return
*/
@RequestMapping(method = RequestMethod.GET)
public Result findAll() {
return new Result(true, StatusCode.OK, "查询成功", orderService.findAll());
}
/**
* 根据ID查询
*
* @param id ID
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public Result findById(@PathVariable String id) {
return new Result(true, StatusCode.OK, "查询成功", orderService.findById(id));
}
@RequestMapping(value = "/some/{id}", method = RequestMethod.GET)
public Result findSomeById(@PathVariable String id) {
Order order = orderService.findById(id);
Order newOrder = new Order();
newOrder.setCreate_time(order.getCreate_time());
newOrder.setReward(order.getReward());
newOrder.setOrder_type(order.getOrder_type());
newOrder.setBuy_request(order.getBuy_request());
newOrder.setId(order.getId());
newOrder.setUserid(order.getUserid());
newOrder.setBuy_price(order.getBuy_price());
newOrder.setBuy_weight(order.getBuy_weight());
newOrder.setId(order.getId());
return new Result(true, StatusCode.OK, "查询成功", newOrder);
}
@PutMapping(value = "/updateCancelOrder/{orderid}")
public Result updateCancelOrder(@PathVariable String orderid, @RequestBody String token) {
Claims claims = jwtUtil.parseJWT(token);
String id = claims.getId();
if (id.equals("user")) {
orderService.updateCancelOrder(orderid);
return new Result(true, StatusCode.OK, "修改成功");
} else {
return new Result(false, StatusCode.ERROR, "修改出错");
}
}
/**
* 分页+多条件查询
*
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
*/
@RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap, @PathVariable int page, @PathVariable int size) {
Page<Order> pageList = orderService.findSearch(searchMap, page, size);
return new Result(true, StatusCode.OK, "查询成功", new PageResult<Order>(pageList.getTotalElements(), pageList.getContent()));
}
@RequestMapping(value = "/publicsearch/{page}/{size}", method = RequestMethod.POST)
public Result publicfindSearch(@RequestBody Map searchMap, @PathVariable int page, @PathVariable int size) {
Page<Order> pageList = orderService.findSearch(searchMap, page, size);
return new Result(true, StatusCode.OK, "查询成功", new PageResult<Order>(pageList.getTotalElements(), pageList.getContent()));
}
/**
* 根据条件查询
*
* @param searchMap
* @return
*/
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap) {
return new Result(true, StatusCode.OK, "查询成功", orderService.findSearch(searchMap));
}
/**
* 增加
*
* @param order
*/
@RequestMapping(method = RequestMethod.POST)
public Result add(@RequestBody Order order) {
orderService.add(order);
return new Result(true, StatusCode.OK, "增加成功");
}
/**
* 修改
*
* @param order
*/
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public Result update(@RequestBody Order order, @PathVariable String id) {
order.setId(id);
orderService.update(order);
return new Result(true, StatusCode.OK, "修改成功");
}
@RequestMapping(value = "/orderStatus/{id}", method = RequestMethod.PUT)
public Result updateOrderStatus(@RequestBody Order order, @PathVariable String id) {
order.setId(id);
orderService.updateOrderStatusAndPaytime(order);
return new Result(true, StatusCode.OK, "修改成功");
}
/**
* 删除
*
* @param id
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public Result delete(@PathVariable String id) {
orderService.deleteById(id);
return new Result(true, StatusCode.OK, "删除成功");
}
@PostMapping(value = "/sendOrder")
public Result saveSendOrder(@RequestBody Order order) {
Object claims_user = request.getAttribute("claims_user");
System.out.println(claims_user);
Claims claims = (Claims) claims_user;
if (claims == null) {
return new Result(false, StatusCode.ACCESSERROR, "请登录后再下单");
}
order.setUserid(claims.getId());
order.setCreate_time(new Date());
order.setStatus("1");
order.setIs_userdelete("N");
order.setIs_errandsdelete("N");
order.setIs_errC("N");
order.setIs_userC("N");
order.setOrder_type(2);
orderService.add(order);
Map map = new HashMap();
map.put("orderid", order.getId());
map.put("money", order.getReward());
return new Result(true, StatusCode.OK, "下单成功", map);
}
@PostMapping(value = "/takeOrder")
public Result saveTakeOrder(@RequestBody Order order) {
Object claims_user = request.getAttribute("claims_user");
System.out.println(claims_user);
Claims claims = (Claims) claims_user;
if (claims == null) {
return new Result(false, StatusCode.ACCESSERROR, "请登录后再下单");
}
order.setUserid(claims.getId());
order.setCreate_time(new Date());
order.setStatus("1");
order.setIs_userdelete("N");
order.setIs_errandsdelete("N");
order.setIs_errC("N");
order.setIs_userC("N");
order.setOrder_type(3);
orderService.add(order);
Map map = new HashMap();
map.put("orderid", order.getId());
map.put("money", order.getReward());
return new Result(true, StatusCode.OK, "下单成功", map);
}
@PostMapping(value = "/queueOrder")
public Result saveQueueOrder(@RequestBody Order order) {
Object claims_user = request.getAttribute("claims_user");
System.out.println(claims_user);
Claims claims = (Claims) claims_user;
if (claims == null) {
return new Result(false, StatusCode.ACCESSERROR, "请登录后再下单");
}
order.setUserid(claims.getId());
order.setCreate_time(new Date());
order.setStatus("1");
order.setIs_userdelete("N");
order.setIs_errandsdelete("N");
order.setIs_errC("N");
order.setIs_userC("N");
order.setOrder_type(4);
orderService.add(order);
Map map = new HashMap();
map.put("orderid", order.getId());
map.put("money", orde
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本人十余年JAVA架构设计经验,擅长JAVA高可用、分布式、高并发系统架构设计。有志于做JAVA系统性的技术提升的同学可与我联系,交个朋友哦~ 本人十余年JAVA架构设计经验,擅长JAVA高可用、分布式、高并发系统架构设计。有志于做JAVA系统性的技术提升的同学可与我联系,交个朋友哦~ 本人十余年JAVA架构设计经验,擅长JAVA高可用、分布式、高并发系统架构设计。有志于做JAVA系统性的技术提升的同学可与我联系,交个朋友哦~
资源推荐
资源详情
资源评论
收起资源包目录
《毕业设计&代码复用》--仿uu跑腿的跑腿网站。SpringBoot+Vue,集成支付宝支付.zip (2000个子文件)
sui.min.css 220KB
sui.min.css 220KB
samples.css 64KB
samples.css 64KB
FormMaking.css 43KB
font-awesome.css 37KB
font-awesome.css 37KB
editor_ie7.css 33KB
editor_ie7.css 33KB
editor_iequirks.css 31KB
editor_iequirks.css 31KB
editor_ie8.css 31KB
editor_ie8.css 31KB
editor_ie.css 31KB
editor_ie.css 31KB
font-awesome.min.css 30KB
font-awesome.min.css 30KB
editor_gecko.css 30KB
editor_gecko.css 30KB
editor.css 30KB
editor.css 30KB
sui-append.min.css 21KB
sui-append.min.css 21KB
publicSys.css 16KB
dialog_ie7.css 15KB
dialog_ie7.css 15KB
dialog_ie8.css 14KB
dialog_ie8.css 14KB
dialog_iequirks.css 14KB
dialog_iequirks.css 14KB
dialog_ie.css 14KB
dialog_ie.css 14KB
dialog.css 13KB
dialog.css 13KB
iconfont.css 11KB
page-sj-qa-tagDetail.css 11KB
page-sj-qa-tagDetail.css 11KB
page-sj-person-myfile.css 11KB
page-sj-person-myfile.css 11KB
page-sj-person-myreaded.css 10KB
page-sj-person-myreaded.css 10KB
page-sj-makeFriends-list.css 10KB
page-sj-makeFriends-list.css 10KB
page-sj-headline-login.css 9KB
page-sj-headline-login.css 9KB
page-headline-logined.css 9KB
page-headline-logined.css 9KB
page-sj-person-dynamic.css 9KB
page-sj-person-dynamic.css 9KB
page-sj-person-myanswer.css 9KB
page-sj-person-myanswer.css 9KB
page-sj-person-mycollect.css 9KB
page-sj-person-mycollect.css 9KB
page-sj-makeFriends-index.css 8KB
page-sj-makeFriends-index.css 8KB
demo.css 8KB
page-sj-person-homepage.css 8KB
page-sj-person-homepage.css 8KB
normalize.css 8KB
normalize.css 8KB
page-sj-makeFriends-edit.css 8KB
page-sj-makeFriends-edit.css 8KB
page-sj-person-myfocus.css 8KB
page-sj-person-myfocus.css 8KB
codemirror.css 8KB
codemirror.css 8KB
page-sj-makeFriends-talk.css 8KB
page-sj-makeFriends-talk.css 8KB
page-sj-person-account.css 7KB
page-sj-person-account.css 7KB
page-sj-headline-submit.css 7KB
page-sj-headline-submit.css 7KB
chat.css 7KB
chat.css 7KB
metroStyle.css 6KB
page-sj-person-myquestion.css 6KB
page-sj-person-myquestion.css 6KB
page-sj-person-myshare.css 6KB
page-sj-person-myshare.css 6KB
page-sj-qa-logined.css 6KB
page-sj-qa-logined.css 6KB
page-sj-qa-login.css 6KB
page-sj-qa-login.css 6KB
page-sj-acticle-editorGrammar.css 6KB
page-sj-acticle-editorGrammar.css 6KB
zTreeStyle.css 6KB
widget-submit-headline.css 6KB
widget-submit-headline.css 6KB
page-sj-qa-detail.css 5KB
page-sj-qa-detail.css 5KB
widget-tabtags-bottom-line.css 5KB
widget-tabtags-bottom-line.css 5KB
page-sj-acticle-feedback.css 5KB
page-sj-acticle-feedback.css 5KB
page-sj-recruit-area.css 5KB
page-sj-recruit-area.css 5KB
page-sj-recruit-job.css 5KB
page-sj-recruit-job.css 5KB
widget-file-edit.css 5KB
widget-file-edit.css 5KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
季风泯灭的季节
- 粉丝: 1898
- 资源: 3370
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 全球干旱数据集【自校准帕尔默干旱程度指数scPDSI】-190101-202312-0.5x0.5
- 基于Python实现的VAE(变分自编码器)训练算法源代码+使用说明
- 全球干旱数据集【标准化降水蒸发指数SPEI-12】-190101-202312-0.5x0.5
- C语言小游戏-五子棋-详细代码可运行
- 全球干旱数据集【标准化降水蒸发指数SPEI-03】-190101-202312-0.5x0.5
- spring boot aop记录修改前后的值demo
- 全球干旱数据集【标准化降水蒸发指数SPEI-01】-190101-202312-0.5x0.5
- ActiveReports
- vgbvdsbnjkbfnb
- effsefefeffsfwfse
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功