36e6c4d2a4cafbbc2ac1241297b46b5e359e9812.svn-base 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. package cn.com.goldenwater.dcproj.controller.meeting;
  2. import cn.com.goldenwater.dcproj.constValue.SmsCodeEnum;
  3. import cn.com.goldenwater.dcproj.model.GwComFile;
  4. import cn.com.goldenwater.dcproj.model.MeetMeetingInfo;
  5. import cn.com.goldenwater.dcproj.model.MeetPersList;
  6. import cn.com.goldenwater.dcproj.param.MeetMeetingInfoParam;
  7. import cn.com.goldenwater.dcproj.service.GwComFileService;
  8. import cn.com.goldenwater.dcproj.service.MeetMeetingInfoService;
  9. import cn.com.goldenwater.core.web.BaseController;
  10. import cn.com.goldenwater.core.web.BaseResponse;
  11. import cn.com.goldenwater.dcproj.utils.impexcel.ExportExcel;
  12. import cn.com.goldenwater.id.util.UuidUtil;
  13. import io.swagger.annotations.Api;
  14. import io.swagger.annotations.ApiOperation;
  15. import io.swagger.annotations.ApiParam;
  16. import org.apache.commons.lang3.StringUtils;
  17. import com.github.pagehelper.PageInfo;
  18. import org.slf4j.Logger;
  19. import org.slf4j.LoggerFactory;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.data.redis.core.RedisTemplate;
  22. import org.springframework.web.bind.annotation.PathVariable;
  23. import org.springframework.web.bind.annotation.RequestBody;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RequestMethod;
  26. import org.springframework.web.bind.annotation.RequestParam;
  27. import org.springframework.web.bind.annotation.RestController;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.io.ByteArrayOutputStream;
  30. import java.io.File;
  31. import java.io.FileInputStream;
  32. import java.io.InputStream;
  33. import java.util.List;
  34. /**
  35. * @author lune
  36. * @date 2019-7-23
  37. */
  38. @Api(value = "MEET 培训会议信息管理管理", tags = "MEET 培训会议信息管理管理")
  39. @RestController
  40. @RequestMapping("/meet/meeting/info")
  41. public class MeetMeetingInfoController extends BaseController {
  42. private Logger logger = LoggerFactory.getLogger(getClass());
  43. @Autowired
  44. private MeetMeetingInfoService meetMeetingInfoService;
  45. @Autowired
  46. private GwComFileService gwComFileService;
  47. @Autowired
  48. private RedisTemplate redisTemplate;
  49. @ApiOperation(value = "添加/修改培训会议信息管理")
  50. @RequestMapping(value = "", method = RequestMethod.POST)
  51. public BaseResponse<MeetMeetingInfo> insert(@ApiParam(name = "meetMeetingInfo", value = "MeetMeetingInfo", required = true) @RequestBody MeetMeetingInfo meetMeetingInfo) {
  52. if (StringUtils.isBlank(meetMeetingInfo.getId())) {
  53. String uuid = UuidUtil.uuid(); // 生成uuid
  54. meetMeetingInfo.setId(uuid);
  55. meetMeetingInfoService.insert(meetMeetingInfo);
  56. } else {
  57. meetMeetingInfoService.update(meetMeetingInfo);
  58. }
  59. if (meetMeetingInfo.getGwComFiles() != null && meetMeetingInfo.getGwComFiles().size() > 0) {
  60. gwComFileService.updateBiz(meetMeetingInfo.getGwComFiles(), meetMeetingInfo.getId());
  61. }
  62. return buildSuccessResponse(meetMeetingInfo);
  63. }
  64. @ApiOperation(value = "根据ID删除培训会议信息管理")
  65. @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
  66. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  67. int ret = meetMeetingInfoService.delete(id);
  68. return buildSuccessResponse();
  69. }
  70. @ApiOperation(value = "根据ID获取培训会议信息管理(单表)")
  71. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  72. public BaseResponse<MeetMeetingInfo> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  73. MeetMeetingInfo meetMeetingInfo = meetMeetingInfoService.get(id);
  74. return buildSuccessResponse(meetMeetingInfo);
  75. }
  76. @ApiOperation(value = "获取培训会议信息管理(列表所有)")
  77. @RequestMapping(value = "/list", method = RequestMethod.POST)
  78. public BaseResponse<List<MeetMeetingInfo>> list(@ApiParam(name = "meetMeetingInfoParam", value = "meetMeetingInfoParam", required = true) @RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
  79. List<MeetMeetingInfo> meetMeetingInfoList = meetMeetingInfoService.findList(meetMeetingInfoParam);
  80. return buildSuccessResponse(meetMeetingInfoList);
  81. }
  82. @ApiOperation(value = "获取培训会议信息管理(列表--分页)")
  83. @RequestMapping(value = "/page", method = RequestMethod.POST)
  84. public BaseResponse<PageInfo<MeetMeetingInfo>> page(@ApiParam(name = "meetMeetingInfoParam", value = "meetMeetingInfoParam", required = true) @RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
  85. PageInfo<MeetMeetingInfo> meetMeetingInfoList = meetMeetingInfoService.findPageInfo(meetMeetingInfoParam);
  86. return buildSuccessResponse(meetMeetingInfoList);
  87. }
  88. @ApiOperation(value = "发送验证码")
  89. @RequestMapping(value = "/sendMessage", method = {RequestMethod.POST})
  90. public BaseResponse sendMessage(@RequestParam String phone, @RequestParam String persName) {
  91. String resultCode = meetMeetingInfoService.sendMessage(persName, phone);
  92. if (SmsCodeEnum.SUCCESS.getKey().equals(resultCode)) {
  93. return buildSuccessResponse(SmsCodeEnum.SUCCESS.getDesc());
  94. } else if (SmsCodeEnum.NO_USER.getKey().equals(resultCode)) {
  95. return buildFailResponse(10002, SmsCodeEnum.NO_USER.getDesc());
  96. } else if (SmsCodeEnum.NO_MEET.getKey().equals(resultCode)) {
  97. return buildFailResponse(10003, SmsCodeEnum.NO_MEET.getDesc());
  98. }
  99. return buildFailResponse(10001, SmsCodeEnum.ERROR.getDesc());
  100. }
  101. @ApiOperation(value = "用户验证码登录")
  102. @RequestMapping(value = "/loginByCode", method = {RequestMethod.POST})
  103. public BaseResponse<MeetPersList> loginByCode(@RequestParam String phone, @RequestParam String code) {
  104. MeetPersList meetPersList;
  105. String oldCode = (String) redisTemplate.opsForValue().get(phone);
  106. if (StringUtils.isNotBlank(code) && code.equals(oldCode)) {
  107. meetPersList = meetMeetingInfoService.loginByCode(phone, code);
  108. if (meetPersList == null) {
  109. return buildFailResponse(10003, SmsCodeEnum.NO_MEET.getDesc());
  110. }else{
  111. return buildSuccessResponse(meetPersList);
  112. }
  113. }else{
  114. return buildFailResponse(10004,SmsCodeEnum.NO_CODE.getDesc());
  115. }
  116. }
  117. @ApiOperation(value = "获取培训会议文件")
  118. @RequestMapping(value = "/getFileByMeetId", method = RequestMethod.POST)
  119. public BaseResponse getFileByMeetId(@RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
  120. List<GwComFile> list = gwComFileService.findFileByBiz(meetMeetingInfoParam.getId());
  121. return buildSuccessResponse(list);
  122. }
  123. @ApiOperation(value = "下载培训会议文件")
  124. @RequestMapping(value = "/downFileByFileId", method = {RequestMethod.GET, RequestMethod.POST})
  125. public BaseResponse downFileByFileId(HttpServletResponse response, @RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
  126. GwComFile comFile = gwComFileService.get(meetMeetingInfoParam.getFileId());
  127. if (comFile == null) {
  128. return buildFailResponse(10001, "文件不存在");
  129. }
  130. try {
  131. File file = new File(comFile.getFilePath());
  132. if (!file.exists()) {
  133. return buildFailResponse(10001, "文件不存在");
  134. }
  135. comFile.setDownNum(comFile.getDownNum()+1);
  136. gwComFileService.update(comFile);
  137. InputStream is = new FileInputStream(file);
  138. byte[] bytes = new byte[is.available()];
  139. is.read(bytes);
  140. ByteArrayOutputStream opt = new ByteArrayOutputStream();
  141. opt.write(bytes);
  142. ExportExcel.downloadExcelFile(response, opt, comFile.getFileName());
  143. } catch (Exception e) {
  144. return buildFailResponse(e.getMessage());
  145. }
  146. return buildSuccessResponse();
  147. }
  148. }