Commit 9b88068b authored by luzhuang's avatar luzhuang

feat: 新增FeignConfig

parent d01b1e29
......@@ -1273,12 +1273,42 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
* 查询平台推荐
* @return
*/
@Select(" select * from b_lesson " +
" where 1=1 " +
" and del_flag != 1 " +
" and flag = 1 " +
" and is_push = 1 " +
" and corp_id = #{corpId} ")
@Select(" <script> select distinct bl.* " +
" ,su.name lecturerName " +
" ,suc.name createByName " +
" from b_lesson bl " +
" left join s_user su on su.business_id = bl.lecturer_id " +
// " and su.del_flag != 1 and su.flag = 1 " +
" and su.corp_id = #{curUser.corpId} "+
" left join s_user suc on suc.business_id = bl.create_by " +
// " and suc.del_flag != 1 and suc.flag = 1 " +
" and suc.corp_id = #{curUser.corpId} "+
" left join b_viewrange bv on bl.business_id = bv.lesson_id " +
" and bv.del_flag != 1 and bv.flag = 1 " +
" and bv.corp_id = #{curUser.corpId} "+
" left join b_viewrange_son bvs on bv.business_id = bvs.viewrange_id " +
// " left join b_course bc on bc.business_id = bl.course_id " +
" where bl.del_flag != 1 and bl.flag = 1 " +
" and bl.corp_id = #{curUser.corpId} "+
" and bl.release_state = 2 " +
" and ((bvs.type = 0 and bvs.target_id = #{curUser.userId}) " +
" or (bl.lecturer_id = #{curUser.userId}) " +
" <if test=\"departs != null and departs.size() > 0 \"> " +
" or (bvs.type = 1 and bvs.target_id in " +
" <foreach item='item' index='index' collection='departs' open='(' separator=',' close=')'> #{item} </foreach>)" +
" </if> " +
" or (bl.business_id not in (select lesson_id from b_viewrange where del_flag != 1 and flag = 1 AND lesson_id IS NOT NULL ))) " +
" and bl.person_number >= (select `value` from b_dictionary where type = 'ZXRS' and corp_id = #{curUser.corpId}) + 0 " + //ZXRS 在学人数
" order by CAST(bl.person_number AS UNSIGNED) desc,bl.release_date desc " +
"</script>")
@ResultMap(value = "BasePushResultMap")
List<BLesson> queryPush(String corpId);
......
......@@ -248,16 +248,18 @@ public class BLessonServiceImpl implements BLessonService {
@Override
public List<BLesson> queryPushByPagination(PageUtil pageUtil, CurUser curUser) {
List<BLesson> result = bLessonRepository.queryPush(curUser.getCorpId());
for (BLesson b : result){
String pushLable = bLessonRepository.getPushLable(b.getBusinessId());
if( StringUtils.isEmpty(pushLable)){
b.setLabelList(bLessonRepository.queryLabelByLessonId(b.getBusinessId()));
}else {
b.setLabelList(bLessonRepository.queryPushLabelByLessonId(pushLable,b.getBusinessId()));
}
List<String> ids = Arrays.asList(new String[]{curUser.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
}
List<BLesson> result = bLessonRepository.queryPersonMore(curUser, departs);
return addNew(result);
}
......
......@@ -70,6 +70,17 @@ public class BMessageController extends PaginationController<BMessage> {
bMessage);
}
@ApiOperation(value="修改共享 ", notes="修改")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping("/updateSycn")
public Result updateSycn(CurUser curUser,@Valid BMessage bMessage, BindingResult bindingResult) {
PersistModel data = bMessageServiceImpl.updateSycn(curUser,bMessage);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bMessage);
}
@ApiOperation(value="查看 集合", notes="查看 集合")
@GetMapping(value = "/query")
......
......@@ -33,6 +33,13 @@ public interface BMessageService {
*/
PersistModel merge(CurUser curUser , BMessage bMessage);
/**
* 修改
* @param bMessage
* @return
*/
PersistModel updateSycn(CurUser curUser , BMessage bMessage);
/**
* 根据id查询
* @param id
......
......@@ -98,18 +98,30 @@ public class BMessageServiceImpl implements BMessageService {
@Override
public PersistModel merge(CurUser curUser , BMessage bMessage){
//判断是否修改课程共享状态
if(bMessage.getSort() == 8){
sendLog(curUser,bMessage);
//开启共享时同步课程
if("1".equals(bMessage.getTimeValue()))
sycnBPLesson(curUser);
}
UserUtil.setCurrentMergeOperation(bMessage);
int line = bMessageRepository.updateByPrimaryKeySelective(bMessage);
return new PersistModel(line);
}
/**
* 修改 bMessage
* @param bMessage
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel updateSycn(CurUser curUser , BMessage bMessage){
//保存课程日志
sendLog(curUser,bMessage);
//开启共享时同步课程
if("1".equals(bMessage.getTimeValue()))
sycnBPLesson(curUser);
UserUtil.setCurrentMergeOperation(bMessage);
int line = bMessageRepository.updateByPrimaryKeySelective(bMessage);
return new PersistModel(line);
}
/**
* 根据id查询 bMessage
* @param id
......
......@@ -79,16 +79,6 @@ public class MTUserInfoRspDTO {
private List<RolesBean> roles;
public String getIsHide() {
return isHide;
}
public void setIsHide(String isHide) {
this.isHide = isHide;
}
private String isHide;
public String getId() {
return id;
}
......
package org.rcisoft.config;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import feign.codec.Decoder;
import feign.codec.Encoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.ResponseEntityDecoder;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
/**
* 重写Feign序列化和反序列化的接口
* Feign 调用接收参数不需要 一一对应
*/
@Configuration
public class FeignConfig {
public ObjectMapper customObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
//Customize as much as you want
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}
/**
* 重写解码器
*
* @return Decoder
*/
@Bean
public Decoder feignDecoder() {
HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(customObjectMapper());
ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
return new ResponseEntityDecoder(new SpringDecoder(objectFactory));
}
/**
* 重写编码器
*
* @return Encoder
*/
@Bean
public Encoder feignEncoder() {
HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(customObjectMapper());
ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
return new SpringEncoder(objectFactory);
}
}
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