diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index 1d04f184..8019efe3 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -9,6 +9,7 @@ import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.service.ResourceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -18,6 +19,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; @@ -84,7 +86,6 @@ public class ResourceController { return new Result().ok(data); } - @GetMapping("/selectTotal") @ApiOperation("查询系统及本部门已汇聚能力") @LogOperation("查询系统及本部门已汇聚能力") @@ -99,7 +100,6 @@ public class ResourceController { return new Result<>().ok(resourceService.selectNewest(jsonObject)); } - @GetMapping("/selectMostPopular") @ApiOperation("查询热门能力") @LogOperation("查询热门能力") @@ -107,6 +107,16 @@ public class ResourceController { return new Result<>().ok(resourceService.selectMostPopular(jsonObject)); } + @GetMapping("/updateVisits") + @ApiOperation("更新能力访问量") + @LogOperation("更新能力访问量") + public Result updateVisits(@RequestBody ResourceEntity resourceEntity) { + if (ObjectUtils.isEmpty(resourceEntity.getId()) || ObjectUtils.isEmpty(resourceEntity.getVisits())) { + return new Result().error(); + } + resourceService.updateVisits(resourceEntity); + return new Result(); + } @PostMapping("/insert") @ApiOperation("保存") diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index 8e590ab3..46ab971b 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -37,4 +37,6 @@ public interface ResourceService extends CrudService updateWrapper = new UpdateWrapper<>(); + updateWrapper.lambda() + .set(ResourceEntity::getVisits, resourceEntity.getVisits() + 1L) + .eq(ResourceEntity::getId, resourceEntity.getId()) + .eq(ResourceEntity::getDelFlag, 0); + resourceDao.update(null, updateWrapper); + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/controller/ResourceCollectionController.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/controller/ResourceCollectionController.java new file mode 100644 index 00000000..ddef97c0 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/controller/ResourceCollectionController.java @@ -0,0 +1,110 @@ +package io.renren.modules.resourceCollection.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.renren.common.annotation.LogOperation; +import io.renren.common.utils.ExcelUtils; +import io.renren.common.utils.Result; +import io.renren.common.validator.ValidatorUtils; +import io.renren.common.validator.group.DefaultGroup; +import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO; +import io.renren.modules.resourceCollection.entity.ResourceCollectionEntity; +import io.renren.modules.resourceCollection.excel.ResourceCollectionExcel; +import io.renren.modules.resourceCollection.service.ResourceCollectionService; +import io.swagger.annotations.Api; +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.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** +* 能力收藏表 +* +* @author dg +* @since 1.0 2022-04-22 +*/ +@RestController +@RequestMapping("/resourcecollection") +@Api(tags="能力收藏表") +public class ResourceCollectionController { + @Autowired + private ResourceCollectionService resourceCollectionService; + + @GetMapping("/page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "当前页码,从1开始", paramType = "body", required = true, dataType="int") , + @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "body",required = true, dataType="int") , + @ApiImplicitParam(name = "type", value = "资源类型", paramType = "body", dataType="String"), + @ApiImplicitParam(name = "name", value = "资源名称", paramType = "body", dataType="String") + }) + //@RequiresPermissions("resourceCar:resourcecar:page") + public Result> page(@ApiIgnore @RequestParam Map params){ + return new Result>().ok(resourceCollectionService.selectPage(params)); + } + + @GetMapping("/select/{id}") + @ApiOperation("信息") + //@RequiresPermissions("resourceCollection:resourcecollection:info") + public Result get(@PathVariable("id") Long id){ + ResourceCollectionDTO data = resourceCollectionService.get(id); + + return new Result().ok(data); + } + + @PostMapping("/insert") + @ApiOperation("保存") + @LogOperation("保存") + //@RequiresPermissions("resourceCollection:resourcecollection:save") + public Result save(@RequestBody List list){ + //效验数据 + //ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + resourceCollectionService.insertList(list); + + return new Result(); + } + + @PutMapping("/update") + @ApiOperation("修改") + @LogOperation("修改") + //@RequiresPermissions("resourceCollection:resourcecollection:update") + public Result update(@RequestBody ResourceCollectionDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + resourceCollectionService.update(dto); + + return new Result(); + } + + @DeleteMapping("/delete") + @ApiOperation("删除") + @LogOperation("删除") + //@RequiresPermissions("resourceCollection:resourcecollection:delete") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + //AssertUtils.isArrayEmpty(ids, "id"); + + resourceCollectionService.deleteByIds(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") + //@RequiresPermissions("resourceCollection:resourcecollection:export") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = resourceCollectionService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, "能力收藏表", list, ResourceCollectionExcel.class); + } + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/dao/ResourceCollectionDao.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dao/ResourceCollectionDao.java new file mode 100644 index 00000000..bbbfc8dc --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dao/ResourceCollectionDao.java @@ -0,0 +1,26 @@ +package io.renren.modules.resourceCollection.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO; +import io.renren.modules.resourceCollection.entity.ResourceCollectionEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** +* 能力收藏表 +* +* @author dg +* @since 1.0 2022-04-22 +*/ +@Mapper +public interface ResourceCollectionDao extends BaseDao { + + Integer deleteByIds(@Param("ids") Long[] ids); + + List selectPageWithResource(@Param("params") Map params, + @Param("pageNum") Integer pageNum, + @Param("pageSize") Integer pageSize); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/dto/ResourceCollectionDTO.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dto/ResourceCollectionDTO.java new file mode 100644 index 00000000..3ab844d1 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/dto/ResourceCollectionDTO.java @@ -0,0 +1,50 @@ +package io.renren.modules.resourceCollection.dto; + +import io.renren.modules.resource.dto.ResourceDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* 能力收藏表 +* +* @author dg +* @since 1.0 2022-04-22 +*/ +@Data +@ApiModel(value = "能力收藏表") +public class ResourceCollectionDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + @ApiModelProperty(value = "用户ID") + private Long userId; + @ApiModelProperty(value = "能力ID") + private Long resourceId; + @ApiModelProperty(value = "删除标志:0:正常;1:已删除;9:其他") + private Integer delFlag; + @ApiModelProperty(value = "创建人") + private Long creator; + @ApiModelProperty(value = "创建时间") + private Date createDate; + @ApiModelProperty(value = "修改人") + private Long updater; + @ApiModelProperty(value = "修改时间") + private Date updateDate; + @ApiModelProperty(value = "备用字段1") + private String note1; + @ApiModelProperty(value = "备用字段2") + private String note2; + @ApiModelProperty(value = "备用字段3") + private String note3; + @ApiModelProperty(value = "备用字段4") + private String note4; + @ApiModelProperty(value = "备用字段5") + private String note5; + + @ApiModelProperty(value = "资源信息") + private ResourceDTO resourceDTO; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/entity/ResourceCollectionEntity.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/entity/ResourceCollectionEntity.java new file mode 100644 index 00000000..54cea42e --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/entity/ResourceCollectionEntity.java @@ -0,0 +1,74 @@ +package io.renren.modules.resourceCollection.entity; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.baomidou.mybatisplus.annotation.*; +import java.util.Date; + +/** + * 能力收藏表 + * + * @author dg + * @since 1.0 2022-04-22 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_resource_collection") +public class ResourceCollectionEntity { + private static final long serialVersionUID = 1L; + + @TableId + private Long id; + /** + * 用户ID + */ + private Long userId; + /** + * 能力ID + */ + private Long resourceId; + /** + * 删除标志:0:正常;1:已删除;9:其他 + */ + private Integer delFlag; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + private Long creator; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createDate; + /** + * 修改人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updater; + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + /** + * 备用字段1 + */ + private String note1; + /** + * 备用字段2 + */ + private String note2; + /** + * 备用字段3 + */ + private String note3; + /** + * 备用字段4 + */ + private String note4; + /** + * 备用字段5 + */ + private String note5; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/excel/ResourceCollectionExcel.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/excel/ResourceCollectionExcel.java new file mode 100644 index 00000000..7f154863 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/excel/ResourceCollectionExcel.java @@ -0,0 +1,47 @@ +package io.renren.modules.resourceCollection.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; +import java.util.Date; + +/** + * 能力收藏表 + * + * @author dg + * @since 1.0 2022-04-22 + */ +@Data +@ContentRowHeight(20) +@HeadRowHeight(20) +@ColumnWidth(25) +public class ResourceCollectionExcel { + @ExcelProperty(value = "Long", index = 0) + private Long id; + @ExcelProperty(value = "用户ID", index = 1) + private Long userId; + @ExcelProperty(value = "能力ID", index = 2) + private Long resourceId; + @ExcelProperty(value = "删除标志:0:正常;1:已删除;9:其他", index = 3) + private Integer delFlag; + @ExcelProperty(value = "创建人", index = 4) + private Object creator; + @ExcelProperty(value = "创建时间", index = 5) + private Date createDate; + @ExcelProperty(value = "修改人", index = 6) + private Long updater; + @ExcelProperty(value = "修改时间", index = 7) + private Date updateDate; + @ExcelProperty(value = "备用字段1", index = 8) + private String note1; + @ExcelProperty(value = "备用字段2", index = 9) + private String note2; + @ExcelProperty(value = "备用字段3", index = 10) + private String note3; + @ExcelProperty(value = "备用字段4", index = 11) + private String note4; + @ExcelProperty(value = "备用字段5", index = 12) + private String note5; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/ResourceCollectionService.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/ResourceCollectionService.java new file mode 100644 index 00000000..2ac29f6f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/ResourceCollectionService.java @@ -0,0 +1,25 @@ +package io.renren.modules.resourceCollection.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.renren.common.service.CrudService; +import io.renren.modules.resourceCar.dto.ResourceCarDTO; +import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO; +import io.renren.modules.resourceCollection.entity.ResourceCollectionEntity; + +import java.util.List; +import java.util.Map; + +/** + * 能力收藏表 + * + * @author dg + * @since 1.0 2022-04-22 + */ +public interface ResourceCollectionService extends CrudService { + + void insertList(List list); + + void deleteByIds(Long[] ids); + + IPage selectPage(Map params); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java new file mode 100644 index 00000000..d7617708 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCollection/service/impl/ResourceCollectionServiceImpl.java @@ -0,0 +1,88 @@ +package io.renren.modules.resourceCollection.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.common.constant.Constant; +import io.renren.modules.resource.service.ResourceService; +import io.renren.modules.resourceCar.dto.ResourceCarDTO; +import io.renren.modules.resourceCollection.dao.ResourceCollectionDao; +import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO; +import io.renren.modules.resourceCollection.entity.ResourceCollectionEntity; +import io.renren.modules.resourceCollection.service.ResourceCollectionService; +import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.security.user.UserDetail; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 能力收藏表 + * + * @author dg + * @since 1.0 2022-04-22 + */ +@Service +public class ResourceCollectionServiceImpl extends CrudServiceImpl implements ResourceCollectionService { + + @Autowired + private ResourceCollectionDao resourceCollectionDao; + + @Autowired + private ResourceService resourceService; + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + } + + @Override + public IPage selectPage(Map params) { + UserDetail user = SecurityUser.getUser(); + int pageNum = Integer.parseInt(params.get("pageNum").toString()); + int pageSize = Integer.parseInt(params.get("pageSize").toString()); + Page page = new Page(pageNum, pageSize); + params.put("userId", user.getId()); + List resourceCollectionDTOS = resourceCollectionDao.selectPageWithResource(params, (pageNum - 1) * pageSize, pageSize); + resourceCollectionDTOS.forEach(item -> { + item.setResourceDTO(resourceService.selectWithAttrs(item.getResourceId())); + }); + List resourceCollectionDTOSs = resourceCollectionDao.selectPageWithResource(params, 0, 100000); + page.setRecords(resourceCollectionDTOS); + page.setTotal(resourceCollectionDTOSs.size()); + return page; + } + + @Override + @Transactional + public void insertList(List list) { + UserDetail user = SecurityUser.getUser(); + list.forEach(item -> { + item.setUserId(user.getId()); + item.setDelFlag(0); + HashMap selectMap = new HashMap<>(); + selectMap.put("resource_id", item.getResourceId()); + selectMap.put("user_id", user.getId()); + selectMap.put("del_flag", 0); + List collectionEntities = resourceCollectionDao.selectByMap(selectMap); + if (collectionEntities.isEmpty()) { + resourceCollectionDao.insert(item); + } + }); + } + + @Override + public void deleteByIds(Long[] ids) { + resourceCollectionDao.deleteByIds(ids); + } +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/controller/ResourceScoreController.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/controller/ResourceScoreController.java new file mode 100644 index 00000000..bedb7bc1 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/controller/ResourceScoreController.java @@ -0,0 +1,121 @@ +package io.renren.modules.resourceScore.controller; + +import io.renren.common.annotation.LogOperation; +import io.renren.common.constant.Constant; +import io.renren.common.page.PageData; +import io.renren.common.utils.ExcelUtils; +import io.renren.common.utils.Result; +import io.renren.common.validator.AssertUtils; +import io.renren.common.validator.ValidatorUtils; +import io.renren.common.validator.group.AddGroup; +import io.renren.common.validator.group.DefaultGroup; +import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.resourceScore.dto.ResourceScoreDTO; +import io.renren.modules.resourceScore.excel.ResourceScoreExcel; +import io.renren.modules.resourceScore.service.ResourceScoreService; +import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.security.user.UserDetail; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** +* 能力评分表 +* +* @author dg +* @since 1.0 2022-04-24 +*/ +@RestController +@RequestMapping("/resourcescore") +@Api(tags="能力评分表") +public class ResourceScoreController { + @Autowired + private ResourceScoreService resourceScoreService; + + @GetMapping("/page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") + }) + //@RequiresPermissions("resourceScore:resourcescore:page") + public Result> page(@ApiIgnore @RequestParam Map params){ + PageData page = resourceScoreService.page(params); + + return new Result>().ok(page); + } + + @GetMapping("/select/{resourceId}") + @ApiOperation("查询个人评价信息") + //@RequiresPermissions("resourceScore:resourcescore:info") + public Result get(@PathVariable("resourceId") Long resourceId){ + ResourceScoreDTO data = resourceScoreService.selectByRidAndUid(resourceId); + + return new Result().ok(data); + } + + @PostMapping("/insert") + @ApiOperation("保存") + @LogOperation("保存") + //@RequiresPermissions("resourceScore:resourcescore:save") + public Result save(@RequestBody ResourceScoreDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + + UserDetail user = SecurityUser.getUser(); + dto.setUserId(user.getId()); + dto.setDelFlag(0); + resourceScoreService.save(dto); + + return new Result(); + } + + @PutMapping("/update") + @ApiOperation("修改") + @LogOperation("修改") + //@RequiresPermissions("resourceScore:resourcescore:update") + public Result update(@RequestBody ResourceScoreDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + + resourceScoreService.update(dto); + + return new Result(); + } + + @DeleteMapping("/delete") + @ApiOperation("删除") + @LogOperation("删除") + //@RequiresPermissions("resourceScore:resourcescore:delete") + public Result delete(@RequestBody Long[] ids){ + //效验数据 + //AssertUtils.isArrayEmpty(ids, "id"); + + resourceScoreService.deleteByIds(ids); + + return new Result(); + } + + @GetMapping("export") + @ApiOperation("导出") + @LogOperation("导出") + //@RequiresPermissions("resourceScore:resourcescore:export") + public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + List list = resourceScoreService.list(params); + + ExcelUtils.exportExcelToTarget(response, null, "能力评分表", list, ResourceScoreExcel.class); + } + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/dao/ResourceScoreDao.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/dao/ResourceScoreDao.java new file mode 100644 index 00000000..55d7146f --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/dao/ResourceScoreDao.java @@ -0,0 +1,18 @@ +package io.renren.modules.resourceScore.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.resourceScore.entity.ResourceScoreEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** +* 能力评分表 +* +* @author dg +* @since 1.0 2022-04-24 +*/ +@Mapper +public interface ResourceScoreDao extends BaseDao { + + Integer deleteByIds(@Param("ids") Long[] ids); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/dto/ResourceScoreDTO.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/dto/ResourceScoreDTO.java new file mode 100644 index 00000000..1ed616d6 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/dto/ResourceScoreDTO.java @@ -0,0 +1,56 @@ +package io.renren.modules.resourceScore.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* 能力评分表 +* +* @author dg +* @since 1.0 2022-04-24 +*/ +@Data +@ApiModel(value = "能力评分表") +public class ResourceScoreDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + private Long id; + @ApiModelProperty(value = "用户ID") + private Long userId; + @ApiModelProperty(value = "用户姓名") + private String userName; + @ApiModelProperty(value = "用户所属部门") + private String userDept; + @ApiModelProperty(value = "能力ID") + private Long resourceId; + @ApiModelProperty(value = "评分,1-5分,1分差评,5分好评") + private Integer score; + @ApiModelProperty(value = "评论内容") + private String comment; + @ApiModelProperty(value = "删除标志;0:正常;1:已删除") + private Integer delFlag; + @ApiModelProperty(value = "创建人") + private Long creator; + @ApiModelProperty(value = "创建时间") + private Date createDate; + @ApiModelProperty(value = "修改人") + private Long updater; + @ApiModelProperty(value = "修改时间") + private Date updateDate; + @ApiModelProperty(value = "备用字段1") + private String note1; + @ApiModelProperty(value = "备用字段2") + private String note2; + @ApiModelProperty(value = "备用字段3") + private String note3; + @ApiModelProperty(value = "备用字段4") + private String note4; + @ApiModelProperty(value = "备用字段5") + private String note5; + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/entity/ResourceScoreEntity.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/entity/ResourceScoreEntity.java new file mode 100644 index 00000000..68f32acc --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/entity/ResourceScoreEntity.java @@ -0,0 +1,85 @@ +package io.renren.modules.resourceScore.entity; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.baomidou.mybatisplus.annotation.*; +import java.util.Date; + +/** + * 能力评分表 + * + * @author dg + * @since 1.0 2022-04-24 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_resource_score") +public class ResourceScoreEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 用户ID + */ + private Long userId; + /** + * 能力ID + */ + private Long resourceId; + /** + * 评分,1-5分,1分差评,5分好评 + */ + private Integer score; + /** + * 评论内容 + */ + private String comment; + /** + * 删除标志;0:正常;1:已删除 + */ + private Integer delFlag; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + private Long creator; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createDate; + /** + * 修改人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updater; + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + /** + * 备用字段1 + */ + private String note1; + /** + * 备用字段2 + */ + private String note2; + /** + * 备用字段3 + */ + private String note3; + /** + * 备用字段4 + */ + private String note4; + /** + * 备用字段5 + */ + private String note5; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/excel/ResourceScoreExcel.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/excel/ResourceScoreExcel.java new file mode 100644 index 00000000..ead826a8 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/excel/ResourceScoreExcel.java @@ -0,0 +1,51 @@ +package io.renren.modules.resourceScore.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; +import java.util.Date; + +/** + * 能力评分表 + * + * @author dg + * @since 1.0 2022-04-24 + */ +@Data +@ContentRowHeight(20) +@HeadRowHeight(20) +@ColumnWidth(25) +public class ResourceScoreExcel { + @ExcelProperty(value = "主键", index = 0) + private Long id; + @ExcelProperty(value = "用户ID", index = 1) + private Long userId; + @ExcelProperty(value = "能力ID", index = 2) + private Long resourceId; + @ExcelProperty(value = "评分,1-5分,1分差评,5分好评", index = 3) + private Integer score; + @ExcelProperty(value = "评论内容", index = 4) + private String comment; + @ExcelProperty(value = "删除标志;0:正常;1:已删除", index = 5) + private Integer delFlag; + @ExcelProperty(value = "创建人", index = 6) + private Long creator; + @ExcelProperty(value = "创建时间", index = 7) + private Date createDate; + @ExcelProperty(value = "修改人", index = 8) + private Long updater; + @ExcelProperty(value = "修改时间", index = 9) + private Date updateDate; + @ExcelProperty(value = "备用字段1", index = 10) + private String note1; + @ExcelProperty(value = "备用字段2", index = 11) + private String note2; + @ExcelProperty(value = "备用字段3", index = 12) + private String note3; + @ExcelProperty(value = "备用字段4", index = 13) + private String note4; + @ExcelProperty(value = "备用字段5", index = 14) + private String note5; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/service/ResourceScoreService.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/service/ResourceScoreService.java new file mode 100644 index 00000000..51d27998 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/service/ResourceScoreService.java @@ -0,0 +1,18 @@ +package io.renren.modules.resourceScore.service; + +import io.renren.common.service.CrudService; +import io.renren.modules.resourceScore.dto.ResourceScoreDTO; +import io.renren.modules.resourceScore.entity.ResourceScoreEntity; + +/** + * 能力评分表 + * + * @author dg + * @since 1.0 2022-04-24 + */ +public interface ResourceScoreService extends CrudService { + + void deleteByIds(Long[] ids); + + ResourceScoreDTO selectByRidAndUid(Long resourceId); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceScore/service/impl/ResourceScoreServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceScore/service/impl/ResourceScoreServiceImpl.java new file mode 100644 index 00000000..edf71798 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceScore/service/impl/ResourceScoreServiceImpl.java @@ -0,0 +1,58 @@ +package io.renren.modules.resourceScore.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.common.constant.Constant; +import io.renren.modules.resourceScore.dao.ResourceScoreDao; +import io.renren.modules.resourceScore.dto.ResourceScoreDTO; +import io.renren.modules.resourceScore.entity.ResourceScoreEntity; +import io.renren.modules.resourceScore.service.ResourceScoreService; +import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.security.user.UserDetail; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * 能力评分表 + * + * @author dg + * @since 1.0 2022-04-24 + */ +@Service +public class ResourceScoreServiceImpl extends CrudServiceImpl implements ResourceScoreService { + + @Autowired + private ResourceScoreDao resourceScoreDao; + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + + + return wrapper; + } + + + @Override + public void deleteByIds(Long[] ids) { + resourceScoreDao.deleteByIds(ids); + } + + @Override + public ResourceScoreDTO selectByRidAndUid(Long resourceId) { + UserDetail user = SecurityUser.getUser(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(ObjectUtils.anyNotNull(resourceId), "resource_id", resourceId) + .eq("user_id", user.getId()) + .eq("del_flag", 0); + ResourceScoreDTO scoreDTO = new ResourceScoreDTO(); + ResourceScoreEntity scoreEntity = resourceScoreDao.selectOne(queryWrapper); + BeanUtils.copyProperties(scoreEntity, scoreDTO); + return scoreDTO; + } +} \ No newline at end of file diff --git a/renren-admin/src/main/resources/application-test.yml b/renren-admin/src/main/resources/application-test.yml index 42ef7767..7240a4e0 100644 --- a/renren-admin/src/main/resources/application-test.yml +++ b/renren-admin/src/main/resources/application-test.yml @@ -5,9 +5,9 @@ spring: druid: #MySQL driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true - username: renren - password: 123456 + url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: root + password: Hisense2019 initial-size: 10 max-active: 100 min-idle: 10 diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index e2e911a1..dcb21590 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -122,7 +122,7 @@ + select trc.* + from tb_resource_collection trc + + left join tb_data_resource tdr on trc.resource_id = tdr.id and tdr.del_flag = 0 + + where 1 = 1 + and trc.del_flag = 0 + and user_id = #{params.userId} + + and tdr.name like CONCAT('%',#{params.name},'%') + + + and tdr.type = #{params.type} + + order by trc.update_date desc, trc.create_date desc + limit ${pageNum}, ${pageSize} + + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resourceScore/ResourceScoreDao.xml b/renren-admin/src/main/resources/mapper/resourceScore/ResourceScoreDao.xml new file mode 100644 index 00000000..99128adf --- /dev/null +++ b/renren-admin/src/main/resources/mapper/resourceScore/ResourceScoreDao.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + update tb_resource_score + set del_flag = 1, + update_date = now() + where 1 = 1 + and id in + + #{item} + + + + \ No newline at end of file