开发语言:Java 框架:ssm JDK版本:JDK1.8 服务器:tomcat7 数据库:mysql 5.7(一定要5.7版本) 数据库工具:Navicat11 开发软件:eclipse/myeclipse/idea Maven包:Maven3.3.9 浏览器:谷歌浏览器
小程序框架:uniapp 小程序开发软件:HBuilder X 小程序运行软件:微信开发者
代码:
/**
- 订单
- 后端接口
- @author
- @date 2022-03-17 10:27:03
*/
@RestController
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private OrdersService ordersService;
/**
- 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,OrdersEntity orders,
HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
orders.setUserid((Long)request.getSession().getAttribute("userId"));
}
EntityWrapper(); PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params)); return R.ok().put("data", page); }
/**
- 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){ EntityWrapper(); PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params)); return R.ok().put("data", page); }
/**
- 列表 */ @RequestMapping("/lists") public R list( OrdersEntity orders){ EntityWrapper(); ew.allEq(MPUtil.allEQMapPre( orders, "orders")); return R.ok().put("data", ordersService.selectListView(ew)); }
/**
- 查询 */ @RequestMapping("/query") public R query(OrdersEntity orders){ EntityWrapper< OrdersEntity> ew = new EntityWrapper< OrdersEntity>(); ew.allEq(MPUtil.allEQMapPre( orders, "orders")); OrdersView ordersView = ordersService.selectView(ew); return R.ok("查询订单成功").put("data", ordersView); }
/**
- 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ OrdersEntity orders = ordersService.selectById(id); return R.ok().put("data", orders); }
/**
- 前端详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ OrdersEntity orders = ordersService.selectById(id); return R.ok().put("data", orders); }
/**
- 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody OrdersEntity orders, HttpServletRequest request){
orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(orders);
orders.setUserid((Long)request.getSession().getAttribute("userId"));
ordersService.insert(orders); return R.ok(); }
/**
- 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody OrdersEntity orders, HttpServletRequest request){
orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(orders);
ordersService.insert(orders); return R.ok(); }
/**
- 修改 */ @RequestMapping("/update") public R update(@RequestBody OrdersEntity orders, HttpServletRequest request){ //ValidatorUtils.validateEntity(orders); ordersService.updateById(orders);//全部更新 return R.ok(); }