diff --git a/doctor-auth/src/main/java/doctor/auth/controller/HealthController.java b/doctor-auth/src/main/java/doctor/auth/controller/HealthController.java index f85c60e..1b42008 100644 --- a/doctor-auth/src/main/java/doctor/auth/controller/HealthController.java +++ b/doctor-auth/src/main/java/doctor/auth/controller/HealthController.java @@ -2,6 +2,7 @@ package doctor.auth.controller; import doctor.auth.service.HealthService; import doctor.auth.vo.DoctorUserVo; +import doctor.common.core.domain.HealthR; import doctor.common.core.domain.R; import doctor.common.security.service.TokenService; import doctor.system.api.model.LoginUser; @@ -21,9 +22,13 @@ public class HealthController { private HealthService healthService; @PostMapping("/login") - public R login(@RequestParam String email,String pwd) { + public HealthR login(@RequestParam String email, @RequestParam String pwd) { DoctorUserVo userInfo = healthService.login(email,pwd); - return R.ok(userInfo); + if (userInfo!=null){ + return HealthR.ok(userInfo); + }else { + return HealthR.fail(); + } } diff --git a/doctor-auth/src/main/java/doctor/auth/service/HealthService.java b/doctor-auth/src/main/java/doctor/auth/service/HealthService.java index 0166629..e9a13e6 100644 --- a/doctor-auth/src/main/java/doctor/auth/service/HealthService.java +++ b/doctor-auth/src/main/java/doctor/auth/service/HealthService.java @@ -29,19 +29,22 @@ public class HealthService { } catch (Exception e) { throw new RuntimeException(e); } - Map token = tokenService.createToken(data); - String accessToken = (String) token.get("access_token"); - doctorUserVo.setSessionId(accessToken); - doctorUserVo.setEmail(data.getSysUser().getEmail()); - doctorUserVo.setUserId(data.getSysUser().getUserId().intValue()); - doctorUserVo.setUserName(data.getSysUser().getUserName()); - doctorUserVo.setNickName(data.getSysUser().getNickName()); - doctorUserVo.setJiGuangPwd(s); - if (data.getSysUser().getSex()=="男"){ - doctorUserVo.setSex(0); - }else { - doctorUserVo.setSex(1); + if (s.equals(data.getSysUser().getPassword())){ + Map token = tokenService.createToken(data); + String accessToken = (String) token.get("access_token"); + doctorUserVo.setSessionId(accessToken); + doctorUserVo.setEmail(data.getSysUser().getEmail()); + doctorUserVo.setUserId(data.getSysUser().getUserId().intValue()); + doctorUserVo.setUserName(data.getSysUser().getUserName()); + doctorUserVo.setNickName(data.getSysUser().getNickName()); + doctorUserVo.setJiGuangPwd(s); + if (data.getSysUser().getSex()=="男"){ + doctorUserVo.setSex(0); + }else { + doctorUserVo.setSex(1); + } + return doctorUserVo; } - return doctorUserVo; + return null; } } diff --git a/doctor-common/doctor-common-core/src/main/java/doctor/common/core/constant/HealthConstants.java b/doctor-common/doctor-common-core/src/main/java/doctor/common/core/constant/HealthConstants.java new file mode 100644 index 0000000..bfbbeb1 --- /dev/null +++ b/doctor-common/doctor-common-core/src/main/java/doctor/common/core/constant/HealthConstants.java @@ -0,0 +1,135 @@ +package doctor.common.core.constant; + +/** + * 通用常量信息 + * + * @author ruoyi + */ +public class HealthConstants +{ + /** + * UTF-8 字符集 + */ + public static final String UTF8 = "UTF-8"; + + /** + * GBK 字符集 + */ + public static final String GBK = "GBK"; + + /** + * www主域 + */ + public static final String WWW = "www."; + + /** + * RMI 远程方法调用 + */ + public static final String LOOKUP_RMI = "rmi:"; + + /** + * LDAP 远程方法调用 + */ + public static final String LOOKUP_LDAP = "ldap:"; + + /** + * LDAPS 远程方法调用 + */ + public static final String LOOKUP_LDAPS = "ldaps:"; + + /** + * http请求 + */ + public static final String HTTP = "http://"; + + /** + * https请求 + */ + public static final String HTTPS = "https://"; + + /** + * 成功标记 + */ + public static final String SUCCESS = "0000"; + + /** + * 失败标记 + */ + public static final String FAIL = "9999"; + + /** + * 登录成功状态 + */ + public static final String LOGIN_SUCCESS_STATUS = "0"; + + /** + * 登录失败状态 + */ + public static final String LOGIN_FAIL_STATUS = "1"; + + /** + * 登录成功 + */ + public static final String LOGIN_SUCCESS = "Success"; + + /** + * 注销 + */ + public static final String LOGOUT = "Logout"; + + /** + * 注册 + */ + public static final String REGISTER = "Register"; + + /** + * 登录失败 + */ + public static final String LOGIN_FAIL = "Error"; + + /** + * 当前记录起始索引 + */ + public static final String PAGE_NUM = "pageNum"; + + /** + * 每页显示记录数 + */ + public static final String PAGE_SIZE = "pageSize"; + + /** + * 排序列 + */ + public static final String ORDER_BY_COLUMN = "orderByColumn"; + + /** + * 排序的方向 "desc" 或者 "asc". + */ + public static final String IS_ASC = "isAsc"; + + /** + * 验证码有效期(分钟) + */ + public static final long CAPTCHA_EXPIRATION = 2; + + /** + * 资源映射路径 前缀 + */ + public static final String RESOURCE_PREFIX = "/profile"; + + /** + * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全) + */ + public static final String[] JSON_WHITELIST_STR = { "org.springframework", "doctor" }; + + /** + * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加) + */ + public static final String[] JOB_WHITELIST_STR = { "doctor" }; + + /** + * 定时任务违规的字符 + */ + public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", + "org.springframework", "org.apache", "doctor.common.core.utils.file" }; +} diff --git a/doctor-common/doctor-common-core/src/main/java/doctor/common/core/domain/HealthR.java b/doctor-common/doctor-common-core/src/main/java/doctor/common/core/domain/HealthR.java new file mode 100644 index 0000000..b15d23e --- /dev/null +++ b/doctor-common/doctor-common-core/src/main/java/doctor/common/core/domain/HealthR.java @@ -0,0 +1,117 @@ +package doctor.common.core.domain; + +import doctor.common.core.constant.Constants; +import doctor.common.core.constant.HealthConstants; + +import java.io.Serializable; + +/** + * 响应信息主体 + * + * @author ruoyi + */ +public class HealthR implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 成功 */ + public static final String SUCCESS = HealthConstants.SUCCESS; + + /** 失败 */ + public static final String FAIL = HealthConstants.FAIL; + + private String message; + + private String status; + + private T result; + + public static HealthR ok() + { + return restResult(null,SUCCESS, null); + } + + public static HealthR ok(T result) + { + return restResult(result,SUCCESS, null); + } + + public static HealthR ok(T result, String message) + { + return restResult(result, SUCCESS, message); + } + + public static HealthR fail() + { + return restResult(null,FAIL, null); + } + + public static HealthR fail(String message) + { + return restResult(null, FAIL, message); + } + + public static HealthR fail(T result) + { + return restResult(result,FAIL, null); + } + + public static HealthR fail(T result, String message) + { + return restResult(result,FAIL, message); + } + + public static HealthR fail(String status, String message) + { + return restResult(null, status, message); + } + + private static HealthR restResult(T result, String status, String message) + { + HealthR apiResult = new HealthR<>(); + apiResult.setStatus(status); + apiResult.setResult(result); + apiResult.setMessage(message); + return apiResult; + } + + public String getMessage() + { + return message; + } + + public void setMessage(String message) + { + this.message = message; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public T getResult() + { + return result; + } + + public void setResult(T result) + { + this.result = result; + } + + public static Boolean isError(HealthR ret) + { + return !isSuccess(ret); + } + + public static Boolean isSuccess(HealthR ret) + { + return HealthR.SUCCESS .equals(ret.getStatus()) ; + } +} diff --git a/doctor-modules/doctor-health/src/main/java/doctor/controller/SysDoctorController.java b/doctor-modules/doctor-health/src/main/java/doctor/controller/SysDoctorController.java index 6f9f27b..746fd64 100644 --- a/doctor-modules/doctor-health/src/main/java/doctor/controller/SysDoctorController.java +++ b/doctor-modules/doctor-health/src/main/java/doctor/controller/SysDoctorController.java @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/doctor") -@DS("slave") +@DS("master") public class SysDoctorController { @Autowired