You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
package LoginController
|
|
|
|
import (
|
|
"dsSupport/Model"
|
|
"dsSupport/MyModel/Login/LoginDao"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
//模块的路由配置
|
|
func Routers(r *gin.RouterGroup) {
|
|
rr := r.Group("/login")
|
|
//配置接口
|
|
rr.POST("/DoLogin", DoLogin)
|
|
|
|
return
|
|
}
|
|
|
|
// @Summary 登录
|
|
// @Description 登录
|
|
// @Tags 登录
|
|
// @Accept application/x-www-form-urlencoded
|
|
// @Produce json
|
|
// @Param loginName formData string true "登录名"
|
|
// @Param loginPwd formData string true "登录密码"
|
|
// @Success 200 {object} Model.Res
|
|
// @Router /support/accessSystem/GetPositionTreeInfo [post]
|
|
func DoLogin(c *gin.Context) {
|
|
//登录名
|
|
loginName := c.PostForm("loginName")
|
|
//登录密码
|
|
loginPwd := c.PostForm("loginPwd")
|
|
|
|
success, _, _, _, err := LoginDao.Login(loginName, loginPwd)
|
|
if err != nil {
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
Success: false,
|
|
Message: err.Error(),
|
|
})
|
|
return
|
|
}
|
|
|
|
if success {
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
Success: true,
|
|
Message: "登录成功!",
|
|
})
|
|
} else {
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
Success: false,
|
|
Message: "用户名或密码不正确!",
|
|
})
|
|
}
|
|
}
|