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

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

parent fec4da72
package cn.chnmuseum.party.common.util;
import cn.hutool.core.net.NetUtil;
import net.sf.json.JSONObject;
import javax.servlet.http.HttpServletRequest;
......@@ -145,4 +146,9 @@ public class AddressUtil {
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 {
@TableField(exist = false)
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;
import cn.chnmuseum.party.common.video.VideoEncryptUtil;
import cn.chnmuseum.party.common.vo.GenericPageParam;
import cn.chnmuseum.party.model.Asset;
import cn.chnmuseum.party.model.ExhibitionBoard;
import cn.chnmuseum.party.model.TBoxOperation;
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.hutool.core.io.IoUtil;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -35,6 +40,7 @@ import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -56,6 +62,9 @@ public class AssetController extends BaseController {
@Resource
private AssetService assetService;
@Resource
private ExhibitionBoardService exhibitionBoardService;
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
......@@ -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]));
}
@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;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -99,6 +100,9 @@ public class ChinaMobileRestApiController extends BaseController {
@Resource
private TAppRunPicService appRunPicService;
@Resource
private LearningContentAssetService learningContentAssetService;
private static final String SHIRO_JWT_TOKEN = "shiro:jwt:token:";
//用户登录次数计数 redisKey 前缀
private static final String SHIRO_LOGIN_COUNT = "shiro_login_count_";
......@@ -498,14 +502,15 @@ public class ChinaMobileRestApiController extends BaseController {
final IPage<ExhibitionBoard> page = this.learningContentBoardService.getBoardPageByLearningContentId(page1, learningContentId, null);
for (ExhibitionBoard exhibitionBoard : page.getRecords()) {
exhibitionBoard.setLearningContentId(learningContentId);
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setBoardCopyrightOwnerName(name);
}
if (exhibitionBoard.getExhibitionBoardCatId() != null) {
String name = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId()).getName();
exhibitionBoard.setExhibitionBoardCatName(name);
}
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setBoardCopyrightOwnerName(name);
}
LambdaQueryWrapper<Asset> assetQueryWrapper;
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId())) {
final VideoContent videoContent = this.videoContentService.getById(exhibitionBoard.getVideoContentId());
......@@ -513,32 +518,43 @@ public class ChinaMobileRestApiController extends BaseController {
exhibitionBoard.setBoardVideoContentThumbnail(videoContent.getThumbnail());
}
assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getVideoContentId());
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper = Wrappers.<Asset>lambdaQuery();
assetQueryWrapper.eq(Asset::getRefItemId, exhibitionBoard.getVideoContentId());
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name());
assetQueryWrapper.eq(Asset::getPublished, true);
List<Asset> videoList = this.assetService.list(assetQueryWrapper);
for (Asset asset : videoList) {
videoList.forEach(asset ->{
asset.setExhibitionBoardName(exhibitionBoard.getName());
asset.setExhibitionBoardId(exhibitionBoard.getId());
}
});
exhibitionBoard.setVideoList(videoList);
assetQueryWrapper.clear();
}
assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name());
List<Asset> datumList = this.assetService.list(assetQueryWrapper);
for (Asset asset : datumList) {
asset.setExhibitionBoardName(exhibitionBoard.getName());
asset.setExhibitionBoardId(exhibitionBoard.getId());
// 该学习内容下的展板参考资料哪些显示
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.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);
for (Asset asset : datumList) {
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()));
// 填充编号
setBoardSerial(exhibitionBoard);
this.setBoardSerial(exhibitionBoard);
}
return getResult(page);
}
......@@ -555,14 +571,15 @@ public class ChinaMobileRestApiController extends BaseController {
@RequestParam(value = "videoLanguage", required = false) LanguageEnum videoLanguage,
@RequestParam(value = "audioLanguage", required = false) LanguageEnum audioLanguage) {
ExhibitionBoard exhibitionBoard = exhibitionBoardService.getById(id);
String exhibitionBoardCatId = exhibitionBoard.getExhibitionBoardCatId();
if (exhibitionBoardCatId != null) {
exhibitionBoard.setExhibitionBoardCatName(this.exhibitionBoardCatService.getById(exhibitionBoardCatId).getName());
}
String boardCopyrightOwnerId = exhibitionBoard.getBoardCopyrightOwnerId();
if (boardCopyrightOwnerId != null) {
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())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setVideoContentCopyrightOwnerName(name);
......
......@@ -412,18 +412,18 @@ public class ExhibitionBoardController extends BaseController {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
}
}
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
final CopyrightOwner copyrightOwner = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId());
if (copyrightOwner == null) {
exhibitionBoard.setVideoContentCopyrightOwnerName("对应的视频内容版权方已被删除");
} else {
exhibitionBoard.setVideoContentCopyrightOwnerName(copyrightOwner.getName());
}
}
if (StringUtils.isEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
}else {
exhibitionBoard.setVideoContentCopyrightOwnerName("无");
exhibitionBoard.setVideoContentName("无");
}
if (exhibitionBoard.getExhibitionBoardCatId() != null) {
final ExhibitionBoardCat exhibitionBoardCat = this.exhibitionBoardCatService.getById(exhibitionBoard.getExhibitionBoardCatId());
if (exhibitionBoardCat == null) {
......@@ -432,7 +432,7 @@ public class ExhibitionBoardController extends BaseController {
exhibitionBoard.setExhibitionBoardCatName(exhibitionBoardCat.getName());
}
}
if (exhibitionBoard.getVideoContentId() != null) {
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentId() )) {
String videoContentId = exhibitionBoard.getVideoContentId();
final VideoContent videoContent = this.videoContentService.getById(videoContentId);
if (videoContent == null) {
......@@ -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));
exhibitionBoard.setVideoList(videoList);
}
}else {
exhibitionBoard.setVideoContentName("无");
}
}
return getResult(page);
......
......@@ -7,6 +7,7 @@ import cn.chnmuseum.party.common.enums.FileCatEnum;
import cn.chnmuseum.party.common.log.MethodLog;
import cn.chnmuseum.party.common.log.OperModule;
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.Update;
import cn.chnmuseum.party.common.vo.GenericPageParam;
......@@ -17,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
......@@ -27,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -74,10 +77,14 @@ public class LearningContentController extends BaseController {
@Autowired
TOrganService organService;
@Resource
private LearningContentAssetService learningContentAssetService;
@PostMapping("/save")
@RequiresAuthentication //@RequiresPermissions("learning:content:save")
@ApiOperation(value = "添加学习内容", notes = "添加学习内容")
@MethodLog(operModule = OperModule.LEARNCONTENT, operType = OperType.ADD)
@Transactional
public Map<String, Object> saveLearningContent(@Validated(value = {Add.class}) LearningContent learningContent, Boolean isMajor) {
TUser tUser1 = getcurUser();
if ("1".equals(tUser1.getType())){
......@@ -154,6 +161,25 @@ public class LearningContentController extends BaseController {
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) {
final Audit audit = Audit.builder()
......@@ -199,6 +225,7 @@ public class LearningContentController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("learning:content:update")
@ApiOperation(value = "修改学习内容信息", notes = "修改学习内容信息")
@MethodLog(operModule = OperModule.LEARNCONTENT, operType = OperType.UPDATE)
@Transactional
public Map<String, Object> updateLearningContent(@Validated(value = {Update.class}) LearningContent learningContent) {
final LambdaQueryWrapper<LearningContent> lambdaQueryWrapper = Wrappers.<LearningContent>lambdaQuery().eq(LearningContent::getName, learningContent.getName().trim());
lambdaQueryWrapper.ne(LearningContent::getId, learningContent.getId());
......@@ -218,6 +245,37 @@ public class LearningContentController extends BaseController {
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());
this.learningContentService.updateById(one);
......@@ -471,32 +529,32 @@ public class LearningContentController extends BaseController {
exhibitionBoard.setBoardCopyrightOwnerName(copyrightOwner.getName());
}
}
if (exhibitionBoard.getVideoContentCopyrightOwnerId() != null) {
if (StringUtils.isNotEmpty(exhibitionBoard.getVideoContentCopyrightOwnerId())) {
String name = this.copyrightOwnerService.getById(exhibitionBoard.getVideoContentCopyrightOwnerId()).getName();
exhibitionBoard.setVideoContentCopyrightOwnerName(name);
}
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::getPublished, true);
final List<Asset> audioList = this.assetService.list(assetQueryWrapper);
exhibitionBoard.setAudioList(audioList);
assetQueryWrapper.clear();
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::getPublished, true);
final List<Asset> datumList = this.assetService.list(assetQueryWrapper);
exhibitionBoard.setDatumList(datumList);
String videoContentId = exhibitionBoard.getVideoContentId();
if (videoContentId != null) {
if (StringUtils.isNotEmpty(videoContentId)) {
final VideoContent videoContent = this.videoContentService.getOne(Wrappers.<VideoContent>lambdaQuery().eq(VideoContent::getId, videoContentId));
if (videoContent != null) {
assetQueryWrapper.clear();
assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, videoContentId);
assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.VIDEO_CONTENT.name());
assetQueryWrapper.eq(Asset::getPublished, true);
final List<Asset> videoList = this.assetService.list(assetQueryWrapper);
exhibitionBoard.setVideoList(videoList);
exhibitionBoard.setVideoContentName(videoContent.getName());
......
......@@ -337,8 +337,6 @@ public class LearningProjectController extends BaseController {
LearningContent data = (LearningContent) map.get("data");
learningProject.setMajorLearning(data);
}
return getResult(learningProject);
}
......
......@@ -69,7 +69,7 @@ public class StatisticController extends BaseController {
@GetMapping("/recordVisitor")
@ApiOperation(value = "记录视频访问者的城市", notes = "记录视频访问者的城市")
public Map recordVisitor(String videoId, HttpServletRequest request){
public Map recordVisitor(String videoId, String ip){
Map<String, String> resultMap = new HashMap<>();
try {
TVideoVisitor tVideoVisitor = new TVideoVisitor();
......@@ -79,13 +79,12 @@ public class StatisticController extends BaseController {
}else {
tVideoVisitor.setVideoId(StringUtils.trimToNull(videoId));
}
String ipAddress = AddressUtil.getIpAddress(request);
if (StringUtils.isBlank(ipAddress)) {
if (StringUtils.isBlank(ip)) {
resultMap.put("resultCoed", "400");
resultMap.put("message", "获取数据异常");
}
tVideoVisitor.setUserIp(ipAddress);
Map<String, String> addressByIp = AddressUtil.getAddressByIp(ipAddress);
tVideoVisitor.setUserIp(ip);
Map<String, String> addressByIp = AddressUtil.getAddressByIp(ip);
if (StringUtils.isNotBlank(addressByIp.get("region"))) {
tVideoVisitor.setAreaCode(addressByIp.get("regionCode"));
}else if(StringUtils.isNotBlank(addressByIp.get("city"))){
......
......@@ -43,6 +43,7 @@ spring.datasource.druid.test-while-idle=true
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://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.password=password
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
......
......@@ -35,7 +35,7 @@ fdfs.tracker-list[0]=192.168.110.85:22122
dfsFileAccessBasePath=http://111.203.232.175:8085
prefixPat=/data/fastdfs/data
IMAGE_BASE_URL=http://111.203.232.175:8085/
#
#fdfs.tracker-list[0]=10.18.121.26:22122
#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