Commit 2421542b by java-lixy

添加举报接口 获取token

parent a024d669
...@@ -44,7 +44,7 @@ public class FrontReportController { ...@@ -44,7 +44,7 @@ public class FrontReportController {
* @return * @return
*/ */
@RequestMapping("addReport") @RequestMapping("addReport")
public ResponseBean addReport(FrontReportBean bean){ public ResponseBean addReport(FrontReportBean bean,String token){
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
if(bean!=null){ if(bean!=null){
if(!CaptchaUtil.validate(bean.getCaptcha(),bean.getCode())){ if(!CaptchaUtil.validate(bean.getCaptcha(),bean.getCode())){
...@@ -57,7 +57,7 @@ public class FrontReportController { ...@@ -57,7 +57,7 @@ public class FrontReportController {
responseBean.setMessage("report_source为空"); responseBean.setMessage("report_source为空");
return responseBean; return responseBean;
}else { }else {
return frontReportService.addReport(bean); return frontReportService.addReport(bean,token);
} }
} }
responseBean.setStatus(ErrorCode.STATUS_CODE_4001); responseBean.setStatus(ErrorCode.STATUS_CODE_4001);
......
...@@ -6,18 +6,31 @@ import com.ejweb.core.api.ResponseBean; ...@@ -6,18 +6,31 @@ import com.ejweb.core.api.ResponseBean;
import com.ejweb.core.service.CrudService; import com.ejweb.core.service.CrudService;
import com.ejweb.core.utils.DateUtils; import com.ejweb.core.utils.DateUtils;
import com.ejweb.core.utils.IdWorker; import com.ejweb.core.utils.IdWorker;
import com.ejweb.core.utils.SpringContextHolder;
import com.ejweb.modules.front.report.bean.FrontReportBean; import com.ejweb.modules.front.report.bean.FrontReportBean;
import com.ejweb.modules.front.report.dao.FrontReportDao; import com.ejweb.modules.front.report.dao.FrontReportDao;
import com.ejweb.modules.front.report.entity.FrontReportEntity; import com.ejweb.modules.front.report.entity.FrontReportEntity;
import com.ejweb.modules.front.sso.dao.SsoDao;
import com.ejweb.modules.front.upload.util.ReportAttachmentUtils; import com.ejweb.modules.front.upload.util.ReportAttachmentUtils;
import com.ejweb.modules.sys.dao.SysUserDao;
import com.ejweb.modules.sys.entity.User; import com.ejweb.modules.sys.entity.User;
import com.ejweb.modules.sys.utils.UserUtils; import com.ejweb.modules.sys.utils.UserUtils;
import com.kingdee.eas.cp.eip.sso.ltpa.LtpaToken;
import com.kingdee.eas.cp.eip.sso.ltpa.LtpaTokenManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.net.URLDecoder;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Created by lenovo on 2017/9/8. * Created by lenovo on 2017/9/8.
...@@ -26,9 +39,11 @@ import java.util.List; ...@@ -26,9 +39,11 @@ import java.util.List;
@Service @Service
@Transactional(readOnly = true) @Transactional(readOnly = true)
public class FrontReportService extends CrudService<FrontReportDao,FrontReportEntity>{ public class FrontReportService extends CrudService<FrontReportDao,FrontReportEntity>{
private static Logger log = LoggerFactory.getLogger(FrontReportService.class);
// 添加举报信息 // 添加举报信息
@Transactional(readOnly = false) @Transactional(readOnly = false)
public ResponseBean addReport(FrontReportBean bean){ public ResponseBean addReport(FrontReportBean bean,String token){
ResponseBean responseBean = new ResponseBean(); ResponseBean responseBean = new ResponseBean();
String reportId = IdWorker.getNextId("R"); String reportId = IdWorker.getNextId("R");
bean.setId(reportId); bean.setId(reportId);
...@@ -36,10 +51,29 @@ public class FrontReportService extends CrudService<FrontReportDao,FrontReportEn ...@@ -36,10 +51,29 @@ public class FrontReportService extends CrudService<FrontReportDao,FrontReportEn
bean.setReportTime(DateUtils.formatDate(date,"yyyy-MM-dd HH:mm:ss")); bean.setReportTime(DateUtils.formatDate(date,"yyyy-MM-dd HH:mm:ss"));
bean.setReportStatus("0"); bean.setReportStatus("0");
log.info("report_source为:"+bean.getReportSource());
log.info("token为:"+token);
if (bean.getReportSource().equals("oa")){ if (bean.getReportSource().equals("oa")){
User oaUser = UserUtils.getUser(); try {
bean.setOaName(oaUser.getName()); DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
Resource resource = resourceLoader.getResource("LtpaToken.properties");
String filePath = resource.getURL().getPath();
LtpaTokenManager.loadConfig(URLDecoder.decode(URLDecoder.decode(filePath)));
token = URLDecoder.decode(token);
token = URLDecoder.decode(token);
token = URLDecoder.decode(token);
String username = "";
boolean result = LtpaTokenManager.isValid(token);
if (result) {//验证Token是否合法有效
logger.debug(".................合法token:\t\t" + token);
LtpaToken ltpaToken = new LtpaToken(token);
username = ltpaToken.getUsername();
bean.setOaName(username);
}
} catch (Exception e) {
e.printStackTrace();
}
} }
// 查询管理员 // 查询管理员
......
...@@ -6,12 +6,22 @@ db.table.prefix=sunac_ ...@@ -6,12 +6,22 @@ db.table.prefix=sunac_
#jdbc.url=jdbc:mysql://123.56.146.7:3306/sunac_report?useUnicode=true&characterEncoding=utf-8 #jdbc.url=jdbc:mysql://123.56.146.7:3306/sunac_report?useUnicode=true&characterEncoding=utf-8
#jdbc.username=reportuser #jdbc.username=reportuser
#jdbc.password=$R@20$7 #jdbc.password=$R@20$7
#融创测试数据库
jdbc.type=oracle jdbc.type=oracle
jdbc.driver.class=oracle.jdbc.driver.OracleDriver jdbc.driver.class=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@192.168.2.53:1521:eas jdbc.url=jdbc:oracle:thin:@192.168.2.53:1521:eas
jdbc.username=eas7531 jdbc.username=eas7531
jdbc.password=sunac jdbc.password=sunac
#正式数据库
#jdbc.type=oracle
#jdbc.driver.class=oracle.jdbc.driver.OracleDriver
#jdbc.url=jdbc:oracle:thin:@192.168.2.24:1521:eas
#jdbc.username= easdba
#jdbc.password= Sunac_1918
#初始化连接 #初始化连接
jdbc.initialSize=0 jdbc.initialSize=0
#连接池的最大活动个数 #连接池的最大活动个数
......
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