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.SysUserTeacherEntity;
import com.zcloud.modules.custormerInfo.service.SysUserTeacherService;
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.Map;

/**
 * @Author wangyitao
 * @Desc (SysUserTeacher)表控制层
 * @Date 2024-10-15 14:32:59
 */
@Api(tags = "")
@RestController
@RequestMapping("sysUserTeacher")
public class SysUserTeacherController extends AbstractController {

    @Autowired
    private SysUserTeacherService sysUserTeacherService;

    @ApiOperation("-新增数据")
    @SysLog("-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody SysUserTeacherEntity param) {
        param.setCreator(getUserId());
		param.setOperator(getUserId());
        sysUserTeacherService.save(param);

        return R.ok();
    }

    @ApiOperation("-编辑数据")
    @SysLog("-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody SysUserTeacherEntity param) {
        param.setOperator(getUserId());
        sysUserTeacherService.updateById(param);

        return R.ok();
    }


    @ApiOperation("-删除数据")
    @SysLog("-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody SysUserTeacherEntity param) {
        sysUserTeacherService.delete(param.getTeacherId(),getUserId());
        return R.ok();
    }

    @ApiOperation("-分页查询")
    @SysLog("-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = sysUserTeacherService.listPage(params);

		return R.ok().put("page", page);
    }


    @ApiOperation("-根据ID查详情")
    @SysLog("-根据ID查详情")
    @PostMapping("/getInfo")
    public R info(@RequestBody SysUserTeacherEntity param) {
        SysUserTeacherEntity sysUserTeacher = sysUserTeacherService.getInfo(param.getTeacherId());
        return R.ok().put("data", sysUserTeacher);
    }

}
