| | |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.LoginEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.service.sys.LoginService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | |
| | |
| | | public class LoginController extends BaseController { |
| | | @Autowired |
| | | LoginService loginService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询记录数") |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入字典") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "loginEntity", value = "字典实体类", dataType = "com.lf.server.entity.sys.LoginEntity", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "com.lf.server.entity.sys.LoginEntity", paramType = "body", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertLogin", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertLogin(@RequestBody LoginEntity loginEntity) { |
| | | public ResponseMsg<Integer> insertLogin(@RequestBody LoginEntity entity, HttpServletRequest req) { |
| | | try { |
| | | int count = loginService.insertLogin(loginEntity); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUserid(ue.getId()); |
| | | } |
| | | |
| | | int count = loginService.insertLogin(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入多条字典") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "loginEntity", value = "字典实体类集合", dataType = "List<LoginEntity>", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "List<LoginEntity>", paramType = "body", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertLogins", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertLogins(@RequestBody List<LoginEntity> loginEntity) { |
| | | public ResponseMsg<Integer> insertLogins(@RequestBody List<LoginEntity> list, HttpServletRequest req) { |
| | | try { |
| | | int count = loginService.insertLogins(loginEntity); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (LoginEntity entity : list) { |
| | | entity.setUserid(ue.getId()); |
| | | } |
| | | } |
| | | |
| | | int count = loginService.insertLogins(list); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "更新一条字典") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "loginEntity", value = "字典ID集合", dataType = "LoginEntity", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "LoginEntity", paramType = "body", example = "") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/updateLogin", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updateLogin(@RequestBody LoginEntity loginEntity) { |
| | | public ResponseMsg<Integer> updateLogin(@RequestBody LoginEntity entity, HttpServletRequest req) { |
| | | try { |
| | | int count = loginService.updateLogin(loginEntity); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUserid(ue.getId()); |
| | | } |
| | | |
| | | int count = loginService.updateLogin(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |