| | |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.sys.DepEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.sys.DepService; |
| | | 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.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | DepService depService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "DepEntity", value = "字典实体类", dataType = "com.lf.server.entity.sys.DepEntity", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "com.lf.server.entity.sys.DepEntity", paramType = "body", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertDep", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertDep(@RequestBody DepEntity depEntity) { |
| | | public ResponseMsg<Integer> insertDep(@RequestBody DepEntity entity, HttpServletRequest req) { |
| | | try { |
| | | int count = depService.insertDep(depEntity); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = depService.insertDep(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "插入多条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "DepEntity", value = "字典实体类", dataType = "com.lf.server.entity.sys.DepEntity", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "com.lf.server.entity.sys.DepEntity", paramType = "body", example = "") |
| | | }) |
| | | @PostMapping(value = "/insertDes", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> insertDes(@RequestBody List<DepEntity> depEntity) { |
| | | public ResponseMsg<Integer> insertDes(@RequestBody List<DepEntity> list, HttpServletRequest req) { |
| | | try { |
| | | int count = depService.insertDeps(depEntity); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (DepEntity entity : list) { |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | | } |
| | | |
| | | int count = depService.insertDeps(list); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "更新一条数据") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "depEntity", value = "主键ID集合", dataType = "DepEntity", paramType = "body", example = "") |
| | | @ApiImplicitParam(name = "entity", value = "实体类", dataType = "DepEntity", paramType = "body", example = "") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/updateDep", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updateDep(@RequestBody DepEntity depEntity) { |
| | | public ResponseMsg<Integer> updateDep(@RequestBody DepEntity entity, HttpServletRequest req) { |
| | | try { |
| | | int count = depService.updateDep(depEntity); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | |
| | | int count = depService.updateDep(entity); |
| | | |
| | | return success(count); |
| | | } catch (Exception ex) { |
| | |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/updateDeps", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<Integer> updateDeps(@RequestBody List<DepEntity> list) { |
| | | public ResponseMsg<Integer> updateDeps(@RequestBody List<DepEntity> list, HttpServletRequest req) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue != null) { |
| | | for (DepEntity entity : list) { |
| | | entity.setUpdateUser(ue.getId()); |
| | | } |
| | | } |
| | | |
| | | int count = depService.updateDeps(list); |
| | | |
| | | return success(count); |