package com.younike.store.controller;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import com.younike.common.bean.APIResult;
import com.younike.common.bean.ResultGenerator;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import com.younike.common.core.page.PageParam;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.younike.common.annotation.OpLog;
import com.younike.common.core.controller.BaseController;
import com.younike.common.constant.BusinessType;
import com.younike.service.pojo.StoreAuditLog;
import com.younike.service.service.IStoreAuditLogService;

/**
 * 门店资质审核记录Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/storeAuditLog")
public class StoreAuditLogController extends BaseController {
    @Autowired
    private IStoreAuditLogService storeAuditLogService;

    /**
     * 查询门店资质审核记录列表
     */
    @RequiresPermissions("log:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<StoreAuditLog> page) {

        return storeAuditLogService.page(page);
    }


    /**
     * 获取门店资质审核记录详细信息
     */
    @RequiresPermissions("log:query")
    @GetMapping(value = "/{storeAuditLogId}")
    public APIResult getInfo(@PathVariable("storeAuditLogId") String storeAuditLogId) {
        return ResultGenerator.getSuccessResult(storeAuditLogService.getById(storeAuditLogId));
    }

    /**
     * 新增门店资质审核记录
     */
    @RequiresPermissions("log:add")
    @OpLog(title = "门店资质审核记录", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody StoreAuditLog storeAuditLog) {
        return ResultGenerator.getSuccessResult(storeAuditLogService.save(storeAuditLog));
    }

    /**
     * 修改门店资质审核记录
     */
    @RequiresPermissions("log:edit")
    @OpLog(title = "门店资质审核记录", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody StoreAuditLog storeAuditLog) {
        return ResultGenerator.getSuccessResult(storeAuditLogService.updateById(storeAuditLog));
    }

    /**
     * 删除门店资质审核记录
     */
    @RequiresPermissions("log:remove")
    @OpLog(title = "门店资质审核记录", type = BusinessType.DELETE)
    @DeleteMapping("/{storeAuditLogIds}")
    public APIResult remove(@PathVariable List<String> storeAuditLogIds) {
        return ResultGenerator.getSuccessResult(storeAuditLogService.removeByIds(storeAuditLogIds));
    }
}
