package com.zhongzheng.controller.user;

import java.util.List;
import java.util.Arrays;

import com.zhongzheng.modules.user.bo.UserCertificateAddBo;
import com.zhongzheng.modules.user.bo.UserCertificateEditBo;
import com.zhongzheng.modules.user.bo.UserCertificateQueryBo;
import com.zhongzheng.modules.user.service.IUserCertificateService;
import com.zhongzheng.modules.user.vo.UserCertificateVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 用户证书Controller
 *
 * @author hjl
 * @date 2022-02-17
 */
@Api(value = "用户证书控制器", tags = {"用户证书管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/user/certificate")
public class UserCertificateController extends BaseController {

    private final IUserCertificateService iUserCertificateService;

    /**
     * 查询用户证书列表
     */
    @ApiOperation("查询用户证书列表")
    @PreAuthorize("@ss.hasPermi('system:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo<UserCertificateVo> list(UserCertificateQueryBo bo) {
        startPage();
        List<UserCertificateVo> list = iUserCertificateService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出用户证书列表
     */
   /* @ApiOperation("导出用户证书列表")
    @PreAuthorize("@ss.hasPermi('system:certificate:export')")
    @Log(title = "用户证书", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<UserCertificateVo> export(UserCertificateQueryBo bo) {
        List<UserCertificateVo> list = iUserCertificateService.queryList(bo);
        ExcelUtil<UserCertificateVo> util = new ExcelUtil<UserCertificateVo>(UserCertificateVo.class);
        return util.exportExcel(list, "用户证书");
    }*/

    /**
     * 获取用户证书详细信息
     */
    @ApiOperation("获取用户证书详细信息")
    @PreAuthorize("@ss.hasPermi('system:certificate:query')")
    @GetMapping("/{id}")
    public AjaxResult<UserCertificateVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iUserCertificateService.queryById(id));
    }

    /**
     * 新增用户证书
     */
   /* @ApiOperation("新增用户证书")
    @PreAuthorize("@ss.hasPermi('system:certificate:add')")
    @Log(title = "用户证书", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody UserCertificateAddBo bo) {
        return toAjax(iUserCertificateService.insertByAddBo(bo) ? 1 : 0);
    }*/

    /**
     * 修改用户证书
     */
   /* @ApiOperation("修改用户证书")
    @PreAuthorize("@ss.hasPermi('system:certificate:edit')")
    @Log(title = "用户证书", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody UserCertificateEditBo bo) {
        return toAjax(iUserCertificateService.updateByEditBo(bo) ? 1 : 0);
    }*/

    /**
     * 删除用户证书
     */
   /* @ApiOperation("删除用户证书")
    @PreAuthorize("@ss.hasPermi('system:certificate:remove')")
    @Log(title = "用户证书" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iUserCertificateService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }*/
}
