Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李丛阳
education
Commits
5f3805ad
Commit
5f3805ad
authored
Jan 24, 2018
by
YangZhaoJun1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
试题
parent
438f8539
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
92 deletions
+68
-92
BFileServiceImpl.java
...rcisoft/business/bfile/service/impl/BFileServiceImpl.java
+3
-1
TQuestionController.java
...ft/business/tquestion/controller/TQuestionController.java
+31
-36
TQuestionRepository.java
...g/rcisoft/business/tquestion/dao/TQuestionRepository.java
+4
-5
TQuestion.java
...java/org/rcisoft/business/tquestion/entity/TQuestion.java
+4
-0
TQuestionService.java
.../rcisoft/business/tquestion/service/TQuestionService.java
+2
-5
TQuestionServiceImpl.java
...business/tquestion/service/impl/TQuestionServiceImpl.java
+14
-44
FileUtil.java
src/main/java/org/rcisoft/core/util/FileUtil.java
+10
-1
No files found.
src/main/java/org/rcisoft/business/bfile/service/impl/BFileServiceImpl.java
View file @
5f3805ad
...
...
@@ -8,6 +8,7 @@ import org.rcisoft.common.component.Global;
import
org.rcisoft.core.aop.PageUtil
;
import
org.rcisoft.core.constant.DelStatus
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.util.FileUtil
;
import
org.rcisoft.core.util.IdGen
;
import
org.rcisoft.core.util.OfficeToPdf
;
import
org.rcisoft.core.util.UserUtil
;
...
...
@@ -237,7 +238,8 @@ public class BFileServiceImpl implements BFileService {
String
name
=
uploadFile
.
substring
(
uploadFile
.
lastIndexOf
(
File
.
separator
)
+
1
,
uploadFile
.
lastIndexOf
(
'.'
));
// 截取上传文件的后缀
String
uploadFileSuffix
=
uploadFile
.
substring
(
uploadFile
.
lastIndexOf
(
'.'
)
+
1
,
uploadFile
.
length
());
String
uploadFileSuffix
=
FileUtil
.
getFilePostfix
(
uploadFile
);
//uploadFile.substring(uploadFile.lastIndexOf('.') + 1, uploadFile.length());
// 设置文件名为乱码
String
uploadFileName
=
IdGen
.
uuid
();
...
...
src/main/java/org/rcisoft/business/tquestion/controller/TQuestionController.java
View file @
5f3805ad
...
...
@@ -43,12 +43,13 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation
(
value
=
"新增试题"
,
notes
=
"新增试题"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"sl
_id"
,
value
=
"课程ID"
,
required
=
fals
e
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"chap
_i
d"
,
value
=
"章ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"sl
Id"
,
value
=
"课程ID"
,
required
=
tru
e
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"chap
I
d"
,
value
=
"章ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qtype"
,
value
=
"1 选择题 2 多选题 3 判断题"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qtitle"
,
value
=
"题干"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qdesc"
,
value
=
"解析"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qanswer"
,
value
=
"单选从0开始;判断:0错误 1正确;多选 0,1,2"
,
required
=
true
,
dataType
=
"varchar"
)})
@ApiImplicitParam
(
name
=
"qanswer"
,
value
=
"单选从0开始;判断:0错误 1正确;多选 0,1,2"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"questionOptions"
,
value
=
"选项"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
"/add"
)
@PreAuthorize
(
"hasRole('ROLE_1002')"
)
public
Result
add
(
TQuestion
tQuestion
)
{
...
...
@@ -59,32 +60,6 @@ public class TQuestionController extends PaginationController<TQuestion> {
tQuestion
);
}
@ApiOperation
(
value
=
"新增选项"
,
notes
=
"新增加一个选项"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qid"
,
value
=
"题目id"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"alias"
,
value
=
"列别名"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"desc"
,
value
=
"列描述"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
"/addOption"
)
@PreAuthorize
(
"hasRole('ROLE_1002')"
)
public
Result
addoption
(
@PathVariable
TQuestionOptions
tQuestionOptions
){
PersistModel
data
=
tQuestionServiceImpl
.
saveoption
(
tQuestionOptions
);
return
Result
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
tQuestionOptions
);
}
@ApiOperation
(
value
=
"删除选项"
,
notes
=
"根据ID删除一个选项"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"id"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)})
@PostMapping
(
"/removeOption"
)
@PreAuthorize
(
"hasRole('ROLE_1002')"
)
public
Result
deleteOption
(
@PathVariable
String
id
)
{
return
Result
.
builder
(
new
PersistModel
(
tQuestionServiceImpl
.
removeOption
(
id
,
getToken
())),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
id
);
}
@ApiOperation
(
value
=
"删除题目"
,
notes
=
"根据ID删除一个题"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)
...
...
@@ -110,10 +85,17 @@ public class TQuestionController extends PaginationController<TQuestion> {
}
@ApiOperation
(
value
=
"修改"
,
notes
=
"修改"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
false
,
dataType
=
"varchar"
)})
@PutMapping
(
"/{id:\\d+}"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"章ID"
,
required
=
true
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"课程ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"chapId"
,
value
=
"章ID"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qtype"
,
value
=
"1 选择题 2 多选题 3 判断题"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qtitle"
,
value
=
"题干"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qdesc"
,
value
=
"解析"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qanswer"
,
value
=
"单选从0开始;判断:0错误 1正确;多选 0,1,2"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"questionOptions"
,
value
=
"选项"
,
required
=
false
,
dataType
=
"varchar"
)})
@PostMapping
(
"/update"
)
@PreAuthorize
(
"hasRole('ROLE_1002')"
)
public
Result
update
(
@Valid
TQuestion
tQuestion
,
BindingResult
bindingResult
)
{
public
Result
update
(
TQuestion
tQuestion
)
{
tQuestion
.
setToken
(
getToken
());
PersistModel
data
=
tQuestionServiceImpl
.
merge
(
tQuestion
);
return
Result
.
builder
(
data
,
...
...
@@ -129,21 +111,22 @@ public class TQuestionController extends PaginationController<TQuestion> {
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
tQuestionServiceImpl
.
findById
(
id
));
tQuestionServiceImpl
.
findById
(
id
));
}
@ApiOperation
(
value
=
"根据条件分页查询"
,
notes
=
"根据URL中的参数分页查询"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"qtype"
,
value
=
"题目类型"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"qtitle"
,
value
=
"关键字"
,
required
=
false
,
dataType
=
"varchar"
)})
@ApiImplicitParam
(
name
=
"qtitle"
,
value
=
"关键字"
,
required
=
false
,
dataType
=
"varchar"
),
@ApiImplicitParam
(
name
=
"slId"
,
value
=
"课程ID"
,
required
=
true
,
dataType
=
"varchar"
)})
@GetMapping
(
value
=
"/queryTQuestionByPagination"
)
@PreAuthorize
(
"hasRole('ROLE_1002')"
)
public
GridModel
listByPagination
(
TQuestion
tQuestion
)
{
tQuestion
.
setCreateBy
(
UserUtil
.
getUserInfoProp
(
getToken
(),
UserUtil
.
USER_ID
));
//
tQuestion.setCreateBy(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
tQuestionServiceImpl
.
findAllByPagination
(
getPaginationUtility
(),
tQuestion
);
return
getGridModelResponse
();
}
@ApiOperation
(
value
=
"根据条件查询"
,
notes
=
"根据URL中的参数查询全部"
)
@ApiOperation
(
value
=
"根据条件查询
(不分页)
"
,
notes
=
"根据URL中的参数查询全部"
)
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
false
,
dataType
=
"varchar"
)
@GetMapping
(
value
=
"/queryTQestions"
)
@PreAuthorize
(
"hasRole('ROLE_1002')"
)
...
...
@@ -154,4 +137,16 @@ public class TQuestionController extends PaginationController<TQuestion> {
MessageConstant
.
MESSAGE_ALERT_ERROR
,
tQuestionServiceImpl
.
queryTQuestions
(
tQuestion
));
}
@ApiOperation
(
value
=
"题目详情"
,
notes
=
"根据题目ID获取题目详情"
)
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)
@GetMapping
(
value
=
"/queryTQestionById"
)
@PreAuthorize
(
"hasRole('ROLE_1002')"
)
public
Result
queryTQestionById
(
String
BusinessId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
tQuestionServiceImpl
.
queryTQestionById
(
BusinessId
));
}
}
src/main/java/org/rcisoft/business/tquestion/dao/TQuestionRepository.java
View file @
5f3805ad
...
...
@@ -20,25 +20,24 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
* 分页查询 tQuestion
*
*/
@Select
(
"<script>select * from t_question where
1=1
"
@Select
(
"<script>select * from t_question where
sl_id = #{slId}
"
+
"<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+
"<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+
"<if test=\"qtype != null and qtype != '' \">and qtype = #{qtype} </if>"
+
"<if test=\"qtitle != null and qtitle != '' \">and qtitle LIKE CONCAT ('%',#{qtitle},'%')</if>"
+
"</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
TQuestion
>
queryTQuestions
ByPagination
(
TQuestion
tQuestion
);
List
<
TQuestion
>
queryTQuestions
(
TQuestion
tQuestion
);
@Select
(
"<script>select * "
/*
@Select("<script>select * "
+"from t_question tq"
+"left join t_question_options tqo on tqo.qid = tq.business_id"
+"where 1=1"
+"<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+"<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+"<if test=\"business_id != null and business_id != ''\">and business_id = #{business_id}</if></script>")
List
<
TQuestion
>
queryTQuestions
(
TQuestion
tQuestion
);
List<TQuestion> queryTQuestions(TQuestion tQuestion);
*/
@Update
(
"<script> update t_question set del_flag = 1 , flag = 0 where FIND_IN_SET(business_id,#{idInfoList})</script>"
)
int
deleteByIds
(
String
idInfoList
);
...
...
src/main/java/org/rcisoft/business/tquestion/entity/TQuestion.java
View file @
5f3805ad
...
...
@@ -44,6 +44,10 @@ public class TQuestion extends IdEntity<TQuestion> {
@Transient
List
<
Map
<
String
,
Object
>>
questionOptions
;
List
<
TQuestionOptions
>
options
;
public
TQuestion
(
String
businessId
)
{
this
.
businessId
=
businessId
;
}
}
src/main/java/org/rcisoft/business/tquestion/service/TQuestionService.java
View file @
5f3805ad
...
...
@@ -46,15 +46,12 @@ public interface TQuestionService {
* @param tQuestion
* @return
*/
List
<
TQuestion
>
findAllByPagination
(
PageUtil
<
TQuestion
>
paginationUtility
,
TQuestion
tQuestion
);
List
<
TQuestion
>
findAllByPagination
(
PageUtil
<
TQuestion
>
paginationUtility
,
TQuestion
tQuestion
);
List
<
TQuestion
>
queryTQuestions
(
TQuestion
tQuestion
);
int
removeByIds
(
String
idInfoList
);
PersistModel
saveoption
(
TQuestionOptions
tQuestionOptions
);
int
removeOption
(
String
id
,
String
token
);
TQuestion
queryTQestionById
(
String
businessId
);
}
src/main/java/org/rcisoft/business/tquestion/service/impl/TQuestionServiceImpl.java
View file @
5f3805ad
...
...
@@ -46,54 +46,19 @@ public class TQuestionServiceImpl implements TQuestionService {
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
PersistModel
save
(
TQuestion
tQuestion
){
List
<
TQuestionOptions
>
optionList
=
new
ArrayList
();
//增加主表题干信息
UserUtil
.
setCurrentPersistOperation
(
tQuestion
);
int
line
=
tQuestionRepository
.
insertSelective
(
tQuestion
);
//增加选项信息
for
(
Map
<
String
,
Object
>
map
:
tQuestion
.
getQuestionOptions
()){
TQuestionOptions
tQuestionOptions
=
new
TQuestionOptions
();
tQuestionOptions
.
setCommonBusinessId
();
tQuestionOptions
.
setQid
(
tQuestion
.
getBusinessId
());
tQuestionOptions
.
setAlias
(
String
.
valueOf
(
map
.
keySet
()));
tQuestionOptions
.
setDescribe
(
String
.
valueOf
(
map
.
get
(
map
.
keySet
())));
optionList
.
add
(
tQuestionOptions
);
for
(
TQuestionOptions
option
:
tQuestion
.
getOptions
()){
option
.
setCommonBusinessId
();
option
.
setQid
(
tQuestion
.
getBusinessId
());
}
tQuestionRepository
.
insertOptionsList
(
optionList
);
tQuestionRepository
.
insertOptionsList
(
tQuestion
.
getOptions
()
);
return
new
PersistModel
(
line
);
}
/**
* 增加选项
* @param tQuestionOptions
* @return
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
PersistModel
saveoption
(
TQuestionOptions
tQuestionOptions
)
{
tQuestionOptions
.
setCommonBusinessId
();
int
line
=
tQuestionOptionsRepository
.
insertSelective
(
tQuestionOptions
);
return
new
PersistModel
(
line
);
}
/**
* 删除选项
* @param id
* @param token
* @return
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
isolation
=
Isolation
.
DEFAULT
)
@Override
public
int
removeOption
(
String
id
,
String
token
){
TQuestionOptions
tQuestionOptions
=
new
TQuestionOptions
();
tQuestionOptions
.
setBusinessId
(
id
);
// UserUtil.setCurrentMergeOperation(tQuestion);
int
line
=
tQuestionOptionsRepository
.
deleteByPrimaryKey
(
id
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"逻辑删除了ID为"
+
tQuestionOptions
.
getBusinessId
()+
"的信息"
);
return
line
;
}
/**
* 逻辑删除
...
...
@@ -106,9 +71,10 @@ public class TQuestionServiceImpl implements TQuestionService {
TQuestion
tQuestion
=
new
TQuestion
();
tQuestion
.
setBusinessId
(
id
);
UserUtil
.
setCurrentMergeOperation
(
tQuestion
);
tQuestion
.
setDeleted
();
int
line
=
tQuestionRepository
.
logicalDelete
(
tQuestion
);
log
.
info
(
UserUtil
.
getUserInfoProp
(
token
,
UserUtil
.
USER_USERNAME
)+
"逻辑删除了ID为"
+
tQuestion
.
getBusinessId
()+
"的信息"
);
/*
log.info(UserUtil.getUserInfoProp(token,UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
tQuestion.getBusinessId()+"的信息");
*/
return
line
;
}
...
...
@@ -141,11 +107,10 @@ public class TQuestionServiceImpl implements TQuestionService {
* @param tQuestion
* @return
*/
public
List
<
TQuestion
>
findAllByPagination
(
PageUtil
<
TQuestion
>
paginationUtility
,
TQuestion
tQuestion
){
public
List
<
TQuestion
>
findAllByPagination
(
PageUtil
<
TQuestion
>
paginationUtility
,
TQuestion
tQuestion
){
tQuestion
.
setStart
();
tQuestion
.
setNotDeleted
();
return
tQuestionRepository
.
queryTQuestions
ByPagination
(
tQuestion
);
return
tQuestionRepository
.
queryTQuestions
(
tQuestion
);
}
@Override
...
...
@@ -158,5 +123,10 @@ public class TQuestionServiceImpl implements TQuestionService {
return
tQuestionRepository
.
deleteByIds
(
idInfoList
);
}
@Override
public
TQuestion
queryTQestionById
(
String
businessId
)
{
return
tQuestionRepository
.
selectOne
(
new
TQuestion
(
businessId
));
}
}
src/main/java/org/rcisoft/core/util/FileUtil.java
View file @
5f3805ad
...
...
@@ -16,7 +16,16 @@ public class FileUtil {
public
static
String
getFilePostfix
(
String
fileName
){
if
(
StringUtils
.
isEmpty
(
fileName
))
return
""
;
return
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)+
1
);
String
fileSuffix
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
)+
1
);
if
(
fileSuffix
.
equals
(
"docx"
)){
return
"doc"
;
}
else
if
(
fileSuffix
.
equals
(
"pptx"
)){
return
"ppt"
;
}
else
if
(
fileSuffix
.
equals
(
"xlsx"
)){
return
"xls"
;
}
else
{
return
""
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment