package com.kmall.admin.controller;

import java.util.List;
import java.util.Map;

import com.kmall.admin.entity.OrderProcessRecordEntity;
import com.kmall.admin.service.OrderProcessRecordService;
import com.kmall.common.utils.PageUtils;
import com.kmall.common.utils.Query;
import com.kmall.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 订单流转过程记录表Controller
 *
 * @author emato
 * @email admin@qhdswl.com
 * @date 2018-10-27 16:38:50
 */
@RestController
@RequestMapping("orderprocessrecord")
public class OrderProcessRecordController {
    @Autowired
    private OrderProcessRecordService orderProcessRecordService;

    /**
     * 查看列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("orderprocessrecord:list")
    @ResponseBody
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        Query query = new Query(params);

        List<OrderProcessRecordEntity> orderProcessRecordList = orderProcessRecordService.queryList(query);
        int total = orderProcessRecordService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(orderProcessRecordList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }

    /**
     * 查看信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("orderprocessrecord:info")
    @ResponseBody
    public R info(@PathVariable("id") Integer id) {
        OrderProcessRecordEntity orderProcessRecord = orderProcessRecordService.queryObject(id);

        return R.ok().put("orderProcessRecord", orderProcessRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("orderprocessrecord:save")
    @ResponseBody
    public R save(@RequestBody OrderProcessRecordEntity orderProcessRecord) {
        orderProcessRecordService.save(orderProcessRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("orderprocessrecord:update")
    @ResponseBody
    public R update(@RequestBody OrderProcessRecordEntity orderProcessRecord) {
        orderProcessRecordService.update(orderProcessRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("orderprocessrecord:delete")
    @ResponseBody
    public R delete(@RequestBody Integer[]ids) {
        orderProcessRecordService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 查看所有列表
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    public R queryAll(@RequestParam Map<String, Object> params) {

        List<OrderProcessRecordEntity> list = orderProcessRecordService.queryList(params);

        return R.ok().put("list", list);
    }
}
