Commit 66aa6dd3 authored by nie'hong's avatar nie'hong

修改-学习内容中的展板参考资料可指定是否在app中显示

parent fec4da72
package cn.chnmuseum.party.common.util; package cn.chnmuseum.party.common.util;
import cn.hutool.core.net.NetUtil;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -145,4 +146,9 @@ public class AddressUtil { ...@@ -145,4 +146,9 @@ public class AddressUtil {
return map; return map;
} }
public static void main(String[] args) {
Map<String, String> addressByIp1 = getAddressByIp("192.168.207.244");
System.out.println(addressByIp1);
}
} }
\ No newline at end of file
package cn.chnmuseum.party.mapper;
import cn.chnmuseum.party.model.LearningContentAsset;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description:
* @author: nh
* @create: 2021-06-22 09:58
**/
public interface LearningContentAssetMapper extends BaseMapper<LearningContentAsset> {
}
...@@ -151,4 +151,8 @@ public class LearningContent implements Serializable { ...@@ -151,4 +151,8 @@ public class LearningContent implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private List<Audit> auditHistoryList; private List<Audit> auditHistoryList;
@ApiModelProperty("在app展示的学习资料")
@TableField(exist = false)
private List<String> fileList;
} }
package cn.chnmuseum.party.model;
import cn.chnmuseum.party.common.validator.groups.Update;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @description: 学习内容下的展板参考资料是否在app显示
* @author: nh
* @create: 2021-06-22 09:38
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@TableName("learning_content_asset")
@ApiModel(value = "学习内容展板参考资料是否展示", description = "学习内容展板参考资料是否展示")
public class LearningContentAsset implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("ID")
@TableId(value = "id", type = IdType.ASSIGN_ID)
@NotNull(message = "ID不能为空", groups = {Update.class})
private String id;
@ApiModelProperty("学习内容")
@TableField(value = "learning_content_id")
private String learningContentId;
@ApiModelProperty("展板")
@TableField(value = "board_id")
private String boardId;
@ApiModelProperty("参考资料")
@TableField(value = "asset_id")
private String assetId;
}
package cn.chnmuseum.party.service;
import cn.chnmuseum.party.model.LearningContentAsset;
import com.baomidou.mybatisplus.extension.service.IService;
public interface LearningContentAssetService extends IService<LearningContentAsset> {
}
package cn.chnmuseum.party.service.impl;
import cn.chnmuseum.party.mapper.LearningContentAssetMapper;
import cn.chnmuseum.party.model.LearningContentAsset;
import cn.chnmuseum.party.service.LearningContentAssetService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* @description:
* @author: nh
* @create: 2021-06-22 09:57
**/
@Service
public class LearningContentAssetServiceImpl extends ServiceImpl<LearningContentAssetMapper,LearningContentAsset> implements LearningContentAssetService {
}
package cn.chnmuseum.party.vo;
import io.swagger.annotations.ApiModel;
import lombok.*;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @description:
* @author: nh
* @create: 2021-06-22 11:08
**/
@ApiModel("学习内容展板中的参考资料")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class AssetVo implements Serializable {
private String id;
private String boardName;
private String fileName;
private String fileType;
}
...@@ -9,11 +9,16 @@ import cn.chnmuseum.party.common.util.TimeUtils; ...@@ -9,11 +9,16 @@ import cn.chnmuseum.party.common.util.TimeUtils;
import cn.chnmuseum.party.common.video.VideoEncryptUtil; import cn.chnmuseum.party.common.video.VideoEncryptUtil;
import cn.chnmuseum.party.common.vo.GenericPageParam; import cn.chnmuseum.party.common.vo.GenericPageParam;
import cn.chnmuseum.party.model.Asset; import cn.chnmuseum.party.model.Asset;
import cn.chnmuseum.party.model.ExhibitionBoard;
import cn.chnmuseum.party.model.TBoxOperation; import cn.chnmuseum.party.model.TBoxOperation;
import cn.chnmuseum.party.service.AssetService; import cn.chnmuseum.party.service.AssetService;
import cn.chnmuseum.party.service.ExhibitionBoardService;
import cn.chnmuseum.party.vo.AssetVo;
import cn.chnmuseum.party.web.controller.base.BaseController; import cn.chnmuseum.party.web.controller.base.BaseController;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -35,6 +40,7 @@ import java.io.InputStream; ...@@ -35,6 +40,7 @@ import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -56,6 +62,9 @@ public class AssetController extends BaseController { ...@@ -56,6 +62,9 @@ public class AssetController extends BaseController {
@Resource @Resource
private AssetService assetService; private AssetService assetService;
@Resource
private ExhibitionBoardService exhibitionBoardService;
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
...@@ -157,5 +166,27 @@ public class AssetController extends BaseController { ...@@ -157,5 +166,27 @@ public class AssetController extends BaseController {
ZipUtil.zip(response.getOutputStream(), map.keySet().toArray(new String[0]), map.values().toArray(new InputStream[0])); ZipUtil.zip(response.getOutputStream(), map.keySet().toArray(new String[0]), map.values().toArray(new InputStream[0]));
} }
@ApiOperation(value = "获取展板中的参考资料", notes = "后去展板中的参考资料")
@RequiresAuthentication
@GetMapping("/getAssetByBoard")
public Map<String, Object> getAssetByBoard(@RequestParam(value = "boardList", required = true) List<String> boardList){
LambdaQueryWrapper<Asset> assetLambdaQueryWrapper = Wrappers.<Asset>lambdaQuery();
assetLambdaQueryWrapper.in(Asset::getRefItemId, boardList);
List<Asset> list = this.assetService.list(assetLambdaQueryWrapper);
List<AssetVo> assetVos = new ArrayList<>();
for (Asset asset : list) {
ExhibitionBoard board = this.exhibitionBoardService.getById(asset.getRefItemId());
AssetVo assetVo = AssetVo.builder()
.id(asset.getId())
.fileName(asset.getFileName())
.fileType(asset.getFileExtName())
.boardName(board.getName())
.build();
assetVos.add(assetVo);
}
return getResult(assetVos);
}
} }
...@@ -32,6 +32,7 @@ import org.apache.shiro.authc.IncorrectCredentialsException; ...@@ -32,6 +32,7 @@ import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -99,6 +100,9 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -99,6 +100,9 @@ public class ChinaMobileRestApiController extends BaseController {
@Resource @Resource
private TAppRunPicService appRunPicService; private TAppRunPicService appRunPicService;
@Resource
private LearningContentAssetService learningContentAssetService;
private static final String SHIRO_JWT_TOKEN = "shiro:jwt:token:"; private static final String SHIRO_JWT_TOKEN = "shiro:jwt:token:";
//用户登录次数计数 redisKey 前缀 //用户登录次数计数 redisKey 前缀
private static final String SHIRO_LOGIN_COUNT = "shiro_login_count_"; private static final String SHIRO_LOGIN_COUNT = "shiro_login_count_";
...@@ -498,14 +502,15 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -498,14 +502,15 @@ public class ChinaMobileRestApiController extends BaseController {
final IPage<ExhibitionBoard> page = this.learningContentBoardService.getBoardPageByLearningContentId(page1, learningContentId, null); final IPage<ExhibitionBoard> page = this.learningContentBoardService.getBoardPageByLearningContentId(page1, learningContentId, null);
for (ExhibitionBoard exhibitionBoard : page.getRecords()) { for (ExhibitionBoard exhibitionBoard : page.getRecords()) {
exhibitionBoard.setLearningContentId(learningContentId); exhibitionBoard.setLearningContentId(learningContentId);
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setBoardCopyrightOwnerName(name);
}
if (exhibitionBoard.getExhibitionBoardCatId() != null) { if (exhibitionBoard.getExhibitionBoardCatId() != null) {
String name = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId()).getName(); String name = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId()).getName();
exhibitionBoard.setExhibitionBoardCatName(name); exhibitionBoard.setExhibitionBoardCatName(name);
} }
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setBoardCopyrightOwnerName(name);
}
LambdaQueryWrapper<Asset> assetQueryWrapper; LambdaQueryWrapper<Asset> assetQueryWrapper;
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId())) { if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId())) {
final VideoContent videoContent = this.videoContentService.getById(exhibitionBoard.getVideoContentId()); final VideoContent videoContent = this.videoContentService.getById(exhibitionBoard.getVideoContentId());
...@@ -513,32 +518,43 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -513,32 +518,43 @@ public class ChinaMobileRestApiController extends BaseController {
exhibitionBoard.setBoardVideoContentThumbnail(videoContent.getThumbnail()); exhibitionBoard.setBoardVideoContentThumbnail(videoContent.getThumbnail());
} }
assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getVideoContentId()); assetQueryWrapper = Wrappers.<Asset>lambdaQuery();
assetQueryWrapper.eq(Asset::getPublished, true); assetQueryWrapper.eq(Asset::getRefItemId, exhibitionBoard.getVideoContentId());
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name()); assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name());
assetQueryWrapper.eq(Asset::getPublished, true);
List<Asset> videoList = this.assetService.list(assetQueryWrapper); List<Asset> videoList = this.assetService.list(assetQueryWrapper);
for (Asset asset : videoList) { videoList.forEach(asset ->{
asset.setExhibitionBoardName(exhibitionBoard.getName()); asset.setExhibitionBoardName(exhibitionBoard.getName());
asset.setExhibitionBoardId(exhibitionBoard.getId()); asset.setExhibitionBoardId(exhibitionBoard.getId());
} });
exhibitionBoard.setVideoList(videoList); exhibitionBoard.setVideoList(videoList);
assetQueryWrapper.clear(); assetQueryWrapper.clear();
} }
// 该学习内容下的展板参考资料哪些显示
LambdaQueryWrapper<LearningContentAsset> wrapper = Wrappers.<LearningContentAsset>lambdaQuery().eq(LearningContentAsset::getLearningContentId, learningContentId);
wrapper.eq(LearningContentAsset::getBoardId, exhibitionBoard.getId());
wrapper.select(LearningContentAsset::getAssetId);
List<String> list = this.learningContentAssetService.listObjs(wrapper,Object::toString);
if (!CollectionUtils.isEmpty(list)) {
assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId()); assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name()); assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name());
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.in(Asset::getId, list);
List<Asset> datumList = this.assetService.list(assetQueryWrapper); List<Asset> datumList = this.assetService.list(assetQueryWrapper);
for (Asset asset : datumList) { for (Asset asset : datumList) {
asset.setExhibitionBoardName(exhibitionBoard.getName());
asset.setExhibitionBoardId(exhibitionBoard.getId()); asset.setExhibitionBoardId(exhibitionBoard.getId());
asset.setExhibitionBoardName(exhibitionBoard.getName());
} }
exhibitionBoard.setDatumList(datumList); exhibitionBoard.setDatumList(datumList);
}
//videoList.addAll(datumList.stream().filter(x -> FileTypeEnum.VIDEO.name().equalsIgnoreCase(x.getFileType())).collect(Collectors.toList())); //videoList.addAll(datumList.stream().filter(x -> FileTypeEnum.VIDEO.name().equalsIgnoreCase(x.getFileType())).collect(Collectors.toList()));
// 填充编号 // 填充编号
setBoardSerial(exhibitionBoard); this.setBoardSerial(exhibitionBoard);
} }
return getResult(page); return getResult(page);
} }
...@@ -555,14 +571,15 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -555,14 +571,15 @@ public class ChinaMobileRestApiController extends BaseController {
@RequestParam(value = "videoLanguage", required = false) LanguageEnum videoLanguage, @RequestParam(value = "videoLanguage", required = false) LanguageEnum videoLanguage,
@RequestParam(value = "audioLanguage", required = false) LanguageEnum audioLanguage) { @RequestParam(value = "audioLanguage", required = false) LanguageEnum audioLanguage) {
ExhibitionBoard exhibitionBoard = exhibitionBoardService.getById(id); ExhibitionBoard exhibitionBoard = exhibitionBoardService.getById(id);
String exhibitionBoardCatId = exhibitionBoard.getExhibitionBoardCatId();
if (exhibitionBoardCatId != null) {
exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
}
String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId(); String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
if (boardCopyrightOwnerId != null) { if (boardCopyrightOwnerId != null) {
exhibitionBoard.setBoardCopyrightOwnerName(this.copyrightOwnerService.getById(boardCopyrightOwnerId).getName()); exhibitionBoard.setBoardCopyrightOwnerName(this.copyrightOwnerService.getById(boardCopyrightOwnerId).getName());
} }
String exhibitionBoardCatId = exhibitionBoard.getExhibitionBoardCatId();
if (exhibitionBoardCatId != null) {
exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
}
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) { if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName(); String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setVideoContentCopyrightOwnerName(name); exhibitionBoard.setVideoContentCopyrightOwnerName(name);
......
...@@ -412,18 +412,18 @@ public class ExhibitionBoardController extends BaseController { ...@@ -412,18 +412,18 @@ public class ExhibitionBoardController extends BaseController {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName()); exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
} }
} }
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) { if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()); final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId());
if (copyrightOwner == null) { if (copyrightOwner == null) {
exhibitionBoard.setVideoContentCopyrightOwnerName("对应的视频内容版权方已被删除"); exhibitionBoard.setVideoContentCopyrightOwnerName("对应的视频内容版权方已被删除");
} else { } else {
exhibitionBoard.setVideoContentCopyrightOwnerName(copyrightOwner.getName()); exhibitionBoard.setVideoContentCopyrightOwnerName(copyrightOwner.getName());
} }
} }else {
if (StringUtils.isEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
exhibitionBoard.setVideoContentCopyrightOwnerName("无"); exhibitionBoard.setVideoContentCopyrightOwnerName("无");
exhibitionBoard.setVideoContentName("无"); exhibitionBoard.setVideoContentName("无");
} }
if (exhibitionBoard.getExhibitionBoardCatId() != null) { if (exhibitionBoard.getExhibitionBoardCatId() != null) {
final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId()); final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId());
if (exhibitionBoardCat == null) { if (exhibitionBoardCat == null) {
...@@ -432,7 +432,7 @@ public class ExhibitionBoardController extends BaseController { ...@@ -432,7 +432,7 @@ public class ExhibitionBoardController extends BaseController {
exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName()); exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName());
} }
} }
if (exhibitionBoard.getVideoContentId() != null) { if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId() )) {
String videoContentId = exhibitionBoard.getVideoContentId(); String videoContentId = exhibitionBoard.getVideoContentId();
final VideoContent videoContent = this.videoContentService.getById(videoContentId); final VideoContent videoContent = this.videoContentService.getById(videoContentId);
if (videoContent == null) { if (videoContent == null) {
...@@ -442,6 +442,8 @@ public class ExhibitionBoardController extends BaseController { ...@@ -442,6 +442,8 @@ public class ExhibitionBoardController extends BaseController {
final List<Asset> videoList = this.assetService.list(Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId).eq(Asset::getPublished, true)); final List<Asset> videoList = this.assetService.list(Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId).eq(Asset::getPublished, true));
exhibitionBoard.setVideoList(videoList); exhibitionBoard.setVideoList(videoList);
} }
}else {
exhibitionBoard.setVideoContentName("无");
} }
} }
return getResult(page); return getResult(page);
......
...@@ -7,6 +7,7 @@ import cn.chnmuseum.party.common.enums.FileCatEnum; ...@@ -7,6 +7,7 @@ import cn.chnmuseum.party.common.enums.FileCatEnum;
import cn.chnmuseum.party.common.log.MethodLog; import cn.chnmuseum.party.common.log.MethodLog;
import cn.chnmuseum.party.common.log.OperModule; import cn.chnmuseum.party.common.log.OperModule;
import cn.chnmuseum.party.common.log.OperType; import cn.chnmuseum.party.common.log.OperType;
import cn.chnmuseum.party.common.util.ListUtil;
import cn.chnmuseum.party.common.validator.groups.Add; import cn.chnmuseum.party.common.validator.groups.Add;
import cn.chnmuseum.party.common.validator.groups.Update; import cn.chnmuseum.party.common.validator.groups.Update;
import cn.chnmuseum.party.common.vo.GenericPageParam; import cn.chnmuseum.party.common.vo.GenericPageParam;
...@@ -17,6 +18,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -17,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -27,6 +29,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -27,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -74,10 +77,14 @@ public class LearningContentController extends BaseController { ...@@ -74,10 +77,14 @@ public class LearningContentController extends BaseController {
@Autowired @Autowired
TOrganService organService; TOrganService organService;
@Resource
private LearningContentAssetService learningContentAssetService;
@PostMapping("/save") @PostMapping("/save")
@RequiresAuthentication //@RequiresPermissions("learning:content:save") @RequiresAuthentication //@RequiresPermissions("learning:content:save")
@ApiOperation(value = "添加学习内容", notes = "添加学习内容") @ApiOperation(value = "添加学习内容", notes = "添加学习内容")
@MethodLog(operModule = OperModule.LEARNCONTENT, operType = OperType.ADD) @MethodLog(operModule = OperModule.LEARNCONTENT, operType = OperType.ADD)
@Transactional
public Map<String, Object> saveLearningContent(@Validated(value = {Add.class}) LearningContent learningContent, Boolean isMajor) { public Map<String, Object> saveLearningContent(@Validated(value = {Add.class}) LearningContent learningContent, Boolean isMajor) {
TUser tUser1 = getcurUser(); TUser tUser1 = getcurUser();
if ("1".equals(tUser1.getType())){ if ("1".equals(tUser1.getType())){
...@@ -154,6 +161,25 @@ public class LearningContentController extends BaseController { ...@@ -154,6 +161,25 @@ public class LearningContentController extends BaseController {
this.learningContentBoardService.save(learningContentBoard); this.learningContentBoardService.save(learningContentBoard);
} }
// 保存需要在app端显示的参考资料
List<String> fileList = learningContent.getFileList();
if (!CollectionUtils.isEmpty(fileList)) {
List<LearningContentAsset> learningContentAssets = new ArrayList<>();
List<Asset> assets = this.assetService.listByIds(fileList);
assets.forEach(asset -> {
LearningContentAsset learningContentAsset = LearningContentAsset.builder()
.learningContentId(learningContentId)
.boardId(asset.getRefItemId())
.assetId(asset.getId())
.build();
learningContentAssets.add(learningContentAsset);
});
boolean b = this.learningContentAssetService.saveBatch(learningContentAssets);
if (!b) {
return getFailResult("添加数据失败!");
}
}
// 返回操作结果 // 返回操作结果
if (result && nonUnitRole) { if (result && nonUnitRole) {
final Audit audit = Audit.builder() final Audit audit = Audit.builder()
...@@ -199,6 +225,7 @@ public class LearningContentController extends BaseController { ...@@ -199,6 +225,7 @@ public class LearningContentController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("learning:content:update") @RequiresAuthentication //@RequiresPermissions("learning:content:update")
@ApiOperation(value = "修改学习内容信息", notes = "修改学习内容信息") @ApiOperation(value = "修改学习内容信息", notes = "修改学习内容信息")
@MethodLog(operModule = OperModule.LEARNCONTENT, operType = OperType.UPDATE) @MethodLog(operModule = OperModule.LEARNCONTENT, operType = OperType.UPDATE)
@Transactional
public Map<String, Object> updateLearningContent(@Validated(value = {Update.class}) LearningContent learningContent) { public Map<String, Object> updateLearningContent(@Validated(value = {Update.class}) LearningContent learningContent) {
final LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery().eq(LearningContent::getName, learningContent.getName().trim()); final LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery().eq(LearningContent::getName, learningContent.getName().trim());
lambdaQueryWrapper.ne(LearningContent::getId, learningContent.getId()); lambdaQueryWrapper.ne(LearningContent::getId, learningContent.getId());
...@@ -218,6 +245,37 @@ public class LearningContentController extends BaseController { ...@@ -218,6 +245,37 @@ public class LearningContentController extends BaseController {
return getFailResult("单位管理员只能修改所属机构及其子机构的学习内容"); return getFailResult("单位管理员只能修改所属机构及其子机构的学习内容");
} }
} }
// 学习内容下显示的参考信息被修改
LambdaQueryWrapper<LearningContentAsset> lambdaQuery = Wrappers.lambdaQuery();
lambdaQuery.eq(LearningContentAsset::getLearningContentId,one.getId());
lambdaQuery.select(LearningContentAsset::getAssetId);
List<String> list = this.learningContentAssetService.listObjs(lambdaQuery, Object::toString);
if (!ListUtil.compareValue(list, learningContent.getFileList())) {
LambdaUpdateWrapper<LearningContentAsset> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.eq(LearningContentAsset::getLearningContentId, one.getId());
boolean remove = this.learningContentAssetService.remove(updateWrapper);
if (!remove) {
return getFailResult("更新数据失败!");
}
List<String> fileList = learningContent.getFileList();
if (!CollectionUtils.isEmpty(fileList)) {
LambdaQueryWrapper<Asset> queryWrapper = Wrappers.<Asset>lambdaQuery().in(Asset::getId, fileList);
List<Asset> list1 = this.assetService.list(queryWrapper);
ArrayList<LearningContentAsset> learningContentAssets = new ArrayList<>();
list1.forEach(asset -> {
LearningContentAsset learningContentAsset = LearningContentAsset.builder()
.learningContentId(learningContent.getId())
.boardId(asset.getRefItemId())
.assetId(asset.getId())
.build();
learningContentAssets.add(learningContentAsset);
});
boolean b = this.learningContentAssetService.saveBatch(learningContentAssets);
if (!b) {
return getFailResult("更新数据失败!");
}
}
}
one.setAuditStatus(AuditStatusEnum.TBC.name()); one.setAuditStatus(AuditStatusEnum.TBC.name());
this.learningContentService.updateById(one); this.learningContentService.updateById(one);
...@@ -471,32 +529,32 @@ public class LearningContentController extends BaseController { ...@@ -471,32 +529,32 @@ public class LearningContentController extends BaseController {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName()); exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
} }
} }
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) { if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName(); String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setVideoContentCopyrightOwnerName(name); exhibitionBoard.setVideoContentCopyrightOwnerName(name);
} }
LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId()); LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_AUDIO.name()); assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_AUDIO.name());
assetQueryWrapper.eq(Asset::getPublished, true);
final List<Asset> audioList = this.assetService.list(assetQueryWrapper); final List<Asset> audioList = this.assetService.list(assetQueryWrapper);
exhibitionBoard.setAudioList(audioList); exhibitionBoard.setAudioList(audioList);
assetQueryWrapper.clear(); assetQueryWrapper.clear();
assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId()); assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name()); assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name());
assetQueryWrapper.eq(Asset::getPublished, true);
final List<Asset> datumList = this.assetService.list(assetQueryWrapper); final List<Asset> datumList = this.assetService.list(assetQueryWrapper);
exhibitionBoard.setDatumList(datumList); exhibitionBoard.setDatumList(datumList);
String videoContentId = exhibitionBoard.getVideoContentId(); String videoContentId = exhibitionBoard.getVideoContentId();
if (videoContentId != null) { if (StringUtils.isNotEmpty(videoContentId)) {
final VideoContent videoContent = this.videoContentService.getOne(Wrappers.<VideoContent>lambdaQuery().eq(VideoContent::getId, videoContentId)); final VideoContent videoContent = this.videoContentService.getOne(Wrappers.<VideoContent>lambdaQuery().eq(VideoContent::getId, videoContentId));
if (videoContent != null) { if (videoContent != null) {
assetQueryWrapper.clear(); assetQueryWrapper.clear();
assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId); assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId);
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name()); assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name());
assetQueryWrapper.eq(Asset::getPublished, true);
final List<Asset> videoList = this.assetService.list(assetQueryWrapper); final List<Asset> videoList = this.assetService.list(assetQueryWrapper);
exhibitionBoard.setVideoList(videoList); exhibitionBoard.setVideoList(videoList);
exhibitionBoard.setVideoContentName(videoContent.getName()); exhibitionBoard.setVideoContentName(videoContent.getName());
......
...@@ -337,8 +337,6 @@ public class LearningProjectController extends BaseController { ...@@ -337,8 +337,6 @@ public class LearningProjectController extends BaseController {
LearningContent data = (LearningContent) map.get("data"); LearningContent data = (LearningContent) map.get("data");
learningProject.setMajorLearning(data); learningProject.setMajorLearning(data);
} }
return getResult(learningProject); return getResult(learningProject);
} }
......
...@@ -69,7 +69,7 @@ public class StatisticController extends BaseController { ...@@ -69,7 +69,7 @@ public class StatisticController extends BaseController {
@GetMapping("/recordVisitor") @GetMapping("/recordVisitor")
@ApiOperation(value = "记录视频访问者的城市", notes = "记录视频访问者的城市") @ApiOperation(value = "记录视频访问者的城市", notes = "记录视频访问者的城市")
public Map recordVisitor(String videoId, HttpServletRequest request){ public Map recordVisitor(String videoId, String ip){
Map<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
try { try {
TVideoVisitor tVideoVisitor = new TVideoVisitor(); TVideoVisitor tVideoVisitor = new TVideoVisitor();
...@@ -79,13 +79,12 @@ public class StatisticController extends BaseController { ...@@ -79,13 +79,12 @@ public class StatisticController extends BaseController {
}else { }else {
tVideoVisitor.setVideoId(StringUtils.trimToNull(videoId)); tVideoVisitor.setVideoId(StringUtils.trimToNull(videoId));
} }
String ipAddress = AddressUtil.getIpAddress(request); if (StringUtils.isBlank(ip)) {
if (StringUtils.isBlank(ipAddress)) {
resultMap.put("resultCoed", "400"); resultMap.put("resultCoed", "400");
resultMap.put("message", "获取数据异常"); resultMap.put("message", "获取数据异常");
} }
tVideoVisitor.setUserIp(ipAddress); tVideoVisitor.setUserIp(ip);
Map<String, String> addressByIp = AddressUtil.getAddressByIp(ipAddress); Map<String, String> addressByIp = AddressUtil.getAddressByIp(ip);
if (StringUtils.isNotBlank(addressByIp.get("region"))) { if (StringUtils.isNotBlank(addressByIp.get("region"))) {
tVideoVisitor.setAreaCode(addressByIp.get("regionCode")); tVideoVisitor.setAreaCode(addressByIp.get("regionCode"));
}else if(StringUtils.isNotBlank(addressByIp.get("city"))){ }else if(StringUtils.isNotBlank(addressByIp.get("city"))){
......
...@@ -43,6 +43,7 @@ spring.datasource.druid.test-while-idle=true ...@@ -43,6 +43,7 @@ spring.datasource.druid.test-while-idle=true
spring.datasource.druid.time-between-eviction-runs-millis=60000 spring.datasource.druid.time-between-eviction-runs-millis=60000
spring.datasource.druid.url=jdbc:mysql://192.168.110.93:3306/chnmuseum-party?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai spring.datasource.druid.url=jdbc:mysql://192.168.110.93:3306/chnmuseum-party?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
#spring.datasource.druid.url=jdbc:mysql://10.18.121.26:3306/chnmuseum-party?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai #spring.datasource.druid.url=jdbc:mysql://10.18.121.26:3306/chnmuseum-party?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.druid.username=root spring.datasource.druid.username=root
spring.datasource.druid.password=password spring.datasource.druid.password=password
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
......
...@@ -35,7 +35,7 @@ fdfs.tracker-list[0]=192.168.110.85:22122 ...@@ -35,7 +35,7 @@ fdfs.tracker-list[0]=192.168.110.85:22122
dfsFileAccessBasePath=http://111.203.232.175:8085 dfsFileAccessBasePath=http://111.203.232.175:8085
prefixPat=/data/fastdfs/data prefixPat=/data/fastdfs/data
IMAGE_BASE_URL=http://111.203.232.175:8085/ IMAGE_BASE_URL=http://111.203.232.175:8085/
#
#fdfs.tracker-list[0]=10.18.121.26:22122 #fdfs.tracker-list[0]=10.18.121.26:22122
#dfsFileAccessBasePath=http://101.96.131.110:9999 #dfsFileAccessBasePath=http://101.96.131.110:9999
......
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