| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- package cn.com.goldenwater.dcproj.controller.meeting;
- import cn.com.goldenwater.dcproj.constValue.SmsCodeEnum;
- import cn.com.goldenwater.dcproj.model.GwComFile;
- import cn.com.goldenwater.dcproj.model.MeetMeetingInfo;
- import cn.com.goldenwater.dcproj.model.MeetPersList;
- import cn.com.goldenwater.dcproj.param.MeetMeetingInfoParam;
- import cn.com.goldenwater.dcproj.service.GwComFileService;
- import cn.com.goldenwater.dcproj.service.MeetMeetingInfoService;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.utils.impexcel.ExportExcel;
- import cn.com.goldenwater.id.util.UuidUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang3.StringUtils;
- import com.github.pagehelper.PageInfo;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import javax.servlet.http.HttpServletResponse;
- import java.io.ByteArrayOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.util.List;
- /**
- * @author lune
- * @date 2019-7-23
- */
- @Api(value = "MEET 培训会议信息管理管理", tags = "MEET 培训会议信息管理管理")
- @RestController
- @RequestMapping("/meet/meeting/info")
- public class MeetMeetingInfoController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private MeetMeetingInfoService meetMeetingInfoService;
- @Autowired
- private GwComFileService gwComFileService;
- @Autowired
- private RedisTemplate redisTemplate;
- @ApiOperation(value = "添加/修改培训会议信息管理")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<MeetMeetingInfo> insert(@ApiParam(name = "meetMeetingInfo", value = "MeetMeetingInfo", required = true) @RequestBody MeetMeetingInfo meetMeetingInfo) {
- if (StringUtils.isBlank(meetMeetingInfo.getId())) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- meetMeetingInfo.setId(uuid);
- meetMeetingInfoService.insert(meetMeetingInfo);
- } else {
- meetMeetingInfoService.update(meetMeetingInfo);
- }
- if (meetMeetingInfo.getGwComFiles() != null && meetMeetingInfo.getGwComFiles().size() > 0) {
- gwComFileService.updateBiz(meetMeetingInfo.getGwComFiles(), meetMeetingInfo.getId());
- }
- return buildSuccessResponse(meetMeetingInfo);
- }
- @ApiOperation(value = "根据ID删除培训会议信息管理")
- @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = meetMeetingInfoService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取培训会议信息管理(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<MeetMeetingInfo> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- MeetMeetingInfo meetMeetingInfo = meetMeetingInfoService.get(id);
- return buildSuccessResponse(meetMeetingInfo);
- }
- @ApiOperation(value = "获取培训会议信息管理(列表所有)")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<MeetMeetingInfo>> list(@ApiParam(name = "meetMeetingInfoParam", value = "meetMeetingInfoParam", required = true) @RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
- List<MeetMeetingInfo> meetMeetingInfoList = meetMeetingInfoService.findList(meetMeetingInfoParam);
- return buildSuccessResponse(meetMeetingInfoList);
- }
- @ApiOperation(value = "获取培训会议信息管理(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<MeetMeetingInfo>> page(@ApiParam(name = "meetMeetingInfoParam", value = "meetMeetingInfoParam", required = true) @RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
- PageInfo<MeetMeetingInfo> meetMeetingInfoList = meetMeetingInfoService.findPageInfo(meetMeetingInfoParam);
- return buildSuccessResponse(meetMeetingInfoList);
- }
- @ApiOperation(value = "发送验证码")
- @RequestMapping(value = "/sendMessage", method = {RequestMethod.POST})
- public BaseResponse sendMessage(@RequestParam String phone, @RequestParam String persName) {
- String resultCode = meetMeetingInfoService.sendMessage(persName, phone);
- if (SmsCodeEnum.SUCCESS.getKey().equals(resultCode)) {
- return buildSuccessResponse(SmsCodeEnum.SUCCESS.getDesc());
- } else if (SmsCodeEnum.NO_USER.getKey().equals(resultCode)) {
- return buildFailResponse(10002, SmsCodeEnum.NO_USER.getDesc());
- } else if (SmsCodeEnum.NO_MEET.getKey().equals(resultCode)) {
- return buildFailResponse(10003, SmsCodeEnum.NO_MEET.getDesc());
- }
- return buildFailResponse(10001, SmsCodeEnum.ERROR.getDesc());
- }
- @ApiOperation(value = "用户验证码登录")
- @RequestMapping(value = "/loginByCode", method = {RequestMethod.POST})
- public BaseResponse<MeetPersList> loginByCode(@RequestParam String phone, @RequestParam String code) {
- MeetPersList meetPersList;
- String oldCode = (String) redisTemplate.opsForValue().get(phone);
- if (StringUtils.isNotBlank(code) && code.equals(oldCode)) {
- meetPersList = meetMeetingInfoService.loginByCode(phone, code);
- if (meetPersList == null) {
- return buildFailResponse(10003, SmsCodeEnum.NO_MEET.getDesc());
- }else{
- return buildSuccessResponse(meetPersList);
- }
- }else{
- return buildFailResponse(10004,SmsCodeEnum.NO_CODE.getDesc());
- }
- }
- @ApiOperation(value = "获取培训会议文件")
- @RequestMapping(value = "/getFileByMeetId", method = RequestMethod.POST)
- public BaseResponse getFileByMeetId(@RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
- List<GwComFile> list = gwComFileService.findFileByBiz(meetMeetingInfoParam.getId());
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "下载培训会议文件")
- @RequestMapping(value = "/downFileByFileId", method = {RequestMethod.GET, RequestMethod.POST})
- public BaseResponse downFileByFileId(HttpServletResponse response, @RequestBody MeetMeetingInfoParam meetMeetingInfoParam) {
- GwComFile comFile = gwComFileService.get(meetMeetingInfoParam.getFileId());
- if (comFile == null) {
- return buildFailResponse(10001, "文件不存在");
- }
- try {
- File file = new File(comFile.getFilePath());
- if (!file.exists()) {
- return buildFailResponse(10001, "文件不存在");
- }
- comFile.setDownNum(comFile.getDownNum()+1);
- gwComFileService.update(comFile);
- InputStream is = new FileInputStream(file);
- byte[] bytes = new byte[is.available()];
- is.read(bytes);
- ByteArrayOutputStream opt = new ByteArrayOutputStream();
- opt.write(bytes);
- ExportExcel.downloadExcelFile(response, opt, comFile.getFileName());
- } catch (Exception e) {
- return buildFailResponse(e.getMessage());
- }
- return buildSuccessResponse();
- }
- }
|