diff --git a/jeecg-module-app/src/main/java/org/jeecg/modules/controller/LoginController.java b/jeecg-module-app/src/main/java/org/jeecg/modules/controller/LoginController.java index 97883e0e..8cbb320a 100644 --- a/jeecg-module-app/src/main/java/org/jeecg/modules/controller/LoginController.java +++ b/jeecg-module-app/src/main/java/org/jeecg/modules/controller/LoginController.java @@ -1,11 +1,64 @@ package org.jeecg.modules.controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.constant.CacheConstant; +import org.jeecg.common.constant.CommonConstant; +import org.jeecg.common.system.util.JwtUtil; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.common.util.PasswordUtil; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.base.entity.postgre.SysDepart; +import org.jeecg.modules.base.entity.postgre.SysUser; +import org.jeecg.modules.model.SysLoginModel; +import org.jeecg.modules.service.LoginService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; @RestController @RequestMapping("") public class LoginController { + @Autowired + private LoginService loginService; + /** + * app登录 + * @param sysLoginModel + * @return + * @throws Exception + */ + @RequestMapping(value = "/mLogin", method = RequestMethod.POST) + public Result mLogin(@RequestBody SysLoginModel sysLoginModel) { + return loginService.mLogin(sysLoginModel); + } + + /** + * 退出登录 + * @param request + * @param response + * @return + */ + @RequestMapping(value = "/logout") + public Result logout(HttpServletRequest request, HttpServletResponse response) { + //用户退出逻辑 + return loginService.logout(request, response); + } + + /** + * 后台生成图形验证码 :有效 + * @param response + * @param key + */ + @ApiOperation("获取验证码") + @GetMapping(value = "/randomImage/{key}") + public Result randomImage(HttpServletResponse response,@PathVariable("key") String key) { + return loginService.randomImage(response, key); + } } diff --git a/jeecg-module-app/src/main/java/org/jeecg/modules/model/SysLoginModel.java b/jeecg-module-app/src/main/java/org/jeecg/modules/model/SysLoginModel.java new file mode 100644 index 00000000..859a71dc --- /dev/null +++ b/jeecg-module-app/src/main/java/org/jeecg/modules/model/SysLoginModel.java @@ -0,0 +1,55 @@ +package org.jeecg.modules.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * 登录表单 + * + * @Author scott + * @since 2019-01-18 + */ +@ApiModel(value="登录对象", description="登录对象") +public class SysLoginModel { + @ApiModelProperty(value = "账号") + private String username; + @ApiModelProperty(value = "密码") + private String password; + @ApiModelProperty(value = "验证码") + private String captcha; + @ApiModelProperty(value = "验证码key") + private String checkKey; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getCaptcha() { + return captcha; + } + + public void setCaptcha(String captcha) { + this.captcha = captcha; + } + + public String getCheckKey() { + return checkKey; + } + + public void setCheckKey(String checkKey) { + this.checkKey = checkKey; + } + +} diff --git a/jeecg-module-app/src/main/java/org/jeecg/modules/service/LoginService.java b/jeecg-module-app/src/main/java/org/jeecg/modules/service/LoginService.java index aa56963f..b755cd72 100644 --- a/jeecg-module-app/src/main/java/org/jeecg/modules/service/LoginService.java +++ b/jeecg-module-app/src/main/java/org/jeecg/modules/service/LoginService.java @@ -1,11 +1,46 @@ package org.jeecg.modules.service; +import com.alibaba.fastjson.JSONObject; +import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.base.entity.postgre.SysEmail; +import org.jeecg.modules.model.SysLoginModel; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; @Component -@FeignClient("armd-system") +@FeignClient(value = "armd-system", path = "/sys") public interface LoginService { + /** + * 登录 + * @return + */ + @GetMapping("/mLogin") + Result mLogin(SysLoginModel sysLoginModel); + /** + * 登出 + * @return + */ + @GetMapping("/logout") + Result logout(HttpServletRequest request, HttpServletResponse response); + + /** + * 图形验证码 + */ + @GetMapping("/randomImage/{key}") + Result randomImage(HttpServletResponse response,@PathVariable("key") String key); + + /** + * 图形验证码 + * @return + */ + @PostMapping("/checkCaptcha") + Result checkCaptcha(); }