CompanyController.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package com.hssx.cloudmodel.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.hssx.cloudmodel.entity.Company;
  4. import com.hssx.cloudmodel.entity.User;
  5. import com.hssx.cloudmodel.entity.vo.CompanyVO;
  6. import com.hssx.cloudmodel.service.CompanyService;
  7. import com.hssx.cloudmodel.util.HttpRespMsg;
  8. import com.hssx.cloudmodel.util.PageUtil;
  9. import io.swagger.annotations.ApiOperation;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.ResponseBody;
  16. import javax.servlet.http.HttpServletRequest;
  17. import javax.servlet.http.HttpServletResponse;
  18. import java.util.List;
  19. /**
  20. * @author 吴涛涛
  21. * @since 2019-07-26
  22. */
  23. @Controller
  24. @RequestMapping("/company")
  25. @Slf4j
  26. public class CompanyController {
  27. @Autowired
  28. private CompanyService companyService;
  29. /**
  30. * 添加/修改公司
  31. *
  32. * 参数:companyName 公司名 companyAddress 公司地址
  33. * companyType公司类型 0-资产方 1-生产方(yLng 经度 xLat 纬度)
  34. * flag 0-添加,1-修改
  35. * @return
  36. */
  37. @ApiOperation("添加/修改公司")
  38. @RequestMapping("/add")
  39. @ResponseBody
  40. public HttpRespMsg addAndUpdateRole(CompanyVO companyVO, HttpServletRequest request, Integer flag,
  41. HttpServletResponse response) {
  42. HttpRespMsg msg = new HttpRespMsg();
  43. msg = companyService.addAndUpdateRole(companyVO, flag);
  44. return msg;
  45. }
  46. /**
  47. * 删除公司
  48. *
  49. * @param company 参数 id 公司id
  50. * @return
  51. */
  52. @ApiOperation("删除公司")
  53. @RequestMapping("/delete")
  54. @ResponseBody
  55. public HttpRespMsg delete(Company company, HttpServletRequest request,
  56. HttpServletResponse response) {
  57. HttpRespMsg msg = new HttpRespMsg();
  58. msg = companyService.deleteById(company.getId());
  59. return msg;
  60. }
  61. /**
  62. * 公司列表
  63. * 参数:pageNum 当前页码,pageSize 每页条数 keyName 关键字查询,companyType 公司类型 0-资产方 1-生产方
  64. * @return
  65. */
  66. @ApiOperation("公司列表")
  67. @RequestMapping("/list")
  68. @ResponseBody
  69. public HttpRespMsg deleteRole(@RequestParam(required = false)String keyName, HttpServletRequest request,
  70. HttpServletResponse response, PageUtil page,@RequestParam(required = false)Integer companyType) {
  71. HttpRespMsg msg = new HttpRespMsg();
  72. msg = companyService.pageList(page,keyName,companyType);
  73. return msg;
  74. }
  75. /**
  76. * 创建模具获取的(资产方)公司列表
  77. * @return
  78. */
  79. @ApiOperation("创建模具获取的公司列表")
  80. @RequestMapping("/getCompanys")
  81. @ResponseBody
  82. public HttpRespMsg getCompanys() {
  83. HttpRespMsg msg = new HttpRespMsg();
  84. QueryWrapper<Company> qw = new QueryWrapper<>();
  85. qw.eq("company_type",0);
  86. msg.data = companyService.list(qw);
  87. return msg;
  88. }
  89. /**
  90. * 创建账号是所获取的公司列表
  91. * parentId 当前用户的上级id id 当前用户id
  92. * @return
  93. */
  94. @ApiOperation(value = "获取公司列表")
  95. @RequestMapping("/getCompanyList")
  96. @ResponseBody
  97. public HttpRespMsg getCompanyList(User user){
  98. HttpRespMsg msg = new HttpRespMsg();
  99. List<Company> list = companyService.getIdAndNamelist(user);
  100. msg.data = list;
  101. return msg;
  102. }
  103. /**
  104. * 项目分配生产方公司列表
  105. * @return
  106. */
  107. @ApiOperation(value = "项目分配生产方公司列表")
  108. @RequestMapping("/addCompanyListToProject")
  109. @ResponseBody
  110. public HttpRespMsg addCompanyListToProject(User user){
  111. HttpRespMsg msg = new HttpRespMsg();
  112. List<Company> list = companyService.addCompanyListToProject(user);
  113. msg.data = list;
  114. return msg;
  115. }
  116. }