parent
fcc3fdaa84
commit
0961639ed1
10 changed files with 233 additions and 3 deletions
@ -0,0 +1,47 @@ |
|||||||
|
package com.blockchain.server.yyyf.init; |
||||||
|
|
||||||
|
import com.blockchain.server.yyyf.service.AssessUserService; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className InitData |
||||||
|
* @description |
||||||
|
* @date 2020-05-06 15:42 |
||||||
|
*/ |
||||||
|
public class InitData { |
||||||
|
private static InitData initData=null; |
||||||
|
|
||||||
|
public InitData(){ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static InitData getInstance(){ |
||||||
|
synchronized (InitData.class){ |
||||||
|
if(initData==null){ |
||||||
|
initData=new InitData(); |
||||||
|
} |
||||||
|
} |
||||||
|
return initData; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void init(){ |
||||||
|
initExamPaperDto(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @description 初始化试卷(项目)数据 |
||||||
|
* @author Mr.Xu |
||||||
|
* @date 2020-05-06 16:21:52 |
||||||
|
* @param [] |
||||||
|
* @return void |
||||||
|
**/ |
||||||
|
private void initExamPaperDto(){ |
||||||
|
AssessUserService trainManageService= (AssessUserService) SpringContextUtil.getBean("assessUserService"); |
||||||
|
trainManageService.initAllExamPaperDto(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.blockchain.server.yyyf.init; |
||||||
|
|
||||||
|
|
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.boot.ApplicationArguments; |
||||||
|
import org.springframework.boot.ApplicationRunner; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Mr.Xu |
||||||
|
* @version 1.0 |
||||||
|
* @className InitProject |
||||||
|
* @description 初始化项目 |
||||||
|
* @date 2020-05-06 16:16 |
||||||
|
*/ |
||||||
|
@Component |
||||||
|
public class InitProject implements ApplicationRunner { |
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(InitProject.class); |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void run(ApplicationArguments args) throws Exception { |
||||||
|
LOG.info("==========init project==========="); |
||||||
|
try { |
||||||
|
InitData.getInstance().init(); |
||||||
|
LOG.info("============init data success============"); |
||||||
|
} catch (Exception e) { |
||||||
|
LOG.error("init data error={}", e.getMessage()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
package com.blockchain.server.yyyf.init; |
||||||
|
|
||||||
|
import org.springframework.beans.BeansException; |
||||||
|
import org.springframework.context.ApplicationContext; |
||||||
|
import org.springframework.context.ApplicationContextAware; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
import org.springframework.web.context.request.RequestContextHolder; |
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import javax.servlet.http.HttpSession; |
||||||
|
|
||||||
|
@Component |
||||||
|
public class SpringContextUtil implements ApplicationContextAware { |
||||||
|
|
||||||
|
// Spring应用上下文环境
|
||||||
|
private static ApplicationContext applicationContext; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实现ApplicationContextAware接口的回调方法。设置上下文环境 |
||||||
|
* |
||||||
|
* @param applicationContext |
||||||
|
*/ |
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) { |
||||||
|
SpringContextUtil.applicationContext = applicationContext; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return ApplicationContext |
||||||
|
*/ |
||||||
|
public static ApplicationContext getApplicationContext() { |
||||||
|
return applicationContext; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取对象 |
||||||
|
* |
||||||
|
* @param name |
||||||
|
* @return Object |
||||||
|
* @throws BeansException |
||||||
|
*/ |
||||||
|
public static Object getBean(String name) throws BeansException { |
||||||
|
return applicationContext.getBean(name); |
||||||
|
} |
||||||
|
public static <T> T getBean(Class<T> requiredType) throws BeansException { |
||||||
|
return applicationContext.getBean(requiredType); |
||||||
|
} |
||||||
|
public static HttpServletRequest getHttpServletRequest() { |
||||||
|
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
||||||
|
} |
||||||
|
public static HttpServletResponse getHttpServletResponse() { |
||||||
|
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse(); |
||||||
|
} |
||||||
|
public static HttpSession getHttpSession() { |
||||||
|
HttpServletRequest request = getHttpServletRequest(); |
||||||
|
return request.getSession(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package com.blockchain.server.yyyf.mapper; |
||||||
|
|
||||||
|
import com.blockchain.server.train.dto.ExamPaperDto; |
||||||
|
import org.springframework.stereotype.Repository; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* (TrainCaseManage)表数据库访问层 |
||||||
|
* |
||||||
|
* @author qianqian.zhang |
||||||
|
* @since 2020-04-16 16:03:48 |
||||||
|
*/ |
||||||
|
@Repository |
||||||
|
public interface TrainCaseManageMapper { |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @description |
||||||
|
* @author Mr.Xu |
||||||
|
* @date 2020-05-06 15:50:51 |
||||||
|
* @param [] |
||||||
|
* @return void |
||||||
|
**/ |
||||||
|
|
||||||
|
List<ExamPaperDto> getAllExamPaperDto(); |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.blockchain.server.yyyf.mapper.TrainCaseManageMapper"> |
||||||
|
|
||||||
|
|
||||||
|
<resultMap type="com.blockchain.server.train.dto.ExamPaperDto" id="ExamPaperDtoMap"> |
||||||
|
<result property="id" column="id" jdbcType="VARCHAR"/> |
||||||
|
<result property="name" column="name" jdbcType="VARCHAR"/> |
||||||
|
<result property="type" column="type" jdbcType="INTEGER"/> |
||||||
|
<result property="wechatInitMoney" column="wechat_init_money" jdbcType="DECIMAL"/> |
||||||
|
<result property="alipayInitMoney" column="alipay_init_money" jdbcType="DECIMAL"/> |
||||||
|
<result property="bankcardInitMoney" column="bankcard_init_money" jdbcType="DECIMAL"/> |
||||||
|
<result property="digitwalletInitMoney" column="digitwallet_init_money" jdbcType="DECIMAL"/> |
||||||
|
<collection property="trainCaseTargetList" javaType="list" ofType="com.blockchain.server.train.dto.TrainCaseTargetDto"> |
||||||
|
<result property="id" column="case_target_id" jdbcType="VARCHAR"/> |
||||||
|
<result property="name" column="target_name" jdbcType="VARCHAR"/> |
||||||
|
<result property="taskOperate" column="task_operate" jdbcType="INTEGER"/> |
||||||
|
<result property="taskRate" column="task_rate" jdbcType="DOUBLE"/> |
||||||
|
<result property="taskScore" column="task_score" jdbcType="DOUBLE"/> |
||||||
|
<result property="targetId" column="target_id" jdbcType="VARCHAR"/> |
||||||
|
<result property="code" column="code" jdbcType="VARCHAR"/> |
||||||
|
</collection> |
||||||
|
</resultMap> |
||||||
|
<select id="getAllExamPaperDto" resultMap="ExamPaperDtoMap"> |
||||||
|
SELECT |
||||||
|
cm.id ,cm.name,cm.type,cm.wechat_init_money,cm.alipay_init_money,cm.bankcard_init_money,cm.digitwallet_init_money,ct.id case_target_id,dt.name target_name,ct.task_rate,ct.task_score,ct.task_operate,dt.code,dt.id target_id |
||||||
|
FROM |
||||||
|
train_case_manage cm, |
||||||
|
train_case_target ct, |
||||||
|
train_dict_target dt |
||||||
|
WHERE |
||||||
|
cm.id = ct.case_id and ct.target_id=dt.id |
||||||
|
AND cm.is_del = 0 |
||||||
|
</select> |
||||||
|
|
||||||
|
</mapper> |
Loading…
Reference in new issue