CompanyController.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.entity.vo.UserVO;
  7. import com.hssx.cloudmodel.service.CompanyService;
  8. import com.hssx.cloudmodel.util.HttpRespMsg;
  9. import com.hssx.cloudmodel.util.PageUtil;
  10. import io.swagger.annotations.ApiOperation;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Controller;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.ResponseBody;
  17. import javax.servlet.http.HttpServletRequest;
  18. import javax.servlet.http.HttpServletResponse;
  19. import java.util.List;
  20. /**
  21. * @author 吴涛涛
  22. * @since 2019-07-26
  23. */
  24. @Controller
  25. @RequestMapping("/company")
  26. @Slf4j
  27. public class CompanyController {
  28. @Autowired
  29. private CompanyService companyService;
  30. /**
  31. * 添加/修改公司
  32. *
  33. * 参数:companyName 公司名 companyAddress 公司地址 companyIds 关联公司的ids "1,2,3"
  34. * companyType公司类型 0-资产方 1-生产方(yLng 经度 xLat 纬度)
  35. * flag 0-添加,1-修改
  36. * @return
  37. */
  38. @ApiOperation("添加/修改公司")
  39. @RequestMapping("/add")
  40. @ResponseBody
  41. public HttpRespMsg addAndUpdateRole(CompanyVO companyVO, HttpServletRequest request, Integer flag,
  42. HttpServletResponse response,@RequestParam(required = false) String companyIds) {
  43. HttpRespMsg msg = new HttpRespMsg();
  44. msg = companyService.addAndUpdateRole(companyVO, flag,companyIds);
  45. return msg;
  46. }
  47. /**
  48. * 删除公司
  49. *
  50. * @param company 参数 id 公司id
  51. * @return
  52. */
  53. @ApiOperation("删除公司")
  54. @RequestMapping("/delete")
  55. @ResponseBody
  56. public HttpRespMsg delete(Company company, HttpServletRequest request,
  57. HttpServletResponse response) {
  58. HttpRespMsg msg = new HttpRespMsg();
  59. msg = companyService.deleteById(company.getId());
  60. return msg;
  61. }
  62. /**
  63. * 公司列表
  64. * 参数:pageNum 当前页码,pageSize 每页条数 keyName 关键字查询,companyType 公司类型 0-资产方 1-生产方
  65. * @return
  66. */
  67. @ApiOperation("公司列表")
  68. @RequestMapping("/list")
  69. @ResponseBody
  70. public HttpRespMsg deleteRole(@RequestParam(required = false)String keyName, HttpServletRequest request,
  71. HttpServletResponse response, PageUtil page,@RequestParam(required = false)Integer companyType) {
  72. HttpRespMsg msg = new HttpRespMsg();
  73. msg = companyService.pageList(page,keyName,companyType);
  74. return msg;
  75. }
  76. /**
  77. * 建立关联公司时的公司列表
  78. * 参数:companyType 公司类型 0-资产方 1-生产方
  79. * @return
  80. */
  81. @ApiOperation("建立关联公司时的公司列表")
  82. @RequestMapping("/relationList")
  83. @ResponseBody
  84. public HttpRespMsg relationList(@RequestParam(required = false)Integer companyType) {
  85. HttpRespMsg msg = new HttpRespMsg();
  86. msg = companyService.relationList(companyType);
  87. return msg;
  88. }
  89. /**
  90. * 创建模具获取的(资产方)公司列表
  91. * @return
  92. */
  93. @ApiOperation("创建模具获取的公司列表")
  94. @RequestMapping("/getCompanys")
  95. @ResponseBody
  96. public HttpRespMsg getCompanys() {
  97. HttpRespMsg msg = new HttpRespMsg();
  98. QueryWrapper<Company> qw = new QueryWrapper<>();
  99. qw.eq("company_type",0);
  100. msg.data = companyService.list(qw);
  101. return msg;
  102. }
  103. /**
  104. * 创建账号是所获取的公司列表
  105. * parentId 当前用户的上级id id 当前用户id
  106. * @return
  107. */
  108. @ApiOperation(value = "获取公司列表")
  109. @RequestMapping("/getCompanyList")
  110. @ResponseBody
  111. public HttpRespMsg getCompanyList(User user){
  112. HttpRespMsg msg = new HttpRespMsg();
  113. List<Company> list = companyService.getIdAndNamelist(user);
  114. msg.data = list;
  115. return msg;
  116. }
  117. /**
  118. * 项目分配生产方公司列表
  119. * @return
  120. */
  121. @ApiOperation(value = "项目分配生产方公司列表")
  122. @RequestMapping("/addCompanyListToProject")
  123. @ResponseBody
  124. public HttpRespMsg addCompanyListToProject(User user){
  125. HttpRespMsg msg = new HttpRespMsg();
  126. List<Company> list = companyService.addCompanyListToProject(user);
  127. msg.data = list;
  128. return msg;
  129. }
  130. /**
  131. * 生产方公司和公司下所属的模具
  132. * 参数 token 用户身份凭证
  133. * @return
  134. */
  135. @ApiOperation(value = "生产方公司和公司下所属的模具")
  136. @RequestMapping("/getCoutomCompanyAndMouldsByUser")
  137. @ResponseBody
  138. public HttpRespMsg getCoutomCompanyAndMouldsByUser(UserVO userVO){
  139. HttpRespMsg msg = new HttpRespMsg();
  140. msg = companyService.getCoutomCompanyAndMouldsByUser(userVO);
  141. return msg;
  142. }
  143. /**
  144. * 公司详情
  145. * 参数 token 用户身份凭证 companyId 公司id
  146. * @return
  147. */
  148. @ApiOperation(value = "公司详情")
  149. @RequestMapping("/detail")
  150. @ResponseBody
  151. public HttpRespMsg detail(UserVO userVO){
  152. HttpRespMsg msg = new HttpRespMsg();
  153. msg = companyService.detail(userVO);
  154. return msg;
  155. }
  156. }