CusSelfInfoController.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package com.boot.security.server.controller;
  2. import java.util.List;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.web.bind.annotation.DeleteMapping;
  5. import org.springframework.web.bind.annotation.GetMapping;
  6. import org.springframework.web.bind.annotation.PathVariable;
  7. import org.springframework.web.bind.annotation.PostMapping;
  8. import org.springframework.web.bind.annotation.PutMapping;
  9. import org.springframework.web.bind.annotation.RequestBody;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RestController;
  12. import com.boot.security.server.page.table.PageTableRequest;
  13. import com.boot.security.server.page.table.PageTableHandler;
  14. import com.boot.security.server.page.table.PageTableResponse;
  15. import com.boot.security.server.page.table.PageTableHandler.CountHandler;
  16. import com.boot.security.server.page.table.PageTableHandler.ListHandler;
  17. import com.boot.security.server.dao.CusSelfInfoDao;
  18. import com.boot.security.server.model.CusSelfInfo;
  19. import io.swagger.annotations.ApiOperation;
  20. @RestController
  21. @RequestMapping("/cusSelfInfos")
  22. public class CusSelfInfoController {
  23. @Autowired
  24. private CusSelfInfoDao cusSelfInfoDao;
  25. @PostMapping
  26. @ApiOperation(value = "保存")
  27. public CusSelfInfo save(@RequestBody CusSelfInfo cusSelfInfo) {
  28. cusSelfInfoDao.save(cusSelfInfo);
  29. return cusSelfInfo;
  30. }
  31. @GetMapping("/{id}")
  32. @ApiOperation(value = "根据id获取")
  33. public CusSelfInfo get(@PathVariable String id) {
  34. return cusSelfInfoDao.getById(id);
  35. }
  36. @PutMapping
  37. @ApiOperation(value = "修改")
  38. public CusSelfInfo update(@RequestBody CusSelfInfo cusSelfInfo) {
  39. cusSelfInfoDao.update(cusSelfInfo);
  40. return cusSelfInfo;
  41. }
  42. @GetMapping
  43. @ApiOperation(value = "列表")
  44. public PageTableResponse list(PageTableRequest request) {
  45. return new PageTableHandler(new CountHandler() {
  46. @Override
  47. public int count(PageTableRequest request) {
  48. return cusSelfInfoDao.count(request.getParams());
  49. }
  50. }, new ListHandler() {
  51. @Override
  52. public List<CusSelfInfo> list(PageTableRequest request) {
  53. return cusSelfInfoDao.list(request.getParams(), request.getOffset(), request.getLimit());
  54. }
  55. }).handle(request);
  56. }
  57. @DeleteMapping("/{id}")
  58. @ApiOperation(value = "删除")
  59. public void delete(@PathVariable String id) {
  60. CusSelfInfo detail = cusSelfInfoDao.getById(id);
  61. if(detail!=null) {
  62. String openid = detail.getOpenId();
  63. // 删除登录表信息
  64. // 若存在手机授权,删除手机授权记录表信息
  65. // 删除大V认证表信息
  66. cusSelfInfoDao.deleteByOpenid(openid);
  67. }
  68. cusSelfInfoDao.delete(id);
  69. }
  70. }