| | |
| | | import com.lf.server.controller.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.LoginEntity; |
| | | import com.lf.server.entity.data.TokenEntity; |
| | | import com.lf.server.entity.data.UsersEntity; |
| | | import com.lf.server.entity.sys.LoginInfo; |
| | | import com.lf.server.entity.sys.Result; |
| | | import com.lf.server.entity.sys.User; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.data.LoginService; |
| | | import com.lf.server.service.data.TokenService; |
| | | import com.lf.server.service.data.UsersService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | @Autowired |
| | | LoginService loginService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | /** |
| | | * 跳到首页 |
| | |
| | | * |
| | | * @return String |
| | | */ |
| | | @PostMapping(value="/login", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<String> login(@RequestBody UsersEntity user, HttpServletRequest req, HttpServletResponse res) { |
| | | @PostMapping(value = "/login", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<TokenEntity> login(@RequestBody UsersEntity user, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | if (user == null) { |
| | | return fail("请输入用户名和密码!", null); |
| | |
| | | le.setStatus(1); |
| | | loginService.insertLogin(le); |
| | | |
| | | return null; |
| | | TokenEntity te = tokenService.getNewToken(ue.getId(), req); |
| | | tokenService.insertToken(te); |
| | | |
| | | return success(te); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |