package com.srs.web.controller.comprehensive;

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

import com.srs.comprehensive.domain.SrsAspect;
import com.srs.comprehensive.service.ISrsAspectService;
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.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.core.page.TableDataInfo;

/**
 * 加分规则Controller
 * 
 * @author srs
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/system/aspect")
public class SrsAspectController extends BaseController
{
    @Autowired
    private ISrsAspectService srsAspectService;

    /**
     * 查询加分规则列表
     */
//    @PreAuthorize("@ss.hasPermi('system:aspect:list')")
    @GetMapping("/list")
    public TableDataInfo list(SrsAspect srsAspect)
    {
        startPage();
        List<SrsAspect> list = srsAspectService.selectSrsAspectList(srsAspect);
        return getDataTable(list);
    }

    /**
     * 查询加分规则列表 树形结构
     */
//    @PreAuthorize("@ss.hasPermi('system:aspect:list')")
    @GetMapping("/lists")
    public TableDataInfo listTree(SrsAspect srsAspect)
    {
        startPage();
        List<Object> list = srsAspectService.selectSrsAspectListTree(srsAspect);
        return getDataTable(list);
    }


    /**
     * 导出加分规则列表
     */
//    @PreAuthorize("@ss.hasPermi('system:aspect:export')")
    @Log(title = "加分规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SrsAspect srsAspect)
    {
        List<SrsAspect> list = srsAspectService.selectSrsAspectList(srsAspect);
        ExcelUtil<SrsAspect> util = new ExcelUtil<SrsAspect>(SrsAspect.class);
        util.exportExcel(response, list, "加分规则数据");
    }

    /**
     * 获取加分规则详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:aspect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(srsAspectService.selectSrsAspectById(id));
    }

    /**
     * 新增加分规则
     */
//    @PreAuthorize("@ss.hasPermi('system:aspect:add')")
    @Log(title = "加分规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SrsAspect srsAspect)
    {
        return toAjax(srsAspectService.insertSrsAspect(srsAspect));
    }

    /**
     * 修改加分规则
     */
//    @PreAuthorize("@ss.hasPermi('system:aspect:edit')")
    @Log(title = "加分规则", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SrsAspect srsAspect)
    {
        return toAjax(srsAspectService.updateSrsAspect(srsAspect));
    }

    /**
     * 删除加分规则
     */
//    @PreAuthorize("@ss.hasPermi('system:aspect:remove')")
    @Log(title = "加分规则", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(srsAspectService.deleteSrsAspectByIds(ids));
    }
}
