|  | @ -0,0 +1,112 @@
 | 
	
		
			
				|  |  | package com.yihu.wlyy.web.patient.feedback;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.app.feedback.AppealService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.app.feedback.FeedbackService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.util.CommonUtil;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.web.BaseController;
 | 
	
		
			
				|  |  | import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  | import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Controller;
 | 
	
		
			
				|  |  | 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.ResponseBody;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.util.regex.Pattern;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by Reece on 2017/5/6.
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Controller
 | 
	
		
			
				|  |  | @RequestMapping(value = "/patient/feedback")
 | 
	
		
			
				|  |  | @Api(description = "居民端意见反馈与账号申诉")
 | 
	
		
			
				|  |  | public class PatientFeedbackController extends BaseController {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private FeedbackService feedbackService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private AppealService appealService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 居民端保存意见反馈
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param description 问题描述
 | 
	
		
			
				|  |  |      * @param type        选择类型
 | 
	
		
			
				|  |  |      * @param images      图片,多图逗号分隔
 | 
	
		
			
				|  |  |      * @param contact     联系方式
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/saveFeedback", method = RequestMethod.GET)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "居民端保存反馈")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public String saveFeedback(
 | 
	
		
			
				|  |  |             @RequestParam String description,
 | 
	
		
			
				|  |  |             @RequestParam int type,
 | 
	
		
			
				|  |  |             @RequestParam(required = false) String images,
 | 
	
		
			
				|  |  |             @RequestParam(required = false) String contact) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             String email = null;
 | 
	
		
			
				|  |  |             if (StringUtils.isNotEmpty(contact)) {
 | 
	
		
			
				|  |  |                 //        邮箱正则|QQ号正则
 | 
	
		
			
				|  |  |                 String regexEmail = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
 | 
	
		
			
				|  |  |                 String regexQQ = "^[1-9][0-9]{4,}$";
 | 
	
		
			
				|  |  |                 Boolean emailFlag = Pattern.matches(regexEmail, contact);
 | 
	
		
			
				|  |  |                 Boolean qqFlag = Pattern.matches(regexQQ, contact);
 | 
	
		
			
				|  |  |                 if (emailFlag || qqFlag) {
 | 
	
		
			
				|  |  |                     return write(-1, "QQ/邮箱格式错误!");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 email = contact;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | //        图片上传
 | 
	
		
			
				|  |  |             if (StringUtils.isNotEmpty(images)) {
 | 
	
		
			
				|  |  |                 images = CommonUtil.copyTempImage(images);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | //        保存到数据库
 | 
	
		
			
				|  |  |             feedbackService.saveFeedback(getUID(),description,type,images,contact,1);
 | 
	
		
			
				|  |  |             return write(200, "保存成功!");
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return invalidUserException(e, -1, "保存失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 居民端保存账号申诉
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param description 问题描述
 | 
	
		
			
				|  |  |      * @param type        选择类型
 | 
	
		
			
				|  |  |      * @param images      图片,多图逗号分隔
 | 
	
		
			
				|  |  |      * @param phone       手机号码
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @RequestMapping(value = "/saveAppeal", method = RequestMethod.GET)
 | 
	
		
			
				|  |  |     @ApiOperation(value = "居民端保存申诉")
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public String saveAppeal(
 | 
	
		
			
				|  |  |             @RequestParam String description,
 | 
	
		
			
				|  |  |             @RequestParam int type,
 | 
	
		
			
				|  |  |             @RequestParam(required = false) String images,
 | 
	
		
			
				|  |  |             @RequestParam String phone) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  | //        手机号正则
 | 
	
		
			
				|  |  |             String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
 | 
	
		
			
				|  |  |             if (Pattern.matches(regex, phone)) {
 | 
	
		
			
				|  |  | //        图片上传
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotEmpty(images)) {
 | 
	
		
			
				|  |  |                     images = CommonUtil.copyTempImage(images);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | //             保存到数据库
 | 
	
		
			
				|  |  |                 appealService.saveAppeal(getUID(),description,type,images,phone,1);
 | 
	
		
			
				|  |  |                 return write(200, "保存成功!");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 return write(-1, "手机号码有误!");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return invalidUserException(e, -1, "保存失败!");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |