Commit 24ab5575 authored by 廖旭伟's avatar 廖旭伟

未登录用户可以提建议

parent 53b14dc0
...@@ -5376,6 +5376,8 @@ msg|String|消息|- ...@@ -5376,6 +5376,8 @@ msg|String|消息|-
:---|:---|:---|:------- :---|:---|:---|:-------
content|String|是|建议内容 content|String|是|建议内容
screenshot|String|是|截图地址 screenshot|String|是|截图地址
custName|String|否|客户名称(登录用户不用填写)
contactTelphone|String|否|联系电话(登录用户不用填写)
**请求样例:** **请求样例:**
``` ```
......
package com.mortals.xhx.base.framework.interceptor; package com.mortals.xhx.base.framework.interceptor;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.service.IAuthTokenService; import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.service.IUser; import com.mortals.framework.service.IUser;
import com.mortals.framework.util.AESUtil; import com.mortals.framework.util.AESUtil;
...@@ -11,9 +12,12 @@ import com.mortals.xhx.common.key.Constant; ...@@ -11,9 +12,12 @@ import com.mortals.xhx.common.key.Constant;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
/** /**
* 用户权限验证,基于token * 用户权限验证,基于token
...@@ -36,6 +40,17 @@ public class AuthUserInterceptor extends BaseInterceptor { ...@@ -36,6 +40,17 @@ public class AuthUserInterceptor extends BaseInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception { throws Exception {
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
UnAuth annotation = method.getAnnotation(UnAuth.class);
if (annotation != null) {
//取消校验
return true;
}
} else if (handler instanceof ResourceHttpRequestHandler) {
return true;
}
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
try { try {
String uri = request.getServletPath(); String uri = request.getServletPath();
......
...@@ -55,15 +55,17 @@ public class ProposalServiceImpl extends AbstractCRUDServiceImpl<ProposalDao, Pr ...@@ -55,15 +55,17 @@ public class ProposalServiceImpl extends AbstractCRUDServiceImpl<ProposalDao, Pr
@Override @Override
protected void updateAfter(ProposalEntity entity, Context context) throws AppException { protected void updateAfter(ProposalEntity entity, Context context) throws AppException {
if(StringUtils.isNotEmpty(entity.getReplyContent()) && entity.getSendMode()!= SendModeEnum.ON_SMS.getValue()){ if(StringUtils.isNotEmpty(entity.getReplyContent()) && entity.getSendMode()!= SendModeEnum.ON_SMS.getValue()){
ProposalEntity proposalEntity = this.get(entity.getId()); if(entity.getCustomerId()!=null) {
NewsEntity newsEntity = new NewsEntity(); ProposalEntity proposalEntity = this.get(entity.getId());
newsEntity.setMessageId(proposalEntity.getId()); NewsEntity newsEntity = new NewsEntity();
newsEntity.setCustomerId(proposalEntity.getCustomerId()); newsEntity.setMessageId(proposalEntity.getId());
newsEntity.setContent(proposalEntity.getReplyContent()); newsEntity.setCustomerId(proposalEntity.getCustomerId());
newsEntity.setMessageType(0); newsEntity.setContent(proposalEntity.getReplyContent());
newsEntity.setReadStatus(ReadStatusEnum.UN_READ.getValue()); newsEntity.setMessageType(0);
newsEntity.setReceiveTime(new Date()); newsEntity.setReadStatus(ReadStatusEnum.UN_READ.getValue());
newsService.save(newsEntity,context); newsEntity.setReceiveTime(new Date());
newsService.save(newsEntity, context);
}
} }
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.proposal.web; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.proposal.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit; import com.mortals.framework.annotation.RepeatSubmit;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum; import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
...@@ -53,17 +54,15 @@ public class ProposalController extends BaseCRUDJsonBodyMappingController<Propos ...@@ -53,17 +54,15 @@ public class ProposalController extends BaseCRUDJsonBodyMappingController<Propos
@Override @Override
protected void saveBefore(ProposalEntity entity, Map<String, Object> model, Context context) throws AppException { protected void saveBefore(ProposalEntity entity, Map<String, Object> model, Context context) throws AppException {
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){ if(this.getCurUser()!=null&&this.getCurUser().getUserType()== Constant.CUSTOMER_USER){
throw new AppException("非法用户,不可访问"); CustomerEntity customerEntity = customerService.get(this.getCurUser().getId());
entity.setCustomerId(this.getCurUser().getId());
entity.setCustName(customerEntity.getCustName());
entity.setContactTelphone(customerEntity.getContactTelphone());
} }
CustomerEntity customerEntity = customerService.get(this.getCurUser().getId());
entity.setCustomerId(this.getCurUser().getId());
entity.setCustName(customerEntity.getCustName());
entity.setContactTelphone(customerEntity.getContactTelphone());
if(entity.newEntity()){ if(entity.newEntity()){
entity.setReplyStatus(ReplyStatusEnum.UN_REPLY.getValue()); entity.setReplyStatus(ReplyStatusEnum.UN_REPLY.getValue());
} }
} }
@Override @Override
...@@ -121,4 +120,68 @@ public class ProposalController extends BaseCRUDJsonBodyMappingController<Propos ...@@ -121,4 +120,68 @@ public class ProposalController extends BaseCRUDJsonBodyMappingController<Propos
return ret.toJSONString(); return ret.toJSONString();
} }
@PostMapping({"save"})
@UnAuth
public String save(@RequestBody ProposalEntity entity) {
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "保存" + this.getModuleDesc();
int code=1;
try {
this.saveBefore(entity, model, context);
IUser user;
if (entity.newEntity()) {
busiDesc = "新增" + this.getModuleDesc();
entity.setCreateTime(new Date());
entity.setUpdateTime(entity.getCreateTime());
user = this.getCurUser();
if (user != null) {
entity.setCreateUserId(user.getId());
entity.setCreateUser(user.getLoginName());
entity.setCreateUserName(user.getRealName());
entity.setCreateUserDeptId(user.getDeptId());
entity.setCreateUserDeptName(user.getDeptName());
entity.setUpdateUserId(user.getId());
entity.setUpdateUser(user.getLoginName());
entity.setUpdateUserName(user.getRealName());
entity.setUpdateUserDeptId(user.getDeptId());
entity.setUpdateUserDeptName(user.getDeptName());
}
this.service.save(entity, context);
} else {
busiDesc = "修改" + this.getModuleDesc();
entity.setUpdateTime(new Date());
user = this.getCurUser();
if (user != null) {
entity.setUpdateUserId(user.getId());
entity.setUpdateUser(user.getLoginName());
entity.setUpdateUserName(user.getRealName());
entity.setUpdateUserDeptId(user.getDeptId());
entity.setUpdateUserDeptName(user.getDeptName());
}
this.service.update(entity, context);
}
model.put("id", entity.getId());
code = this.saveAfter(entity, model, context);
model.put("entity", entity);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + entity.getId() + "]");
} catch (Exception var7) {
this.doException(this.request, busiDesc, model, var7);
model.put("entity", entity);
this.init(model, context);
code = this.saveException(entity, model, context, var7);
}
this.init(model, context);
JSONObject ret = new JSONObject();
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment