Commit 47ba7c3f authored by YangZhaoJun1's avatar YangZhaoJun1

整理代码

parent 48e3d55e
...@@ -282,6 +282,7 @@ public class BSlServiceImpl implements BSlService { ...@@ -282,6 +282,7 @@ public class BSlServiceImpl implements BSlService {
BSl bsl = new BSl(); BSl bsl = new BSl();
bsl.setBusinessId(id); bsl.setBusinessId(id);
UserUtil.setCurrentMergeOperation(bsl); UserUtil.setCurrentMergeOperation(bsl);
bSl.setDeleted();
int line = bSlRepository.logicalDelete(bSl); int line = bSlRepository.logicalDelete(bSl);
//int line = bSlRepository.deleteByPrimaryKey(id); //int line = bSlRepository.deleteByPrimaryKey(id);
return new PersistModel(line); return new PersistModel(line);
......
...@@ -254,6 +254,7 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -254,6 +254,7 @@ public class BStudentServiceImpl implements BStudentService {
} }
BStudent bStudent = new BStudent(); BStudent bStudent = new BStudent();
bStudent.setBusinessId(id); bStudent.setBusinessId(id);
bStudent.setDeleted();
UserUtil.setCurrentMergeOperation(bStudent); UserUtil.setCurrentMergeOperation(bStudent);
BStudent student = bStudentRepository.selectOne(bStudent); BStudent student = bStudentRepository.selectOne(bStudent);
sysUserMapper.deleteByCode(student.getCode()); sysUserMapper.deleteByCode(student.getCode());
......
...@@ -3,6 +3,7 @@ package org.rcisoft.business.bteacher.entity; ...@@ -3,6 +3,7 @@ package org.rcisoft.business.bteacher.entity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.rcisoft.core.entity.IdEntity; import org.rcisoft.core.entity.IdEntity;
import javax.persistence.Entity; import javax.persistence.Entity;
...@@ -40,6 +41,7 @@ public class BTeacher extends IdEntity<BTeacher> { ...@@ -40,6 +41,7 @@ public class BTeacher extends IdEntity<BTeacher> {
private String recommendCourse; private String recommendCourse;
@Transient @Transient
@Length(min = 1,max = 200,message = "长度最小为1,最大为15")
private String name; private String name;
@Transient @Transient
......
...@@ -5,6 +5,7 @@ package org.rcisoft.business.tquestion.controller; ...@@ -5,6 +5,7 @@ package org.rcisoft.business.tquestion.controller;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.json.JSONArray;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -30,7 +31,7 @@ import java.util.List; ...@@ -30,7 +31,7 @@ import java.util.List;
* Created by yangzhaojun on 2018-1-15 19:49:07. * Created by yangzhaojun on 2018-1-15 19:49:07.
*/ */
@RestController @RestController
@RequestMapping("/t/question") @RequestMapping("/tQuestion")
public class TQuestionController extends PaginationController<TQuestion> { public class TQuestionController extends PaginationController<TQuestion> {
@Autowired @Autowired
...@@ -40,14 +41,9 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -40,14 +41,9 @@ public class TQuestionController extends PaginationController<TQuestion> {
@ApiOperation(value="添加", notes="添加") @ApiOperation(value="添加", notes="添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) //@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping @PostMapping
@PreAuthorize("hasRole('ROLE_1001')") @PreAuthorize("hasRole('ROLE_1002')")
public Result add(@Valid TQuestion tQuestion, BindingResult bindingResult) { public Result add(@Valid TQuestion tQuestion, String[] questionOptions) {
if (bindingResult.hasErrors()) { PersistModel data = tQuestionServiceImpl.save(tQuestion,questionOptions);
throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR.getCode(),
bindingResult.getFieldError().getDefaultMessage());
}
tQuestion.setToken(getToken());
PersistModel data = tQuestionServiceImpl.save(tQuestion);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
...@@ -59,11 +55,7 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -59,11 +55,7 @@ public class TQuestionController extends PaginationController<TQuestion> {
@PostMapping("/remove") @PostMapping("/remove")
@PreAuthorize("hasRole('ROLE_1001')") @PreAuthorize("hasRole('ROLE_1001')")
public Result delete(@PathVariable String id) { public Result delete(@PathVariable String id) {
TQuestion tQuestion = new TQuestion(); return Result.builder(new PersistModel(tQuestionServiceImpl.remove(id,getToken())),
tQuestion.setBusinessId(id);
tQuestion.setToken(getToken());
PersistModel data = tQuestionServiceImpl.remove(tQuestion);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); id);
......
...@@ -43,7 +43,7 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> { ...@@ -43,7 +43,7 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
+"where 1=1" +"where 1=1"
+"<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> " +"<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+"<if test=\"flag !=null and flag != '' \">and flag = #{flag} </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>") +"<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);
} }
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
@Table(name = "t_question") @Table(name = "t_question")
public class TQuestion extends IdEntity<TQuestion> { public class TQuestion extends IdEntity<TQuestion> {
private static final long serialVersionUID = -3700402045439337539L;
private String slId; private String slId;
...@@ -39,7 +39,7 @@ public class TQuestion extends IdEntity<TQuestion> { ...@@ -39,7 +39,7 @@ public class TQuestion extends IdEntity<TQuestion> {
@Transient @Transient
private String alias; private String alias;
@Transient
private String desc; private String desc;
......
...@@ -16,14 +16,14 @@ public interface TQuestionService { ...@@ -16,14 +16,14 @@ public interface TQuestionService {
* @param tQuestion * @param tQuestion
* @return * @return
*/ */
PersistModel save(TQuestion tQuestion); PersistModel save(TQuestion tQuestion, String[] questionOptions);
/** /**
* 逻辑删除 * 逻辑删除
* @param tQuestion * @param id
* @return * @return
*/ */
PersistModel remove(TQuestion tQuestion); int remove(String id, String token);
/** /**
* 修改 * 修改
......
package org.rcisoft.business.tquestion.service.impl; package org.rcisoft.business.tquestion.service.impl;
import org.apache.commons.collections.MapUtils;
import org.json.JSONArray;
import org.rcisoft.business.tquestion.entity.TQuestionOptions; import org.rcisoft.business.tquestion.entity.TQuestionOptions;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
...@@ -17,7 +19,11 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -17,7 +19,11 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
...@@ -39,9 +45,10 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -39,9 +45,10 @@ public class TQuestionServiceImpl implements TQuestionService {
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(TQuestion tQuestion){ public PersistModel save(TQuestion tQuestion, String[] questionOptions){
List<String> list = Arrays.asList(questionOptions);
Map map = MapUtils.putAll(new HashMap(), questionOptions);
TQuestionOptions tQuestionOptions = new TQuestionOptions(); TQuestionOptions tQuestionOptions = new TQuestionOptions();
tQuestion.setCommonBusinessId();
//增加操作 //增加操作
UserUtil.setCurrentPersistOperation(tQuestion); UserUtil.setCurrentPersistOperation(tQuestion);
int line = tQuestionRepository.insertSelective(tQuestion); int line = tQuestionRepository.insertSelective(tQuestion);
...@@ -57,17 +64,19 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -57,17 +64,19 @@ public class TQuestionServiceImpl implements TQuestionService {
/** /**
* 逻辑删除 * 逻辑删除
* @param tQuestion * @param id
* @return * @return
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel remove(TQuestion tQuestion){ public int remove(String id, String token){
TQuestion tQuestion = new TQuestion();
tQuestion.setBusinessId(id);
UserUtil.setCurrentMergeOperation(tQuestion); UserUtil.setCurrentMergeOperation(tQuestion);
int line = tQuestionRepository.logicalDelete(tQuestion); int line = tQuestionRepository.logicalDelete(tQuestion);
log.info(UserUtil.getUserInfoProp(tQuestion.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+ log.info(UserUtil.getUserInfoProp(token,UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
tQuestion.getBusinessId()+"的信息"); tQuestion.getBusinessId()+"的信息");
return new PersistModel(line,MessageConstant.MESSAGE_ALERT_SUCCESS); return line;
} }
/** /**
......
...@@ -2,21 +2,19 @@ ...@@ -2,21 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.tquestion.dao.TQuestionRepository"> <mapper namespace="org.rcisoft.business.tquestion.dao.TQuestionRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.tquestion.entity.TQuestion"> <resultMap id="BaseResultMap" type="org.rcisoft.business.tquestion.entity.TQuestion">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/> <id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="sl_id" jdbcType="VARCHAR" property="slId"/> <result column="sl_id" jdbcType="VARCHAR" property="slId"/>
<result column="chap_id" jdbcType="VARCHAR" property="chapId"/> <result column="chap_id" jdbcType="VARCHAR" property="chapId"/>
<result column="qtype" jdbcType="VARCHAR" property="qtype"/> <result column="qtype" jdbcType="VARCHAR" property="qtype"/>
<result column="qtitle" jdbcType="VARCHAR" property="qtitle"/> <result column="qtitle" jdbcType="VARCHAR" property="qtitle"/>
<result column="qdesc" jdbcType="VARCHAR" property="qdesc"/> <result column="qdesc" jdbcType="VARCHAR" property="qdesc"/>
<result column="qanswer" jdbcType="VARCHAR" property="qanswer"/> <result column="qanswer" jdbcType="VARCHAR" property="qanswer"/>
<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"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/> <result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/> <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
</resultMap> </resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper> </mapper>
\ 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