package com.jianshui.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jianshui.common.core.domain.entity.SysUser;
import com.jianshui.common.utils.StringUtils;
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.jianshui.common.annotation.Log;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.enums.BusinessType;
import com.jianshui.system.domain.CompanyserviceProp;
import com.jianshui.system.service.ICompanyservicePropService;
import com.jianshui.common.utils.poi.ExcelUtil;
import com.jianshui.common.core.page.TableDataInfo;

/**
 * 企业扩展属性，包括大象key等Controller
 * 
 * @author Gong Quanlin
 * @date 2022-04-06
 */
@RestController
@RequestMapping("/system/prop")
public class CompanyservicePropController extends BaseController
{
    @Autowired
    private ICompanyservicePropService companyservicePropService;

    /**
     * 查询企业扩展属性，包括大象key等列表
     */
    @PreAuthorize("@ss.hasPermi('system:prop:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyserviceProp companyserviceProp)
    {
        startPage();
        List<CompanyserviceProp> list = companyservicePropService.selectCompanyservicePropList(companyserviceProp);
        return getDataTable(list);
    }

    /**
     * 导出企业扩展属性，包括大象key等列表
     */
    @PreAuthorize("@ss.hasPermi('system:prop:export')")
    @Log(title = "企业扩展属性，包括大象key等", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompanyserviceProp companyserviceProp)
    {
        List<CompanyserviceProp> list = companyservicePropService.selectCompanyservicePropList(companyserviceProp);
        ExcelUtil<CompanyserviceProp> util = new ExcelUtil<CompanyserviceProp>(CompanyserviceProp.class);
        util.exportExcel(response, list, "企业扩展属性，包括大象key等数据");
    }

    /**
     * 获取企业扩展属性，包括大象key等详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:prop:query')")
    @GetMapping(value = "/{companyid}")
    public AjaxResult getInfo(@PathVariable("companyid") Long companyid)
    {
        return AjaxResult.success(companyservicePropService.selectCompanyservicePropByCompanyid(companyid));
    }

    /**
     * 新增企业扩展属性，包括大象key等
     */
    @PreAuthorize("@ss.hasPermi('system:prop:add')")
    @Log(title = "企业扩展属性，包括大象key等", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyserviceProp companyserviceProp)
    {
        return toAjax(companyservicePropService.insertCompanyserviceProp(companyserviceProp));
    }

    /**
     * 修改企业扩展属性，包括大象key等
     */
    @PreAuthorize("@ss.hasPermi('system:prop:edit')")
    @Log(title = "企业扩展属性，包括大象key等", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyserviceProp companyserviceProp)
    {
        return toAjax(companyservicePropService.updateCompanyserviceProp(companyserviceProp));
    }

    /**
     * 删除企业扩展属性，包括大象key等
     */
    @PreAuthorize("@ss.hasPermi('system:prop:remove')")
    @Log(title = "企业扩展属性，包括大象key等", businessType = BusinessType.DELETE)
	@DeleteMapping("/{companyids}")
    public AjaxResult remove(@PathVariable Long[] companyids)
    {
        return toAjax(companyservicePropService.deleteCompanyservicePropByCompanyids(companyids));
    }

    /**
     * 获取企业扩展属性，包括大象key等详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:prop:query')")
    @GetMapping(value = "/init/{companyid}")
    public AjaxResult init(@PathVariable("companyid") Long companyid)
    {
        return AjaxResult.success(companyservicePropService.initCompanyserviceProp(companyid));
    }
}
