package com.pannk.mms.modules.sys.controller;

import com.pannk.mms.common.base.BaseController;
import com.pannk.mms.common.base.Result;
import com.pannk.mms.modules.sys.entity.SysUserEntity;
import com.pannk.mms.modules.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wolf on 20-11-2.
 */
@RequestMapping("/sys/user")
@RestController
public class SysUserController extends BaseController {

    @Autowired
    private SysUserService sysUserService;



    @GetMapping("/list")
    public Result list() {
        return Result.success(sysUserService.list());
    }

    @GetMapping("/info/{id}")
    public Result detail(@PathVariable Long id) {
        return Result.success(sysUserService.queryUserInfo(id));
    }

    @GetMapping("/save")
    public Result save() {
        SysUserEntity sysUserEntity = new SysUserEntity();
        sysUserEntity.setCode("P00001");
        sysUserEntity.setEmail("qxd@126.com");
        sysUserEntity.setFullName("秦晓东");
        sysUserEntity.setGender(0);
        sysUserEntity.setStatus(0);
        sysUserEntity.setUserName("qxd");
        sysUserEntity.setPassword("123456");
        createData(sysUserEntity);
        sysUserService.save(sysUserEntity);
        return Result.success(sysUserEntity);
    }
}
