Commit 34993a86 authored by luzhuang's avatar luzhuang

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents 3c95d9d8 3da9006d
......@@ -416,6 +416,12 @@
<version>4.5.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/it.sauronsoftware/jave -->
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
......
package org.rcisoft.base;
/**
* 通用check异常
* 一般是由于数据出现问题, api调用方式不对导致
* 不需要为rest api调用方返回特定错误
* 只需要记录好日志即可
*/
public class BizCommonCheckException extends BizCommonException {
public BizCommonCheckException() {
}
public BizCommonCheckException(String message) {
super(message);
}
public BizCommonCheckException(String message, Throwable cause) {
super(message, cause);
}
}
package org.rcisoft.base;
/**
* 通用业务异常基类
*/
public class BizCommonException extends RuntimeException implements IBizException {
/**
* 展示给前端看的错误消息参数
*/
protected String[] restErrMsgArgs;
/**
* 错误详情对象, 包含各类错误对象
*/
protected transient ErrInfo errInfo;
public BizCommonException() {
super();
}
public BizCommonException(String message) {
super(message);
}
public BizCommonException(String message, Throwable cause) {
super(message, cause);
}
public BizCommonException setRestErrMsgArgs(String[] restErrMsgArgs) {
this.restErrMsgArgs = restErrMsgArgs;
return this;
}
public BizCommonException setErrInfo(ErrInfo errInfo) {
this.errInfo = errInfo;
return this;
}
public String[] getRestErrMsgArgs() {
return restErrMsgArgs;
}
public ErrInfo getErrInfo() {
return errInfo;
}
}
package org.rcisoft.base;
import org.apache.commons.collections4.CollectionUtils;
import java.util.List;
/**
* 所有错误消息编码
* 某一个异常可以对应一个错误编码
* 对应消息参考/config/i18n/messages*.properties
*/
public enum ErrCode {
///////////////////////////////////////////
/////////// 通用错误 ////////////////////
///////////////////////////////////////////
M0000("M0000"),//成功
M0001("M0001"),//不完全成功
M0005("M0005"),//无权限访问
///////////////////////////////////////////
/////////// 客户端错误 ///////////////////
///////////////////////////////////////////
M4000("M4000"),
M4001("M4001"),
///////////////////////////////////////////
/////////// 服务端错误 ///////////////////
///////////////////////////////////////////
M5000("M5000"),//服务器出现其他RuntimeException, 代码问题
M5001("M5001"),//service级别的Validation错误
M5002("M5002"),//抛出的继承了 IBizException 的异常, 但是没有对应的 errcode 做对应
M5004("M5004", ResultMoreThanOneException.class),//数据异常
;
////////////////////////////////////////////////////////////////
private String code; //错误编码
private Class<? extends IBizException> ex;
public static List<ErrCodeBean> customErrCodeList;
ErrCode(String code) {
this.code = code;
}
ErrCode(String code, Class<? extends IBizException> ex) {
this.code = code;
this.ex = ex;
}
/**
* 根据异常来获取当前ErrCode
*
* @param exception
* @return
*/
public static ErrCodeBean get(IBizException exception) {
Class<? extends IBizException> clazz = exception.getClass();
ErrCodeBean ret = null;
// 1. 先找 ErrCode 内部声明的错误信息
for (ErrCode ec : values()) {
if (ec.ex == clazz) {
ret = new ErrCodeBean(ec.getCode(), ec.ex);
break;
}
}
// 2. 找 customErrCodeList 中声明的错误, 这是每个微服务启动时注入进来的
if (ret == null && CollectionUtils.isNotEmpty(customErrCodeList)) {
for (ErrCodeBean customErrCode : customErrCodeList) {
if(customErrCode.getEx() == clazz){
ret = new ErrCodeBean(customErrCode.getCode(), customErrCode.getEx());
break;
}
}
}
//3. 如果最终没找到, 则用 M5002 代替
if (ret == null) {
ret = new ErrCodeBean(ErrCode.M5002.code, ErrCode.M5002.ex);
}
return ret;
}
public String getCode() {
return code;
}
}
package org.rcisoft.base;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ErrCodeBean {
private String code;
private Class<? extends IBizException> ex;
public ErrCodeBean(String code, Class<? extends IBizException> ex) {
this.code = code;
this.ex = ex;
}
}
package org.rcisoft.base;
import lombok.Getter;
import lombok.Setter;
/**
* @author David
*/
@Getter
@Setter
public class ErrInfo {
/**
* 发生错误时的对象
* 可以是一个String 如: id, 也可以是一个对象, 即一组参数
*/
protected Object errObj;
/**
* 造成错误的对象
* 如: 文件名已存在, 那么需要告诉用户是哪个文件id造成的重名
*/
protected Object causeErrObj;
public ErrInfo(Object errObj, Object causeErrObj) {
this.errObj = errObj;
this.causeErrObj = causeErrObj;
}
public ErrInfo setErrObj(Object errObj) {
this.errObj = errObj;
return this;
}
public ErrInfo setCauseErrObj(Object causeErrObj) {
this.causeErrObj = causeErrObj;
return this;
}
}
package org.rcisoft.base; /** * 所有自定义异常都实现这个接口 * 方便统一处理异常程序知道哪些是自定义业务异常 */public interface IBizException {}
\ No newline at end of file
package org.rcisoft.base;
/**
* 请求上下文
* 主要用来生成/获取请求id等信息
* <p>
* 访问controller时生成
* controller在return时候获取
* Created by yc on 2017/3/28.
*/
public class RequestContext {
private static ThreadLocal<RequestInfo> requestInfoTheadLocal = new ThreadLocal<>();
private RequestContext(){}
/**
* 生成并设置
*
* @return
*/
public static void setRequestInfo(RequestInfo requestInfo) {
if(requestInfo == null){
throw new BizCommonCheckException("requestInfo is null");
}
requestInfoTheadLocal.remove();
long requestId = 1;
requestInfo.setRequestId(requestId);
requestInfoTheadLocal.set(requestInfo);
}
/**
* 获取
*
* @return
*/
public static RequestInfo getRequestInfo() {
return requestInfoTheadLocal.get();
}
/**
* 清除
*/
public static void clear() {
requestInfoTheadLocal.remove();
}
}
package org.rcisoft.base;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@NoArgsConstructor
public class RequestInfo implements Serializable {
private static final long serialVersionUID = 1L;
private long requestId;
}
package org.rcisoft.base;
/**
* 返回信息
*
* @author David
*/
public class ResponseMessage<T> {
private String respCode;
private String respMsg;
private T data;
private boolean ok;
public ResponseMessage() {
}
public ResponseMessage(String respCode, String message) {
this.respCode = respCode;
this.respMsg = message;
this.ok = true;
}
public ResponseMessage(String respCode, String message, boolean ok) {
this.respCode = respCode;
this.respMsg = message;
this.ok = ok;
}
public ResponseMessage(String respCode, String message, boolean ok, T data) {
this.respCode = respCode;
this.respMsg = message;
this.ok = ok;
this.data = data;
}
public String getRespCode() {
return this.respCode;
}
public void setRespCode(String respCode) {
this.respCode = respCode;
}
public String getMessage() {
return this.respMsg;
}
public void setMessage(String message) {
this.respMsg = message;
}
public T getData() {
return this.data;
}
public void setData(T data) {
this.data = data;
}
public boolean isOk() {
return this.ok;
}
}
package org.rcisoft.base;
/**
* 返回状态
*
* @author David
*/
public enum ResponseMessageCodeEnum {
/**
* 成功
*/
SUCCESS("0"),
/**
* 失败
*/
ERROR("-1");
private String code;
ResponseMessageCodeEnum(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
}
package org.rcisoft.base;
/**
* 返回信息
*
* @author David
*/
public class Result {
private Result() {
}
public static ResponseMessage success() {
return new ResponseMessage(ResponseMessageCodeEnum.SUCCESS.getCode(), "", true);
}
public static <T> ResponseMessage<T> success(String code, T t) {
return new ResponseMessage(code, "", true, t);
}
public static <T> ResponseMessage<T> success(String code, String message) {
return new ResponseMessage(code, message);
}
public static <T> ResponseMessage<T> success(String code, String message, T t) {
return new ResponseMessage(code, message, true, t);
}
public static <T> ResponseMessage<T> success(T t) {
return new ResponseMessage(ResponseMessageCodeEnum.SUCCESS.getCode(), "", true, t);
}
public static ResponseMessage error() {
return error("");
}
public static ResponseMessage error(String message) {
return error(ResponseMessageCodeEnum.ERROR.getCode(), message);
}
public static ResponseMessage error(String code, String message) {
return error(code, message, (Object)null);
}
public static <T> ResponseMessage<T> error(String code, String message, T t) {
return new ResponseMessage(code, message, false, t);
}
}
package org.rcisoft.base;
/**
* 查询到的结果应该是一条, 实际多条
* 请查看表数据异常
*/
public class ResultMoreThanOneException extends BizCommonException {
public ResultMoreThanOneException() {
}
public ResultMoreThanOneException(String message) {
super(message);
}
public ResultMoreThanOneException(String message, Throwable cause) {
super(message, cause);
}
}
package org.rcisoft.base;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
@NoArgsConstructor
public class UserInfo implements Serializable {
private static final long serialVersionUID = 1L;
private String uid;
}
......@@ -41,6 +41,10 @@ public interface BCourseRepository extends BaseMapper<BCourse> {
@ResultMap(value = "BaseResultMapDTO")
List<QueryCourseResDTO> queryFirstLevel();
/**
* 查询所有分类存到List中
* @return
*/
@Select("select * from b_course where del_flag != '1' and flag ='1'")
@ResultMap(value = "AllCourseResultMap")
List<AllCourseDTO> findAllCourse();
......
......@@ -2,6 +2,7 @@ package org.rcisoft.business.bdiscuss.controller;
/*固定导入*/
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
......@@ -28,6 +29,7 @@ import java.util.List;
/**
* Created by on 2019-9-25 9:03:09.
*/
@Api(tags = "8 章节")
@RestController
@RequestMapping("bdiscuss")
public class BDiscussController extends PaginationController<BDiscuss> {
......
......@@ -10,6 +10,7 @@ import org.rcisoft.business.bcourse.service.BCourseService;
import org.rcisoft.business.blesson.dto.AddLessonDTO;
import org.rcisoft.business.blesson.dto.FindAllLessonDTO;
import org.rcisoft.business.blesson.dto.FirstPageQueryDTO;
import org.rcisoft.business.blesson.dto.LessonTrainDTO;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.common.component.Global;
......@@ -112,11 +113,7 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiOperation(value="606 分页查询大家都在学", notes="分页查询大家都在学")
@GetMapping(value = "/queryPersonMoreByPagination")
public Result queryPersonMoreByPagination(CurUser curUser,@Valid FirstPageQueryDTO firstPageQueryDTO, BindingResult bindingResult) {
List<AllCourseDTO> allCourse = null;
if (StringUtils.isNotEmpty(firstPageQueryDTO.getCourseLevelOne())){
allCourse = bCourseService.findAllCourse();
}
bLessonService.queryPersonMoreByPagination(getPaginationUtility(),firstPageQueryDTO,allCourse);
bLessonService.queryPersonMoreByPagination(getPaginationUtility());
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -127,12 +124,8 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiOperation(value="607 分页查询推荐", notes="分页查询推荐")
@GetMapping(value = "/queryRecommendByPagination")
public Result queryRecommendByPagination(CurUser curUser,@Valid FirstPageQueryDTO firstPageQueryDTO, BindingResult bindingResult) {
List<AllCourseDTO> allCourse = null;
if (StringUtils.isNotEmpty(firstPageQueryDTO.getCourseLevelOne())){
allCourse = bCourseService.findAllCourse();
}
String userId = curUser.getUserId();
bLessonService.queryRecommendByPagination(getPaginationUtility(),userId, firstPageQueryDTO,allCourse);
bLessonService.queryRecommendByPagination(getPaginationUtility(),userId);
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -142,12 +135,8 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiOperation(value="608 分页查询最受关注", notes="分页查询最受关注")
@GetMapping(value = "/queryConcernByPagination")
public Result queryConcernByPagination(CurUser curUser,@Valid FirstPageQueryDTO firstPageQueryDTO, BindingResult bindingResult) {
List<AllCourseDTO> allCourse = null;
if (StringUtils.isNotEmpty(firstPageQueryDTO.getCourseLevelOne())){
allCourse = bCourseService.findAllCourse();
}
bLessonService.queryConcernByPagination(getPaginationUtility(), firstPageQueryDTO,allCourse);
public Result queryConcernByPagination(CurUser curUser) {
bLessonService.queryConcernByPagination(getPaginationUtility());
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -158,12 +147,46 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiOperation(value="609 分页查询可能感兴趣", notes="分页查询可能感兴趣")
@GetMapping(value = "/queryInterestedByPagination")
public Result queryInterestedByPagination(CurUser curUser, @Valid FirstPageQueryDTO firstPageQueryDTO, BindingResult bindingResult) {
public Result queryInterestedByPagination(CurUser curUser) {
bLessonService.queryInterestedByPagination(getPaginationUtility());
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
gridModel);
}
@ApiOperation(value="610 首页分页查询全部课程", notes="根据条件分页查询全部课程")
@GetMapping(value = "/queryHomeBLessonsByPagination")
public Result queryHomeBLessonsByPagination(CurUser curUser, @Valid FirstPageQueryDTO firstPageQueryDTO, BindingResult bindingResult) {
List<AllCourseDTO> allCourse = null;
if (StringUtils.isNotEmpty(firstPageQueryDTO.getCourseLevelOne())){
allCourse = bCourseService.findAllCourse();
}
bLessonService.queryInterestedByPagination(getPaginationUtility(), firstPageQueryDTO,allCourse);
bLessonService.queryHomeBLessonsByPagination(getPaginationUtility(),firstPageQueryDTO,allCourse);
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
gridModel);
}
@ApiOperation(value="611 关闭课程", notes="根据ID关闭一个课程")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
@PostMapping(value = "/close")
public Result close(CurUser curUser,String businessId,BindingResult bindingResult) {
PersistModel data = bLessonService.closeBLesson(businessId);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
}
@ApiOperation(value="612 课程培训条件查询", notes="课程培训条件查询(工作台)")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
@PostMapping(value = "/findLessonTrain")
public Result findLessonTrain(CurUser curUser, @Valid LessonTrainDTO lessonTrainDTO, BindingResult bindingResult) {
bLessonService.findLessonTrain(getPaginationUtility(),lessonTrainDTO);
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......
......@@ -70,11 +70,24 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
@Delete("<script>delete from b_lesson_label where lesson_id = #{businessId}</script>")
int removeLabelByLessonId(BLesson model);
@Select("<script>select * from b_lesson " +
"" +
"where del_flag != 1 and flag = 1 and lecturer_id = #{lecturerId}" +
"<if test=\"param.releaseState!=null and param.releaseState != ''\">and release_state = #{param.releaseState} </if>" +
"order by update_date desc</script>")
/**
* 单一查询课程信息
* @param businessId
* @return
*/
@Select(" <script> select bl.* " +
" ,su.name lecturerName " +
" ,suc.name createByName " +
" ,bc.c_name courseName " +
" from b_lesson bl " +
" left join s_user su on su.business_id = bl.lecturer_id " +
" left join s_user suc on suc.business_id = bl.create_by " +
" left join b_course bc on bc.business_id = bl.course_type " +
" where bl.del_flag != 1 and bl.flag = 1 " +
" and su.del_flag != 1 and su.flag = 1 " +
" and suc.del_flag != 1 and suc.flag = 1 " +
" and bl.business_id = #{businessId} " +
"</script>")
@ResultMap(value = "BaseResultMap")
BLesson selectInfoById(String businessId);
......@@ -91,7 +104,6 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" from b_lesson bl " +
" left join s_user su on su.business_id = bl.lecturer_id " +
" left join s_user suc on suc.business_id = bl.create_by " +
// " left join b_course bc on bc.business_id = bl.course_type " +
" where bl.del_flag != 1 and bl.flag = 1 " +
" and su.del_flag != 1 and su.flag = 1 " +
" and suc.del_flag != 1 and suc.flag = 1 " +
......@@ -125,15 +137,10 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" and su.del_flag != 1 and su.flag = 1 " +
" and suc.del_flag != 1 and suc.flag = 1 " +
" and bl.release_state = 2 " +
" <if test= \" param.viewParam !=null and param.viewParam != ''\">and (bl.lesson_name like CONCAT('%',#{param.viewParam},'%') " +
" or su.name like CONCAT('%',#{param.viewParam},'%'))</if> " +
" <if test= \" courseIds !=null and courseIds.size() > 0 \">and course_type in " +
" <foreach item='item' index='index' collection='courseIds' open='(' separator=',' close=')'> #{item} </foreach> " +
" </if> " +
" order by bl.person_number desc " +
"</script>")
@ResultMap(value = "BaseResultMap")
List<BLesson> queryPersonMore(@Param("param") FirstPageQueryDTO firstPageQueryDTO,@Param("courseIds") List<String> sonCourseIds);
List<BLesson> queryPersonMore();
/**
* 按学习人数降序查询推荐
......@@ -147,20 +154,15 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" left join b_lesson bl on br.lesson_id = bl.business_id " +
" left join s_user su on su.business_id = bl.lecturer_id " +
" left join s_user suc on suc.business_id = bl.create_by " +
// " left join b_course bc on bc.business_id = bl.course_type " +
" where bl.del_flag != 1 and bl.flag = 1 " +
" and su.del_flag != 1 and su.flag = 1 " +
" and suc.del_flag != 1 and suc.flag = 1 " +
" and bl.release_state = 2 " +
" and br.person_id = #{userId} " +
" <if test= \" param.viewParam !=null and param.viewParam != ''\">and (bl.lesson_name like CONCAT('%',#{param.viewParam},'%') " +
" or su.name like CONCAT('%',#{param.viewParam},'%'))</if> " +
" <if test= \" courseIds !=null and courseIds.size() > 0 \">and course_type in " +
" <foreach item='item' index='index' collection='courseIds' open='(' separator=',' close=')'> #{item} </foreach> " +
" </if> " +
" order by bl.person_number desc " +
"</script>")
@ResultMap(value = "BaseResultMap")
List<BLesson> queryRecommend(@Param("userId") String userId, @Param("param") FirstPageQueryDTO param,@Param("courseIds") List<String> sonCourseIds);
List<BLesson> queryRecommend(String userId);
/**
* 按学习人数降序查询
......@@ -178,15 +180,10 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" and su.del_flag != 1 and su.flag = 1 " +
" and suc.del_flag != 1 and suc.flag = 1 " +
" and bl.release_state = 2 " +
" <if test= \" param.viewParam !=null and param.viewParam != ''\">and (bl.lesson_name like CONCAT('%',#{param.viewParam},'%') " +
" or su.name like CONCAT('%',#{param.viewParam},'%'))</if> " +
" <if test= \" courseIds !=null and courseIds.size() > 0 \">and course_type in " +
" <foreach item='item' index='index' collection='courseIds' open='(' separator=',' close=')'> #{item} </foreach> " +
" </if> " +
" order by bl.collect_number desc " +
"</script>")
@ResultMap(value = "BaseResultMap")
List<BLesson> queryConcern(@Param("param") FirstPageQueryDTO firstPageQueryDTO,@Param("courseIds") List<String> sonCourseIds);
List<BLesson> queryConcern();
@Select(" <script> select bl.* " +
" ,su.name lecturerName " +
......@@ -199,15 +196,10 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" and su.del_flag != 1 and su.flag = 1 " +
" and suc.del_flag != 1 and suc.flag = 1 " +
" and bl.release_state = 2 " +
" <if test= \" param.viewParam !=null and param.viewParam != ''\">and (bl.lesson_name like CONCAT('%',#{param.viewParam},'%') " +
" or su.name like CONCAT('%',#{param.viewParam},'%'))</if> " +
" <if test= \" courseIds !=null and courseIds.size() > 0 \">and course_type in " +
" <foreach item='item' index='index' collection='courseIds' open='(' separator=',' close=')'> #{item} </foreach> " +
" </if> " +
" order by bl.hot_number desc " +
"</script>")
@ResultMap(value = "BaseResultMap")
List<BLesson> queryInterested(@Param("param") FirstPageQueryDTO firstPageQueryDTO,@Param("courseIds") List<String> sonCourseIds);
List<BLesson> queryInterested();
//查询课程中的标签
@Select(" <script> select blb.business_id businessId,blb.l_name lName" +
......@@ -219,5 +211,43 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" and bls.business_id = #{lessonId} " +
"</script>")
List<QueryLabelResDTO> queryLabelByLessonId(String lessonId);
@Select(" <script> select bl.* " +
" ,su.name lecturerName " +
" ,suc.name createByName " +
" from b_lesson bl " +
" left join s_user su on su.business_id = bl.lecturer_id " +
" left join s_user suc on suc.business_id = bl.create_by " +
// " left join b_course bc on bc.business_id = bl.course_type " +
" where bl.del_flag != 1 and bl.flag = 1 " +
" and su.del_flag != 1 and su.flag = 1 " +
" and suc.del_flag != 1 and suc.flag = 1 " +
" and bl.release_state = 2 " +
" <if test= \" param.viewParam !=null and param.viewParam != ''\">and (bl.lesson_name like CONCAT('%',#{param.viewParam},'%') " +
" or su.name like CONCAT('%',#{param.viewParam},'%'))</if> " +
" <if test= \" courseIds !=null and courseIds.size() > 0 \">and course_type in " +
" <foreach item='item' index='index' collection='courseIds' open='(' separator=',' close=')'> #{item} </foreach> " +
" </if> " +
" order by bl.person_number desc " +
"</script>")
@ResultMap(value = "BaseResultMap")
List<BLesson> queryHomeBLesson(@Param("param") FirstPageQueryDTO firstPageQueryDTO,@Param("courseIds") List<String> sonCourseIds);
/**
* 根据课程id关闭课程
* @param model
* @return
*/
@Update({"<script>",
"update b_lesson",
" <set>",
" <if test='updateBy != null'>update_by=#{updateBy},</if>",
" <if test='updateDate != null'>update_date=#{updateDate},</if>",
" release_state = '4'",
" </set>",
"where business_id=#{businessId}",
"</script>"})
int closeLesson(BLesson model);
}
......@@ -13,20 +13,19 @@ public class AddLessonDTO {
@ApiModelProperty(value = "课程id")
private String businessId;
@NotBlank
@Length(min = 1,max = 64,message = "长度最小为1,最大为50")
@ApiModelProperty(value = "课程编号")
private String code;
@NotBlank
@ApiModelProperty(value = "课程名称")
@ApiModelProperty(value = "课程名称",required = true)
@Length(min = 1,max = 200,message = "长度最小为1,最大为150")
private String lessonName;
@ApiModelProperty(value = "默认封面图片url")
private String defaultUrl;
@ApiModelProperty(value = "课程分类")
@ApiModelProperty(value = "课程分类",required = true)
@NotBlank
@Length(min = 1,max = 64,message = "长度最小为1,最大为50")
private String courseType;
......@@ -41,7 +40,7 @@ public class AddLessonDTO {
private String viewRange;
@ApiModelProperty(value = "课程类型(0:课程 1:培训)")
@ApiModelProperty(value = "课程类型(0:课程 1:培训)",required = true)
@NotBlank
@Length(min = 1,max = 64,message = "长度最小为1,最大为50")
private String lessonType;
......
package org.rcisoft.business.blesson.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.persistence.Transient;
@Data
public class LessonTrainDTO {
@ApiModelProperty(value = "课程名称",required = false)
@Length(min = 1,max = 200,message = "长度最小为1,最大为150")
private String lessonName;
@ApiModelProperty(value = "发布状态(0:待发布 1:审核中 2:已发布 3:已驳回 4:已关闭)")
@Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String releaseState;
@ApiModelProperty(value = "创建人姓名")
@Transient
private String createByName;
@ApiModelProperty(value = "课程类型(0:课程 1:培训)")
@Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String lessonType;
}
......@@ -75,7 +75,7 @@ public class BLesson extends IdEntity<BLesson> {
private Date releaseDate;
@ApiModelProperty(value = "课程类型(0:课程 1:培训)")
@Length(min = 1,max = 64,message = "长度最小为1,最大为50")
@Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String lessonType;
@ApiModelProperty(value = "评论数")
......@@ -106,11 +106,7 @@ public class BLesson extends IdEntity<BLesson> {
@Transient
private String lecturerName;
@ApiModelProperty(value = "是否学完")
@Transient
private String isLearnOver;
@ApiModelProperty(value = "标签集合")
@ApiModelProperty(value = "接收标签集合 用‘,’分隔")
@Transient
private String labels;
......@@ -118,8 +114,12 @@ public class BLesson extends IdEntity<BLesson> {
@Transient
private String createByName;
@ApiModelProperty(value = "标签集合")
@ApiModelProperty(value = "返回标签集合")
@Transient
private List<QueryLabelResDTO> labelList;
@ApiModelProperty(value = "分类名")
@Transient
private String courseName;
}
package org.rcisoft.business.blesson.service;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bcourse.dto.AllCourseDTO;
import org.rcisoft.business.blesson.dto.AddLessonDTO;
import org.rcisoft.business.blesson.dto.BLessonIPublishDTO;
import org.rcisoft.business.blesson.dto.FindAllLessonDTO;
import org.rcisoft.business.blesson.dto.FirstPageQueryDTO;
import org.rcisoft.business.blesson.dto.*;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import java.io.IOException;
import java.util.List;
/**
......@@ -56,7 +50,7 @@ public interface BLessonService{
* @param
* @return
*/
List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse);
List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil);
/**
* 分页查找推荐
......@@ -64,7 +58,7 @@ public interface BLessonService{
* @param
* @return
*/
List<BLesson> queryRecommendByPagination(PageUtil pageUtil,String userId,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse);
List<BLesson> queryRecommendByPagination(PageUtil pageUtil,String userId);
/**
* 分页查找最受关注
......@@ -72,7 +66,7 @@ public interface BLessonService{
* @param
* @return
*/
List<BLesson> queryConcernByPagination(PageUtil pageUtil,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse);
List<BLesson> queryConcernByPagination(PageUtil pageUtil);
/**
* 分页查找可能感兴趣的
......@@ -80,7 +74,7 @@ public interface BLessonService{
* @param
* @return
*/
List<BLesson> queryInterestedByPagination(PageUtil pageUtil,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse);
List<BLesson> queryInterestedByPagination(PageUtil pageUtil);
/**
* 插入
......@@ -90,16 +84,31 @@ public interface BLessonService{
PersistModel persist(AddLessonDTO model);
/**
* 课程信息excel导入
* @param hwb
* 逻辑删除
* @param id
* @return
*/
PersistModel importExcel(HSSFWorkbook hwb) throws IOException;
PersistModel removeBLesson(String id);
/**
* 逻辑删除
* 首页条件查询全部课程
* @return
*/
List<BLesson> queryHomeBLessonsByPagination(PageUtil pageUtil, FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse);
/**
* 关闭课程
* @param id
* @return
*/
PersistModel removeBLesson(String id);
PersistModel closeBLesson(String id);
/**
* 课程培训条件查询
* @param pageUtil
* @param lessonTrainDTO
* @return
*/
List<BLesson> findLessonTrain(PageUtil pageUtil, LessonTrainDTO lessonTrainDTO);
}
......@@ -7,10 +7,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.rcisoft.business.bcourse.dao.BCourseRepository;
import org.rcisoft.business.bcourse.dto.AllCourseDTO;
import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.dto.AddLessonDTO;
import org.rcisoft.business.blesson.dto.BLessonIPublishDTO;
import org.rcisoft.business.blesson.dto.FindAllLessonDTO;
import org.rcisoft.business.blesson.dto.FirstPageQueryDTO;
import org.rcisoft.business.blesson.dto.*;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.business.blesson.entity.BLessonLabel;
......@@ -18,10 +15,7 @@ import org.rcisoft.business.blesson.util.recursion;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.ExcelUtil;
import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,7 +23,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -80,38 +73,21 @@ public class BLessonServiceImpl implements BLessonService {
}
@Override
public List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse) {
List<String> sonCourseIds = null;
if (allCourse != null){
sonCourseIds = recursion.FindSons(firstPageQueryDTO.getCourseLevelOne(),allCourse);
}
return bLessonRepository.queryPersonMore(firstPageQueryDTO,sonCourseIds);
public List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil) {
return bLessonRepository.queryPersonMore();
}
@Override
public List<BLesson> queryRecommendByPagination(PageUtil pageUtil,String userId,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse) {
List<String> sonCourseIds = null;
if (allCourse != null){
sonCourseIds = recursion.FindSons(firstPageQueryDTO.getCourseLevelOne(),allCourse);
}
return bLessonRepository.queryRecommend(userId,firstPageQueryDTO,sonCourseIds);
public List<BLesson> queryRecommendByPagination(PageUtil pageUtil,String userId) {
return bLessonRepository.queryRecommend(userId);
}
@Override
public List<BLesson> queryConcernByPagination(PageUtil pageUtil,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse) {
List<String> sonCourseIds = null;
if (allCourse != null){
sonCourseIds = recursion.FindSons(firstPageQueryDTO.getCourseLevelOne(),allCourse);
}
return bLessonRepository.queryConcern(firstPageQueryDTO,sonCourseIds);
public List<BLesson> queryConcernByPagination(PageUtil pageUtil) {
return bLessonRepository.queryConcern();
}
@Override
public List<BLesson> queryInterestedByPagination(PageUtil pageUtil,FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse) {
List<String> sonCourseIds = null;
if (allCourse != null){
sonCourseIds = recursion.FindSons(firstPageQueryDTO.getCourseLevelOne(),allCourse);
}
return bLessonRepository.queryInterested(firstPageQueryDTO,sonCourseIds);
public List<BLesson> queryInterestedByPagination(PageUtil pageUtil) {
return bLessonRepository.queryInterested();
}
......@@ -176,118 +152,6 @@ public class BLessonServiceImpl implements BLessonService {
}
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public PersistModel importExcel(HSSFWorkbook hwb) throws IOException {
ArrayList<BLesson> lessons = new ArrayList<BLesson>();
ArrayList<String> repeatCode = new ArrayList<String>();
List<String> errorCode = new ArrayList<>();
ArrayList<String> direction = new ArrayList<String>();
List<String> isChinese = new ArrayList<>();
List<String> isNegative = new ArrayList<>();
List<String> currentlyCode = new ArrayList<>();
String innerRepeatResult = "";
String[] headers = {"课程编号","课程名称","课程方向编号","学时","学分"};
ArrayList<String[]> values = ExcelUtil.importExcel(hwb,headers,false,1); //获取excel数据
if (values.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
}
// for(String[] value:values){ //将数据封装到entity
// BLesson bLesson = null;
// String classCode = value[0];
//
// //判断编号是否含有中文
// if(TestChinese.isChinese(classCode)){
// isChinese.add(value[0]);
// continue;
// };
//
// //判断1:班级编号是否满足<15位;
// if(classCode.length()>15){
// //该用户不满足要求,记入valuesShort中
// errorCode.add(value[0]);
// continue;
// }
//
// if(Integer.parseInt(value[4])<0||Integer.parseInt(value[3])<0){
// //该用户不满足要求,记入valuesShort中
// isNegative.add(value[0]);
// continue;
// }
// if((bLesson=bLessonRepository.queryBLessonByCode(value[0]))!=null) {
// repeatCode.add(value[0]);
// continue;
// }
// BDirection b_direction = bDirectionRepository.selectOne(new BDirection(value[2]));
// if (b_direction == null) {
// if (!direction.contains(value[2]))
// direction.add(value[2]);
// continue;
// }
// bLesson= new BLesson(value[0],value[1],value[3],value[4]);
// bLesson.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION());
// UserUtil.setCurrentPersistOperation(bLesson);
// //表中去重
// if(currentlyCode.contains(bLesson.getCode())){
// innerRepeatResult += "编号 " + value[1] + " 在Excel中重复出现,除第一条以外的数据插入失败 \n";
// continue;
// }
// if(!lessons.contains(bLesson)){
// currentlyCode.add(bLesson.getCode());
// lessons.add(bLesson);
//
// BLessonDirection bDirection = new BLessonDirection();
// bDirection.setDirectionId(b_direction.getBusinessId());
// bDirection.setBusinessId(IdGen.uuid());
// bDirection.setLessionId(bLesson.getBusinessId());
// bDirectionRepository.insertBLessonDirection(bDirection);
// }
// }
String result ="";
if(lessons.size()>0){
int line = bLessonRepository.insertList(lessons);
if (line>0) {
result+="成功导入"+lessons.size()+"门课程。";
}else{
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DB_INSERT_ERROR);
}
}
if(isNegative.size()>0){
result+="以下课程的学时或学分不能为负数:"+ JSON.toJSONString(isNegative)+"。";
}
if(isChinese.size()>0){
result+="以下编号格式不正确:"+ JSON.toJSONString(isChinese)+"。";
}
if(repeatCode.size()>0){
result+="以下课程编号存在重复:"+ JSON.toJSONString(repeatCode)+"。";
}
if(errorCode.size()>0){
result+="以下课程编号超过15位:"+ JSON.toJSONString(errorCode)+"。";
}
if(direction.size()>0){
result+="以下课程方向编号不存在:"+ JSON.toJSONString(direction)+"。";
}
if (lessons.size()<1){
throw new ServiceException(ResultServiceEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),result);
}
return new PersistModel(1,result + innerRepeatResult);
}
public PersistModel importPic(HSSFWorkbook hwb) throws IOException
{
return null;
}
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public PersistModel removeBLesson(String id) {
......@@ -307,6 +171,30 @@ public class BLessonServiceImpl implements BLessonService {
}
@Override
public List<BLesson> queryHomeBLessonsByPagination(PageUtil pageUtil, FirstPageQueryDTO firstPageQueryDTO,List<AllCourseDTO> allCourse) {
List<String> sonCourseIds = null;
if (allCourse != null){
sonCourseIds = recursion.FindSons(firstPageQueryDTO.getCourseLevelOne(),allCourse);
}
return bLessonRepository.queryHomeBLesson(firstPageQueryDTO,sonCourseIds);
}
@Override
public PersistModel closeBLesson(String id) {
BLesson bLesson = new BLesson();
bLesson.setBusinessId(id);
UserUtil.setCurrentMergeOperation(bLesson);
int line = bLessonRepository.closeLesson(bLesson);
//int line = bLessonRepository.deleteByPrimaryKey(id);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
@Override
public List<BLesson> findLessonTrain(PageUtil pageUtil, LessonTrainDTO lessonTrainDTO) {
return null;
}
private Map<String,Object> queryParamHandler(BLesson model){
Map param = new HashMap<String, Object>();
if(model.getLessonName()!=null)
......
package org.rcisoft.business.blessonperson.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
......@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
@Api(tags = "9 学生-课程")
@RestController
@RequestMapping("/BLessonPerson")
@Slf4j
......@@ -32,7 +34,7 @@ public class BLessonPersonController extends PaginationController<BLesson> {
@Autowired
private BLessonPersonService bLessonPersonService;
@ApiOperation(value="退出课程", notes="根据ID停用一条记录")
@ApiOperation(value="901 退出课程", notes="根据ID停用一条记录")
@ApiImplicitParam(name = "businessId", value = "退出课程的选课id", required = true, dataType = "varchar")
@PostMapping(value = "/quit")
public Result remove(CurUser curUser, String businessId, BindingResult bindingResult) {
......@@ -43,7 +45,7 @@ public class BLessonPersonController extends PaginationController<BLesson> {
businessId);
}
@ApiOperation(value="分页查询我学习", notes="分页查询我学习")
@ApiOperation(value="902 分页查询我学习", notes="分页查询我学习")
@GetMapping(value = "/queryLearnBLessonsByPagination")
public Result queryLearnBLessonsByPagination(CurUser curUser, @Valid ILearnLessonDTO param, BindingResult bindingResult) {
String userId = curUser.getUserId();
......
......@@ -25,7 +25,8 @@ public interface BLessonPersonRepository extends BaseMapper<BLabel> {
" where blp.del_flag != 1 and blp.flag = 1 " +
" and bl.del_flag != 1 and bl.flag = 1 " +
" and su.del_flag != 1 and su.flag = 1 " +
" and bl.release_state = '2' and blp.person_id = #{userId} " +
// " and bl.release_state = '2' " +
" and blp.person_id = #{userId} " +
" <if test= \" param.isFinish != null and param.isFinish != ''\">and blp.is_finish = #{param.isFinish} </if> " +
" <if test= \" param.lessonType !=null and param.lessonType != ''\">and bl.lesson_type = #{param.lessonType} </if> " +
" order by blp.update_date desc</script>")
......
......@@ -2,6 +2,7 @@ package org.rcisoft.business.brstudentchapter.controller;
/*固定导入*/
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
......@@ -28,6 +29,7 @@ import java.util.List;
/**
* Created by on 2019-9-25 10:01:43.
*/
@Api("10 章节")
@RestController
@RequestMapping("brstudentchapter")
public class BRStudentChapterController extends PaginationController<BRStudentChapter> {
......@@ -36,7 +38,7 @@ public class BRStudentChapterController extends PaginationController<BRStudentCh
private BRStudentChapterService bRStudentChapterServiceImpl;
@ApiOperation(value="添加/更新", notes="添加/更新")
@ApiOperation(value="1001 添加/更新学生端观看章节进度", notes="添加/更新")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/add")
public Result addOrUpdate(@Valid BRStudentChapterDto brStudentChapterDto, BindingResult bindingResult) {
......
package org.rcisoft.common.util.feignClient;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignDto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
......
package org.rcisoft.common.util.feignClient;
import feign.Headers;
import org.rcisoft.common.util.feignDto.DimCodeReqDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* 设备库客户端
*/
@FeignClient(value = "SF-EUQIPMENT")
public interface EuqipmentFeignClient {
@RequestMapping(value = "/api/equipment/v1/dictionary/getDictionaryBySearch",method = RequestMethod.POST)
@Headers({"clientType: app"})
ResponseEntity<String> getDictionaryBySearch(@RequestBody DimCodeReqDTO dimCodeReqDTO,
@RequestParam("dictionaryCode") String dictionaryCode,
@RequestHeader("corpId") String corpId,
@RequestParam("zxClientType") String zxClientType,
@RequestParam("zxAccountId") Long zxAccountId);
@RequestMapping(value = "/api/equipment/v1//data/getEquipment/{equipmentCodeOrName}",method = RequestMethod.GET)
ResponseEntity<String> getEquipment(@PathVariable("equipmentCodeOrName") String equipmentCodeOrName,
@RequestParam("dimCode") String dimCode,
@RequestHeader("corpId") String corpId,
@RequestParam("zxClientType") String zxClientType,
@RequestParam("zxAccountId") Long zxAccountId);
}
package org.rcisoft.common.util.feignClient;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignDto.MTOssRspDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
......
package org.rcisoft.common.util.feignClient;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignDto.RefreshDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
......
package org.rcisoft.common.util.feignClient;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignDto.GroupAddPersonRDTO;
import org.rcisoft.common.util.feignDto.GroupCreateRDTO;
import org.rcisoft.common.util.feignDto.GroupDismissRDTO;
......
package org.rcisoft.common.util.feignClient;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignDto.MTNotificationSendReqDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
......
......@@ -3,12 +3,12 @@ package org.rcisoft.common.util.outClient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.base.Ret;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.common.util.OkHttpUtil;
import org.rcisoft.common.util.feignClient.ContactFeignClient;
import org.rcisoft.common.util.feignClient.GateWayFeignClient;
import org.rcisoft.common.util.OkHttpUtil;
import org.rcisoft.common.util.feignDto.*;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.core.result.Ret;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......
package org.rcisoft.common.util.outClient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.common.util.feignClient.EuqipmentFeignClient;
import org.rcisoft.common.util.feignDto.DimCodeReqDTO;
import org.rcisoft.common.util.feignDto.DimCodeRspDTO;
import org.rcisoft.common.util.feignDto.MTEquipmentInfoDTO;
import org.rcisoft.common.util.feignDto.MTEquipmentInfoRspDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 设备接口
* @author David
*/
@Slf4j
@Component
public class MTEquipmentApiRequestClient {
// @Autowired
private EuqipmentFeignClient euqipmentFeignClient;
public static String zxClientType = "app";
public static Long zxAccountId = (long)1;
/**
* 模糊搜索列表
* @return
*/
public List<MTEquipmentInfoDTO> getEquipment(String equipmentCodeOrName, String dimCode, String corpId) {
ResponseEntity<String> obj = euqipmentFeignClient.getEquipment(equipmentCodeOrName,dimCode,corpId,zxClientType,zxAccountId);
MTEquipmentInfoRspDTO mtEquipmentInfoRspDTO = JSON.parseObject(obj.getBody(), new TypeReference<MTEquipmentInfoRspDTO>() {});
return mtEquipmentInfoRspDTO.getData();
}
/**
* 查询所有的dimCode
* @param corpId
* @return
*/
public DimCodeRspDTO getDictionaryBySearch(String corpId) {
DimCodeReqDTO dimCodeReqDTO = DimCodeReqDTO.builder().name("").pageNum(1).pageSize(1000).build();
ResponseEntity<String> obj = euqipmentFeignClient.getDictionaryBySearch(dimCodeReqDTO,"dim",corpId,zxClientType,zxAccountId);
DimCodeRspDTO list = JSON.parseObject(obj.getBody(), new TypeReference<DimCodeRspDTO>() {});
return list;
}
}
package org.rcisoft.common.util.outClient;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignClient.MessageFeignClient;
import org.rcisoft.common.util.feignDto.GroupAddPersonRDTO;
import org.rcisoft.common.util.feignDto.GroupCreateRDTO;
......
......@@ -3,7 +3,8 @@ package org.rcisoft.common.util.outClient;
//import com.zgiot.zx.schedule.service.INotificationService;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.ResultCode;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignClient.NotificationFeignClient;
import org.rcisoft.common.util.feignDto.MTNotificationSendReqDTO;
import org.rcisoft.common.util.feignDto.MTUserGetsReqDTO;
......@@ -52,7 +53,7 @@ public class MTNotificationApiRequestClient {
mtNotificationSendReqDTO.setChannels("ALL");
mtNotificationSendReqDTO.setCategoryCodes(Arrays.asList(new String[]{type}));
Ret ret = notificationFeignClient.sendMessage(mtNotificationSendReqDTO,"app",(long)1);
if(ret != null && "M0000".equals(ret.getCode())){
if(ret != null && ResultCode.SUCCESS.getCode().toString().equals(ret.getCode())){
return true;
}
return false;
......
......@@ -4,7 +4,7 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.base.Ret;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.OkHttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......
......@@ -92,13 +92,13 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
handlerMethod.getBean().getClass().getName(),
handlerMethod.getMethod().getName(),
e.getMessage());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage(message);
result.setCode(ResultCode.ERROR).setMessage(message);
}
} else {
if (e instanceof NoHandlerFoundException) {
result.setCode(ResultCode.NOT_FOUND).setMessage("接口 [" + request.getRequestURI() + "] 不存在");
} else {
result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage(e.getMessage());
result.setCode(ResultCode.ERROR).setMessage(e.getMessage());
}
}
log.error(e.getMessage());
......
......@@ -33,13 +33,13 @@ public class Result {
public void setErrorMessage(String message, Object data) {
this.code = ResultCode.FAIL.code;
this.code = ResultCode.FAIL.getCode();
this.message = message;
this.data = data;
}
public void setSucessMessage(String message, Object data) {
this.code = ResultCode.SUCCESS.code;
this.code = ResultCode.SUCCESS.getCode();
this.message = message;
this.data = data;
}
......@@ -48,7 +48,7 @@ public class Result {
public Result setCode(ResultCode resultCode) {
this.code = resultCode.code;
this.code = resultCode.getCode();
return this;
}
......
package org.rcisoft.core.result;
import lombok.Data;
/**
* 响应码枚举,参考HTTP状态码的语义
*/
public enum ResultCode {
SUCCESS(200),//成功
FAIL(400),//失败
UNAUTHORIZED(401),//未认证(签名错误)
NOT_FOUND(404),//接口不存在
INTERNAL_SERVER_ERROR(500),//服务器内部错误
ERROR(500),//服务器内部错误
SERVICE_ERROR(999);//自定义异常
public int code;
private Integer code;
public Integer getCode() {
return code;
}
ResultCode(int code) {
this.code = code;
......
package org.rcisoft.base;
package org.rcisoft.core.result;
import com.google.common.base.MoreObjects;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.rcisoft.core.util.UserUtil;
import org.springframework.core.annotation.Order;
import java.io.Serializable;
......@@ -35,37 +36,30 @@ public class Ret<T> implements Serializable {
private T data;
public Ret() {
this.ctime = System.currentTimeMillis();
if (RequestContext.getRequestInfo() != null) {
this.requestID = String.valueOf(RequestContext.getRequestInfo().getRequestId());
}
this(null);
}
public Ret(String code) {
this.code = code;
this.ctime = System.currentTimeMillis();
if (RequestContext.getRequestInfo() != null) {
this.requestID = String.valueOf(RequestContext.getRequestInfo().getRequestId());
}
this(code, null);
}
public Ret(String code, String msg) {
this.code = code;
this.msg = msg;
this.ctime = System.currentTimeMillis();
if (RequestContext.getRequestInfo() != null) {
this.requestID = String.valueOf(RequestContext.getRequestInfo().getRequestId());
if (UserUtil.getCurUser() != null) {
this.requestID = String.valueOf(UserUtil.getCurUser().getRequireId());
}
}
//构建成功返回
public static Ret ok() {
return new Ret(ErrCode.M0000.getCode(), "ok");
return new Ret(ResultCode.SUCCESS.getCode().toString(), "ok");
}
//构建系统异常返回
public static Ret error() {
return new Ret(ErrCode.M5000.getCode(), "false");
return new Ret(ResultCode.ERROR.getCode().toString(), "false");
}
......
package org.rcisoft.core.util;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.base.BizCommonCheckException;
import org.rcisoft.base.UserInfo;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.common.util.feignDto.UserInfoDTO;
import org.rcisoft.core.entity.IdEntity;
......@@ -37,11 +35,13 @@ public class UserUtil {
* 设置登陆人
* @param obj
*/
public static void setCurUser(Object obj){
public static void setCurUser(CurUser obj){
Map<String,Object> user = null;
user = local.get();
if(null == user)
user = new HashMap<>();
//设置请求id
obj.setRequireId(IdGen.uuid());
user.put(UserUtil.USER_MODEL,obj);
local.set(user);
}
......
......@@ -23,4 +23,8 @@ public class CurUser {
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(required = false,value = "请求id,不需要传递")
private String requireId;
}
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