Commit b36a2e83 authored by YangZhaoJun1's avatar YangZhaoJun1

Merge branch 'master' of http://103.249.252.109:90/lcy/education

# Conflicts:
#	src/main/java/org/rcisoft/business/texaminfo/dao/TExamInfoRepository.java
#	src/main/java/org/rcisoft/business/texaminfo/entity/TExamInfo.java
parents 8739a8c6 016a9423
...@@ -17,6 +17,8 @@ import org.rcisoft.common.controller.PaginationController; ...@@ -17,6 +17,8 @@ import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.common.model.GridModel; import org.rcisoft.common.model.GridModel;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
...@@ -37,15 +39,15 @@ public class TExamInfoController extends PaginationController<TExamInfo> { ...@@ -37,15 +39,15 @@ public class TExamInfoController extends PaginationController<TExamInfo> {
@ApiOperation(value="添加", notes="添加") @ApiOperation(value="添加", notes="添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) @ApiImplicitParams({@ApiImplicitParam(name = "chapterId", value = "chapterId", required = true, dataType = "varchar")})
@PostMapping @PostMapping("/add")
public Result add(@Valid TExamInfo tExamInfo, BindingResult bindingResult) { public Result add(String chapterId, HttpServletRequest request) {
tExamInfo.setToken(getToken()); String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID);
PersistModel data = tExamInfoServiceImpl.save(tExamInfo); PersistModel data = tExamInfoServiceImpl.save(chapterId,userId,request);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
tExamInfo); chapterId);
} }
@ApiOperation(value="逻辑删除", notes="逻辑删除") @ApiOperation(value="逻辑删除", notes="逻辑删除")
......
package org.rcisoft.business.texaminfo.service; package org.rcisoft.business.texaminfo.service;
import org.apache.tools.ant.taskdefs.condition.Http;
import org.rcisoft.business.texaminfo.entity.TExamInfo; import org.rcisoft.business.texaminfo.entity.TExamInfo;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
/** /**
...@@ -13,10 +15,10 @@ public interface TExamInfoService { ...@@ -13,10 +15,10 @@ public interface TExamInfoService {
/** /**
* 保存 * 保存
* @param tExamInfo * @param chapterId
* @return * @return
*/ */
PersistModel save(TExamInfo tExamInfo); PersistModel save(String chapterId, String userId, HttpServletRequest request);
/** /**
* 逻辑删除 * 逻辑删除
......
package org.rcisoft.business.texaminfo.service.impl; package org.rcisoft.business.texaminfo.service.impl;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.util.IpUtil;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
...@@ -18,6 +20,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -18,6 +20,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
/** /**
* Created by yangzhaojun on 2018-1-15 19:49:07. * Created by yangzhaojun on 2018-1-15 19:49:07.
*/ */
...@@ -32,14 +36,20 @@ public class TExamInfoServiceImpl implements TExamInfoService { ...@@ -32,14 +36,20 @@ public class TExamInfoServiceImpl implements TExamInfoService {
/** /**
* 保存 tExamInfo * 保存 tExamInfo
* @param tExamInfo * @param chapterId
* @return * @return
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(TExamInfo tExamInfo){ public PersistModel save(String chapterId, String userId, HttpServletRequest request){
TExamInfo tExamInfo = new TExamInfo();
List<String> list = tExamInfoRepository.queryPidByChapterId(chapterId);
String pId = list.get(0);
tExamInfo.setCommonBusinessId(); tExamInfo.setCommonBusinessId();
//增加操作 tExamInfo.setPId(pId);
tExamInfoRepository.updateStatus(pId);
tExamInfo.setUId(userId);
tExamInfo.setIp(IpUtil.getIpAddr(request));
UserUtil.setCurrentPersistOperation(tExamInfo); UserUtil.setCurrentPersistOperation(tExamInfo);
int line = tExamInfoRepository.insertSelective(tExamInfo); int line = tExamInfoRepository.insertSelective(tExamInfo);
log.info(UserUtil.getUserInfoProp(tExamInfo.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+ log.info(UserUtil.getUserInfoProp(tExamInfo.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+
...@@ -47,6 +57,7 @@ public class TExamInfoServiceImpl implements TExamInfoService { ...@@ -47,6 +57,7 @@ public class TExamInfoServiceImpl implements TExamInfoService {
return new PersistModel(line); return new PersistModel(line);
} }
/** /**
* 逻辑删除 * 逻辑删除
* @param tExamInfo * @param tExamInfo
......
package org.rcisoft.core.util;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* Created by liuzhichao on 2018/1/31.
*/
public class IpUtil {
public static String getIpAddr(HttpServletRequest request) {
String ipAddress = null;
try {
ipAddress = request.getHeader("x-forwarded-for");
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("WL-Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getRemoteAddr();
if (ipAddress.equals("127.0.0.1")) {
// 根据网卡取本机配置的IP
InetAddress inet = null;
try {
inet = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
ipAddress = inet.getHostAddress();
}
}
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if (ipAddress != null && ipAddress.length() > 15) { // "***.***.***.***".length()
// = 15
if (ipAddress.indexOf(",") > 0) {
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
}
}
} catch (Exception e) {
ipAddress="";
}
// ipAddress = this.getRequest().getRemoteAddr();
return ipAddress;
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<result column="status" jdbcType="VARCHAR" property="status"/> <result column="status" jdbcType="VARCHAR" property="status"/>
<result column="p_score" jdbcType="FLOAT" property="pScore"/> <result column="p_score" jdbcType="FLOAT" property="pScore"/>
<result column="sorder" jdbcType="INTEGER" property="sorder"/> <result column="sorder" jdbcType="INTEGER" property="sorder"/>
<result column="ip" jdbcType="VARCHAR" property="ip"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/> <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/> <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/> <result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
......
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