diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java b/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java index 49029172..c2448a84 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java @@ -70,6 +70,23 @@ public class WorkerController extends BaseController { return prefix + "/worker"; } + @PostMapping("/login") + @ResponseBody + public AjaxResult login(@RequestBody Worker worker){ + try { + List workerList = workerService.getWorkList(worker); + if(workerList.size() > 0){ + return AjaxResult.success(workerList.get(0)); + }else { + return AjaxResult.error("用户名或密码错误!"); + } + }catch (Exception e){ + e.printStackTrace(); + logger.error(ExceptionUtil.getExceptionMessage(e)); + return AjaxResult.error("登陆失败!"); + } + } + @PostMapping("/register") @ResponseBody public AjaxResult register(@RequestBody Worker request){ diff --git a/ghy-worker/src/main/resources/mapper/worker/WorkerMapper.xml b/ghy-worker/src/main/resources/mapper/worker/WorkerMapper.xml index 878cacec..bba3a955 100644 --- a/ghy-worker/src/main/resources/mapper/worker/WorkerMapper.xml +++ b/ghy-worker/src/main/resources/mapper/worker/WorkerMapper.xml @@ -48,6 +48,12 @@ AND w.name LIKE '%${name}%' + + AND w.phone = #{phone} + + + AND w.password = #{password} +