浏览记录的处理

This commit is contained in:
wangliwen 2022-07-06 15:45:12 +08:00
parent 419ad451bd
commit 898e1c5ae5
3 changed files with 11 additions and 6 deletions

View File

@ -35,7 +35,6 @@ import io.renren.modules.resource.entity.ResourceEntityDelFlag;
import io.renren.modules.resource.entity.TbDataResourceRelEntity;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import io.renren.modules.resourceCar.dao.ResourceCarDao;
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
@ -690,11 +689,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
updateWrapper.lambda().eq(ResourceEntity::getId, resourceEntity.getId())
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
resourceDao.update(entity, updateWrapper);
ResourceBrowseEntity browseEntity = new ResourceBrowseEntity();
browseEntity.setResourceId(id);
browseEntity.setUserId(SecurityUser.getUserId());
browseEntity.setState(0);
resourceBrowseDao.insert(browseEntity);
// ResourceBrowseEntity browseEntity = new ResourceBrowseEntity();
// browseEntity.setResourceId(id);
// browseEntity.setUserId(SecurityUser.getUserId());
// browseEntity.setState(0);
// resourceBrowseDao.insert(browseEntity);
jdbcTemplate.update("update tb_data_resource,\n" +
"tb_data_resource_assignmark\n" +
"SET tb_data_resource.total = round(tb_data_resource_assignmark.total) WHERE tb_data_resource.id =" + id);

View File

@ -19,6 +19,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -41,6 +42,8 @@ public class ResourceBrowseController {
private ResourceBrowseService resourceBrowseService;
@Autowired
private ResourceService resourceService;
@Autowired
private JdbcTemplate jdbcTemplate;
@GetMapping("/page")
@ApiOperation("浏览记录-分页查询")
@ -83,6 +86,7 @@ public class ResourceBrowseController {
dto.setCreator(SecurityUser.getUserId());
dto.setUserId(SecurityUser.getUserId());
resourceBrowseService.save(dto);
jdbcTemplate.update("UPDATE tb_data_resource SET visitor = (SELECT COUNT(id) FROM tb_resource_browse WHERE resource_id = tb_data_resource.id) WHERE tb_data_resource.id = " + dto.getResourceId());
return new Result().ok(dto);
}

View File

@ -0,0 +1,2 @@
alter table `share_platform`.`tb_data_resource` ADD COLUMN `visitor` bigint NULL comment '浏览量';
UPDATE tb_data_resource SET visitor = (SELECT COUNT(id) FROM tb_resource_browse WHERE resource_id = tb_data_resource.id);