package cn.jbit.controller; import cn.jbit.entity.ResponseBean; import cn.jbit.entity.User; import cn.jbit.service.UserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.Map; @RestController @RequestMapping("/user") @Validated @Api(tags = "用户信息管理") public class UserController { @Autowired private UserService userService; @ApiOperation(value = "查询用户信息列表",notes = "分页查询用户信息列表") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum",value = "当前页",paramType = "query",defaultValue = "1",dataType = "int"), @ApiImplicitParam(name = "pageSize",value = "条数",paramType = "query",defaultValue = "5",dataType = "int"), @ApiImplicitParam(name = "name",value = "模糊查询用户名称",paramType = "query",dataType = "String"), }) @GetMapping("/list-page") public ResponseBean lists(@RequestParam(defaultValue = "1", required = false) Integer pageNum, @RequestParam(defaultValue = "5", required = false) Integer pageSize, @ApiIgnore @RequestParam Map<String, String> conditionMap) { Page<User> page = userService.listPage(pageNum, pageSize, conditionMap); return ResponseBean.success(page.getContent()); } @ApiOperation(value = "查询用户信息",notes = "通过ID查询用户信息") @ApiImplicitParam(name = "id",value = "主键Id",paramType = "path",dataType = "int",required = true) @GetMapping("/get/{id}") public ResponseBean findById(@NotNull(message = "主键ID不能为空") @PathVariable("id") Integer id) { try { User user = userService.getById(id); if (null == user) { return ResponseBean.failed(500, "用户信息不存在"); } return ResponseBean.success(user); } catch (Exception e) { e.printStackTrace(); System.err.println("查询用户信息发生异常。。。。。。。"); return ResponseBean.failed(500); } } @ApiOperation(value = "新增用户信息,修改用户信息",notes = "根据ID修改,ID不存在添加") @PostMapping("/save") public ResponseBean save(@Validated User user) { try { userService.saveOrUpdate(user); return ResponseBean.success(); } catch (Exception e) { e.printStackTrace(); System.err.println("保存用户信息发生异常。。。。。。。"); return ResponseBean.failed(500); } } @ApiOperation(value = "删除用户信息",notes = "根据ID删除用户信息") @ApiImplicitParam(name = "id",value = "主键Id",paramType = "path",dataType = "int",required = true) @GetMapping("/delete/{id}") public ResponseBean delete(@NotNull(message = "主键ID不能为空") @PathVariable("id") Integer id) { try { userService.delete(id); return ResponseBean.success(); } catch (Exception e) { e.printStackTrace(); System.err.println("删除发生异常。。。。。。。"); return ResponseBean.failed(500); } } @ApiOperation(value = "批量删除",notes = "根据ID批量删除用户信息") @ApiImplicitParam(name = "ids",value = "主键id数组",paramType = "body",allowMultiple = true,required = true) @PostMapping("/delete") public ResponseBean deleteBatch(@RequestBody @NotEmpty(message = "id不能为空") Integer[] ids) { try { userService.deleteBatch(ids); return ResponseBean.success(); } catch (Exception e) { e.printStackTrace(); System.err.println("批量删除发生异常。。。。。。。"); return ResponseBean.failed(500); } } }

15719908287 LV9
2024年6月19日
微信网友_6368711690080256 LV3
2023年2月28日
1203174100 LV1
2023年2月22日
282363 LV1
2022年10月4日
cao1992 LV24
2022年7月18日
yijie110 LV5
2022年4月18日
gy12345 LV6
2022年2月15日
taskmaster LV6
2022年1月2日
zcl02036716 LV17
2021年12月3日
123854216 LV5
2021年11月24日

微信网友_7255460400304128
4月22日
暂无贡献等级
2577288043
3月19日
暂无贡献等级
yy1124218793 LV9
2月8日
he0516
2024年12月21日
暂无贡献等级
15719908287 LV9
2024年6月19日
计科一班 LV7
2024年6月19日
Eliauk1121332121
2024年5月30日
暂无贡献等级
ma406805131 LV19
2024年5月11日
913600932
2024年4月28日
暂无贡献等级
内心向阳 LV4
2023年11月7日