package com.zhongzheng.controller.base;

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

import com.zhongzheng.modules.base.bo.ProfileFieldAddBo;
import com.zhongzheng.modules.base.bo.ProfileFieldEditBo;
import com.zhongzheng.modules.base.bo.ProfileFieldQueryBo;
import com.zhongzheng.modules.base.service.IProfileFieldService;
import com.zhongzheng.modules.base.vo.ProfileFieldVo;
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 2021-11-19
 */
@Api(value = "资料字段控制器", tags = {"资料字段管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/base/profile/field")
public class ProfileFieldController extends BaseController {

    private final IProfileFieldService iProfileFieldService;

    /**
     * 查询资料字段列表
     */
    @ApiOperation("查询资料字段列表")
    @PreAuthorize("@ss.hasPermi('system:field:list')")
    @GetMapping("/list")
    public TableDataInfo<ProfileFieldVo> list(ProfileFieldQueryBo bo) {
        startPage();
        List<ProfileFieldVo> list = iProfileFieldService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出资料字段列表
     */
  /*  @ApiOperation("导出资料字段列表")
    @PreAuthorize("@ss.hasPermi('system:field:export')")
    @Log(title = "资料字段", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ProfileFieldVo> export(ProfileFieldQueryBo bo) {
        List<ProfileFieldVo> list = iProfileFieldService.queryList(bo);
        ExcelUtil<ProfileFieldVo> util = new ExcelUtil<ProfileFieldVo>(ProfileFieldVo.class);
        return util.exportExcel(list, "资料字段");
    }*/

    /**
     * 获取资料字段详细信息
     */
    @ApiOperation("获取资料字段详细信息")
    @PreAuthorize("@ss.hasPermi('system:field:query')")
    @GetMapping("/{fieldId}")
    public AjaxResult<ProfileFieldVo> getInfo(@PathVariable("fieldId" ) Long fieldId) {
        return AjaxResult.success(iProfileFieldService.queryById(fieldId));
    }

    /**
     * 新增资料字段
     */
    /*@ApiOperation("新增资料字段")
    @PreAuthorize("@ss.hasPermi('system:field:add')")
    @Log(title = "资料字段", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody ProfileFieldAddBo bo) {
        return toAjax(iProfileFieldService.insertByAddBo(bo) ? 1 : 0);
    }*/

    /**
     * 修改资料字段
     */
   /* @ApiOperation("修改资料字段")
    @PreAuthorize("@ss.hasPermi('system:field:edit')")
    @Log(title = "资料字段", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody ProfileFieldEditBo bo) {
        return toAjax(iProfileFieldService.updateByEditBo(bo) ? 1 : 0);
    }*/

    /**
     * 删除资料字段
     */
    /*@ApiOperation("删除资料字段")
    @PreAuthorize("@ss.hasPermi('system:field:remove')")
    @Log(title = "资料字段" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{fieldIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] fieldIds) {
        return toAjax(iProfileFieldService.deleteWithValidByIds(Arrays.asList(fieldIds), true) ? 1 : 0);
    }*/
}
