package com.ruoyi.platform.controller.git;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.GenericsAjaxResult;
import com.ruoyi.platform.service.GitService;
import com.ruoyi.system.api.domain.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("gitLink")
@Api("gitLink")
public class GitLinkController extends BaseController {

    @Resource
    private GitService gitService;

    @GetMapping("/login")
    @ApiOperation("刷新giotLink用户信息")
    public GenericsAjaxResult<String> gitLinkLogin(@RequestParam("username") String username, @RequestParam("password") String password) {
        return genericsSuccess(gitService.login(username, password));
    }

    @PostMapping("/createGitLinkUser")
    @ApiOperation("新增gitLink用户")
    public GenericsAjaxResult<String> createGitLinkUser(@RequestBody SysUser sysUser) throws Exception {
        gitService.createUser(sysUser);
        return GenericsAjaxResult.success("新增成功");
    }

    @PostMapping("/resetPwd")
    @ApiOperation("更改gitLink用户密码")
    public GenericsAjaxResult<String> resetPwd(@RequestBody SysUser sysUser) throws Exception {
        gitService.resetPwd(sysUser);
        return GenericsAjaxResult.success("修改成功");
    }

    @PutMapping("/resetEmail")
    @ApiOperation("更改gitLink用户邮箱")
    public GenericsAjaxResult<String> resetEmail(@RequestBody SysUser sysUser) throws Exception {
        gitService.resetEmail(sysUser);
        return GenericsAjaxResult.success("修改成功");
    }

    @PutMapping("/resetPhoneNum")
    @ApiOperation("更改gitLink用户手机号")
    public GenericsAjaxResult<String> resetPhoneNum(@RequestBody SysUser sysUser) throws Exception {
        gitService.resetPhoneNum(sysUser);
        return GenericsAjaxResult.success("修改成功");
    }

    @DeleteMapping("/deleteGitLinkUser")
    @ApiOperation("删除gitLink用户")
    public GenericsAjaxResult<String> deleteGitLinkUser(@RequestBody SysUser sysUser) throws Exception {
        gitService.deleteUser(sysUser);
        return GenericsAjaxResult.success("删除成功");
    }
}
