package com.zcloud.modules.custormerInfo.controller;
 
import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.utils.PageUtils;
import com.zcloud.common.utils.R;
import com.zcloud.modules.custormerInfo.entity.SysDeveloperLogEntity;
import com.zcloud.modules.custormerInfo.service.SysDeveloperLogService;
import com.zcloud.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;
import java.util.Map;
 
/**
 * @Author lizenan
 * @Desc 系统日志(SysDeveloperLog)表控制层
 * @Date 2024-04-11 11:53:29
 */
@Api(tags = "系统日志")
@RestController
@RequestMapping("sysDeveloperLog")
public class SysDeveloperLogController extends AbstractController {
 
    @Autowired
    private SysDeveloperLogService sysDeveloperLogService;
 
    @ApiOperation("系统日志-新增数据")
    @SysLog("系统日志-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody SysDeveloperLogEntity param) {
//        param.setCreator(getUserId());
//		param.setOperator(getUserId());
        sysDeveloperLogService.save(param);
        
        return R.ok();
    }
    
    @ApiOperation("系统日志-编辑数据")
    @SysLog("系统日志-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody SysDeveloperLogEntity param) {
//        param.setOperator(getUserId());
        sysDeveloperLogService.updateById(param);
        
        return R.ok();
    }
    
     
    @ApiOperation("系统日志-删除数据")
    @SysLog("系统日志-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody SysDeveloperLogEntity param) {
        sysDeveloperLogService.delete(param.getId(),getUserId());
        return R.ok();
    }
 
    @ApiOperation("系统日志-分页查询")
    @SysLog("系统日志-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = sysDeveloperLogService.listPage(params);

		return R.ok().put("page", page);
    }
    
 
    @ApiOperation("系统日志-根据ID查详情")
    @SysLog("系统日志-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody SysDeveloperLogEntity param) {
        SysDeveloperLogEntity sysDeveloperLog = sysDeveloperLogService.getById(param.getId());
        return R.ok().put("data", sysDeveloperLog);
    }

    @PostMapping("/listYear")
    public R listYear() {
        List<String> strings = sysDeveloperLogService.listYear();
        return R.ok().put("data", strings);
    }

}
