Commit cf8559c8 by liangkaiping

copy

parent d09f09c2
# album-project
专辑
\ No newline at end of file
专辑
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>cloud-album</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.yizhi</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>cloud-album-api</artifactId>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-orm</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yizhi.album.application.feign;
import com.yizhi.album.application.vo.domain.AlStudentActivityRecord;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(name = "album", contextId = "AlStudentActivityRecordClient")
public interface AlStudentActivityRecordClient {
@GetMapping("/remote/alStudentActivityRecord/statistics/getRecordeAllWorkId")
public List<Long> getRecordeAllWorkId();
@GetMapping("/remote/alStudentActivityRecord/statistics/getAllRecordeByTimeLimit")
public List<AlStudentActivityRecord> getAllRecordeByTimeLimit(@RequestParam(value="startDate",required=true)String startDate,@RequestParam(value="endDate",required=true)String endDate,@RequestParam(value="relationId",required=true)Long relationId);
}
package com.yizhi.album.application.feign;
import com.yizhi.album.application.vo.domain.AlThemeActivity;
import com.yizhi.album.application.vo.AlbumVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@FeignClient(name = "album", contextId = "AlThemeActivityClient")
public interface AlThemeActivityClient {
@PostMapping("/remote/alThemeActivity/save")
public Boolean sava(@RequestBody AlbumVo vo);
@GetMapping("/remote/alThemeActivity/delete")
public Boolean delete(@RequestParam(name = "id") Long id);
@PostMapping("/remote/alThemeActivity/sortActivity")
public Boolean sortActivity(@RequestBody List<AlThemeActivity> list);
@PostMapping("/remote/alThemeActivity/unLock")
public Boolean unLock(@RequestBody AlThemeActivity activity);
@GetMapping("/remote/alThemeActivity/list")
public AlbumVo list(@RequestParam(name = "albumId") Long albumId);
}
package com.yizhi.album.application.feign;
import com.yizhi.album.application.vo.domain.AlTheme;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@FeignClient(name = "album", contextId = "AlThemeClient")
public interface AlThemeClient {
@GetMapping("/remote/alTheme/delete")
public Boolean delete(@RequestParam(name = "id")Long id);
@PostMapping("/remote/alTheme/sortActivity")
public int sortTheme(@RequestBody List<AlTheme> list);
@GetMapping("/remote/alTheme/updateName")
public Boolean updateName(@RequestParam(name = "id") Long id,@RequestParam(name = "albumId") Long albumId,@RequestParam(name = "name") String name);
}
package com.yizhi.album.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.vo.domain.AlbumClassify;
import com.yizhi.album.application.vo.AlbumClassifyVo;
import com.yizhi.album.application.vo.ApiAlbumClassifyVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@FeignClient(name = "album", contextId = "AlbumClassifyClient")
public interface AlbumClassifyClient {
@GetMapping("/remote/albumClassify/find/id")
public AlbumClassify getById(@RequestParam(name = "id") Long id);
@ApiOperation("添加分类")
@RequestMapping(value = "/remote/albumClassify/save", method = RequestMethod.POST)
public int saveClassify(@RequestBody AlbumClassify classify);
/**
* 检查是否存在分类名称
*
* @param name 分类名称
* @param parentId 分类的上级id(一级分类为0)
* @param siteId 站点id
* @param type 检查类型(1:新增,2:修改(需要传classifyId))
* @param classifyId 分类id,修改检查时用到
* @return 不存在返回true,存放相同名返回false
*/
@GetMapping("/remote/albumClassify/check/name")
public boolean checkExtisClassifyName(@RequestParam(name = "name") String name,
@RequestParam(name = "parentId", required = false) Long parentId, @RequestParam(name="siteId") Long siteId,
@RequestParam(name="type") Integer type, @RequestParam(name = "classifyId", required = false) Long classifyId);
@ApiOperation("分类删除")
@RequestMapping(value = "/remote/albumClassify/delete", method = RequestMethod.POST)
public int deleteClassify(@RequestBody AlbumClassify classify);
@ApiOperation("分类名称修改")
@RequestMapping(value = "/remote/albumClassify/update", method = RequestMethod.POST)
public int updateClassify(@RequestBody AlbumClassify classify);
@ApiOperation("分类查询")
@RequestMapping(value = "/remote/albumClassify/list", method = RequestMethod.GET)
public Page<AlbumClassify> listClassify(@RequestParam(required = false, name = "isStartHQ") Boolean isStartHQ,
@RequestParam(required = false,name = "name") String name, @RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds);
@ApiOperation("分类排序")
@RequestMapping(value = "/remote/albumClassify/sort", method = RequestMethod.POST)
public int sortClassify(@RequestBody List<AlbumClassify> list);
@ApiOperation("分类分页查询")
@RequestMapping(value = "/remote/albumClassify/page/list", method = RequestMethod.GET)
public Page<ApiAlbumClassifyVo> pageList(@RequestParam(name = "name", required = false) String name,
@RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds);
/**
* 验证同站点下 同级的分类不能重名
*
* @param name 分类名
* @param layer 分类层级
* @param companyId 企业名
* @param siteId 站点id
* @param id 分类id (修改的时候传入)
* @return Boolean
*/
@GetMapping("/remote/albumClassify/vail/name")
public Boolean vailName(@RequestParam(name = "name") String name, @RequestParam(name = "layer") Integer layer,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "id", required = false) Long id);
@GetMapping("/remote/albumClassify/getClassifyName")
public String getClassifyName(@RequestParam("classifyId") Long classifyId);
@GetMapping("/remote/albumClassify/classify/list")
public List<AlbumClassifyVo> listClassifyInfo(
@RequestParam(value="classifyId",required = false) Long classifyId);
}
package com.yizhi.album.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.vo.*;
import com.yizhi.album.application.vo.domain.Album;
import com.yizhi.album.application.vo.domain.AlbumVisibleRange;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.vo.DroolsVo;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@FeignClient(name = "album", contextId = "AlbumClient")
public interface AlbumClient {
/**
* 管理端专辑列表接口
* @param name
* @param alClassifyId
* @param status
* @param overed
* @param companyId
* @param siteId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/remote/album/list")
public Page<Album> list(@RequestParam(name = "name",required = false) String name,
@RequestParam(name = "alClassifyId",required = false) Long alClassifyId, @RequestParam(name = "status",required = false) Integer status,
@RequestParam(name = "overed",required = false) Integer overed, @RequestParam(name = "companyId") Long companyId,
@RequestParam(name = "siteId") Long siteId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize);
/**
* 管理端专辑详情接口
* @param id
* @return
*/
@GetMapping("/remote/album/get")
public Album get(@RequestParam(name = "id") Long id);
/**
* 管理端专辑主体新增接口
* @param albumVo
* @return
*/
@PostMapping("/remote/album/save")
public AlbumVo save(@RequestBody AlbumVo albumVo);
/**
* 管理端专辑主体修改接口
* @param albumVo
* @return
*/
@PostMapping("/remote/album/update")
public Boolean update(@RequestBody AlbumVo albumVo);
/**
* 专辑下架 当专辑为上架状态 1 时 才下架
*
* @param albumId 参数中有专辑主键id
* @return
*/
@GetMapping("/remote/album/down")
public Boolean down(@RequestParam(name = "albumId") Long albumId);
/**
* 专辑上架
*
* @param albumId 参数中有专辑主键id
* @return
*/
@Deprecated
@GetMapping(value = "/remote/album/up")
public Boolean up(@RequestParam(name = "albumId") Long albumId,@RequestParam(name = "type")Integer type);
/**
* 专辑上架
*
* @param albumId 参数中有专辑主键id
* @return
*/
@GetMapping(value = "/remote/album/up2")
public Integer up2(@RequestParam(name = "albumId") Long albumId,@RequestParam(name = "type")Integer type);
/**
* 专辑可见范围新增
* @param albumVisableRanges
* @return
*/
@PostMapping("/remote/album/authorize/insert")
public Boolean insertAlbumVisibleRanges(@RequestBody List<AlbumVisibleRange> albumVisableRanges);
/**
* 专辑可见范围查看
* @param albumId
* @return
*/
@GetMapping("/remote/album/VisibleRange")
public List<AlbumVisibleRange> VisibleRange(@RequestParam("albumId") Long albumId);
/**
* 专辑课程清单导出
* @param albumId
* @return
*/
@GetMapping("/remote/album/activity/export")
public Map<String, Object> activityExport(@RequestParam(name = "albumId", required = true) Long albumId);
/**
* 专辑列表查询
* @param name
* @param companyId
* @param siteId
* @return
*/
@GetMapping("/remote/album/searchList")
public List<Album> searchList(@RequestParam(name = "name",required = false) String name,@RequestParam(name = "ids",required = false) List<Long> ids,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId);
/**
* 学员端专辑首页列表
* @param apiSearchAlbumVo
* @return
*/
@PostMapping("/remote/album/searchPage")
public Page<ApiListAlbumVo> searchPage(@RequestBody ApiSearchAlbumVo apiSearchAlbumVo);
/**
* 学员端我的专辑
* @param siteId
* @param accountId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/remote/album/getMyAlbumList")
public Page<ApiListAlbumVo> getMyAlbumList(@RequestParam("siteId") Long siteId,
@RequestParam("accountId") Long accountId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize);
/**
* 学员端专辑详情
* @param albumId
* @param accountId
* @param siteId
* @param companyId
* @return
*/
@GetMapping("/remote/album/getDeatil")
public AlbumDetailVo getDeatil(@RequestParam("albumId") Long albumId, @RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId);
/**
* 学员端专辑内容
* @param albumId
* @param accountId
* @param siteId
* @param companyId
* @param type
* @param display
* @return
*/
@GetMapping("/remote/album/getContent")
public List<AlbumThemeVo> getContent(@RequestParam("albumId") Long albumId,
@RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId,
@RequestParam("companyId") Long companyId, @RequestParam("type") Integer type,
@RequestParam("display") Integer display);
/**
* 首页获取专辑列表
* @param ids
* @return
*/
@PostMapping("/remote/album/getPortalList")
public List<ApiListAlbumVo> getPortalList(@RequestBody List<Long> ids);
/**
* 我的订阅专辑
* @param vo
* @return
*/
@PostMapping("/remote/album/getMySubscribePage")
public Page<ApiListAlbumVo> getMySubscribePage(@RequestBody ApiSearchAlbumVo vo);
@PostMapping("/remote/album/delete")
public Integer delete(@RequestBody List<Long> ids);
@PostMapping("/remote/album/getMyAlbumCount")
public Integer getMyAlbumCount(@RequestBody RequestContext context);
@PostMapping("/remote/album/getSubcribeNum")
public Integer getSubcribeNum(@RequestBody List<Long> ids);
@GetMapping("/remote/album/getPageByDrools")
Page<DroolsVo> getPageByDrools(@RequestParam("field") String field,
@RequestParam(value = "value", required = false) String value,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize);
/**
* 日历任务获取专辑列表
* @return
*/
@PostMapping("/remote/album/getPageToCalendar")
public Page<AlbumCalendarVo> getPageToCalendar(@ApiParam("paramVo") @RequestBody CalendarTaskParamVo paramVo);
@PostMapping("/remote/album/listNoIds")
public Page<Album> listNoIds(@RequestBody ApiSearchAlbumVo vo);
}
package com.yizhi.album.application.feign;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@FeignClient(name = "album", contextId = "AlbumJobHandleClient")
public interface AlbumJobHandleClient {
/**
* 定时任务执行实际的处理逻辑类
* 定时任务业务逻辑处理
*
* @param
* @return
*/
@GetMapping("/remote/album/albumUnLock")
@ApiOperation(value = "定时解锁专辑课程", response = String.class)
public void unLockCourse();
}
package com.yizhi.album.application.feign;
import com.yizhi.album.application.vo.domain.ClassifyStrategy;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "album", contextId = "ClassifyStrategyClient")
public interface ClassifyStrategyClient {
@GetMapping("/remote/classifyStrategy/update")
public ClassifyStrategy update(@RequestParam(value = "type", required = true) Integer type,@RequestParam(value = "status", required = true) Integer status);
@GetMapping("/remote/classifyStrategy/get")
public ClassifyStrategy get(@RequestParam(value = "companyId", required = true) Long companyId,@RequestParam(value = "siteId", required = true) Long siteId);
}
package com.yizhi.album.application.feign;
import com.yizhi.album.application.vo.AlbumVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(name = "album", contextId = "StatisticsAlbumClient")
public interface StatisticsAlbumClient {
/**
* 所有专辑
* @param companyId
* @param siteId
* @return
*/
@GetMapping("/remote/statisticsAlbum/getAllAlbums")
public List<AlbumVo> getAllAlbums(@RequestParam(name = "companyId",required = false)Long companyId,@RequestParam(name = "siteId",required = false)Long siteId);
}
package com.yizhi.album.application.vo;
import java.util.List;
import com.yizhi.album.application.vo.domain.AlThemeActivity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class AlThemeVo {
@ApiModelProperty(value = "专辑主题id")
private Long id;
@ApiModelProperty(value = "专辑id")
private Long albumId;
@ApiModelProperty(value = "主题名称")
private String name;
@ApiModelProperty(value = "排序字段")
private Integer sort;
@ApiModelProperty(value = "主题活动")
private List<AlThemeActivity> activities;
@ApiModelProperty(value = "主题活动删除id")
private List<Long> deleteList;
}
package com.yizhi.album.application.vo;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "专辑内容--活动vo")
public class AlbumActivityVo {
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "专辑id")
private Long albumId;
@ApiModelProperty(value = "关联的活动的id")
private Long relationId;
@ApiModelProperty(value = "活动名称,从活动那边取过来,不能自定义")
private String name;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "当前状态")
private String status;
@ApiModelProperty(value = "解锁状态 0已解锁 1发布及解锁 2自定义解锁")
private Integer unlock;
@ApiModelProperty(value = "课程更新时间")
private Date updateTime;
@ApiModelProperty(value = "课程更新标识")
private Integer isNew;
@ApiModelProperty(value = "课程时长")
private Long duration;
}
package com.yizhi.album.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class AlbumCalendarVo {
@ApiModelProperty(value = "专辑主键id")
private Long id;
@ApiModelProperty(value = "专辑名称")
private String name;
@ApiModelProperty(value = "专辑封面图")
private String image;
@ApiModelProperty("业务按钮状态")
public List<String> taskButtonStatus;
@ApiModelProperty(value = "日历任务开始时间:enable-task不为0时,有值")
private Date taskStartDate;
@ApiModelProperty(value = "日历任务结束时间:enable-task不为0时,有值")
private Date taskEndDate;
}
package com.yizhi.album.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class AlbumClassifyVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "层级")
private Integer layer;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "编码")
private String code;
@ApiModelProperty(value = "状态")
private Integer status;
private String createTime;
private Integer total;
@ApiModelProperty(value = "状态")
private Integer sort;
@ApiModelProperty(value = "描述")
private String description;
@ApiModelProperty(value = "是否存在子节点")
private Boolean existChildNode = false;
}
package com.yizhi.album.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class AlbumDetailVo {
@ApiModelProperty(value = "专辑id")
private Long id;
@ApiModelProperty(value = "专辑名称")
private String name;
@ApiModelProperty(value = "专辑封面图")
private String image;
@ApiModelProperty(value = "分类id")
private Long classifyId;
@ApiModelProperty(value = "学习时长")
private Long duration;
@ApiModelProperty(value = "学习数")
private Integer studyNum;
@ApiModelProperty(value = "最新解锁时间")
private Date unLockTime;
@ApiModelProperty("完成状态 0:连载中,1已完结")
private Integer overed;
@ApiModelProperty(value = "完成百分比")
private Integer percent;
@ApiModelProperty(value = "专辑介绍")
private String description;
private String tags;
@ApiModelProperty(value = "评论设置0上架评论及评分1关闭评论")
private Integer commentEnable;
@ApiModelProperty(value = "专辑资料 0显示 1不显示 默认显示")
private Integer documentEnable;
@ApiModelProperty(value = "显示模式 0全部显示 1只显示已解锁课程 默认全部显示")
private Integer display;
@ApiModelProperty(value = "专辑是否订阅 0未订阅 1已订阅")
private Integer subscribe;
@ApiModelProperty(value = "订阅数")
private Integer subscribeNum;
@ApiModelProperty(value = "已完结状态下;课程数量")
private Integer courseNum;
}
package com.yizhi.album.application.vo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "专辑内容--主题vo")
public class AlbumThemeVo {
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "主题名称")
private String name;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "课程更新时间")
private Date updateTime;
@ApiModelProperty(value = "课程更新标识")
private Integer isNew;
@ApiModelProperty(value = "活动集合")
private List<AlbumActivityVo> list = new ArrayList<AlbumActivityVo>();
}
package com.yizhi.album.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class AlbumVo {
@ApiModelProperty(value = "专辑主键id")
private Long id;
@ApiModelProperty(value = "专辑名称")
private String name;
@ApiModelProperty(value = "0 未上架 1 已上架 2 草稿")
private Integer shelves;
@ApiModelProperty(value = "分类id")
private Long classifyId;
@ApiModelProperty(value = "分类名称")
private String classifyName;
@ApiModelProperty(value = "专辑封面图")
private String image;
@ApiModelProperty(value = "专辑介绍")
private String description;
private String tags;
@ApiModelProperty(value = "可见范围 0 游客 1 平台用户 2 指定范围")
private Integer scope;
@ApiModelProperty(value = "评论设置0上架评论及评分1关闭评论")
private Integer commentEnable;
private Long companyId;
private Long orgId;
private Long siteId;
private Long createById;
private String createByName;
@ApiModelProperty("创建时间,列表的时候用")
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
@ApiModelProperty(value = "专辑资料 0显示 1不显示 默认显示")
private Integer documentEnable;
@ApiModelProperty(value = "0:默认未删除;1表示删除")
private Integer delFlg;
@ApiModelProperty(value = "完成状态 0连载中 1已完结")
private Integer overed;
@ApiModelProperty(value = "显示模式 0全部显示 1只显示已解锁课程 默认全部显示")
private Integer display;
@ApiModelProperty(value = "连载中最近解锁时间")
private String newest;
@ApiModelProperty(value = "课程时长")
private Long duration;
@ApiModelProperty(value = "学习人数")
private Integer studyCount;
@ApiModelProperty(value = "主题列表")
private List<AlThemeVo> list;
@ApiModelProperty(value = "删除的主题id")
private List<Long> deleteList;
@ApiModelProperty(value = "评论人数")
private Integer commentCount;
@ApiModelProperty(value = "订阅人数")
private Integer subscribeCount;
@ApiModelProperty(value = "未解锁课程数")
private Integer lockNum;
@ApiModelProperty(value = "专辑是否在日历中显示 默认为 0:不开启 1:开启")
private Integer enableTask;
@ApiModelProperty(value = "日历任务开始时间:enable-task不为0时,有值")
private Date taskStartDate;
@ApiModelProperty(value = "日历任务结束时间:enable-task不为0时,有值")
private Date taskEndDate;
}
package com.yizhi.album.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class ApiAlbumClassifyVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "父id ")
private Long parentId;
@ApiModelProperty(value = "层级")
private Integer layer;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "编码")
private String code;
@ApiModelProperty(value = "备注")
private String description;
@ApiModelProperty(value = "状态")
private Integer status;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
private Long orgId;
private Long companyId;
private Long siteId;
@ApiModelProperty(value = "顶层节点id")
private Long rootId;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "分类路径")
private String path;
@ApiModelProperty(value = "上一个主键ID")
private Long moveUpId = -1L;
@ApiModelProperty(value = "下一个主键ID")
private Long moveDownId = -1L;
private List<ApiAlbumClassifyVo> children = new ArrayList<ApiAlbumClassifyVo>();
}
package com.yizhi.album.application.vo;
import java.util.Date;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Api(
tags = {"ApiListAlbumVo"},
description = "课程接对象"
)
@Data
public class ApiListAlbumVo {
@ApiModelProperty(value = "专辑id")
private Long id;
@ApiModelProperty(value = "专辑名称")
private String name;
@ApiModelProperty(value = "专辑封面图")
private String image;
@ApiModelProperty(value = "分类id")
private Long classifyId;
@ApiModelProperty(value = "学习时长")
private Long duration;
@ApiModelProperty(value = "学习数")
private Integer studyNum;
@ApiModelProperty(value = "最新解锁时间")
private Date unLockTime;
@ApiModelProperty("完成状态 0:连载中,1已完结")
private Integer overed;
@ApiModelProperty(value = "完成百分比")
private Integer percent;
@ApiModelProperty(value = "更新标识")
private Integer isNew;
@ApiModelProperty(value = "已完结状态下;课程数量")
private Integer courseNum;
}
package com.yizhi.album.application.vo;
import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ApiSearchAlbumVo {
@ApiModelProperty(value = "专辑名称")
private String name;
@ApiModelProperty(value = "分类id")
private Long classifyId;
@ApiModelProperty(value = "当前用户学员")
private Long accountId;
private Long companyId;
private Long siteId;
private Integer pageNo;
private Integer pageSize;
private List<Long> ids;
}
package com.yizhi.album.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class CalendarTaskParamVo {
@ApiModelProperty("时间参数")
public Date date;
@ApiModelProperty("业务类型")
public Integer taskType = 0;
@ApiModelProperty("当前页数")
public Integer pageNo;
@ApiModelProperty("页内条数")
public Integer pageSize;
}
package com.yizhi.album.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑分类策略
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "ClassifyStrategyVO", description = "专辑分类策略")
public class ClassifyStrategyVO {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "策略类型 0平铺式 1展开式 默认平铺式")
private Integer type;
@ApiModelProperty(value = "状态")
private Integer status;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
private Long companyId;
private Long siteId;
}
package com.yizhi.album.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 学员完成专辑活动记录
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlStudentActivityRecord", description = "学员完成专辑活动记录")
public class AlStudentActivityRecord {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "学员id")
private Long accountId;
@ApiModelProperty(value = "冗余专辑id")
private Long albumId;
@ApiModelProperty(value = "课程id")
private Long relationId;
@ApiModelProperty(value = "若是课程,需要记录学习时长")
private Long seconds;
@ApiModelProperty(value = "是否完成(1是,0否),默认未完成。")
private Integer finished;
@ApiModelProperty(value = "完成时间")
private Date finishDate;
@ApiModelProperty(value = "所属站点id")
private Long siteId;
}
package com.yizhi.album.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑 - 主题
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlTheme", description = "专辑 - 主题")
public class AlTheme {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "所属专辑id")
private Long albumId;
@ApiModelProperty(value = "主题名称")
private String name;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "是否删除(1是,0否),默认否")
private Integer deleted;
@ApiModelProperty(value = "创建者id")
private Long createById;
@ApiModelProperty(value = "创建者名称")
private String createByName;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新者id")
private Long updateById;
@ApiModelProperty(value = "修改者名称")
private String updateByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "站点id")
private Long siteId;
@ApiModelProperty(value = "组织id")
private Long orgId;
@ApiModelProperty(value = "企业id")
private Long companyId;
}
package com.yizhi.album.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 主题中的课程
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlThemeActivity", description = "主题中的课程")
public class AlThemeActivity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "冗余专辑id")
private Long albumId;
@ApiModelProperty(value = "主题id")
private Long themeId;
@ApiModelProperty(value = "主题名称")
private String themeName;
@ApiModelProperty(value = "课程id")
private Long relationId;
@ApiModelProperty(value = "课程code")
private String relationCode;
@ApiModelProperty(value = "课程名称")
private String name;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "是否删除(1是,0否),默认否")
private Integer deleted;
@ApiModelProperty(value = "解锁状态 0已解锁 1发布及解锁 2自定义解锁")
private Integer unlock;
@ApiModelProperty(value = "解锁时间")
private Date unlockTime;
@ApiModelProperty(value = "创建者id")
private Long createById;
@ApiModelProperty(value = "创建者名称")
private String createByName;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新者id")
private Long updateById;
@ApiModelProperty(value = "修改者名称")
private String updateByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "站点id")
private Long siteId;
@ApiModelProperty(value = "组织id")
private Long orgId;
@ApiModelProperty(value = "企业id")
private Long companyId;
}
package com.yizhi.album.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑表
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "Album", description = "专辑表")
public class Album {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "专辑名称")
private String name;
@ApiModelProperty(value = "专辑封面图")
private String image;
@ApiModelProperty(value = "专辑介绍")
private String description;
@ApiModelProperty(value = "自定义关键字")
private String tags;
@ApiModelProperty(value = "0 未上架 1 已上架 2草稿")
private Integer shelves;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
private Long companyId;
private Long orgId;
private Long siteId;
@ApiModelProperty(value = "分类id")
private Long classifyId;
@ApiModelProperty(value = "可见范围 1 平台用户 2 指定范围 默认全平台可见")
private Integer scope;
@ApiModelProperty(value = "专辑评论 0显示 1不显示 默认显示")
private Integer commentEnable;
@ApiModelProperty(value = "专辑资料 0显示 1不显示 默认显示")
private Integer documentEnable;
@ApiModelProperty(value = "0:默认未删除;1表示删除")
private Integer delFlg;
@ApiModelProperty(value = "完成状态 0连载中 1已完结")
private Integer overed;
@ApiModelProperty(value = "显示模式 0全部显示 1只显示已解锁课程 默认全部显示")
private Integer display;
@ApiModelProperty(value = "专辑是否在日历中显示 默认为 0:不开启 1:开启")
private Integer enableTask;
@ApiModelProperty(value = "日历任务开始时间:enable-task不为0时,有值")
private Date taskStartDate;
@ApiModelProperty(value = "日历任务结束时间:enable-task不为0时,有值")
private Date taskEndDate;
}
package com.yizhi.album.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑分类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlbumClassify", description = "专辑分类")
public class AlbumClassify {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "父id ")
private Long parentId;
@ApiModelProperty(value = "层级")
private Integer layer;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "分类编码")
private String code;
@ApiModelProperty(value = "备注")
private String description;
@ApiModelProperty(value = "状态")
private Integer status;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
private Long orgId;
private Long companyId;
private Long siteId;
@ApiModelProperty(value = "顶层节点id")
private Long rootId;
@ApiModelProperty(value = "排序")
private Integer sort;
private String path;
}
package com.yizhi.album.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 专辑可见范围表
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@ApiModel(value = "AlbumVisableRange", description = "专辑可见范围表")
@Data
public class AlbumVisibleRange {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "专辑主键_ID,外键")
private Long albumId;
@ApiModelProperty(value = "1用户 2组织")
private Integer type;
@ApiModelProperty(value = "存放人或组织的ID")
private Long relationId;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "真实姓名")
private String fullName;
@ApiModelProperty(value = "0删除 1有效,默认有效")
private Integer state;
@ApiModelProperty(value = "站点_ID")
private Long siteId;
@ApiModelProperty(value = "企业_ID")
private Long companyId;
}
package com.yizhi.album.application.vo.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑分类策略
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "ClassifyStrategy", description = "专辑分类策略")
public class ClassifyStrategy {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "策略类型 0平铺式 1展开式 默认平铺式")
private Integer type;
@ApiModelProperty(value = "状态")
private Integer status;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
private Long companyId;
private Long siteId;
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>cloud-album</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>cloud-album-service</artifactId>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-album-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-comment-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-point-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-job-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-site-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-course-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-newMessage-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-course-studyLog-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>-->
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-orm</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- deploy 时跳过该模块 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yizhi.album.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.yizhi"})
@ComponentScan(basePackages = {"com.yizhi"})
public class AlbumApplication {
public static void main(String[] args) {
SpringApplication.run(AlbumApplication.class, args);
}
}
package com.yizhi.album.application;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("专辑")
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.yizhi.album.application"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("专辑")
//版本
.version("1.0")
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("docs.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package com.yizhi.album.application.controller;
import com.yizhi.album.application.mapper.AlStudentActivityRecordMapper;
import com.yizhi.album.application.vo.domain.AlStudentActivityRecord;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 学员完成专辑活动记录 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/alStudentActivityRecord")
public class AlStudentActivityRecordController {
@Autowired
private AlStudentActivityRecordMapper aStudentActivityRecordMapper;
@GetMapping("/statistics/getRecordeAllWorkId")
public List<Long> getRecordeAllWorkId(){
return aStudentActivityRecordMapper.getRecordeAllWorkId();
}
@GetMapping("/statistics/getAllRecordeByTimeLimit")
public List<AlStudentActivityRecord> getAllRecordeByTimeLimit(@RequestParam(value="startDate",required=true)String startDate, @RequestParam(value="endDate",required=true)String endDate, @RequestParam(value="relationId",required=true)Long relationId){
List<AlStudentActivityRecord> alStudentActivityRecords =
BeanCopyListUtil.copyListProperties(aStudentActivityRecordMapper.getAllRecordeByTimeLimit(startDate, endDate, relationId), AlStudentActivityRecord::new);
return alStudentActivityRecords;
}
}
package com.yizhi.album.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.domain.Album;
import com.yizhi.album.application.service.IAlThemeActivityService;
import com.yizhi.album.application.service.IAlThemeService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.vo.AlThemeVo;
import com.yizhi.album.application.vo.AlbumVo;
import com.yizhi.album.application.vo.domain.AlThemeActivity;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p>
* 主题中的课程 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/alThemeActivity")
public class AlThemeActivityControllerV2 {
private Logger logger = LoggerFactory.getLogger(AlThemeActivityControllerV2.class);
@Autowired
private IAlbumService albumService;
@Autowired
private IAlThemeActivityService alThemeActivityService;
@Autowired
private IAlThemeService alThemeService;
@Autowired
IdGenerator idGenerator;
@PostMapping("/save")
public Boolean sava(@RequestBody AlbumVo vo) {
RequestContext context = ContextHolder.get();
Long siteId = context.getSiteId();
Long accountId = context.getAccountId();
Long companyId = context.getCompanyId();
Long orgId = context.getOrgId();
Date date = new Date();
String name = context.getAccountName();
List<AlThemeVo> themeVos = vo.getList();
Album album = albumService.selectById(vo.getId());
album.setOvered(vo.getOvered());
album.setUpdateById(accountId);
album.setUpdateByName(name);
album.setUpdateTime(date);
album.setDisplay(vo.getDisplay());
albumService.updateById(album);
//删除主题
if (CollectionUtils.isNotEmpty(vo.getDeleteList())) {
for(Long id:vo.getDeleteList()) {
AlTheme theme = alThemeService.selectById(id);
theme.setDeleted(1);
theme.setUpdateById(accountId);
theme.setUpdateByName(name);
theme.setUpdateTime(date);
alThemeService.updateById(theme);
}
}
if (CollectionUtils.isNotEmpty(themeVos)) {
for(AlThemeVo themeVo:themeVos) {
//删除主题中活动
if (CollectionUtils.isNotEmpty(themeVo.getDeleteList())) {
for(Long id:themeVo.getDeleteList()) {
com.yizhi.album.application.domain.AlThemeActivity activity = alThemeActivityService.selectById(id);
activity.setDeleted(1);
activity.setUpdateById(accountId);
activity.setUpdateByName(name);
activity.setUpdateTime(date);
alThemeActivityService.updateById(activity);
}
}
AlTheme theme = new AlTheme();
if (themeVo.getId()==null||themeVo.getId()==0) {
if (!alThemeService.vaidName(null,vo.getId(), themeVo.getName(), siteId)) {
return Boolean.FALSE;
}
theme.setId(idGenerator.generate());
theme.setCreateById(accountId);
theme.setCreateByName(name);
theme.setCreateTime(date);
theme.setSiteId(siteId);
theme.setCompanyId(companyId);
theme.setOrgId(orgId);
}else {
theme.setId(themeVo.getId());
if (!alThemeService.vaidName(themeVo.getId(),vo.getId(), themeVo.getName(), siteId)) {
return Boolean.FALSE;
}
}
theme.setAlbumId(themeVo.getAlbumId());
theme.setName(themeVo.getName());
theme.setSort(themeVo.getSort());
theme.setDeleted(0);
theme.setUpdateById(accountId);
theme.setUpdateByName(name);
theme.setUpdateTime(date);
alThemeService.insertOrUpdate(theme);
for(AlThemeActivity activityVo:themeVo.getActivities()) {
AlThemeActivity activity = new AlThemeActivity();
if (activityVo.getId()==null||activityVo.getId()==0) {
activity.setId(idGenerator.generate());
activity.setCreateById(accountId);
activity.setCreateByName(name);
activity.setCreateTime(date);
activity.setSiteId(siteId);
activity.setCompanyId(companyId);
activity.setOrgId(orgId);
}else {
activity.setId(activityVo.getId());
}
activity.setAlbumId(activityVo.getAlbumId());
activity.setThemeId(theme.getId());
activity.setThemeName(theme.getName());
activity.setRelationId(activityVo.getRelationId());
activity.setRelationCode(activityVo.getRelationCode());
activity.setName(activityVo.getName());
activity.setSort(activityVo.getSort());
activity.setDeleted(0);
// activity.setUnlock(activityVo.getUnlock());
activity.setUnlock(vo.getShelves() == 1 && activityVo.getUnlock() == 1 ? 0 : activityVo.getUnlock());
activity.setUnlockTime(activityVo.getUnlockTime());
com.yizhi.album.application.domain.AlThemeActivity alThemeActivity = new com.yizhi.album.application.domain.AlThemeActivity();
BeanUtils.copyProperties(activity, alThemeActivity);
alThemeActivityService.insertOrUpdate(alThemeActivity);
}
}
}
return Boolean.TRUE;
}
@GetMapping("/delete")
public Boolean delete(@RequestParam(name = "id")Long id) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
boolean b = false;
com.yizhi.album.application.domain.AlThemeActivity activity = new com.yizhi.album.application.domain.AlThemeActivity();
BeanUtils.copyProperties(alThemeActivityService.selectById(id), activity);
/*AlThemeActivity activity = alThemeActivityService.selectById(id);*/
if (activity!=null) {
activity.setDeleted(1);
activity.setUpdateById(accountId);
activity.setUpdateByName(name);
activity.setUpdateTime(date);
b = alThemeActivityService.updateById(activity);
}
return b;
}
@PostMapping("/sortActivity")
public Boolean sortActivity(@RequestBody List<AlThemeActivity> list) {
logger.info("管理端传入要排序的ID列表==========================:" + list);
List<com.yizhi.album.application.domain.AlThemeActivity> alThemeActivities =
BeanCopyListUtil.copyListProperties(list, com.yizhi.album.application.domain.AlThemeActivity::new);
return alThemeActivityService.sortActivity(alThemeActivities);
}
@PostMapping("/unLock")
public Boolean unLock(@RequestBody AlThemeActivity activity) {
logger.info("管理端传入定时解锁的活动==========================:" + activity);
com.yizhi.album.application.domain.AlThemeActivity alThemeActivity = new com.yizhi.album.application.domain.AlThemeActivity();
BeanUtils.copyProperties(activity, alThemeActivity);
return alThemeActivityService.updateById(alThemeActivity);
}
@GetMapping("/list")
public AlbumVo list(@RequestParam(name = "albumId")Long albumId){
AlbumVo albumVo = new AlbumVo();
Album album = albumService.selectById(albumId);
albumVo.setId(album.getId());
albumVo.setName(album.getName());
albumVo.setShelves(album.getShelves());
albumVo.setClassifyId(album.getClassifyId());
albumVo.setImage(album.getImage());
albumVo.setDescription(album.getDescription());
albumVo.setTags(album.getTags());
albumVo.setScope(album.getScope());
albumVo.setCommentEnable(album.getCommentEnable());
albumVo.setDocumentEnable(album.getDocumentEnable());
albumVo.setOvered(album.getOvered());
albumVo.setDisplay(album.getDisplay());
List<AlThemeVo> list = new ArrayList<AlThemeVo>();
AlTheme theme = new AlTheme();
theme.setAlbumId(albumId);
theme.setDeleted(0);
EntityWrapper<AlTheme> wrapper = new EntityWrapper<AlTheme>(theme);
wrapper.orderBy("sort", true);
List<AlTheme> themes = alThemeService.selectList(wrapper);
for(AlTheme alTheme:themes) {
AlThemeVo themeVo = new AlThemeVo();
themeVo.setAlbumId(albumId);
themeVo.setId(alTheme.getId());
themeVo.setName(alTheme.getName());
List<com.yizhi.album.application.domain.AlThemeActivity> activities = new ArrayList<com.yizhi.album.application.domain.AlThemeActivity>();
com.yizhi.album.application.domain.AlThemeActivity activity = new com.yizhi.album.application.domain.AlThemeActivity();
activity.setThemeId(alTheme.getId());
activity.setDeleted(0);
EntityWrapper<com.yizhi.album.application.domain.AlThemeActivity> entityWrapper = new EntityWrapper<com.yizhi.album.application.domain.AlThemeActivity>(activity);
entityWrapper.orderBy("sort", true);
activities = alThemeActivityService.selectList(entityWrapper);
activities.forEach(e->e.setThemeName(alTheme.getName()));
List<AlThemeActivity> alThemeActivities = BeanCopyListUtil.copyListProperties(activities, AlThemeActivity::new);
themeVo.setActivities(alThemeActivities);
list.add(themeVo);
}
albumVo.setList(list);
return albumVo;
}
}
package com.yizhi.album.application.controller;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.service.IAlThemeService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
* <p>
* 专辑 - 主题 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/alTheme")
public class AlThemeController {
private Logger logger = LoggerFactory.getLogger(AlThemeActivityControllerV2.class);
@Autowired
private IAlbumService albumService;
@Autowired
private IAlThemeService alThemeService;
@Autowired
IdGenerator idGenerator;
@GetMapping("/delete")
public Boolean delete(@RequestParam(name = "id")Long id) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
boolean b = false;
AlTheme theme = alThemeService.selectById(id);
if (theme!=null) {
theme.setDeleted(1);
theme.setUpdateById(accountId);
theme.setUpdateByName(name);
theme.setUpdateTime(date);
b = alThemeService.updateById(theme);
}
return b;
}
@PostMapping("/sortActivity")
public int sortTheme(@RequestBody List<AlTheme> list) {
logger.info("管理端传入要排序的ID列表==========================:" + list);
return alThemeService.sortTheme(list);
}
@GetMapping("/updateName")
public Boolean updateName(@RequestParam(name = "id") Long id,@RequestParam(name = "albumId") Long albumId,@RequestParam(name = "name") String name) {
RequestContext context = ContextHolder.get();
Long siteId = context.getSiteId();
Long accountId = context.getAccountId();
String accountName = context.getAccountName();
Date date = new Date();
Boolean vaidName = alThemeService.vaidName(id,albumId, name, siteId);
if (!vaidName) {
return Boolean.FALSE;
}
AlTheme theme = alThemeService.selectById(id);
theme.setName(name);
theme.setUpdateById(accountId);
theme.setUpdateByName(accountName);
theme.setUpdateTime(date);
alThemeService.updateById(theme);
return Boolean.TRUE;
}
}
package com.yizhi.album.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.domain.AlbumClassify;
import com.yizhi.album.application.service.IAlbumClassifyService;
import com.yizhi.album.application.vo.AlbumClassifyVo;
import com.yizhi.album.application.vo.ApiAlbumClassifyVo;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.orm.util.QueryUtil;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 专辑分类 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/albumClassify")
public class AlbumClassifyController {
private Logger logger = LoggerFactory.getLogger(AlbumClassifyController.class);
@Autowired
IdGenerator idGenerator;
@Autowired
private IAlbumClassifyService albumClassifyService;
@GetMapping("/find/id")
public com.yizhi.album.application.vo.domain.AlbumClassify getById(@RequestParam(name = "id") Long id) {
com.yizhi.album.application.vo.domain.AlbumClassify albumClassify = new com.yizhi.album.application.vo.domain.AlbumClassify();
BeanUtils.copyProperties(albumClassifyService.selectById(id), albumClassify);
return albumClassify;
}
@ApiOperation("添加分类")
@RequestMapping(value = "/save", method = RequestMethod.POST)
public int saveClassify(@RequestBody AlbumClassify classify) {
return albumClassifyService.saveClassify(classify);
}
/**
* 检查是否存在分类名称
*
* @param name 分类名称
* @param parentId 分类的上级id(一级分类为0)
* @param siteId 站点id
* @param type 检查类型(1:新增,2:修改(需要传classifyId))
* @param classifyId 分类id,修改检查时用到
* @return 不存在返回true,存放相同名返回false
*/
@GetMapping("/check/name")
public boolean checkExtisClassifyName(@RequestParam(name = "name") String name,
@RequestParam(name = "parentId", required = false) Long parentId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "type") Integer type, @RequestParam(name = "classifyId", required = false) Long classifyId) {
return albumClassifyService.checkExtisClassifyName(name, parentId, siteId, type, classifyId);
}
@ApiOperation("分类删除")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public int deleteClassify(@RequestBody AlbumClassify classify) {
return albumClassifyService.deleteClassify(classify.getId());
}
@ApiOperation("分类名称修改")
@RequestMapping(value = "/update", method = RequestMethod.POST)
public int updateClassify(@RequestBody AlbumClassify classify) {
return albumClassifyService.updateClassify(classify);
}
@ApiOperation("分类查询")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Page<com.yizhi.album.application.vo.domain.AlbumClassify> listClassify(@RequestParam(required = false, name = "isStartHQ") Boolean isStartHQ,
@RequestParam(required = false,name = "name") String name, @RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds) {
Page<com.yizhi.album.application.vo.domain.AlbumClassify> page = new Page<>();
Page<AlbumClassify> albumClassifyPage = albumClassifyService.listClassify(name, pageNo, pageSize, companyId, orgIds, siteId, isStartHQ);
BeanUtils.copyProperties(albumClassifyPage, page);
page.setRecords(BeanCopyListUtil.copyListProperties(albumClassifyPage.getRecords(), com.yizhi.album.application.vo.domain.AlbumClassify::new));
return page;
}
@ApiOperation("分类排序")
@RequestMapping(value = "/sort", method = RequestMethod.POST)
public int sortClassify(@RequestBody List<AlbumClassify> list) {
logger.info("管理端传入要排序的ID列表==========================:" + list);
return albumClassifyService.updateClassiyfsort(list);
}
@ApiOperation("分类分页查询")
@RequestMapping(value = "/page/list", method = RequestMethod.GET)
public Page<ApiAlbumClassifyVo> pageList(@RequestParam(name = "name", required = false) String name,
@RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds) {
logger.info("分类分页查询orgIds=", orgIds == null ? 0 : orgIds.size());
Page<ApiAlbumClassifyVo> page = albumClassifyService.selectListByCompanyId(companyId, name, orgIds, siteId,
pageNo, pageSize);
List<AlbumClassify> classifies2 = albumClassifyService.selectClassifyByLayer(companyId, siteId, 2);
List<AlbumClassify> classifies3 = albumClassifyService.selectClassifyByLayer(companyId, siteId, 3);
Map<Long, List<ApiAlbumClassifyVo>> map3 = new HashMap<Long, List<ApiAlbumClassifyVo>>();
for (AlbumClassify c3 : classifies3) {
if (map3.containsKey(c3.getParentId())) {
List<ApiAlbumClassifyVo> apiClassifyVos = map3.get(c3.getParentId());
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c3);
apiClassifyVos.add(apiClassifyVo);
} else {
List<ApiAlbumClassifyVo> apiClassifyVos = new ArrayList<ApiAlbumClassifyVo>();
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c3);
apiClassifyVos.add(apiClassifyVo);
map3.put(c3.getParentId(), apiClassifyVos);
}
}
Map<Long, List<ApiAlbumClassifyVo>> map2 = new HashMap<Long, List<ApiAlbumClassifyVo>>();
for (AlbumClassify c2 : classifies2) {
if (map2.containsKey(c2.getParentId())) {
List<ApiAlbumClassifyVo> apiClassifyVos = map2.get(c2.getParentId());
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c2);
apiClassifyVo.setChildren(map3.get(c2.getId()));
apiClassifyVos.add(apiClassifyVo);
} else {
List<ApiAlbumClassifyVo> apiClassifyVos = new ArrayList<ApiAlbumClassifyVo>();
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c2);
apiClassifyVo.setChildren(map3.get(c2.getId()));
apiClassifyVos.add(apiClassifyVo);
map2.put(c2.getParentId(), apiClassifyVos);
}
}
List<ApiAlbumClassifyVo> classifies = page.getRecords();
int size = classifies.size();
ApiAlbumClassifyVo c1 = null;
for (int i = 0; i < size; i++) {
c1 = classifies.get(i);
c1.setChildren(map2.get(c1.getId()));
logger.info("这是 分页 接口 返回的 page 里的 sort值为:=====" + c1.getName() + "=======================" + c1.getSort());
// 设置上一个分类主键ID
if (i > 0) {
c1.setMoveUpId(classifies.get(i - 1).getId());
}
// 设置下一个分类主键ID
if (i < size - 1) {
c1.setMoveDownId(classifies.get(i + 1).getId());
}
}
// 设置上一个和下一个ID
Page<ApiAlbumClassifyVo> pageTow = null;
if (pageNo > 1) {
pageTow = albumClassifyService.selectListByCompanyId(companyId, name, orgIds, siteId, pageNo - 1, pageSize);
classifies.get(0).setMoveUpId(pageTow.getRecords().get(pageTow.getRecords().size() - 1).getId());
}
pageTow = albumClassifyService.selectListByCompanyId(companyId, name, orgIds, siteId, pageNo + 1, pageSize);
if (pageTow != null && pageTow.getRecords().size() > 0) {
classifies.get(classifies.size() - 1).setMoveDownId(pageTow.getRecords().get(0).getId());
}
return page;
}
private ApiAlbumClassifyVo copyBean(ApiAlbumClassifyVo apiClassifyVo, AlbumClassify classify) {
apiClassifyVo.setCompanyId(classify.getCompanyId());
apiClassifyVo.setCreateById(classify.getCreateById());
apiClassifyVo.setCreateByName(classify.getCreateByName());
apiClassifyVo.setCreateTime(classify.getCreateTime());
apiClassifyVo.setDescription(classify.getDescription());
apiClassifyVo.setId(classify.getId());
apiClassifyVo.setLayer(classify.getLayer());
apiClassifyVo.setName(classify.getName());
apiClassifyVo.setCode(classify.getCode());
apiClassifyVo.setOrgId(classify.getOrgId());
apiClassifyVo.setParentId(classify.getParentId());
apiClassifyVo.setPath(classify.getPath());
apiClassifyVo.setRootId(classify.getRootId());
apiClassifyVo.setSiteId(classify.getSiteId());
apiClassifyVo.setSort(classify.getSort());
apiClassifyVo.setStatus(classify.getStatus());
apiClassifyVo.setUpdateById(classify.getUpdateById());
apiClassifyVo.setUpdateByName(classify.getUpdateByName());
apiClassifyVo.setUpdateTime(classify.getUpdateTime());
return apiClassifyVo;
}
/**
* 验证同站点下 同级的分类不能重名
*
* @param name 分类名
* @param layer 分类层级
* @param companyId 企业名
* @param siteId 站点id
* @param id 分类id (修改的时候传入)
* @return Boolean
*/
@GetMapping("/vail/name")
public Boolean vailName(@RequestParam(name = "name") String name, @RequestParam(name = "layer") Integer layer,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "id", required = false) Long id) {
AlbumClassify classify = new AlbumClassify();
classify.setName(name);
classify.setLayer(layer);
classify.setCompanyId(companyId);
classify.setSiteId(siteId);
EntityWrapper<AlbumClassify> entityWrapper = new EntityWrapper<>(classify);
if (null != id) {
entityWrapper.ne("id", id);
}
int count = albumClassifyService.selectCount(entityWrapper);
if (count > 0) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
@GetMapping("/getClassifyName")
public String getClassifyName(@RequestParam(name = "classifyId") Long classifyId) {
// 专辑分类回写
String classifyName = "";
AlbumClassify classify = albumClassifyService.selectById(classifyId);
if (classify != null && !StringUtils.isEmpty(classify.getPath())) {
Set<Long> idsList = new HashSet<>();
if (classify.getRootId() != 0) {
idsList.add(classify.getRootId());
}
if (classify.getParentId() != 0) {
idsList.add(classify.getParentId());
}
idsList.add(classify.getId());
List<AlbumClassify> classifies = albumClassifyService.selectClassifyByPath(new ArrayList(idsList));
for (AlbumClassify classify1 : classifies) {
if ("".equals(classifyName.toString())) {
classifyName += classify1.getId();
} else {
classifyName += ",";
classifyName += classify1.getId();
}
}
}
return classifyName;
}
@GetMapping("/classify/list")
public List<AlbumClassifyVo> listClassifyInfo(
@RequestParam(value="classifyId",required = false) Long classifyId){
RequestContext rc = ContextHolder.get();
AlbumClassify classify = new AlbumClassify();
classify.setCompanyId(rc.getCompanyId());
classify.setSiteId(rc.getSiteId());
classify.setStatus(1);
if(Objects.isNull(classifyId)){
classify.setLayer(1);
}else {
classify.setParentId(classifyId);
}
List<AlbumClassify> retData = albumClassifyService.selectList(QueryUtil.condition(classify).
orderBy("sort",false));
if(!CollectionUtils.isEmpty(retData)){
Set<Long> cids = retData.stream().map(item->item.getId()).collect(Collectors.toSet());
List<AlbumClassifyVo> existVos = albumClassifyService.findExistChildNodes(new ArrayList<>(cids));
Map<Long,Integer> exitsMap = null;
boolean isExits = false;
if(!CollectionUtils.isEmpty(existVos)){
isExits = true;
exitsMap = existVos.stream().collect(Collectors.toMap(key->key.getId(),val->val.getTotal()));
}
List<AlbumClassifyVo> data = new ArrayList<>();
for(AlbumClassify item : retData){
AlbumClassifyVo vo = new AlbumClassifyVo();
BeanUtils.copyProperties(item,vo);
if(isExits && exitsMap.containsKey(vo.getId())){
vo.setExistChildNode(true);
}
data.add(vo);
}
return data;
}
return null;
}
}
package com.yizhi.album.application.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.domain.*;
import com.yizhi.album.application.mapper.AlStudentActivityRecordMapper;
import com.yizhi.album.application.mapper.AlbumMapper;
import com.yizhi.album.application.service.IAlThemeActivityService;
import com.yizhi.album.application.service.IAlbumClassifyService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.service.IAlbumVisbleRangeService;
import com.yizhi.album.application.task.ActivityListExport;
import com.yizhi.album.application.vo.*;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.orm.util.QueryUtil;
import com.yizhi.comment.application.feign.SubscribeClient;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.vo.DroolsVo;
import com.yizhi.course.application.feign.CoursePcClient;
import com.yizhi.site.application.feign.PortalManagePCFeignClients;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import com.yizhi.util.application.constant.TpActivityType;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 专辑表 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/album")
public class AlbumController {
private Logger logger = LoggerFactory.getLogger(AlbumController.class);
@Autowired
private IAlbumService albumService;
@Autowired
private IAlbumVisbleRangeService albumVisbleRangeService;
@Autowired
private IAlThemeActivityService alThemeActivityService;
@Autowired
private ActivityListExport activityListExport;
@Autowired
IdGenerator idGenerator;
@Autowired
private IAlbumClassifyService classifyService;
@Autowired
private SubscribeClient subscribeClient;
@Autowired
private RedisCache redisCache;
@Autowired
private CoursePcClient coursePcClient;
@Autowired
private AlbumMapper albumMapper;
@Autowired
private AlStudentActivityRecordMapper alStudentActivityRecordMapper;
@Autowired
private PortalManagePCFeignClients portalManagePCFeignClients;
@GetMapping("/list")
public Page<Album> list(@RequestParam(name = "name",required = false) String name,
@RequestParam(name = "alClassifyId",required = false) Long alClassifyId, @RequestParam(name = "status",required = false) Integer status,
@RequestParam(name = "overed",required = false) Integer overed, @RequestParam(name = "companyId") Long companyId,
@RequestParam(name = "siteId") Long siteId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize) {
Page<Album> page = albumService.searchPage(name, alClassifyId, status, overed, companyId, siteId, pageNo,
pageSize);
return page;
}
@GetMapping("/get")
public Album get(@RequestParam(name = "id") Long id) {
Album album = albumService.selectById(id);
return album;
}
@PostMapping("/save")
public AlbumVo save(@RequestBody AlbumVo albumVo) {
return albumService.save(albumVo);
}
@PostMapping("/update")
public Boolean update(@RequestBody AlbumVo albumVo) {
return albumService.update(albumVo);
}
@PostMapping("/delete")
public Integer delete(@RequestBody List<Long> ids) {
RequestContext context = ContextHolder.get();
logger.info("选中需要删除的专辑id={}", ids);
List<Album> list = new ArrayList<Album>();
for (Long id : ids) {
Album album = albumService.selectById(id);
if (album.getShelves() == 1) {
return 1;
} else {
album.setDelFlg(1);
album.setUpdateById(context.getAccountId());
album.setUpdateByName(context.getAccountName());
album.setUpdateTime(new Date());
list.add(album);
}
}
albumService.updateBatchById(list);
return 0;
}
/**
* 专辑下架 当专辑为上架状态 1 时 才下架
*
* @param album 参数中有专辑主键id
* @return
*/
@GetMapping("/down")
public Boolean down(@RequestParam(name = "albumId") Long albumId) {
RequestContext context = ContextHolder.get();
Album album2 = albumService.selectById(albumId);
if (StringUtils.isEmpty(album2)) {
return Boolean.FALSE;
}
if (album2.getShelves() == 1) {
album2.setShelves(0);
albumService.updateById(album2);
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@GetMapping(value = "/up")
public Boolean up(@RequestParam(name = "albumId") Long albumId,@RequestParam(name = "type")Integer type) throws Exception {
// 检查是否有主题活动(课程)
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (type.equals(1)) {
AlThemeActivity activity = new AlThemeActivity();
activity.setAlbumId(albumId);
activity.setDeleted(0);
EntityWrapper<AlThemeActivity> wrapper = new EntityWrapper<AlThemeActivity>(activity);
List<AlThemeActivity> list = alThemeActivityService.selectList(wrapper);
for (AlThemeActivity activity2 : list) {
if (activity2.getUnlock().equals(1)) {
activity2.setUnlock(0);
activity2.setUpdateById(accountId);
activity2.setUpdateByName(name);
activity2.setUpdateTime(date);
activity2.setUnlockTime(date);
alThemeActivityService.updateById(activity2);
Album album = albumService.selectById(albumId);
album.setUpdateById(accountId);
album.setUpdateByName(name);
album.setUpdateTime(date);
albumService.updateById(album);
}
}
if (alThemeActivityService.selectCount(new EntityWrapper<>(activity)) < 1) {
throw new Exception("没有添加主题活动,不能上架!");
}
Album album = albumService.selectById(albumId);
if (album.getShelves() == 0 || album.getShelves() == 2) {
album.setShelves(1);
albumService.updateById(album);
return Boolean.TRUE;
}
}else {
Album album = albumService.selectById(albumId);
album.setShelves(2);
albumService.updateById(album);
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@PostMapping("/authorize/insert")
public Boolean insertAlbumVisibleRanges(@RequestBody List<AlbumVisibleRange> albumVisableRanges) {
if (!CollectionUtils.isEmpty(albumVisableRanges)) {
RequestContext context = ContextHolder.get();
Long albumId = albumVisableRanges.get(0).getAlbumId();
AlbumVisibleRange albumVisableRange = new AlbumVisibleRange();
albumVisableRange.setState(1);
albumVisableRange.setAlbumId(albumId);
EntityWrapper<AlbumVisibleRange> entityWrapper = new EntityWrapper<>(albumVisableRange);
albumVisbleRangeService.delete(entityWrapper);
for (AlbumVisibleRange albumVisableRange1 : albumVisableRanges) {
albumVisableRange1.setId(idGenerator.generate());
albumVisableRange1.setSiteId(context.getSiteId());
albumVisableRange1.setCompanyId(context.getCompanyId());
}
return albumVisbleRangeService.insertBatch(albumVisableRanges);
} else {
logger.error("列表为空 ");
return Boolean.FALSE;
}
}
@GetMapping("/VisibleRange")
public List<AlbumVisibleRange> VisibleRange(@RequestParam("albumId") Long albumId) {
AlbumVisibleRange range = new AlbumVisibleRange();
range.setAlbumId(albumId);
EntityWrapper<AlbumVisibleRange> wrapper = new EntityWrapper<AlbumVisibleRange>(range);
List<AlbumVisibleRange> list = albumVisbleRangeService.selectList(wrapper);
return list;
}
@GetMapping("/activity/export")
public Map<String, Object> activityExport(@RequestParam(name = "albumId", required = true) Long albumId) {
RequestContext requestContext = ContextHolder.get();
Date submitTime = new Date();
Long taskId = submitTime.getTime();
String serialNo = "USER-EXPORT-" + taskId;
String taskName = "专辑课程清单-" + taskId;
String result = "任务编号:" + serialNo + "。任务名称:" + taskName;
Album album = albumService.selectById(albumId);
Map<String, Object> map = new HashMap<String, Object>();
map.put("accountId", requestContext.getAccountId());
map.put("siteId", requestContext.getSiteId());
map.put("companyId", requestContext.getCompanyId());
map.put("serialNo", serialNo);
map.put("taskId", taskId);
map.put("submitTime", submitTime);
map.put("taskName", taskName);
map.put("albumId", album.getId());
map.put("name", album.getName());
map.put("result", result);
activityListExport.execute(map, true);
return map;
}
@GetMapping("/searchList")
public List<Album> searchList(@RequestParam(name = "name",required = false) String name,@RequestParam(name = "ids",required = false) List<Long> ids,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId) {
return albumService.searchlList(name,ids, companyId, siteId);
}
@PostMapping("/searchPage")
public Page<ApiListAlbumVo> searchPage(@RequestBody ApiSearchAlbumVo apiSearchAlbumVo) {
logger.info("微信端专辑分类进入,查询专辑列表参数={}", JSON.toJSONString(apiSearchAlbumVo));
List<Long> classifyIds = null;
Long classifyId = apiSearchAlbumVo.getClassifyId();
if (Objects.nonNull(classifyId) && classifyId.longValue() > 0) {
classifyIds = new ArrayList<>();
// 查询第一级的子分类
AlbumClassify classify = classifyService.selectById(classifyId);
Integer layer = classify.getLayer();
classifyIds.add(classifyId);
if (Objects.nonNull(layer) && layer.intValue() < 3) {
AlbumClassify classify1 = new AlbumClassify();
classify1.setParentId(classifyId);
classify1.setStatus(1);
List<AlbumClassify> firstIds = classifyService.selectList(QueryUtil.condition(classify1));
Set<Long> lastIds = null;
if (!CollectionUtils.isEmpty(firstIds)) {
lastIds = firstIds.stream().map(objfirst -> objfirst.getId()).collect(Collectors.toSet());
classifyIds.addAll(lastIds);
}
// 查询第二级的子分类
if (Objects.nonNull(lastIds) && layer.intValue() < 2) {
EntityWrapper<AlbumClassify> ew = QueryUtil.condition(new AlbumClassify());
ew.in("parent_id", lastIds);
ew.eq("status", 1);
List<AlbumClassify> dataList = classifyService.selectList(ew);
if (!CollectionUtils.isEmpty(dataList)) {
classifyIds
.addAll(dataList.stream().map(objLast -> objLast.getId()).collect(Collectors.toSet()));
}
}
}
}
Page<ApiListAlbumVo> apiListAlbumVos = albumService.searchPageSubClassify(apiSearchAlbumVo.getName(),
classifyIds, apiSearchAlbumVo.getIds(), apiSearchAlbumVo.getCompanyId(), apiSearchAlbumVo.getSiteId(),
apiSearchAlbumVo.getPageNo(), apiSearchAlbumVo.getPageSize());
return apiListAlbumVos;
}
@GetMapping("/getMyAlbumList")
public Page<ApiListAlbumVo> getMyAlbumList(@RequestParam("siteId") Long siteId,
@RequestParam("accountId") Long accountId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize) {
Page<ApiListAlbumVo> page = new Page<ApiListAlbumVo>();
page.setCurrent(pageNo);
page.setSize(pageSize);
List<Long> ids = albumService.getMyStudyList(siteId, accountId,new Page<Long>(pageNo, pageSize));
List<ApiListAlbumVo> list = new ArrayList<ApiListAlbumVo>();
for (Long id : ids) {
ApiListAlbumVo vo = new ApiListAlbumVo();
Album album = albumService.selectById(id);
if (album.getShelves().equals(1)) {
vo.setId(id);
vo.setName(album.getName());
vo.setImage(album.getImage());
vo.setOvered(album.getOvered());
vo.setUnLockTime(album.getUpdateTime());
if (album.getUpdateTime()!=null) {
long day = ((System.currentTimeMillis()-album.getUpdateTime().getTime())/(3600*24*1000));
vo.setIsNew(day>5?0:1);
}else {
vo.setIsNew(0);
}
if (album.getOvered().equals(1)) {
// 计算完成百分比
List<Long> activities = albumMapper.getIdsByAlbumId(id);
Integer finished = albumService.finished(activities,id, accountId, siteId);
Integer unLockNum = albumService.unLockNum(id);
if (unLockNum!=0) {
BigDecimal res = new BigDecimal(0);
BigDecimal dividendN = new BigDecimal(finished.toString());
BigDecimal divisorN = new BigDecimal(unLockNum.toString());
BigDecimal a = dividendN.multiply(new BigDecimal("100"));
res = a.divide(divisorN, 2, BigDecimal.ROUND_HALF_UP);
vo.setPercent(res.intValue());
}else {
vo.setPercent(0);
}
}
list.add(vo);
}
}
page.setRecords(list);
page.setTotal(albumMapper.getMyAlbumNum(siteId, accountId));
return page;
}
@GetMapping("/getDeatil")
public AlbumDetailVo getDeatil(@RequestParam("albumId") Long albumId, @RequestParam("accountId") Long accountId,
@RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId) {
Album album = albumService.selectById(albumId);
AlbumDetailVo vo = null;
if (album != null) {
if (album.getShelves()==1) {
vo = new AlbumDetailVo();
vo.setId(album.getId());
vo.setName(album.getName());
vo.setImage(album.getImage());
vo.setClassifyId(album.getClassifyId());
vo.setUnLockTime(album.getUpdateTime());
vo.setOvered(album.getOvered());
vo.setCommentEnable(album.getCommentEnable());
vo.setDocumentEnable(album.getDocumentEnable());
vo.setDisplay(album.getDisplay());
vo.setDescription(album.getDescription());
vo.setTags(album.getTags());
if (album.getOvered().equals(1)) {
// 计算完成百分比
List<Long> ids = albumMapper.getIdsByAlbumId(albumId);
Integer finished = albumService.finished(ids,albumId, accountId, siteId);
Integer unLockNum = albumService.unLockNum(albumId);
if (unLockNum!=0) {
BigDecimal res = new BigDecimal(0);
BigDecimal dividendN = new BigDecimal(finished.toString());
BigDecimal divisorN = new BigDecimal(unLockNum.toString());
BigDecimal a = dividendN.multiply(new BigDecimal("100"));
res = a.divide(divisorN, 2, BigDecimal.ROUND_HALF_UP);
vo.setPercent(res.intValue());
}else {
vo.setPercent(0);
}
}
SubscribeVo subscribe = subscribeClient.get(albumId, TpActivityType.TYPE_ALBUM, accountId, siteId, companyId);
vo.setSubscribe(subscribe.getStatus());
vo.setStudyNum(albumService.getStudyNum(albumId));
vo.setSubscribeNum(subscribeClient.getSubscribeNum(albumId, TpActivityType.TYPE_ALBUM));
}
}
return vo;
}
@GetMapping("/getContent")
public List<AlbumThemeVo> getContent(@RequestParam("albumId") Long albumId,
@RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId,
@RequestParam("companyId") Long companyId, @RequestParam("type") Integer type,
@RequestParam("display") Integer display) {
List<AlbumThemeVo> list = new ArrayList<AlbumThemeVo>();
List<AlbumThemeVo> themes = albumService.getThemes(albumId, type);
for(AlbumThemeVo themeVo:themes) {
AlThemeActivity activity = new AlThemeActivity();
activity.setAlbumId(albumId);
activity.setThemeId(themeVo.getId());
activity.setDeleted(0);
if (!display.equals(0)) {
activity.setUnlock(0);
}
EntityWrapper<AlThemeActivity> wrapper = new EntityWrapper<AlThemeActivity>(activity);
wrapper.orderBy("sort", type.equals(1)?true:false);
List<AlThemeActivity> activitys = alThemeActivityService.selectList(wrapper);
List<AlbumActivityVo> list2 = new ArrayList<AlbumActivityVo>();
for(AlThemeActivity one:activitys) {
AlStudentActivityRecord record = new AlStudentActivityRecord();
record.setAccountId(accountId);
record.setSiteId(siteId);
record.setRelationId(one.getRelationId());
Integer count = alStudentActivityRecordMapper.selectCount(new EntityWrapper<AlStudentActivityRecord>(record));
AlbumActivityVo vo = new AlbumActivityVo();
vo.setAlbumId(one.getAlbumId());
vo.setUnlock(one.getUnlock());
vo.setId(one.getId());
vo.setRelationId(one.getRelationId());
vo.setName(one.getName());
vo.setSort(one.getSort());
vo.setUpdateTime(one.getUpdateTime());
long firstDayBetween = (System.currentTimeMillis() - vo.getUpdateTime().getTime()) / (60 * 60 * 24 * 1000);
if (firstDayBetween<=5) {
vo.setIsNew(1);
themeVo.setIsNew(1);
}else {
vo.setIsNew(0);
}
Integer status = alStudentActivityRecordMapper.getStatus(albumId, accountId, siteId, one.getRelationId());
if (status!=null) {
vo.setStatus(status.equals(0)?"进行中":"已完成");
}else {
vo.setStatus("未开始");
}
List<Long> courseId = new ArrayList<Long>();
courseId.add(one.getRelationId());
Map<Long, Long> durations = coursePcClient.getMaterialTimeByCourseIds(courseId);
Long duration = (long) 0;
if (null != durations && durations.size() > 0) {
for (Long h : durations.keySet()) {
logger.info("课程时长:" + durations.get(h));
duration = duration + (durations.get(h) != null ? durations.get(h) : 0l);
}
}
vo.setDuration(duration);
list2.add(vo);
}
themeVo.setList(list2);
list.add(themeVo);
}
return list;
}
@PostMapping("/getPortalList")
public List<ApiListAlbumVo> getPortalList(@RequestBody List<Long> ids){
List<ApiListAlbumVo> data = new ArrayList<ApiListAlbumVo>();
if (!CollectionUtils.isEmpty(ids)) {
for(Long id:ids) {
ApiListAlbumVo vo = new ApiListAlbumVo();
Album album = albumService.selectById(id);
vo.setId(album.getId());
vo.setName(album.getName());
vo.setImage(album.getImage());
vo.setOvered(album.getOvered());
vo.setUnLockTime(album.getUpdateTime());
List<Long> courseIds = albumMapper.getCourseIds(vo.getId());
Map<Long, Long> durations = coursePcClient.getMaterialTimeByCourseIds(courseIds);
Long duration = (long) 0;
if (null != durations && durations.size() > 0) {
for (Long h : durations.keySet()) {
logger.info("课程时长:" + durations.get(h));
duration = duration + (durations.get(h) != null ? durations.get(h) : 0l);
}
}
vo.setDuration(duration);
data.add(vo);
}
List<Long> albumIds = data.stream().map(ApiListAlbumVo::getId).collect(Collectors.toList());
List<ApiListAlbumVo> vos = alStudentActivityRecordMapper.getStudentNumByIds(albumIds);
logger.info("专辑学习人数={}", JSON.toJSONString(vos));
if (!CollectionUtils.isEmpty(vos)) {
Map<Long, Integer> dataMap = vos.stream().collect(Collectors.
toMap(key -> key.getId(), val -> val.getStudyNum()));
for (ApiListAlbumVo itemAlbum : data) {
itemAlbum.setStudyNum(dataMap.get(itemAlbum.getId()));
}
}
}
return data;
}
@PostMapping("/getMySubscribePage")
public Page<ApiListAlbumVo> getMySubscribePage(@RequestBody ApiSearchAlbumVo vo){
List<Long> ids = vo.getIds();
Integer pageNo = vo.getPageNo();
Integer pageSize = vo.getPageSize();
Page<ApiListAlbumVo> page = albumService.getMySubscribePage(ids, pageNo, pageSize);
return page;
}
@PostMapping("/getMyAlbumCount")
public Integer getMyAlbumCount(@RequestBody RequestContext context) {
return albumMapper.getMyAlbumNum(context.getSiteId(), context.getAccountId());
}
@PostMapping("/getSubcribeNum")
public Integer getSubcribeNum(@RequestBody List<Long> ids) {
return albumMapper.getSubscribeNum(ids);
}
@GetMapping("/getPageByDrools")
Page<DroolsVo> getPageByDrools(@RequestParam("field") String field,
@RequestParam(value = "value", required = false) String value,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Page<DroolsVo> page = new Page<>(pageNo, pageSize);
return albumService.getPageByDrools(field, value, page);
}
@PostMapping("/getPageToCalendar")
public Page<AlbumCalendarVo> getPageToCalendar(@ApiParam("paramVo") @RequestBody CalendarTaskParamVo paramVo) {
Page<Album> page = new Page(paramVo.getPageNo(), paramVo.getPageSize());
return albumService.getPageToCalendar(paramVo.getDate(),page);
}
@PostMapping("/listNoIds")
public Page<com.yizhi.album.application.vo.domain.Album> listNoIds(@RequestBody ApiSearchAlbumVo vo) {
Page<Album> page = new Page(vo.getPageNo(),vo.getPageSize());
List<Album> data = albumMapper.selectAlbumPage(vo.getName(), vo.getIds(), vo.getCompanyId(), vo.getSiteId(), page);
//page.setRecords(data);
List<com.yizhi.album.application.vo.domain.Album> list =
BeanCopyListUtil.copyListProperties(data, com.yizhi.album.application.vo.domain.Album::new);
Page<com.yizhi.album.application.vo.domain.Album> albumPage = new Page(vo.getPageNo(),vo.getPageSize());
albumPage.setRecords(list);
//BeanUtils.copyProperties(page, albumPage);
return albumPage;
}
}
package com.yizhi.album.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.album.application.domain.ClassifyStrategy;
import com.yizhi.album.application.service.IClassifyStrategyService;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* <p>
* 专辑分类策略 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/classifyStrategy")
public class ClassifyStrategyController {
@Autowired
private IClassifyStrategyService classifyStrategyService;
@Autowired
com.yizhi.application.orm.id.IdGenerator IdGenerator;
@GetMapping("/update")
public com.yizhi.album.application.vo.domain.ClassifyStrategy update(@RequestParam(value = "type", required = true) Integer type, @RequestParam(value = "status", required = true) Integer status) {
RequestContext context = ContextHolder.get();
Long siteId = context.getSiteId();
Long companyId = context.getCompanyId();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
ClassifyStrategy strategy = new ClassifyStrategy();
strategy.setSiteId(siteId);
strategy.setCompanyId(companyId);
EntityWrapper<ClassifyStrategy> wrapper = new EntityWrapper<ClassifyStrategy>(strategy);
ClassifyStrategy one = classifyStrategyService.selectOne(wrapper);
if (one==null) {
one = new ClassifyStrategy();
one.setId(IdGenerator.generate());
one.setType(type);
one.setStatus(status);
one.setCreateById(accountId);
one.setCreateByName(name);
one.setCreateTime(date);
one.setCompanyId(companyId);
one.setSiteId(siteId);
classifyStrategyService.insert(one);
}else {
one.setType(type);
one.setStatus(status);
one.setUpdateById(accountId);
one.setUpdateByName(name);
one.setUpdateTime(date);
classifyStrategyService.updateById(one);
}
com.yizhi.album.application.vo.domain.ClassifyStrategy classifyStrategy = new com.yizhi.album.application.vo.domain.ClassifyStrategy();
BeanUtils.copyProperties(one, classifyStrategy);
return classifyStrategy;
}
@GetMapping("/get")
public com.yizhi.album.application.vo.domain.ClassifyStrategy get(@RequestParam(value = "companyId", required = true) Long companyId, @RequestParam(value = "siteId", required = true) Long siteId) {
ClassifyStrategy strategy = new ClassifyStrategy();
strategy.setSiteId(siteId);
strategy.setCompanyId(companyId);
EntityWrapper<ClassifyStrategy> wrapper = new EntityWrapper<ClassifyStrategy>(strategy);
ClassifyStrategy one = classifyStrategyService.selectOne(wrapper);
com.yizhi.album.application.vo.domain.ClassifyStrategy classifyStrategy = new com.yizhi.album.application.vo.domain.ClassifyStrategy();
BeanUtils.copyProperties(strategy, classifyStrategy);
return classifyStrategy;
}
}
package com.yizhi.album.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.domain.AlThemeActivity;
import com.yizhi.album.application.domain.Album;
import com.yizhi.album.application.mapper.AlbumMapper;
import com.yizhi.album.application.service.IAlThemeActivityService;
import com.yizhi.album.application.service.IAlThemeService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.vo.AlThemeVo;
import com.yizhi.album.application.vo.AlbumVo;
import com.yizhi.comment.application.feign.ManageCommentClient;
import com.yizhi.comment.application.feign.SubscribeClient;
import com.yizhi.course.application.feign.CoursePcClient;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import com.yizhi.util.application.constant.TpActivityType;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <p>
* 专辑报表用
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/statisticsAlbum")
public class StatisticsAlbumController {
@Autowired
private IAlbumService albumService;
@Autowired
private AlbumMapper albumMapper;
@Autowired
private IAlThemeActivityService alThemeActivityService;
@Autowired
private IAlThemeService alThemeService;
@Autowired
private CoursePcClient coursePcClient;
@Autowired
private ManageCommentClient commentClient;
@Autowired
private SubscribeClient subscribeClient;
@GetMapping("/getAllAlbums")
public List<AlbumVo> getAllAlbums(@RequestParam(name = "companyId",required = false)Long companyId, @RequestParam(name = "siteId",required = false)Long siteId){
List<AlbumVo> allAlbums = new ArrayList<AlbumVo>();
List<Long> list = albumMapper.getAllAlbums(companyId, siteId);
List<Long> courseIds = new ArrayList<Long>();
if (CollectionUtils.isNotEmpty(list)) {
for(Long albumId:list) {
int num = 0;
AlbumVo albumVo = new AlbumVo();
Album album = albumService.selectById(albumId);
albumVo.setId(album.getId());
albumVo.setName(album.getName());
albumVo.setShelves(album.getShelves());
albumVo.setClassifyId(album.getClassifyId());
albumVo.setImage(album.getImage());
albumVo.setDescription(album.getDescription());
albumVo.setTags(album.getTags());
albumVo.setScope(album.getScope());
albumVo.setCommentEnable(album.getCommentEnable());
albumVo.setDocumentEnable(album.getDocumentEnable());
albumVo.setOvered(album.getOvered());
albumVo.setDisplay(album.getDisplay());
albumVo.setSiteId(album.getSiteId());
albumVo.setCompanyId(album.getCompanyId());
albumVo.setCreateTime(album.getCreateTime());
List<AlThemeVo> list1 = new ArrayList<AlThemeVo>();
AlTheme theme = new AlTheme();
theme.setAlbumId(albumId);
theme.setDeleted(0);
EntityWrapper<AlTheme> wrapper = new EntityWrapper<AlTheme>(theme);
wrapper.orderBy("sort", true);
List<AlTheme> themes = alThemeService.selectList(wrapper);
for(AlTheme alTheme:themes) {
AlThemeVo themeVo = new AlThemeVo();
themeVo.setAlbumId(albumId);
themeVo.setId(alTheme.getId());
themeVo.setName(alTheme.getName());
List<AlThemeActivity> activities = new ArrayList<AlThemeActivity>();
AlThemeActivity activity = new AlThemeActivity();
activity.setThemeId(alTheme.getId());
activity.setDeleted(0);
EntityWrapper<AlThemeActivity> entityWrapper = new EntityWrapper<AlThemeActivity>(activity);
entityWrapper.orderBy("sort", true);
activities = alThemeActivityService.selectList(entityWrapper);
for(AlThemeActivity alThemeActivity:activities) {
alThemeActivity.setThemeName(alTheme.getName());
if (alThemeActivity.getUnlock().equals(0)) {
courseIds.add(alThemeActivity.getRelationId());
}else {
num++;
}
}
List<com.yizhi.album.application.vo.domain.AlThemeActivity> alThemeActivities =
BeanCopyListUtil.copyListProperties(activities, com.yizhi.album.application.vo.domain.AlThemeActivity::new);
themeVo.setActivities(alThemeActivities);
list1.add(themeVo);
}
Map<Long, Long> durations = coursePcClient.getMaterialTimeByCourseIds(courseIds);
Long duration = (long) 0;
if (null != durations && durations.size() > 0) {
for (Long h : durations.keySet()) {
duration = duration + (durations.get(h) != null ? durations.get(h) : 0l);
}
}
albumVo.setCommentCount(commentClient.getCommentNum(albumId, TpActivityType.TYPE_ALBUM));
albumVo.setSubscribeCount(subscribeClient.getSubscribeNum(albumId, TpActivityType.TYPE_ALBUM));
albumVo.setDuration(duration);
albumVo.setList(list1);
albumVo.setLockNum(num);
allAlbums.add(albumVo);
courseIds.clear();
}
}
return allAlbums;
}
}
package com.yizhi.album.application.controller.remote;
import com.yizhi.album.application.mapper.AlStudentActivityRecordMapper;
import com.yizhi.album.application.vo.domain.AlStudentActivityRecord;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 学员完成专辑活动记录 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController(value = "alStudentActivityRecordController1")
@RequestMapping("/remote/alStudentActivityRecord")
public class AlStudentActivityRecordController {
@Autowired
private AlStudentActivityRecordMapper aStudentActivityRecordMapper;
@GetMapping("/statistics/getRecordeAllWorkId")
public List<Long> getRecordeAllWorkId(){
return aStudentActivityRecordMapper.getRecordeAllWorkId();
}
@GetMapping("/statistics/getAllRecordeByTimeLimit")
public List<AlStudentActivityRecord> getAllRecordeByTimeLimit(@RequestParam(value="startDate",required=true)String startDate, @RequestParam(value="endDate",required=true)String endDate, @RequestParam(value="relationId",required=true)Long relationId){
List<AlStudentActivityRecord> alStudentActivityRecord =
BeanCopyListUtil.copyListProperties(aStudentActivityRecordMapper.getAllRecordeByTimeLimit(startDate, endDate, relationId), AlStudentActivityRecord::new);
return alStudentActivityRecord;
}
}
package com.yizhi.album.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.domain.AlThemeActivity;
import com.yizhi.album.application.domain.Album;
import com.yizhi.album.application.service.IAlThemeActivityService;
import com.yizhi.album.application.service.IAlThemeService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.vo.AlThemeVo;
import com.yizhi.album.application.vo.AlbumVo;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p>
* 主题中的课程 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/remote/alThemeActivity")
public class AlThemeActivityController {
private Logger logger = LoggerFactory.getLogger(AlThemeActivityController.class);
@Autowired
private IAlbumService albumService;
@Autowired
private IAlThemeActivityService alThemeActivityService;
@Autowired
private IAlThemeService alThemeService;
@Autowired
IdGenerator idGenerator;
@PostMapping("/save")
public Boolean sava(@RequestBody AlbumVo vo) {
RequestContext context = ContextHolder.get();
Long siteId = context.getSiteId();
Long accountId = context.getAccountId();
Long companyId = context.getCompanyId();
Long orgId = context.getOrgId();
Date date = new Date();
String name = context.getAccountName();
List<AlThemeVo> themeVos = vo.getList();
Album album = albumService.selectById(vo.getId());
album.setOvered(vo.getOvered());
album.setUpdateById(accountId);
album.setUpdateByName(name);
album.setUpdateTime(date);
album.setDisplay(vo.getDisplay());
albumService.updateById(album);
//删除主题
if (CollectionUtils.isNotEmpty(vo.getDeleteList())) {
for(Long id:vo.getDeleteList()) {
AlTheme theme = alThemeService.selectById(id);
theme.setDeleted(1);
theme.setUpdateById(accountId);
theme.setUpdateByName(name);
theme.setUpdateTime(date);
alThemeService.updateById(theme);
}
}
if (CollectionUtils.isNotEmpty(themeVos)) {
for(AlThemeVo themeVo:themeVos) {
//删除主题中活动
if (CollectionUtils.isNotEmpty(themeVo.getDeleteList())) {
for(Long id:themeVo.getDeleteList()) {
AlThemeActivity activity = alThemeActivityService.selectById(id);
activity.setDeleted(1);
activity.setUpdateById(accountId);
activity.setUpdateByName(name);
activity.setUpdateTime(date);
alThemeActivityService.updateById(activity);
}
}
AlTheme theme = new AlTheme();
if (themeVo.getId()==null||themeVo.getId()==0) {
if (!alThemeService.vaidName(null,vo.getId(), themeVo.getName(), siteId)) {
return Boolean.FALSE;
}
theme.setId(idGenerator.generate());
theme.setCreateById(accountId);
theme.setCreateByName(name);
theme.setCreateTime(date);
theme.setSiteId(siteId);
theme.setCompanyId(companyId);
theme.setOrgId(orgId);
}else {
theme.setId(themeVo.getId());
if (!alThemeService.vaidName(themeVo.getId(),vo.getId(), themeVo.getName(), siteId)) {
return Boolean.FALSE;
}
}
theme.setAlbumId(themeVo.getAlbumId());
theme.setName(themeVo.getName());
theme.setSort(themeVo.getSort());
theme.setDeleted(0);
theme.setUpdateById(accountId);
theme.setUpdateByName(name);
theme.setUpdateTime(date);
alThemeService.insertOrUpdate(theme);
for(com.yizhi.album.application.vo.domain.AlThemeActivity activityVo:themeVo.getActivities()) {
AlThemeActivity activity = new AlThemeActivity();
if (activityVo.getId()==null||activityVo.getId()==0) {
activity.setId(idGenerator.generate());
activity.setCreateById(accountId);
activity.setCreateByName(name);
activity.setCreateTime(date);
activity.setSiteId(siteId);
activity.setCompanyId(companyId);
activity.setOrgId(orgId);
}else {
activity.setId(activityVo.getId());
}
activity.setAlbumId(activityVo.getAlbumId());
activity.setThemeId(theme.getId());
activity.setThemeName(theme.getName());
activity.setRelationId(activityVo.getRelationId());
activity.setRelationCode(activityVo.getRelationCode());
activity.setName(activityVo.getName());
activity.setSort(activityVo.getSort());
activity.setDeleted(0);
// activity.setUnlock(activityVo.getUnlock());
activity.setUnlock(vo.getShelves() == 1 && activityVo.getUnlock() == 1 ? 0 : activityVo.getUnlock());
activity.setUnlockTime(activityVo.getUnlockTime());
alThemeActivityService.insertOrUpdate(activity);
}
}
}
return Boolean.TRUE;
}
@GetMapping("/delete")
public Boolean delete(@RequestParam(name = "id")Long id) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
boolean b = false;
AlThemeActivity activity = alThemeActivityService.selectById(id);
if (activity!=null) {
activity.setDeleted(1);
activity.setUpdateById(accountId);
activity.setUpdateByName(name);
activity.setUpdateTime(date);
b = alThemeActivityService.updateById(activity);
}
return b;
}
@PostMapping("/sortActivity")
public Boolean sortActivity(@RequestBody List<AlThemeActivity> list) {
logger.info("管理端传入要排序的ID列表==========================:" + list);
return alThemeActivityService.sortActivity(list);
}
@PostMapping("/unLock")
public Boolean unLock(@RequestBody AlThemeActivity activity) {
logger.info("管理端传入定时解锁的活动==========================:" + activity);
return alThemeActivityService.updateById(activity);
}
@GetMapping("/list")
public AlbumVo list(@RequestParam(name = "albumId")Long albumId){
AlbumVo albumVo = new AlbumVo();
Album album = albumService.selectById(albumId);
albumVo.setId(album.getId());
albumVo.setName(album.getName());
albumVo.setShelves(album.getShelves());
albumVo.setClassifyId(album.getClassifyId());
albumVo.setImage(album.getImage());
albumVo.setDescription(album.getDescription());
albumVo.setTags(album.getTags());
albumVo.setScope(album.getScope());
albumVo.setCommentEnable(album.getCommentEnable());
albumVo.setDocumentEnable(album.getDocumentEnable());
albumVo.setOvered(album.getOvered());
albumVo.setDisplay(album.getDisplay());
List<AlThemeVo> list = new ArrayList<AlThemeVo>();
AlTheme theme = new AlTheme();
theme.setAlbumId(albumId);
theme.setDeleted(0);
EntityWrapper<AlTheme> wrapper = new EntityWrapper<AlTheme>(theme);
wrapper.orderBy("sort", true);
List<AlTheme> themes = alThemeService.selectList(wrapper);
for(AlTheme alTheme:themes) {
AlThemeVo themeVo = new AlThemeVo();
themeVo.setAlbumId(albumId);
themeVo.setId(alTheme.getId());
themeVo.setName(alTheme.getName());
List<AlThemeActivity> activities = new ArrayList<>();
AlThemeActivity activity = new AlThemeActivity();
activity.setThemeId(alTheme.getId());
activity.setDeleted(0);
EntityWrapper<AlThemeActivity> entityWrapper = new EntityWrapper<AlThemeActivity>(activity);
entityWrapper.orderBy("sort", true);
activities = alThemeActivityService.selectList(entityWrapper);
activities.forEach(e->e.setThemeName(alTheme.getName()));
List<com.yizhi.album.application.vo.domain.AlThemeActivity> alThemeActivities =
BeanCopyListUtil.copyListProperties(activities, com.yizhi.album.application.vo.domain.AlThemeActivity::new);
themeVo.setActivities(alThemeActivities);
list.add(themeVo);
}
albumVo.setList(list);
return albumVo;
}
}
package com.yizhi.album.application.controller.remote;
import com.yizhi.album.application.controller.AlThemeActivityControllerV2;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.service.IAlThemeService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
* <p>
* 专辑 - 主题 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController(value = "alThemeController1")
@RequestMapping("/remote/alTheme")
public class AlThemeController {
private Logger logger = LoggerFactory.getLogger(AlThemeActivityControllerV2.class);
@Autowired
private IAlbumService albumService;
@Autowired
private IAlThemeService alThemeService;
@Autowired
IdGenerator idGenerator;
@GetMapping("/delete")
public Boolean delete(@RequestParam(name = "id")Long id) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
boolean b = false;
AlTheme theme = alThemeService.selectById(id);
if (theme!=null) {
theme.setDeleted(1);
theme.setUpdateById(accountId);
theme.setUpdateByName(name);
theme.setUpdateTime(date);
b = alThemeService.updateById(theme);
}
return b;
}
@PostMapping("/sortActivity")
public int sortTheme(@RequestBody List<AlTheme> list) {
logger.info("管理端传入要排序的ID列表==========================:" + list);
return alThemeService.sortTheme(list);
}
@GetMapping("/updateName")
public Boolean updateName(@RequestParam(name = "id") Long id,@RequestParam(name = "albumId") Long albumId,@RequestParam(name = "name") String name) {
RequestContext context = ContextHolder.get();
Long siteId = context.getSiteId();
Long accountId = context.getAccountId();
String accountName = context.getAccountName();
Date date = new Date();
Boolean vaidName = alThemeService.vaidName(id,albumId, name, siteId);
if (!vaidName) {
return Boolean.FALSE;
}
AlTheme theme = alThemeService.selectById(id);
theme.setName(name);
theme.setUpdateById(accountId);
theme.setUpdateByName(accountName);
theme.setUpdateTime(date);
alThemeService.updateById(theme);
return Boolean.TRUE;
}
}
package com.yizhi.album.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.domain.AlbumClassify;
import com.yizhi.album.application.service.IAlbumClassifyService;
import com.yizhi.album.application.vo.AlbumClassifyVo;
import com.yizhi.album.application.vo.ApiAlbumClassifyVo;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.orm.util.QueryUtil;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 专辑分类 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController("albumClassifyController1")
@RequestMapping("/remote/albumClassify")
public class AlbumClassifyController {
private Logger logger = LoggerFactory.getLogger(AlbumClassifyController.class);
@Autowired
IdGenerator idGenerator;
@Autowired
private IAlbumClassifyService albumClassifyService;
@GetMapping("/find/id")
public AlbumClassify getById(@RequestParam(name = "id") Long id) {
return albumClassifyService.selectById(id);
}
@ApiOperation("添加分类")
@RequestMapping(value = "/save", method = RequestMethod.POST)
public int saveClassify(@RequestBody AlbumClassify classify) {
return albumClassifyService.saveClassify(classify);
}
/**
* 检查是否存在分类名称
*
* @param name 分类名称
* @param parentId 分类的上级id(一级分类为0)
* @param siteId 站点id
* @param type 检查类型(1:新增,2:修改(需要传classifyId))
* @param classifyId 分类id,修改检查时用到
* @return 不存在返回true,存放相同名返回false
*/
@GetMapping("/check/name")
public boolean checkExtisClassifyName(@RequestParam(name = "name") String name,
@RequestParam(name = "parentId", required = false) Long parentId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "type") Integer type, @RequestParam(name = "classifyId", required = false) Long classifyId) {
return albumClassifyService.checkExtisClassifyName(name, parentId, siteId, type, classifyId);
}
@ApiOperation("分类删除")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public int deleteClassify(@RequestBody AlbumClassify classify) {
return albumClassifyService.deleteClassify(classify.getId());
}
@ApiOperation("分类名称修改")
@RequestMapping(value = "/update", method = RequestMethod.POST)
public int updateClassify(@RequestBody AlbumClassify classify) {
return albumClassifyService.updateClassify(classify);
}
@ApiOperation("分类查询")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Page<AlbumClassify> listClassify(@RequestParam(required = false, name = "isStartHQ") Boolean isStartHQ,
@RequestParam(required = false,name = "name") String name, @RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds) {
return albumClassifyService.listClassify(name, pageNo, pageSize, companyId, orgIds, siteId, isStartHQ);
}
@ApiOperation("分类排序")
@RequestMapping(value = "/sort", method = RequestMethod.POST)
public int sortClassify(@RequestBody List<AlbumClassify> list) {
logger.info("管理端传入要排序的ID列表==========================:" + list);
return albumClassifyService.updateClassiyfsort(list);
}
@ApiOperation("分类分页查询")
@RequestMapping(value = "/page/list", method = RequestMethod.GET)
public Page<ApiAlbumClassifyVo> pageList(@RequestParam(name = "name", required = false) String name,
@RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "orgIds", required = false) List<Long> orgIds) {
logger.info("分类分页查询orgIds=", orgIds == null ? 0 : orgIds.size());
Page<ApiAlbumClassifyVo> page = albumClassifyService.selectListByCompanyId(companyId, name, orgIds, siteId,
pageNo, pageSize);
List<AlbumClassify> classifies2 = albumClassifyService.selectClassifyByLayer(companyId, siteId, 2);
List<AlbumClassify> classifies3 = albumClassifyService.selectClassifyByLayer(companyId, siteId, 3);
Map<Long, List<ApiAlbumClassifyVo>> map3 = new HashMap<Long, List<ApiAlbumClassifyVo>>();
for (AlbumClassify c3 : classifies3) {
if (map3.containsKey(c3.getParentId())) {
List<ApiAlbumClassifyVo> apiClassifyVos = map3.get(c3.getParentId());
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c3);
apiClassifyVos.add(apiClassifyVo);
} else {
List<ApiAlbumClassifyVo> apiClassifyVos = new ArrayList<ApiAlbumClassifyVo>();
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c3);
apiClassifyVos.add(apiClassifyVo);
map3.put(c3.getParentId(), apiClassifyVos);
}
}
Map<Long, List<ApiAlbumClassifyVo>> map2 = new HashMap<Long, List<ApiAlbumClassifyVo>>();
for (AlbumClassify c2 : classifies2) {
if (map2.containsKey(c2.getParentId())) {
List<ApiAlbumClassifyVo> apiClassifyVos = map2.get(c2.getParentId());
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c2);
apiClassifyVo.setChildren(map3.get(c2.getId()));
apiClassifyVos.add(apiClassifyVo);
} else {
List<ApiAlbumClassifyVo> apiClassifyVos = new ArrayList<ApiAlbumClassifyVo>();
ApiAlbumClassifyVo apiClassifyVo = new ApiAlbumClassifyVo();
apiClassifyVo = copyBean(apiClassifyVo, c2);
apiClassifyVo.setChildren(map3.get(c2.getId()));
apiClassifyVos.add(apiClassifyVo);
map2.put(c2.getParentId(), apiClassifyVos);
}
}
List<ApiAlbumClassifyVo> classifies = page.getRecords();
int size = classifies.size();
ApiAlbumClassifyVo c1 = null;
for (int i = 0; i < size; i++) {
c1 = classifies.get(i);
c1.setChildren(map2.get(c1.getId()));
logger.info("这是 分页 接口 返回的 page 里的 sort值为:=====" + c1.getName() + "=======================" + c1.getSort());
// 设置上一个分类主键ID
if (i > 0) {
c1.setMoveUpId(classifies.get(i - 1).getId());
}
// 设置下一个分类主键ID
if (i < size - 1) {
c1.setMoveDownId(classifies.get(i + 1).getId());
}
}
// 设置上一个和下一个ID
Page<ApiAlbumClassifyVo> pageTow = null;
if (pageNo > 1) {
pageTow = albumClassifyService.selectListByCompanyId(companyId, name, orgIds, siteId, pageNo - 1, pageSize);
classifies.get(0).setMoveUpId(pageTow.getRecords().get(pageTow.getRecords().size() - 1).getId());
}
pageTow = albumClassifyService.selectListByCompanyId(companyId, name, orgIds, siteId, pageNo + 1, pageSize);
if (pageTow != null && pageTow.getRecords().size() > 0) {
classifies.get(classifies.size() - 1).setMoveDownId(pageTow.getRecords().get(0).getId());
}
return page;
}
private ApiAlbumClassifyVo copyBean(ApiAlbumClassifyVo apiClassifyVo, AlbumClassify classify) {
apiClassifyVo.setCompanyId(classify.getCompanyId());
apiClassifyVo.setCreateById(classify.getCreateById());
apiClassifyVo.setCreateByName(classify.getCreateByName());
apiClassifyVo.setCreateTime(classify.getCreateTime());
apiClassifyVo.setDescription(classify.getDescription());
apiClassifyVo.setId(classify.getId());
apiClassifyVo.setLayer(classify.getLayer());
apiClassifyVo.setName(classify.getName());
apiClassifyVo.setCode(classify.getCode());
apiClassifyVo.setOrgId(classify.getOrgId());
apiClassifyVo.setParentId(classify.getParentId());
apiClassifyVo.setPath(classify.getPath());
apiClassifyVo.setRootId(classify.getRootId());
apiClassifyVo.setSiteId(classify.getSiteId());
apiClassifyVo.setSort(classify.getSort());
apiClassifyVo.setStatus(classify.getStatus());
apiClassifyVo.setUpdateById(classify.getUpdateById());
apiClassifyVo.setUpdateByName(classify.getUpdateByName());
apiClassifyVo.setUpdateTime(classify.getUpdateTime());
return apiClassifyVo;
}
/**
* 验证同站点下 同级的分类不能重名
*
* @param name 分类名
* @param layer 分类层级
* @param companyId 企业名
* @param siteId 站点id
* @param id 分类id (修改的时候传入)
* @return Boolean
*/
@GetMapping("/vail/name")
public Boolean vailName(@RequestParam(name = "name") String name, @RequestParam(name = "layer") Integer layer,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId,
@RequestParam(name = "id", required = false) Long id) {
AlbumClassify classify = new AlbumClassify();
classify.setName(name);
classify.setLayer(layer);
classify.setCompanyId(companyId);
classify.setSiteId(siteId);
EntityWrapper<AlbumClassify> entityWrapper = new EntityWrapper<>(classify);
if (null != id) {
entityWrapper.ne("id", id);
}
int count = albumClassifyService.selectCount(entityWrapper);
if (count > 0) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
@GetMapping("/getClassifyName")
public String getClassifyName(@RequestParam(name = "classifyId") Long classifyId) {
// 专辑分类回写
String classifyName = "";
AlbumClassify classify = albumClassifyService.selectById(classifyId);
if (classify != null && !StringUtils.isEmpty(classify.getPath())) {
Set<Long> idsList = new HashSet<>();
if (classify.getRootId() != 0) {
idsList.add(classify.getRootId());
}
if (classify.getParentId() != 0) {
idsList.add(classify.getParentId());
}
idsList.add(classify.getId());
List<AlbumClassify> classifies = albumClassifyService.selectClassifyByPath(new ArrayList(idsList));
for (AlbumClassify classify1 : classifies) {
if ("".equals(classifyName.toString())) {
classifyName += classify1.getId();
} else {
classifyName += ",";
classifyName += classify1.getId();
}
}
}
return classifyName;
}
@GetMapping("/classify/list")
public List<AlbumClassifyVo> listClassifyInfo(
@RequestParam(value="classifyId",required = false) Long classifyId){
RequestContext rc = ContextHolder.get();
AlbumClassify classify = new AlbumClassify();
classify.setCompanyId(rc.getCompanyId());
classify.setSiteId(rc.getSiteId());
classify.setStatus(1);
if(Objects.isNull(classifyId)){
classify.setLayer(1);
}else {
classify.setParentId(classifyId);
}
List<AlbumClassify> retData = albumClassifyService.selectList(QueryUtil.condition(classify).
orderBy("sort",false));
if(!CollectionUtils.isEmpty(retData)){
Set<Long> cids = retData.stream().map(item->item.getId()).collect(Collectors.toSet());
List<AlbumClassifyVo> existVos = albumClassifyService.findExistChildNodes(new ArrayList<>(cids));
Map<Long,Integer> exitsMap = null;
boolean isExits = false;
if(!CollectionUtils.isEmpty(existVos)){
isExits = true;
exitsMap = existVos.stream().collect(Collectors.toMap(key->key.getId(),val->val.getTotal()));
}
List<AlbumClassifyVo> data = new ArrayList<>();
for(AlbumClassify item : retData){
AlbumClassifyVo vo = new AlbumClassifyVo();
BeanUtils.copyProperties(item,vo);
if(isExits && exitsMap.containsKey(vo.getId())){
vo.setExistChildNode(true);
}
data.add(vo);
}
return data;
}
return null;
}
}
package com.yizhi.album.application.controller.remote;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.domain.*;
import com.yizhi.album.application.mapper.AlStudentActivityRecordMapper;
import com.yizhi.album.application.mapper.AlbumMapper;
import com.yizhi.album.application.service.IAlThemeActivityService;
import com.yizhi.album.application.service.IAlbumClassifyService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.service.IAlbumVisbleRangeService;
import com.yizhi.album.application.task.ActivityListExport;
import com.yizhi.album.application.vo.*;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.orm.util.QueryUtil;
import com.yizhi.comment.application.feign.SubscribeClient;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.vo.DroolsVo;
import com.yizhi.course.application.feign.CoursePcClient;
import com.yizhi.site.application.feign.PortalManagePCFeignClients;
import com.yizhi.util.application.constant.TpActivityType;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 专辑表 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController("albumController1")
@RequestMapping("/remote/album")
public class AlbumController {
private Logger logger = LoggerFactory.getLogger(AlbumController.class);
@Autowired
private IAlbumService albumService;
@Autowired
private IAlbumVisbleRangeService albumVisbleRangeService;
@Autowired
private IAlThemeActivityService alThemeActivityService;
@Autowired
private ActivityListExport activityListExport;
@Autowired
IdGenerator idGenerator;
@Autowired
private IAlbumClassifyService classifyService;
@Autowired
private SubscribeClient subscribeClient;
@Autowired
private RedisCache redisCache;
@Autowired
private CoursePcClient coursePcClient;
@Autowired
private AlbumMapper albumMapper;
@Autowired
private AlStudentActivityRecordMapper alStudentActivityRecordMapper;
@Autowired
private PortalManagePCFeignClients portalManagePCFeignClients;
@GetMapping("/list")
public Page<Album> list(@RequestParam(name = "name",required = false) String name,
@RequestParam(name = "alClassifyId",required = false) Long alClassifyId, @RequestParam(name = "status",required = false) Integer status,
@RequestParam(name = "overed",required = false) Integer overed, @RequestParam(name = "companyId") Long companyId,
@RequestParam(name = "siteId") Long siteId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize) {
Page<Album> page = albumService.searchPage(name, alClassifyId, status, overed, companyId, siteId, pageNo,
pageSize);
return page;
}
@GetMapping("/get")
public Album get(@RequestParam(name = "id") Long id) {
Album album = albumService.selectById(id);
return album;
}
@PostMapping("/save")
public AlbumVo save(@RequestBody AlbumVo albumVo) {
return albumService.save(albumVo);
}
@PostMapping("/update")
public Boolean update(@RequestBody AlbumVo albumVo) {
return albumService.update(albumVo);
}
@PostMapping("/delete")
public Integer delete(@RequestBody List<Long> ids) {
RequestContext context = ContextHolder.get();
logger.info("选中需要删除的专辑id={}", ids);
List<Album> list = new ArrayList<Album>();
for (Long id : ids) {
Album album = albumService.selectById(id);
if (album.getShelves() == 1) {
return 1;
} else {
album.setDelFlg(1);
album.setUpdateById(context.getAccountId());
album.setUpdateByName(context.getAccountName());
album.setUpdateTime(new Date());
list.add(album);
}
}
albumService.updateBatchById(list);
return 0;
}
/**
* 专辑下架 当专辑为上架状态 1 时 才下架
*
* @param album 参数中有专辑主键id
* @return
*/
@GetMapping("/down")
public Boolean down(@RequestParam(name = "albumId") Long albumId) {
RequestContext context = ContextHolder.get();
Album album2 = albumService.selectById(albumId);
if (StringUtils.isEmpty(album2)) {
return Boolean.FALSE;
}
if (album2.getShelves() == 1) {
album2.setShelves(0);
albumService.updateById(album2);
return Boolean.TRUE;
}
return Boolean.FALSE;
}
@GetMapping(value = "/up2")
public Integer up(@RequestParam(name = "albumId") Long albumId,@RequestParam(name = "type")Integer type) {
// 检查是否有主题活动(课程)
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (type.equals(1)) {
AlThemeActivity activity = new AlThemeActivity();
activity.setAlbumId(albumId);
activity.setDeleted(0);
EntityWrapper<AlThemeActivity> wrapper = new EntityWrapper<AlThemeActivity>(activity);
List<AlThemeActivity> list = alThemeActivityService.selectList(wrapper);
for (AlThemeActivity activity2 : list) {
if (activity2.getUnlock().equals(1)) {
activity2.setUnlock(0);
activity2.setUpdateById(accountId);
activity2.setUpdateByName(name);
activity2.setUpdateTime(date);
activity2.setUnlockTime(date);
alThemeActivityService.updateById(activity2);
Album album = albumService.selectById(albumId);
album.setUpdateById(accountId);
album.setUpdateByName(name);
album.setUpdateTime(date);
albumService.updateById(album);
}
}
if (alThemeActivityService.selectCount(new EntityWrapper<>(activity)) < 1) {
return 3;
}
Album album = albumService.selectById(albumId);
if (album.getShelves() == 0 || album.getShelves() == 2) {
album.setShelves(1);
albumService.updateById(album);
return 1;
}
}else {
Album album = albumService.selectById(albumId);
album.setShelves(2);
albumService.updateById(album);
return 1;
}
return 2;
}
@PostMapping("/authorize/insert")
public Boolean insertAlbumVisibleRanges(@RequestBody List<AlbumVisibleRange> albumVisableRanges) {
if (!CollectionUtils.isEmpty(albumVisableRanges)) {
RequestContext context = ContextHolder.get();
Long albumId = albumVisableRanges.get(0).getAlbumId();
AlbumVisibleRange albumVisableRange = new AlbumVisibleRange();
albumVisableRange.setState(1);
albumVisableRange.setAlbumId(albumId);
EntityWrapper<AlbumVisibleRange> entityWrapper = new EntityWrapper<>(albumVisableRange);
albumVisbleRangeService.delete(entityWrapper);
for (AlbumVisibleRange albumVisableRange1 : albumVisableRanges) {
albumVisableRange1.setId(idGenerator.generate());
albumVisableRange1.setSiteId(context.getSiteId());
albumVisableRange1.setCompanyId(context.getCompanyId());
}
return albumVisbleRangeService.insertBatch(albumVisableRanges);
} else {
logger.error("列表为空 ");
return Boolean.FALSE;
}
}
@GetMapping("/VisibleRange")
public List<AlbumVisibleRange> VisibleRange(@RequestParam("albumId") Long albumId) {
AlbumVisibleRange range = new AlbumVisibleRange();
range.setAlbumId(albumId);
EntityWrapper<AlbumVisibleRange> wrapper = new EntityWrapper<AlbumVisibleRange>(range);
List<AlbumVisibleRange> list = albumVisbleRangeService.selectList(wrapper);
return list;
}
@GetMapping("/activity/export")
public Map<String, Object> activityExport(@RequestParam(name = "albumId", required = true) Long albumId) {
RequestContext requestContext = ContextHolder.get();
Date submitTime = new Date();
Long taskId = submitTime.getTime();
String serialNo = "USER-EXPORT-" + taskId;
String taskName = "专辑课程清单-" + taskId;
String result = "任务编号:" + serialNo + "。任务名称:" + taskName;
Album album = albumService.selectById(albumId);
Map<String, Object> map = new HashMap<String, Object>();
map.put("accountId", requestContext.getAccountId());
map.put("siteId", requestContext.getSiteId());
map.put("companyId", requestContext.getCompanyId());
map.put("serialNo", serialNo);
map.put("taskId", taskId);
map.put("submitTime", submitTime);
map.put("taskName", taskName);
map.put("albumId", album.getId());
map.put("name", album.getName());
map.put("result", result);
activityListExport.execute(map, true);
return map;
}
@GetMapping("/searchList")
public List<Album> searchList(@RequestParam(name = "name",required = false) String name,@RequestParam(name = "ids",required = false) List<Long> ids,
@RequestParam(name = "companyId") Long companyId, @RequestParam(name = "siteId") Long siteId) {
return albumService.searchlList(name,ids, companyId, siteId);
}
@PostMapping("/searchPage")
public Page<ApiListAlbumVo> searchPage(@RequestBody ApiSearchAlbumVo apiSearchAlbumVo) {
logger.info("微信端专辑分类进入,查询专辑列表参数={}", JSON.toJSONString(apiSearchAlbumVo));
List<Long> classifyIds = null;
Long classifyId = apiSearchAlbumVo.getClassifyId();
if (Objects.nonNull(classifyId) && classifyId.longValue() > 0) {
classifyIds = new ArrayList<>();
// 查询第一级的子分类
AlbumClassify classify = classifyService.selectById(classifyId);
Integer layer = classify.getLayer();
classifyIds.add(classifyId);
if (Objects.nonNull(layer) && layer.intValue() < 3) {
AlbumClassify classify1 = new AlbumClassify();
classify1.setParentId(classifyId);
classify1.setStatus(1);
List<AlbumClassify> firstIds = classifyService.selectList(QueryUtil.condition(classify1));
Set<Long> lastIds = null;
if (!CollectionUtils.isEmpty(firstIds)) {
lastIds = firstIds.stream().map(objfirst -> objfirst.getId()).collect(Collectors.toSet());
classifyIds.addAll(lastIds);
}
// 查询第二级的子分类
if (Objects.nonNull(lastIds) && layer.intValue() < 2) {
EntityWrapper<AlbumClassify> ew = QueryUtil.condition(new AlbumClassify());
ew.in("parent_id", lastIds);
ew.eq("status", 1);
List<AlbumClassify> dataList = classifyService.selectList(ew);
if (!CollectionUtils.isEmpty(dataList)) {
classifyIds
.addAll(dataList.stream().map(objLast -> objLast.getId()).collect(Collectors.toSet()));
}
}
}
}
Page<ApiListAlbumVo> apiListAlbumVos = albumService.searchPageSubClassify(apiSearchAlbumVo.getName(),
classifyIds, apiSearchAlbumVo.getIds(), apiSearchAlbumVo.getCompanyId(), apiSearchAlbumVo.getSiteId(),
apiSearchAlbumVo.getPageNo(), apiSearchAlbumVo.getPageSize());
return apiListAlbumVos;
}
@GetMapping("/getMyAlbumList")
public Page<ApiListAlbumVo> getMyAlbumList(@RequestParam("siteId") Long siteId,
@RequestParam("accountId") Long accountId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize) {
Page<ApiListAlbumVo> page = new Page<ApiListAlbumVo>();
page.setCurrent(pageNo);
page.setSize(pageSize);
List<Long> ids = albumService.getMyStudyList(siteId, accountId,new Page<Long>(pageNo, pageSize));
List<ApiListAlbumVo> list = new ArrayList<ApiListAlbumVo>();
for (Long id : ids) {
ApiListAlbumVo vo = new ApiListAlbumVo();
Album album = albumService.selectById(id);
if (album.getShelves().equals(1)) {
vo.setId(id);
vo.setName(album.getName());
vo.setImage(album.getImage());
vo.setOvered(album.getOvered());
vo.setUnLockTime(album.getUpdateTime());
if (album.getUpdateTime()!=null) {
long day = ((System.currentTimeMillis()-album.getUpdateTime().getTime())/(3600*24*1000));
vo.setIsNew(day>5?0:1);
}else {
vo.setIsNew(0);
}
if (album.getOvered().equals(1)) {
// 设置完结状态下专辑内课程数
vo.setCourseNum(0);
Long albumTotalCourseCount = albumMapper.getAlbumTotalCourseCount(id);
if (null != albumTotalCourseCount){
vo.setCourseNum(albumTotalCourseCount.intValue());
}
// 计算完成百分比
List<Long> activities = albumMapper.getIdsByAlbumId(id);
Integer finished = albumService.finished(activities,id, accountId, siteId);
Integer unLockNum = albumService.unLockNum(id);
if (unLockNum!=0) {
BigDecimal res = new BigDecimal(0);
BigDecimal dividendN = new BigDecimal(finished.toString());
BigDecimal divisorN = new BigDecimal(unLockNum.toString());
BigDecimal a = dividendN.multiply(new BigDecimal("100"));
res = a.divide(divisorN, 2, BigDecimal.ROUND_HALF_UP);
vo.setPercent(res.intValue());
}else {
vo.setPercent(0);
}
}
list.add(vo);
}
}
page.setRecords(list);
page.setTotal(albumMapper.getMyAlbumNum(siteId, accountId));
return page;
}
@GetMapping("/getDeatil")
public AlbumDetailVo getDeatil(@RequestParam("albumId") Long albumId, @RequestParam("accountId") Long accountId,
@RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId) {
Album album = albumService.selectById(albumId);
AlbumDetailVo vo = null;
if (album != null) {
if (album.getShelves()==1) {
vo = new AlbumDetailVo();
vo.setId(album.getId());
vo.setName(album.getName());
vo.setImage(album.getImage());
vo.setClassifyId(album.getClassifyId());
vo.setUnLockTime(album.getUpdateTime());
vo.setOvered(album.getOvered());
vo.setCommentEnable(album.getCommentEnable());
vo.setDocumentEnable(album.getDocumentEnable());
vo.setDisplay(album.getDisplay());
vo.setDescription(album.getDescription());
vo.setTags(album.getTags());
if (album.getOvered().equals(1)) {
vo.setCourseNum(0);
Long albumTotalCourseCount = albumMapper.getAlbumTotalCourseCount(albumId);
if (null != albumTotalCourseCount){
vo.setCourseNum(albumTotalCourseCount.intValue());
}
// 计算完成百分比
List<Long> ids = albumMapper.getIdsByAlbumId(albumId);
Integer finished = albumService.finished(ids,albumId, accountId, siteId);
Integer unLockNum = albumService.unLockNum(albumId);
if (unLockNum!=0) {
BigDecimal res = new BigDecimal(0);
BigDecimal dividendN = new BigDecimal(finished.toString());
BigDecimal divisorN = new BigDecimal(unLockNum.toString());
BigDecimal a = dividendN.multiply(new BigDecimal("100"));
res = a.divide(divisorN, 2, BigDecimal.ROUND_HALF_UP);
vo.setPercent(res.intValue());
}else {
vo.setPercent(0);
}
}
SubscribeVo subscribe = subscribeClient.get(albumId, TpActivityType.TYPE_ALBUM, accountId, siteId, companyId);
vo.setSubscribe(subscribe.getStatus());
vo.setStudyNum(albumService.getStudyNum(albumId));
vo.setSubscribeNum(subscribeClient.getSubscribeNum(albumId, TpActivityType.TYPE_ALBUM));
}
}
return vo;
}
@GetMapping("/getContent")
public List<AlbumThemeVo> getContent(@RequestParam("albumId") Long albumId,
@RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId,
@RequestParam("companyId") Long companyId, @RequestParam("type") Integer type,
@RequestParam("display") Integer display) {
List<AlbumThemeVo> list = new ArrayList<AlbumThemeVo>();
List<AlbumThemeVo> themes = albumService.getThemes(albumId, type);
for(AlbumThemeVo themeVo:themes) {
AlThemeActivity activity = new AlThemeActivity();
activity.setAlbumId(albumId);
activity.setThemeId(themeVo.getId());
activity.setDeleted(0);
if (!display.equals(0)) {
activity.setUnlock(0);
}
EntityWrapper<AlThemeActivity> wrapper = new EntityWrapper<AlThemeActivity>(activity);
wrapper.orderBy("sort", type.equals(1)?true:false);
List<AlThemeActivity> activitys = alThemeActivityService.selectList(wrapper);
List<AlbumActivityVo> list2 = new ArrayList<AlbumActivityVo>();
for(AlThemeActivity one:activitys) {
AlStudentActivityRecord record = new AlStudentActivityRecord();
record.setAccountId(accountId);
record.setSiteId(siteId);
record.setRelationId(one.getRelationId());
Integer count = alStudentActivityRecordMapper.selectCount(new EntityWrapper<AlStudentActivityRecord>(record));
AlbumActivityVo vo = new AlbumActivityVo();
vo.setAlbumId(one.getAlbumId());
vo.setUnlock(one.getUnlock());
vo.setId(one.getId());
vo.setRelationId(one.getRelationId());
vo.setName(one.getName());
vo.setSort(one.getSort());
vo.setUpdateTime(one.getUpdateTime());
long firstDayBetween = (System.currentTimeMillis() - vo.getUpdateTime().getTime()) / (60 * 60 * 24 * 1000);
if (firstDayBetween<=5) {
vo.setIsNew(1);
themeVo.setIsNew(1);
}else {
vo.setIsNew(0);
}
Integer status = alStudentActivityRecordMapper.getStatus(albumId, accountId, siteId, one.getRelationId());
if (status!=null) {
vo.setStatus(status.equals(0)?"进行中":"已完成");
}else {
vo.setStatus("未开始");
}
List<Long> courseId = new ArrayList<Long>();
courseId.add(one.getRelationId());
Map<Long, Long> durations = coursePcClient.getMaterialTimeByCourseIds(courseId);
Long duration = (long) 0;
if (null != durations && durations.size() > 0) {
for (Long h : durations.keySet()) {
logger.info("课程时长:" + durations.get(h));
duration = duration + (durations.get(h) != null ? durations.get(h) : 0l);
}
}
vo.setDuration(duration);
list2.add(vo);
}
themeVo.setList(list2);
list.add(themeVo);
}
return list;
}
@PostMapping("/getPortalList")
public List<ApiListAlbumVo> getPortalList(@RequestBody List<Long> ids){
List<ApiListAlbumVo> data = new ArrayList<ApiListAlbumVo>();
if (!CollectionUtils.isEmpty(ids)) {
for(Long id:ids) {
ApiListAlbumVo vo = new ApiListAlbumVo();
Album album = albumService.selectById(id);
vo.setId(album.getId());
vo.setName(album.getName());
vo.setImage(album.getImage());
vo.setOvered(album.getOvered());
vo.setUnLockTime(album.getUpdateTime());
Integer overed = album.getOvered();
vo.setCourseNum(0);
if (null != overed && overed.equals(1)){
//获取已完结状态下的所有课程数量
Long totalCourseCount = albumMapper.getAlbumTotalCourseCount(vo.getId());
if (null != totalCourseCount){
vo.setCourseNum(totalCourseCount.intValue());
}
}
List<Long> courseIds = albumMapper.getCourseIds(vo.getId());
Map<Long, Long> durations = coursePcClient.getMaterialTimeByCourseIds(courseIds);
Long duration = (long) 0;
if (null != durations && durations.size() > 0) {
for (Long h : durations.keySet()) {
logger.info("课程时长:" + durations.get(h));
duration = duration + (durations.get(h) != null ? durations.get(h) : 0l);
}
}
vo.setDuration(duration);
data.add(vo);
}
List<Long> albumIds = data.stream().map(ApiListAlbumVo::getId).collect(Collectors.toList());
List<ApiListAlbumVo> vos = alStudentActivityRecordMapper.getStudentNumByIds(albumIds);
logger.info("专辑学习人数={}", JSON.toJSONString(vos));
if (!CollectionUtils.isEmpty(vos)) {
Map<Long, Integer> dataMap = vos.stream().collect(Collectors.
toMap(key -> key.getId(), val -> val.getStudyNum()));
for (ApiListAlbumVo itemAlbum : data) {
itemAlbum.setStudyNum(dataMap.get(itemAlbum.getId()));
}
}
}
return data;
}
@PostMapping("/getMySubscribePage")
public Page<ApiListAlbumVo> getMySubscribePage(@RequestBody ApiSearchAlbumVo vo){
List<Long> ids = vo.getIds();
Integer pageNo = vo.getPageNo();
Integer pageSize = vo.getPageSize();
Page<ApiListAlbumVo> page = albumService.getMySubscribePage(ids, pageNo, pageSize);
return page;
}
@PostMapping("/getMyAlbumCount")
public Integer getMyAlbumCount(@RequestBody RequestContext context) {
return albumMapper.getMyAlbumNum(context.getSiteId(), context.getAccountId());
}
@PostMapping("/getSubcribeNum")
public Integer getSubcribeNum(@RequestBody List<Long> ids) {
return albumMapper.getSubscribeNum(ids);
}
@GetMapping("/getPageByDrools")
Page<DroolsVo> getPageByDrools(@RequestParam("field") String field,
@RequestParam(value = "value", required = false) String value,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Page<DroolsVo> page = new Page<>(pageNo, pageSize);
return albumService.getPageByDrools(field, value, page);
}
@PostMapping("/getPageToCalendar")
public Page<AlbumCalendarVo> getPageToCalendar(@ApiParam("paramVo") @RequestBody CalendarTaskParamVo paramVo) {
Page<Album> page = new Page(paramVo.getPageNo(), paramVo.getPageSize());
return albumService.getPageToCalendar(paramVo.getDate(),page);
}
@PostMapping("/listNoIds")
public Page<Album> listNoIds(@RequestBody ApiSearchAlbumVo vo) {
Page<Album> page = new Page(vo.getPageNo(),vo.getPageSize());
List<Album> data = albumMapper.selectAlbumPage(vo.getName(), vo.getIds(), vo.getCompanyId(), vo.getSiteId(), page);
page.setRecords(data);
return page;
}
}
package com.yizhi.album.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.album.application.domain.ClassifyStrategy;
import com.yizhi.album.application.service.IClassifyStrategyService;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* <p>
* 专辑分类策略 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController(value = "classifyStrategyController1")
@RequestMapping("/remote/classifyStrategy")
public class ClassifyStrategyController {
@Autowired
private IClassifyStrategyService classifyStrategyService;
@Autowired
com.yizhi.application.orm.id.IdGenerator IdGenerator;
@GetMapping("/update")
public com.yizhi.album.application.vo.domain.ClassifyStrategy update(@RequestParam(value = "type", required = true) Integer type, @RequestParam(value = "status", required = true) Integer status) {
RequestContext context = ContextHolder.get();
Long siteId = context.getSiteId();
Long companyId = context.getCompanyId();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
ClassifyStrategy strategy = new ClassifyStrategy();
strategy.setSiteId(siteId);
strategy.setCompanyId(companyId);
EntityWrapper<ClassifyStrategy> wrapper = new EntityWrapper<ClassifyStrategy>(strategy);
ClassifyStrategy one = classifyStrategyService.selectOne(wrapper);
if (one==null) {
one = new ClassifyStrategy();
one.setId(IdGenerator.generate());
one.setType(type);
one.setStatus(status);
one.setCreateById(accountId);
one.setCreateByName(name);
one.setCreateTime(date);
one.setCompanyId(companyId);
one.setSiteId(siteId);
classifyStrategyService.insert(one);
}else {
one.setType(type);
one.setStatus(status);
one.setUpdateById(accountId);
one.setUpdateByName(name);
one.setUpdateTime(date);
classifyStrategyService.updateById(one);
}
com.yizhi.album.application.vo.domain.ClassifyStrategy classifyStrategy = new com.yizhi.album.application.vo.domain.ClassifyStrategy();
BeanUtils.copyProperties(one, classifyStrategy);
return classifyStrategy;
}
@GetMapping("/get")
public com.yizhi.album.application.vo.domain.ClassifyStrategy get(@RequestParam(value = "companyId", required = true) Long companyId, @RequestParam(value = "siteId", required = true) Long siteId) {
ClassifyStrategy strategy = new ClassifyStrategy();
strategy.setSiteId(siteId);
strategy.setCompanyId(companyId);
EntityWrapper<ClassifyStrategy> wrapper = new EntityWrapper<ClassifyStrategy>(strategy);
ClassifyStrategy one = classifyStrategyService.selectOne(wrapper);
com.yizhi.album.application.vo.domain.ClassifyStrategy classifyStrategy = new com.yizhi.album.application.vo.domain.ClassifyStrategy();
BeanUtils.copyProperties(one, classifyStrategy);
return classifyStrategy;
}
}
package com.yizhi.album.application.controller.remote;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.util.BuildJob;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* <p>
* 前端控制器
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController(value = "remoteJobHandleController1")
@Api(tags = "专辑涉及job接口")
@RequestMapping("/remote/album")
public class RemoteJobHandleController {
@Autowired
private BuildJob buildJob;
@Autowired
private IAlbumService albumService;
private Logger logger = LoggerFactory.getLogger(RemoteJobHandleController.class);
/**
* 定时任务执行实际的处理逻辑类
* 定时任务业务逻辑处理
*
* @param
* @return
*/
@GetMapping("/albumUnLock")
@ApiOperation(value = "定时解锁专辑课程", response = String.class)
public void unLockCourse() {
try {
logger.info("开始处理定时任务");
albumService.unLockCourse();
} catch (Exception e) {
e.printStackTrace();
logger.info("定时任务处理异常");
}
}
@GetMapping("/buildJob")
@ApiOperation(value = "构建一个job任务,默认每五分钟处理,也可指定cron表达式", response = String.class)
public void buildJob(@RequestParam(value = "hanldeTime",required = false)Date hanldeTime ) throws Exception {
if (hanldeTime == null){
buildJob.buildJobDefault("定时解锁专辑课程,默认每五分钟处理一次");
}else {
buildJob.buildJob(new Date().toString(),hanldeTime);
}
}
}
package com.yizhi.album.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.domain.AlThemeActivity;
import com.yizhi.album.application.domain.Album;
import com.yizhi.album.application.mapper.AlbumMapper;
import com.yizhi.album.application.service.IAlThemeActivityService;
import com.yizhi.album.application.service.IAlThemeService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.vo.AlThemeVo;
import com.yizhi.album.application.vo.AlbumVo;
import com.yizhi.comment.application.feign.ManageCommentClient;
import com.yizhi.comment.application.feign.SubscribeClient;
import com.yizhi.course.application.feign.CoursePcClient;
import com.yizhi.util.application.beanutil.BeanCopyListUtil;
import com.yizhi.util.application.constant.TpActivityType;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <p>
* 专辑报表用
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@RestController(value = "statisticsAlbumController1")
@RequestMapping("/remote/statisticsAlbum")
public class StatisticsAlbumController {
@Autowired
private IAlbumService albumService;
@Autowired
private AlbumMapper albumMapper;
@Autowired
private IAlThemeActivityService alThemeActivityService;
@Autowired
private IAlThemeService alThemeService;
@Autowired
private CoursePcClient coursePcClient;
@Autowired
private ManageCommentClient commentClient;
@Autowired
private SubscribeClient subscribeClient;
@GetMapping("/getAllAlbums")
public List<AlbumVo> getAllAlbums(@RequestParam(name = "companyId",required = false)Long companyId,@RequestParam(name = "siteId",required = false)Long siteId){
List<AlbumVo> allAlbums = new ArrayList<AlbumVo>();
List<Long> list = albumMapper.getAllAlbums(companyId, siteId);
List<Long> courseIds = new ArrayList<Long>();
if (CollectionUtils.isNotEmpty(list)) {
for(Long albumId:list) {
int num = 0;
AlbumVo albumVo = new AlbumVo();
Album album = albumService.selectById(albumId);
albumVo.setId(album.getId());
albumVo.setName(album.getName());
albumVo.setShelves(album.getShelves());
albumVo.setClassifyId(album.getClassifyId());
albumVo.setImage(album.getImage());
albumVo.setDescription(album.getDescription());
albumVo.setTags(album.getTags());
albumVo.setScope(album.getScope());
albumVo.setCommentEnable(album.getCommentEnable());
albumVo.setDocumentEnable(album.getDocumentEnable());
albumVo.setOvered(album.getOvered());
albumVo.setDisplay(album.getDisplay());
albumVo.setSiteId(album.getSiteId());
albumVo.setCompanyId(album.getCompanyId());
albumVo.setCreateTime(album.getCreateTime());
List<AlThemeVo> list1 = new ArrayList<AlThemeVo>();
AlTheme theme = new AlTheme();
theme.setAlbumId(albumId);
theme.setDeleted(0);
EntityWrapper<AlTheme> wrapper = new EntityWrapper<AlTheme>(theme);
wrapper.orderBy("sort", true);
List<AlTheme> themes = alThemeService.selectList(wrapper);
for(AlTheme alTheme:themes) {
AlThemeVo themeVo = new AlThemeVo();
themeVo.setAlbumId(albumId);
themeVo.setId(alTheme.getId());
themeVo.setName(alTheme.getName());
List<AlThemeActivity> activities = new ArrayList<AlThemeActivity>();
AlThemeActivity activity = new AlThemeActivity();
activity.setThemeId(alTheme.getId());
activity.setDeleted(0);
EntityWrapper<AlThemeActivity> entityWrapper = new EntityWrapper<AlThemeActivity>(activity);
entityWrapper.orderBy("sort", true);
activities = alThemeActivityService.selectList(entityWrapper);
for(AlThemeActivity alThemeActivity:activities) {
alThemeActivity.setThemeName(alTheme.getName());
if (alThemeActivity.getUnlock().equals(0)) {
courseIds.add(alThemeActivity.getRelationId());
}else {
num++;
}
}
//拷贝vo
List<com.yizhi.album.application.vo.domain.AlThemeActivity> alThemeActivityVoList = new ArrayList<>();
for (AlThemeActivity alThemeActivity : activities) {
com.yizhi.album.application.vo.domain.AlThemeActivity activityVo = new com.yizhi.album.application.vo.domain.AlThemeActivity();
BeanUtils.copyProperties(alThemeActivity,activityVo);
alThemeActivityVoList.add(activityVo);
}
themeVo.setActivities(alThemeActivityVoList);
list1.add(themeVo);
}
Map<Long, Long> durations = coursePcClient.getMaterialTimeByCourseIds(courseIds);
Long duration = (long) 0;
if (null != durations && durations.size() > 0) {
for (Long h : durations.keySet()) {
duration = duration + (durations.get(h) != null ? durations.get(h) : 0l);
}
}
albumVo.setCommentCount(commentClient.getCommentNum(albumId, TpActivityType.TYPE_ALBUM));
albumVo.setSubscribeCount(subscribeClient.getSubscribeNum(albumId, TpActivityType.TYPE_ALBUM));
albumVo.setDuration(duration);
albumVo.setList(list1);
albumVo.setLockNum(num);
allAlbums.add(albumVo);
courseIds.clear();
}
}
return allAlbums;
}
}
package com.yizhi.album.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 学员完成专辑活动记录
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlStudentActivityRecord", description = "学员完成专辑活动记录")
@TableName("al_student_activity_record")
public class AlStudentActivityRecord {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "学员id")
@TableField("account_id")
private Long accountId;
@ApiModelProperty(value = "冗余专辑id")
@TableField("album_id")
private Long albumId;
@ApiModelProperty(value = "课程id")
@TableField("relation_id")
private Long relationId;
@ApiModelProperty(value = "若是课程,需要记录学习时长")
private Long seconds;
@ApiModelProperty(value = "是否完成(1是,0否),默认未完成。")
private Integer finished;
@ApiModelProperty(value = "完成时间")
@TableField("finish_date")
private Date finishDate;
@ApiModelProperty(value = "所属站点id")
@TableField("site_id")
private Long siteId;
}
package com.yizhi.album.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑 - 主题
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlTheme", description = "专辑 - 主题")
@TableName("al_theme")
public class AlTheme {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "所属专辑id")
@TableField("album_id")
private Long albumId;
@ApiModelProperty(value = "主题名称")
private String name;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "是否删除(1是,0否),默认否")
private Integer deleted;
@ApiModelProperty(value = "创建者id")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建者名称")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新者id")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改者名称")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "站点id")
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "组织id")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "企业id")
@TableField("company_id")
private Long companyId;
}
package com.yizhi.album.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 主题中的课程
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlThemeActivity", description = "主题中的课程")
@TableName("al_theme_activity")
public class AlThemeActivity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "冗余专辑id")
@TableField("album_id")
private Long albumId;
@ApiModelProperty(value = "主题id")
@TableField("theme_id")
private Long themeId;
@ApiModelProperty(value = "主题名称")
private String themeName;
@ApiModelProperty(value = "课程id")
@TableField("relation_id")
private Long relationId;
@ApiModelProperty(value = "课程code")
@TableField("relation_code")
private String relationCode;
@ApiModelProperty(value = "课程名称")
private String name;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "是否删除(1是,0否),默认否")
private Integer deleted;
@ApiModelProperty(value = "解锁状态 0已解锁 1发布及解锁 2自定义解锁")
private Integer unlock;
@ApiModelProperty(value = "解锁时间")
@TableField("unlock_time")
private Date unlockTime;
@ApiModelProperty(value = "创建者id")
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@ApiModelProperty(value = "创建者名称")
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(value = "更新者id")
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@ApiModelProperty(value = "修改者名称")
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@ApiModelProperty(value = "站点id")
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "组织id")
@TableField("org_id")
private Long orgId;
@ApiModelProperty(value = "企业id")
@TableField("company_id")
private Long companyId;
}
package com.yizhi.album.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑表
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "Album", description = "专辑表")
@TableName("album")
public class Album {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "专辑名称")
private String name;
@ApiModelProperty(value = "专辑封面图")
private String image;
@ApiModelProperty(value = "专辑介绍")
private String description;
@ApiModelProperty(value = "自定义关键字")
private String tags;
@ApiModelProperty(value = "0 未上架 1 已上架 2草稿")
private Integer shelves;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@TableField("company_id")
private Long companyId;
@TableField("org_id")
private Long orgId;
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "分类id")
@TableField("classify_id")
private Long classifyId;
@ApiModelProperty(value = "可见范围 1 平台用户 2 指定范围 默认全平台可见")
private Integer scope;
@ApiModelProperty(value = "专辑评论 0显示 1不显示 默认显示")
@TableField("comment_enable")
private Integer commentEnable;
@ApiModelProperty(value = "专辑资料 0显示 1不显示 默认显示")
@TableField("document_enable")
private Integer documentEnable;
@ApiModelProperty(value = "0:默认未删除;1表示删除")
@TableField("del_flg")
private Integer delFlg;
@ApiModelProperty(value = "完成状态 0连载中 1已完结")
private Integer overed;
@ApiModelProperty(value = "显示模式 0全部显示 1只显示已解锁课程 默认全部显示")
private Integer display;
@ApiModelProperty(value = "专辑是否在日历中显示 默认为 0:不开启 1:开启")
@TableField("enable_task")
private Integer enableTask;
@ApiModelProperty(value = "日历任务开始时间:enable-task不为0时,有值")
@TableField(value = "task_start_date")
private Date taskStartDate;
@ApiModelProperty(value = "日历任务结束时间:enable-task不为0时,有值")
@TableField(value = "task_end_date")
private Date taskEndDate;
}
package com.yizhi.album.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 专辑分类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "AlbumClassify", description = "专辑分类")
@TableName("album_classify")
public class AlbumClassify extends Model<AlbumClassify>{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "父id ")
@TableField("parent_id")
private Long parentId;
@ApiModelProperty(value = "层级")
private Integer layer;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "分类编码")
private String code;
@ApiModelProperty(value = "备注")
private String description;
@ApiModelProperty(value = "状态")
private Integer status;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@TableField("org_id")
private Long orgId;
@TableField("company_id")
private Long companyId;
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "顶层节点id")
@TableField("root_id")
private Long rootId;
@ApiModelProperty(value = "排序")
private Integer sort;
private String path;
@Override
protected Serializable pkVal() {
// TODO Auto-generated method stub
return this.id;
}
}
package com.yizhi.album.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 专辑可见范围表
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@ApiModel(value = "AlbumVisableRange", description = "专辑可见范围表")
@TableName("album_visible_range")
@Data
public class AlbumVisibleRange {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "专辑主键_ID,外键")
@TableField("album_id")
private Long albumId;
@ApiModelProperty(value = "1用户 2组织")
private Integer type;
@ApiModelProperty(value = "存放人或组织的ID")
@TableField("relation_id")
private Long relationId;
@ApiModelProperty(value = "名称")
@TableField("name")
private String name;
@ApiModelProperty(value = "真实姓名")
@TableField("full_name")
private String fullName;
@ApiModelProperty(value = "0删除 1有效,默认有效")
@TableLogic
private Integer state;
@ApiModelProperty(value = "站点_ID")
@TableField("site_id")
private Long siteId;
@ApiModelProperty(value = "企业_ID")
@TableField("company_id")
private Long companyId;
}
package com.yizhi.album.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 专辑分类策略
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "ClassifyStrategy", description = "专辑分类策略")
@TableName("classify_strategy")
public class ClassifyStrategy {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "策略类型 0平铺式 1展开式 默认平铺式")
private Integer type;
@ApiModelProperty(value = "状态")
private Integer status;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@TableField("company_id")
private Long companyId;
@TableField("site_id")
private Long siteId;
}
package com.yizhi.album.application.event;
import com.yizhi.album.application.domain.AlStudentActivityRecord;
import com.yizhi.album.application.mapper.AlStudentActivityRecordMapper;
import com.yizhi.album.application.mapper.AlThemeActivityMapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.cache.CacheNamespace;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.event.EventWrapper;
import com.yizhi.util.application.event.TrainingProjectEvent;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class AlEventHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AlEventHandler.class);
@Autowired
private IdGenerator idGenerator;
@Autowired
private RedisCache redisCache;
@Autowired
private AlStudentActivityRecordMapper alStudentActivityRecordMapper;
@Autowired
private AlThemeActivityMapper alThemeActivityMapper;
public void handle(EventWrapper<TrainingProjectEvent> ew) {
TrainingProjectEvent event = ew.getData();
LOGGER.info("接收到消息:{}", event);
List<Long> list = alThemeActivityMapper.getIdsByActivityId(event.getId(), event.getSiteId());
if (CollectionUtils.isNotEmpty(list)) {
for(Long id :list) {
AlStudentActivityRecord aar = new AlStudentActivityRecord();
aar.setId(idGenerator.generate());
aar.setAccountId(event.getAccountId());
aar.setAlbumId(id);
aar.setFinishDate(event.getNow());
aar.setFinished(event.getCourseFinished() == null ? 0 : event.getCourseFinished() ? 1 : 0);
aar.setSeconds(event.getCourseSeconds());
aar.setRelationId(event.getId());
aar.setSiteId(event.getSiteId());
LOGGER.info("入库主题活动完成记录:{}", aar);
Integer result = alStudentActivityRecordMapper.insert(aar);
// 缓存完成记录
if (result.equals(1)) {
if (aar.getFinished().equals(1)) {
cacheRecord(CacheNamespace.AL_ACTIVITY_FINISHED, aar.getAccountId(), aar.getRelationId(), id,1);
cacheDeleteUnfinished(aar.getAccountId(), aar.getRelationId(),id);
} else {
cacheRecord(CacheNamespace.AL_ACTIVITY_UNFINISHED, aar.getAccountId(), aar.getRelationId(),id, 0);
}
}
}
}
}
/**
* 缓存学习记录
*
* @param keyPrefix
* @param accountId
* @param id planId or relationId
*/
private void cacheRecord(String keyPrefix, long accountId, long id,long albumId, Integer finished) {
redisCache.hsetIfAbsent(keyPrefix.concat(String.valueOf(accountId+":"+albumId)), String.valueOf(id),
String.valueOf(finished));
}
/**
* 删除已完成中曾经的未完成记录
*
* @param accountId
* @param relationId
*/
private void cacheDeleteUnfinished(long accountId, long relationId,long albumId) {
redisCache.hdel(CacheNamespace.AL_ACTIVITY_UNFINISHED.concat(String.valueOf(accountId+":"+albumId)),
new String[] { String.valueOf(relationId) });
}
}
package com.yizhi.album.application.event;
import com.yizhi.core.application.event.EventWrapper;
import com.yizhi.util.application.constant.QueueConstant;
import com.yizhi.util.application.event.TrainingProjectEvent;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@RabbitListener(queues = QueueConstant.ALBUM_EVENT_QUEUE)
public class AlEventListener {
@Autowired
private AlEventHandler alEventHandler;
@RabbitHandler
public void processBizEvent(EventWrapper<TrainingProjectEvent> ew) {
alEventHandler.handle(ew);
}
}
package com.yizhi.album.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.album.application.domain.AlStudentActivityRecord;
import com.yizhi.album.application.vo.ApiListAlbumVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 学员完成专辑活动记录 Mapper 接口
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface AlStudentActivityRecordMapper extends BaseMapper<AlStudentActivityRecord> {
public List<ApiListAlbumVo> getStudentNumByIds(@Param(value = "ids") List<Long> ids);
public Integer getStudyNum(@Param(value = "albumId") Long albumId);
List<Long> getRecordeAllWorkId();
List<AlStudentActivityRecord> getAllRecordeByTimeLimit(@Param(value="startDate")String startDate,@Param(value="endDate")String endDate,@Param("relationId")Long relationId);
Integer getStatus(@Param(value = "albumId") Long albumId, @Param(value = "accountId") Long accountId,
@Param(value = "siteId") Long siteId,@Param("relationId")Long relationId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.yizhi.album.application.mapper.AlStudentActivityRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="ApiResultMap"
type="com.yizhi.album.application.vo.ApiListAlbumVo">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="image" property="image" />
<result column="classify_id" property="classifyId" />
<result column="overed" property="overed" />
<result column="valid" property="valid" />
<result column="update_time" property="unLockTime" />
</resultMap>
<select id="getStudentNumByIds"
resultType="com.yizhi.album.application.vo.ApiListAlbumVo">
select COUNT(DISTINCT a.account_id) studyNum,a.album_id id FROM
al_student_activity_record a
where a.album_id
IN
<foreach collection="ids" index="index" item="id"
separator="," open="(" close=")">
#{id}
</foreach>
GROUP BY a.album_id
</select>
<select id="getStudyNum" resultType="java.lang.Integer">
select COUNT(DISTINCT
a.account_id) studyNum FROM al_student_activity_record
a
where
a.album_id
=#{albumId}
</select>
<select id="getRecordeAllWorkId" resultType="java.lang.Long">
SELECT DISTINCT(relation_id) FROM `al_theme_activity` a LEFT JOIN album b on a.album_id=b.id where a.deleted = 0
</select>
<select id="getAllRecordeByTimeLimit"
resultType="com.yizhi.album.application.vo.domain.AlStudentActivityRecord">
select * from al_student_activity_record a LEFT JOIN album b on a.album_id=b.id
where relation_id=#{relationId} and b.shelves = 1 and b.del_flg =0
<if
test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
AND (<![CDATA[ DATE_FORMAT(finish_date,'%Y-%m-%d')<=DATE_FORMAT(#{endDate,jdbcType=VARCHAR},'%Y-%m-%d') ]]>
AND <![CDATA[ DATE_FORMAT(finish_date,'%Y-%m-%d')>=DATE_FORMAT(#{startDate,jdbcType=VARCHAR},'%Y-%m-%d') ]]>)
</if>
</select>
<select id="getStatus" resultType="java.lang.Integer">
select MAX(finished) from al_student_activity_record where
relation_id=#{relationId} and album_id = #{albumId} and account_id =
#{accountId} and site_id = #{siteId}
</select>
</mapper>
package com.yizhi.album.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.album.application.domain.AlThemeActivity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 主题中的课程 Mapper 接口
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface AlThemeActivityMapper extends BaseMapper<AlThemeActivity> {
Integer maxSort(@Param(value = "themeId")Long themeId,@Param(value = "siteId")Long siteId);
List<AlThemeActivity> list(@Param(value = "themeId")Long themeId,@Param(value = "type")Integer type);
List<Long> getIdsByActivityId(@Param("activityId") Long activityId, @Param("siteId") Long siteId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.yizhi.album.application.mapper.AlThemeActivityMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap"
type="com.yizhi.album.application.domain.AlThemeActivity">
<id column="id" property="id" />
<result column="album_id" property="albumId" />
<result column="theme_id" property="themeId" />
<result column="relation_id" property="relationId" />
<result column="relation_code" property="relationCode" />
<result column="name" property="name" />
<result column="sort" property="sort" />
<result column="deleted" property="deleted" />
<result column="unlock" property="unlock" />
<result column="unlock_time" property="unlockTime" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="create_time" property="createTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="update_time" property="updateTime" />
<result column="company_id" property="companyId" />
<result column="org_id" property="orgId" />
<result column="site_id" property="siteId" />
</resultMap>
<select id="maxSort" resultType="java.lang.Integer">
SELECT
IFNULL(max(a.sort),0)
FROM
al_theme_activity a
WHERE
a.`theme_id` = #{themeId}
AND a.site_id =
#{siteId}
AND a.deleted = 0
</select>
<select id="list" resultMap="BaseResultMap">
SELECT
*
FROM
al_theme_activity a
WHERE
a.deleted = 0
AND a.theme_id = #{themeId}
<choose>
<when test="type != null and type==0">
AND a.`unlock` = 0
</when>
<otherwise>
AND a.`unlock` != 0
</otherwise>
</choose>
ORDER BY a.sort
</select>
<select id="getIdsByActivityId" resultType="java.lang.Long">
select distinct a.id
from album a
left join al_theme_activity ata on ata.album_id = a.id
where ata.relation_id = #{activityId} and a.site_id = #{siteId} and ata.unlock=0 and a.shelves=1 and a.del_flg=0
</select>
</mapper>
package com.yizhi.album.application.mapper;
import com.yizhi.album.application.domain.AlTheme;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 专辑 - 主题 Mapper 接口
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface AlThemeMapper extends BaseMapper<AlTheme> {
Integer vailName(@Param(value = "id") Long id,@Param(value = "albumId") Long albumId, @Param(value = "name") String name, @Param(value = "siteId") Long siteId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yizhi.album.application.mapper.AlThemeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap"
type="com.yizhi.album.application.domain.AlTheme">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="album_id" property="albumId" />
<result column="sort" property="sort" />
<result column="deleted" property="deleted" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="create_time" property="createTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="update_time" property="updateTime" />
<result column="company_id" property="companyId" />
<result column="org_id" property="orgId" />
<result column="site_id" property="siteId" />
</resultMap>
<select id="vailName" resultType="java.lang.Integer">
SELECT
COUNT(a.id)
FROM
al_theme a
WHERE
a.`name` = #{name}
AND a.site_id =
#{siteId}
AND a.`album_id` = #{albumId}
<if test="id!=null ">
AND a.`id` != #{id}
</if>
AND a.deleted = 0
</select>
</mapper>
package com.yizhi.album.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.album.application.domain.AlbumClassify;
import com.yizhi.album.application.vo.AlbumClassifyVo;
import com.yizhi.album.application.vo.ApiAlbumClassifyVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
/**
* <p>
* 专辑分类 Mapper 接口
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface AlbumClassifyMapper extends BaseMapper<AlbumClassify> {
/**
* 查找这个父级分类下的最大排序数
* @param parentId
* @return
*/
int selectSort(@Param("ParentId") Long parentId);
/**
*查找这个分类下的层数
* @param parentId
* @return
*/
@Select("select ifnull(layer,0)\n" +
"from cloud_album.album_classify\n" +
"where parent_id=#{ParentId}\n" +
"limit 1")
int selectLayer(@Param("ParentId") Long parentId);
/**
* 根据id查找层级
* @param Id
* @return
*/
int selectParentLayer(@Param("Id") Long Id);
/**
* 根据id查找root_id
* @param Id
* @return
*/
Long selectRootid(@Param("Id") Long Id);
/**
* 根据id查找其有没有子级分类
* @param Id
* @return
*/
Long selectChild(@Param("Id") Long Id);
/**
* 根据分类id查找下面所挂的专辑
* @param Id
* @return
*/
Long selectAlbum(@Param("Id") Long Id, @Param("siteId") Long siteId);
List<ApiAlbumClassifyVo> selectListByCompanyId(@Param("companyId") Long companyId, @Param("name") String name,
@Param("orgIds") List<Long> orgIds, @Param("siteId") Long siteId,
RowBounds rowBounds);
Integer selectCountByCompanyId(@Param("companyId") Long companyId,@Param("name") String name,@Param("orgIds") List<Long> orgIds,@Param("siteId") Long siteId);
List<AlbumClassify> selectClassifyByRootId(@Param("ids") List<Long> ids);
List<AlbumClassify> selectClassifyByLayer(@Param("companyId") Long companyId,@Param("siteId") Long siteId,@Param("layer") Integer layer);
@Select("<script>" +
"SELECT parent_id AS id ,COUNT(0) AS total FROM album_classify " +
"WHERE parent_id in " +
"<foreach collection=\"classifyIds\" open=\"(\" close=\")\" separator=\",\" item=\"cid\" index=\"index\">"+
"#{cid}"+
"</foreach>"+
" GROUP BY parent_id" +
"</script>")
List<AlbumClassifyVo> findExistChildNodes(@Param("classifyIds") List<Long> classifyIds);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yizhi.album.application.mapper.AlbumClassifyMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.album.application.domain.AlbumClassify">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="layer" property="layer"/>
<result column="name" property="name"/>
<result column="code" property="code"/>
<result column="description" property="description"/>
<result column="status" property="status"/>
<result column="create_by_id" property="createById"/>
<result column="create_by_name" property="createByName"/>
<result column="create_time" property="createTime"/>
<result column="update_by_id" property="updateById"/>
<result column="update_by_name" property="updateByName"/>
<result column="update_time" property="updateTime"/>
<result column="org_id" property="orgId"/>
<result column="company_id" property="companyId"/>
<result column="site_id" property="siteId"/>
<result column="root_id" property="rootId"/>
<result column="sort" property="sort"/>
<result column="path" property="path"/>
</resultMap>
<resultMap id="ApiResultMap" type="com.yizhi.album.application.vo.ApiAlbumClassifyVo">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="layer" property="layer"/>
<result column="name" property="name"/>
<result column="code" property="code"/>
<result column="description" property="description"/>
<result column="status" property="status"/>
<result column="create_by_id" property="createById"/>
<result column="create_by_name" property="createByName"/>
<result column="create_time" property="createTime"/>
<result column="update_by_id" property="updateById"/>
<result column="update_by_name" property="updateByName"/>
<result column="update_time" property="updateTime"/>
<result column="org_id" property="orgId"/>
<result column="company_id" property="companyId"/>
<result column="site_id" property="siteId"/>
<result column="root_id" property="rootId"/>
<result column="sort" property="sort"/>
<result column="path" property="path"/>
</resultMap>
<select id="selectListByCompanyId" resultMap="ApiResultMap">
SELECT
c.*
FROM
album_classify c
WHERE
c.company_id = #{companyId}
AND
c.site_id = #{siteId}
AND
c.layer = 1
AND
c.status = 1
<if test="name != null">
AND ( c.`name` LIKE CONCAT('%', #{name}, '%'))
</if>
ORDER BY
c.sort DESC
</select>
<select id="selectCountByCompanyId" resultType="java.lang.Integer">
SELECT
count(c.id)
FROM
album_classify c
WHERE
c.company_id = #{companyId}
AND
c.site_id = #{siteId}
AND
c.layer = 1
AND
c.status = 1
<if test="name != null">
AND ( c.`name` LIKE CONCAT('%', #{name}, '%'))
</if>
</select>
<select id="selectClassifyByRootId" resultMap="BaseResultMap">
SELECT
*
FROM
album_classify c
WHERE
c.status = 1
AND
(c.id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>)
ORDER BY
c.layer ASC
</select>
<!-- 查询层级分类 -->
<select id="selectClassifyByLayer" resultMap="BaseResultMap">
SELECT
c.*
FROM
album_classify c
WHERE
c.company_id = #{companyId}
AND
c.site_id = #{siteId}
AND
c.status = 1
<if test="layer != null">
AND c.layer = #{layer}
</if>
ORDER BY
c.sort DESC
</select>
<select id="selectSort" resultType="java.lang.Integer">
SELECT
ifnull(max(sort), 0)
FROM
cloud_album.album_classify
WHERE
parent_id = #{ParentId}
LIMIT 1
</select>
<select id="selectParentLayer" resultType="java.lang.Integer">
SELECT
layer
FROM
cloud_album.album_classify
WHERE
id = #{Id}
LIMIT 1
</select>
<select id="selectRootid" resultType="java.lang.Long">
SELECT
root_id
FROM
cloud_album.album_classify
WHERE
id = #{Id}
LIMIT 1
</select>
<select id="selectChild" resultType="java.lang.Long">
SELECT
ifnull(id, 0)
FROM
cloud_album.album_classify
WHERE
parent_id = #{Id}
AND STATUS = 1
LIMIT 1
</select>
<select id="selectAlbum" resultType="java.lang.Long">
SELECT
ifnull(id, 0)
FROM
cloud_album.album
WHERE
classify_id = #{Id}
and site_id = #{siteId}
AND del_flg = 0
LIMIT 1
</select>
</mapper>
package com.yizhi.album.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.domain.Album;
import com.yizhi.album.application.vo.AlbumActivityVo;
import com.yizhi.album.application.vo.AlbumThemeVo;
import com.yizhi.album.application.vo.ApiListAlbumVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import java.util.Date;
import java.util.List;
/**
* <p>
* 专辑表 Mapper 接口
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface AlbumMapper extends BaseMapper<Album> {
List<Album> searchPage(@Param("name") String name, @Param("alClassifyId") Long alClassifyId,
@Param("status") Integer status, @Param("overed") Integer overed, @Param("companyId") Long companyId,
@Param("siteId") Long siteId, Page<Album> page);
Integer vailName(@Param(value = "id") Long id, @Param(value = "name") String name,
@Param(value = "siteId") Long siteId);
List<Album> selectAlbumList(@Param("name") String name,@Param(value = "ids") List<Long> ids, @Param("companyId") Long companyId,
@Param("siteId") Long siteId);
List<Album> selectAlbumPage(@Param("name") String name,@Param(value = "ids") List<Long> ids, @Param("companyId") Long companyId,
@Param("siteId") Long siteId,Page<Album> page);
List<ApiListAlbumVo> searchPageSubClassify(@Param("name") String name, @Param("classifyIds") List<Long> classifyIds,
@Param("ids") List<Long> ids, @Param("companyId") Long companyId, @Param("siteId") Long siteId,
RowBounds rowBounds);
List<Long> getCourseIds(@Param(value = "id") Long id);
List<Long> getMyStudyList(@Param(value = "siteId") Long siteId, @Param(value = "accountId") Long accountId,Page<Long> page);
Integer finished(@Param(value = "ids") List<Long> ids,@Param(value = "albumId") Long albumId, @Param(value = "accountId") Long accountId,
@Param(value = "siteId") Long siteId);
Integer unLockNum(@Param(value = "albumId") Long albumId);
List<AlbumThemeVo> geThemeVos(@Param(value = "albumId") Long albumId, @Param(value = "type") Integer type);
List<AlbumActivityVo> getActivityVos(@Param(value = "albumId") Long albumId, @Param(value = "type") Integer type,
@Param(value = "display") Integer display);
List<Long> getLockList();
List<ApiListAlbumVo> getMySubscribePage(@Param("ids") List<Long> ids, Page<ApiListAlbumVo> page);
List<Long> getAllAlbums(@Param("companyId") Long companyId, @Param("siteId") Long siteId);
List<Long> getIdsByAlbumId(@Param(value = "albumId") Long albumId);
Integer getMyAlbumNum(@Param(value = "siteId") Long siteId, @Param(value = "accountId") Long accountId);
Integer getSubscribeNum(@Param("ids") List<Long> ids);
List<Long> getIdsByDate(@Param("currentDate") Date currentDate, @Param("siteId") Long siteId);
List<Album> getPageToCalendar(@Param("passIds") List<Long> passIds,
@Param("albumIdsFromVisibeRange") List<Long> albumIdsFromVisibeRange,
@Param("currentDate") Date currentDate,
@Param("siteId") Long siteId,
Page page);
Integer getPageToCalendarNum(@Param("passIds") List<Long> passIds,
@Param("albumIdsFromVisibeRange") List<Long> albumIdsFromVisibeRange,
@Param("currentDate") Date currentDate,
@Param("siteId") Long siteId);
/**
* 获取已完结状态下的专辑内课程数
* @param albumId 专辑id
*/
Long getAlbumTotalCourseCount(@Param("albumId") Long albumId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yizhi.album.application.mapper.AlbumMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap"
type="com.yizhi.album.application.domain.Album">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="image" property="image" />
<result column="description" property="description" />
<result column="tags" property="tags" />
<result column="shelves" property="shelves" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="create_time" property="createTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="update_time" property="updateTime" />
<result column="company_id" property="companyId" />
<result column="org_id" property="orgId" />
<result column="site_id" property="siteId" />
<result column="classify_id" property="classifyId" />
<result column="scope" property="scope" />
<result column="comment_enable" property="commentEnable" />
<result column="document_enable" property="documentEnable" />
<result column="del_flg" property="delFlg" />
<result column="overed" property="overed" />
<result column="display" property="display" />
<result column="enable_task" property="enableTask" />
<result column="task_start_date" property="taskStartDate" />
<result column="task_end_date" property="taskEndDate" />
</resultMap>
<select id="searchPage" resultMap="BaseResultMap">
SELECT
*
FROM
album a LEFT JOIN album_classify cy
ON a.classify_id =
cy.id
where
<if test="companyId != null">
a.`company_id` = #{companyId}
</if>
<if test="siteId != null">
AND a.`site_id` = #{siteId}
</if>
<if test="alClassifyId != null">
AND a.classify_id = #{alClassifyId}
</if>
<if test="status != null and status == 1">
AND a.`shelves` = 1
</if>
<if test="status != null and status != 1">
AND (a.`shelves` = 0 OR a.`shelves` = 2)
</if>
<if test="overed != null ">
AND a.`overed` = #{overed}
</if>
<if test="name != null">
AND ( a.`name` LIKE CONCAT('%', #{name}, '%') or a.`tags`
like concat('%', #{name}, '%'))
</if>
AND a.del_flg = 0
ORDER BY a.`create_time` DESC
</select>
<select id="vailName" resultType="java.lang.Integer">
SELECT
COUNT(a.id)
FROM
album a
WHERE
a.`name` = #{name}
AND a.site_id =
#{siteId}
<if test="id!=null">
AND a.`id` != #{id}
</if>
AND a.del_flg = 0
</select>
<select id="selectAlbumList" resultMap="BaseResultMap">
SELECT * FROM
album a
where
a.company_id = #{companyId}
AND
a.site_id =
#{siteId}
AND
a.del_flg = 0
<if test="name!=null">
AND ( a.`name` LIKE CONCAT('%', #{name}, '%') OR a.`tags`
LIKE
CONCAT('%', #{name}, '%') )
</if>
<if test="ids != null and ids.size > 0 ">
AND a.id not in
<foreach collection="ids" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</if>
and a.`shelves` = 1
</select>
<!-- 通用查询映射结果 -->
<resultMap id="ApiResultMap"
type="com.yizhi.album.application.vo.ApiListAlbumVo">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="image" property="image" />
<result column="classify_id" property="classifyId" />
<result column="overed" property="overed" />
<result column="update_time" property="unLockTime" />
</resultMap>
<!-- 专辑学员端分页查询 -->
<select id="searchPageSubClassify" resultMap="ApiResultMap">
SELECT
a.`id`,
a.`image`,
a.`name`,
a.`update_time`,
a.overed,
a.classify_id
FROM
album a
WHERE
a.`shelves` = 1
AND a.`company_id` =
#{companyId}
AND a.`site_id` = #{siteId}
<if test="classifyIds != null and classifyIds.size() > 0 ">
AND a.classify_id in
<foreach collection="classifyIds" item="cid" index="index"
open="(" close=")" separator=",">
#{cid}
</foreach>
</if>
<if test="name!=null">
AND ( a.`name` LIKE CONCAT('%', #{name}, '%') or a.tags
LIKE CONCAT('%', #{name}, '%') )
</if>
AND
(a.`scope` != 2
<if test="ids != null and ids.size > 0">
or
(a.id in
<foreach collection="ids" open="(" close=")" separator=","
item="item">#{item}</foreach>
)
</if>
)
AND a.del_flg = 0
GROUP BY
a.id
ORDER BY
a.update_time
</select>
<select id="getCourseIds" resultType="java.lang.Long">
SELECT a.relation_id from
al_theme_activity a where a.album_id = #{id}
and a.deleted = 0 and a.`unlock` = 0
</select>
<select id="getMyStudyList" resultType="java.lang.Long">
SELECT
DISTINCT a.id
FROM
al_student_activity_record aa LEFT JOIN album a on a.id=aa.album_id
WHERE
aa.account_id = #{accountId}
AND aa.site_id = #{siteId}
and a.shelves = 1 and a.del_flg = 0
ORDER BY
aa.finish_date desc
</select>
<select id="finished" resultType="java.lang.Integer">
SELECT count(DISTINCT
a.relation_id)
FROM
al_student_activity_record a
WHERE
a.account_id = #{accountId}
AND a.site_id = #{siteId}
and a.album_id = #{albumId}
<if test="ids != null and ids.size > 0">
and a.relation_id in
<foreach collection="ids" open="(" close=")" separator=","
item="item">#{item}</foreach>
</if>
and a.finished = 1
</select>
<select id="unLockNum" resultType="java.lang.Integer">
SELECT
COUNT(a.id)
FROM
al_theme_activity a LEFT JOIN al_theme at on a.theme_id = at.id
WHERE
at.deleted = 0 and
a.album_id = #{albumId}
and a.`unlock` = 0
and
a.deleted = 0
</select>
<select id="geThemeVos"
resultType="com.yizhi.album.application.vo.AlbumThemeVo">
SELECT
id,
NAME,
sort
FROM
al_theme a
WHERE
a.album_id = #{albumId}
and a.deleted=0
ORDER BY
sort
<if test="type!=null and type==2">
DESC
</if>
</select>
<select id="getActivityVos"
resultType="com.yizhi.album.application.vo.AlbumActivityVo">
SELECT
id,
NAME,
sort
FROM
al_theme a
WHERE
a.album_id = 1
ORDER BY
sort
<if test="type!=null and type==2">
DESC
</if>
</select>
<select id="getLockList" resultType="java.lang.Long">
SELECT
id
FROM
al_theme_activity a
WHERE
a.deleted = 0
AND a.`unlock` = 2
</select>
<select id="getMySubscribePage" resultMap="ApiResultMap">
select
a.`id`,
a.`image`,
a.`name`,
a.`update_time`,
a.overed
from album a
<if test="ids != null and ids.size > 0">
where a.id in
<foreach collection="ids" open="(" close=")" separator=","
item="item">#{item}</foreach>
and a.shelves=1
</if>
</select>
<select id="getAllAlbums"
resultType="java.lang.Long">
SELECT
id
FROM
album
WHERE
shelves = 1
AND del_flg = 0
<if test="companyId!=null">
and company_id=#{companyId}
</if>
<if test="siteId!=null">
and site_id=#{siteId}
</if>
ORDER BY
create_time
</select>
<select id="getIdsByAlbumId" resultType="java.lang.Long">
select DISTINCT
relation_id from al_theme_activity a
where deleted = 0 and
a.album_id=#{albumId} and
a.unlock = 0 and a.deleted = 0
</select>
<select id="getMyAlbumNum" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT a.id) from album a LEFT JOIN
al_student_activity_record aa on a.id=aa.album_id where aa.account_id
= #{accountId} and aa.site_id = #{siteId} and a.shelves = 1 and a.del_flg = 0
</select>
<select id="getSubscribeNum" resultType="java.lang.Integer">
select
count(a.id)
from album a
<if test="ids != null and ids.size > 0">
where a.id in
<foreach collection="ids" open="(" close=")" separator=","
item="item">#{item}</foreach>
and a.shelves=1
</if>
</select>
<select id="getIdsByDate" resultType="Long">
select id from album c
where 1=1
and c.del_flg = 0
and c.shelves = 1
and c.enable_task = 1
AND c.`site_id` = #{siteId}
AND <![CDATA[ DATE_FORMAT(c.task_start_date, '%Y-%m-%d') <= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
AND <![CDATA[ DATE_FORMAT(c.task_end_date, '%Y-%m-%d') >= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
</select>
<select id="getPageToCalendar" resultMap="BaseResultMap">
select id as id,
name as name,
image as image,
task_start_date as task_start_date,
task_end_date as task_end_date
from album c
where 1=1
<if test="passIds != null and passIds.size > 0">
and c.id not in (<foreach collection="passIds" item="passId" separator=",">#{passId}</foreach>)
</if>
and (c.scope = 1
<if test="albumIdsFromVisibeRange != null and albumIdsFromVisibeRange.size > 0">
or c.id in (<foreach collection="albumIdsFromVisibeRange" item="item" separator=",">#{item}</foreach>)
</if>
)
and c.del_flg = 0
and c.shelves = 1
and c.enable_task = 1
AND c.`site_id` = #{siteId}
AND <![CDATA[ DATE_FORMAT(c.task_start_date, '%Y-%m-%d') <= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
AND <![CDATA[ DATE_FORMAT(c.task_end_date, '%Y-%m-%d') >= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
</select>
<select id="getPageToCalendarNum" resultType="Integer">
select
count(1)
from album c
where 1=1
<if test="passIds != null and passIds.size > 0">
and c.id not in (<foreach collection="passIds" item="id" separator=",">#{id}</foreach>)
</if>
and (c.scope = 1
<if test="albumIdsFromVisibeRange != null and albumIdsFromVisibeRange.size > 0">
or c.id in (<foreach collection="albumIdsFromVisibeRange" item="item" separator=",">#{item}</foreach>)
</if>
)
and c.del_flg = 0
and c.shelves = 1
and c.enable_task = 1
AND c.`site_id` = #{siteId}
AND <![CDATA[ DATE_FORMAT(c.task_start_date, '%Y-%m-%d') <= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
AND <![CDATA[ DATE_FORMAT(c.task_end_date, '%Y-%m-%d') >= DATE_FORMAT(#{currentDate}, '%Y-%m-%d') ]]>
</select>
<select id="selectAlbumPage" resultMap="BaseResultMap">
SELECT * FROM
album a
where
a.company_id = #{companyId}
AND
a.site_id =
#{siteId}
AND
a.del_flg = 0
<if test="name!=null">
AND ( a.`name` LIKE CONCAT('%', #{name}, '%') OR a.`tags`
LIKE
CONCAT('%', #{name}, '%') )
</if>
<if test="ids != null and ids.size > 0 ">
AND a.id not in
<foreach collection="ids" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</if>
and a.`shelves` = 1
</select>
<select id="getAlbumTotalCourseCount" resultType="java.lang.Long">
SELECT count(a.id) from al_theme_activity a
where a.album_id = #{albumId} and a.deleted = '0'
and a.theme_id in
(SELECT alt.id from al_theme alt where alt.album_id = #{albumId} and alt.deleted = '0')
</select>
</mapper>
package com.yizhi.album.application.mapper;
import java.util.List;
import com.yizhi.album.application.domain.AlbumVisibleRange;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
public interface AlbumVisibleRangeMapper extends BaseMapper<AlbumVisibleRange>{
List<Long> selectAlbumIdByRelationId(@Param("relationIds") List<Long> relationIds);
List<Long> getUsefulIds(@Param("ids") List<Long> ids,
@Param("relationIds") List<Long> relationIds,
@Param("siteId") Long siteId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yizhi.album.application.mapper.AlbumVisibleRangeMapper">
<select id="selectAlbumIdByRelationId" resultType="java.lang.Long">
<if test="relationIds != null">
select album_id
from album_visible_range
<where>
state = 1
and relation_id in
<foreach collection="relationIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</where>
</if>
</select>
<select id="getUsefulIds" resultType="java.lang.Long">
<if test="relationIds != null">
select album_id from album_visible_range
<where>
state = 1
and relation_id in
<foreach collection="relationIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
<if test="ids != null and ids.size()>0">
and album_id in <foreach collection="ids" open="(" close=")" item="id" separator=","> #{id} </foreach>
</if>
</where>
</if>
</select>
</mapper>
\ No newline at end of file
package com.yizhi.album.application.mapper;
import com.yizhi.album.application.domain.ClassifyStrategy;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 专辑分类策略 Mapper 接口
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface ClassifyStrategyMapper extends BaseMapper<ClassifyStrategy> {
}
package com.yizhi.album.application.service;
import com.yizhi.album.application.domain.AlStudentActivityRecord;
import com.baomidou.mybatisplus.service.IService;
/**
* <p>
* 学员完成专辑活动记录 服务类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface IAlStudentActivityRecordService extends IService<AlStudentActivityRecord> {
}
package com.yizhi.album.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.album.application.domain.AlThemeActivity;
import java.util.List;
/**
* <p>
* 主题中的课程 服务类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface IAlThemeActivityService extends IService<AlThemeActivity> {
public Integer maxSort(Long id,Long siteId);
public Boolean sortActivity(List<AlThemeActivity> list);
public List<AlThemeActivity> list(Long themeId,Integer type);
}
package com.yizhi.album.application.service;
import com.yizhi.album.application.domain.AlTheme;
import java.util.List;
import com.baomidou.mybatisplus.service.IService;
/**
* <p>
* 专辑 - 主题 服务类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface IAlThemeService extends IService<AlTheme> {
public Boolean vaidName(Long id,Long albumId, String name, Long siteId);
public Integer sortTheme(List<AlTheme> list);
}
package com.yizhi.album.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.album.application.domain.AlbumClassify;
import com.yizhi.album.application.vo.AlbumClassifyVo;
import com.yizhi.album.application.vo.ApiAlbumClassifyVo;
import com.yizhi.core.application.vo.DroolsVo;
import java.util.List;
/**
* <p>
* 专辑分类 服务类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface IAlbumClassifyService extends IService<AlbumClassify> {
/**
* 检查是否存在分类名称
* @param name 分类名称
* @param parentId 分类的上级id(一级分类为0)
* @param siteId 站点id
* @param type 检查类型(1:新增,2:修改(需要传classifyId))
* @param classifyId 分类id,修改检查时用到
* @return 不存在返回true,存放相同名返回false
*/
boolean checkExtisClassifyName(String name, Long parentId,Long siteId,
int type, Long classifyId);
/**
* 添加一个新的课程分类
* @param classify
* @return
*/
int saveClassify(AlbumClassify classify);
/**
* 根据父级分类查询是否存在子分类
* @param classifyIds
* @return
*/
List<AlbumClassifyVo> findExistChildNodes(List<Long> classifyIds);
/**
* 根据id,删除分类
* @param id
* @return
*/
int deleteClassify(Long id);
/**
* 根据分类对象修改分类
* @param classify
* @return
*/
int updateClassify(AlbumClassify classify);
/**
* 根据名称查询分类
* @param name
* @return
*/
Page<AlbumClassify> listClassify(String name, Integer pageNo, Integer pageSize,Long companyId,List<Long> orgIds,Long siteId,Boolean isStartHQ );
/**
* 学员端查询课程分类
* @return
*/
List<AlbumClassify> listStuClassify(Long companyId,Long siteId);
/**
* 更换排序
* @param list
* @return int
*/
int updateClassiyfsort(List<AlbumClassify> list);
/**
* 管理端专辑分类分页查询
* @param companyId 企业id
* @param name 分类名
* @param orgIds 管辖区 部门id list
* @param pageNo 分页 第几页
* @param pageSize 分页数
* @return Page<ApiClassifyVo>
*/
Page<ApiAlbumClassifyVo> selectListByCompanyId( Long companyId,String name,List<Long> orgIds,Long siteId,Integer pageNo,Integer pageSize);
List<AlbumClassify> selectClassifyByPath(List<Long> ids);
/**
* 根据分类层级查询分类
* @param companyId 企业id
* @param siteId 站点id
* @param layer 分类层级
* @return
*/
List<AlbumClassify> selectClassifyByLayer(Long companyId, Long siteId,Integer layer);
Page<DroolsVo> getClassifyNameByDrools(String field, String value, Page<DroolsVo> page);
}
package com.yizhi.album.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.album.application.domain.Album;
import com.yizhi.album.application.vo.*;
import com.yizhi.core.application.vo.DroolsVo;
import java.util.Date;
import java.util.List;
/**
* <p>
* 专辑表 服务类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface IAlbumService extends IService<Album> {
public Page<Album> searchPage(String name, Long alClassifyId, Integer status, Integer overed, Long companyId,
Long siteId, Integer pageNo, Integer pageSize);
public AlbumVo save(AlbumVo albumVo);
public Boolean update(AlbumVo albumVo);
public Boolean vaidName(Long id, String name, Long siteId);
public List<Album> searchlList(String name,List<Long> ids, Long companyId, Long siteId);
public Page<ApiListAlbumVo> searchPageSubClassify(String name, List<Long> classifyIds, List<Long> relationIds,
Long companyId, Long siteId, int pageNo, int pageSize);
public List<Long> getMyStudyList(Long siteId,Long accountId,Page<Long> ids);
public Integer finished(List<Long> ids,Long album,Long accountId,Long siteId);
public Integer unLockNum(Long albumId);
public Integer getStudyNum(Long albumId);
public List<AlbumThemeVo> getThemes(Long albumId, Integer type);
public List<AlbumActivityVo> getActivitys(Long themeId, Integer type, Integer display);
public void unLockCourse();
public Page<ApiListAlbumVo> getMySubscribePage(List<Long> ids, int pageNo, int pageSize);
Page<DroolsVo> getPageByDrools(String field, String value, Page<DroolsVo> page);
Page<AlbumCalendarVo> getPageToCalendar(Date date, Page<Album> page);
}
package com.yizhi.album.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.album.application.domain.AlbumVisibleRange;
public interface IAlbumVisbleRangeService extends IService<AlbumVisibleRange>{
}
package com.yizhi.album.application.service;
import com.yizhi.album.application.domain.ClassifyStrategy;
import com.baomidou.mybatisplus.service.IService;
/**
* <p>
* 专辑分类策略 服务类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
public interface IClassifyStrategyService extends IService<ClassifyStrategy> {
}
package com.yizhi.album.application.service.impl;
import com.yizhi.album.application.domain.AlStudentActivityRecord;
import com.yizhi.album.application.mapper.AlStudentActivityRecordMapper;
import com.yizhi.album.application.service.IAlStudentActivityRecordService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 学员完成专辑活动记录 服务实现类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Service
public class AlStudentActivityRecordServiceImpl extends ServiceImpl<AlStudentActivityRecordMapper, AlStudentActivityRecord> implements IAlStudentActivityRecordService {
}
package com.yizhi.album.application.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.album.application.domain.AlThemeActivity;
import com.yizhi.album.application.mapper.AlThemeActivityMapper;
import com.yizhi.album.application.service.IAlThemeActivityService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 主题中的课程 服务实现类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Service
public class AlThemeActivityServiceImpl extends ServiceImpl<AlThemeActivityMapper, AlThemeActivity> implements IAlThemeActivityService {
@Override
public Integer maxSort(Long themeId,Long siteId) {
// TODO Auto-generated method stub
return this.baseMapper.maxSort(themeId,siteId);
}
@Override
public Boolean sortActivity(List<AlThemeActivity> list) {
if (list.size() == 2) {
AlThemeActivity activityFirst = list.get(0);
AlThemeActivity activityLast = list.get(1);
if(activityFirst.getSort().equals(activityLast.getSort())){
activityLast.setSort(activityLast.getSort().intValue()-1);
}
if ((activityFirst.getUnlock().equals(0)&!activityLast.getUnlock().equals(0))||(!activityFirst.getUnlock().equals(0)&activityLast.getUnlock().equals(0))) {
return Boolean.FALSE;
}
this.baseMapper.updateById(activityFirst);
this.baseMapper.updateById(activityLast);
}
return Boolean.TRUE;
}
@Override
public List<AlThemeActivity> list(Long themeId, Integer type) {
// TODO Auto-generated method stub
return this.baseMapper.list(themeId, type);
}
}
package com.yizhi.album.application.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.mapper.AlThemeMapper;
import com.yizhi.album.application.service.IAlThemeService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 专辑 - 主题 服务实现类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Service
public class AlThemeServiceImpl extends ServiceImpl<AlThemeMapper, AlTheme> implements IAlThemeService {
@Override
public Boolean vaidName(Long id,Long albumId, String name, Long siteId) {
Integer count = this.baseMapper.vailName(id,albumId, name, siteId);
if (count>0) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
@Override
public Integer sortTheme(List<AlTheme> list) {
if (list.size() == 2) {
AlTheme themeFirst = list.get(0);
AlTheme themeLast = list.get(1);
if(themeFirst.getSort().equals(themeLast.getSort())){
themeLast.setSort(themeLast.getSort().intValue()-1);
}
this.baseMapper.updateById(themeFirst);
this.baseMapper.updateById(themeLast);
}
return 1;
}
}
package com.yizhi.album.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.album.application.domain.AlbumClassify;
import com.yizhi.album.application.mapper.AlbumClassifyMapper;
import com.yizhi.album.application.service.IAlbumClassifyService;
import com.yizhi.album.application.vo.AlbumClassifyVo;
import com.yizhi.album.application.vo.ApiAlbumClassifyVo;
import com.yizhi.application.orm.hierarchicalauthorization.HQueryUtil;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.vo.DroolsVo;
import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 专辑分类 服务实现类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Service
public class AlbumClassifyServiceImpl extends ServiceImpl<AlbumClassifyMapper, AlbumClassify> implements IAlbumClassifyService {
private Logger logger = LoggerFactory.getLogger(AlbumClassifyServiceImpl.class);
@Autowired
private AlbumClassifyMapper classifyMapper;
@Autowired
private IdGenerator idGenerator;
@Override
public boolean checkExtisClassifyName(String name, Long parentId, Long siteId, int type, Long classifyId) {
AlbumClassify classify = new AlbumClassify();
classify.setName(name);
classify.setStatus(1);
classify.setParentId(parentId == null ? 0 : parentId.longValue());
classify.setSiteId(siteId);
EntityWrapper wrapper = new EntityWrapper(classify);
if (type == 2) {
wrapper.ne("id", classifyId);
}
return classifyMapper.selectCount(wrapper) == 0;
}
@Override
public int saveClassify(AlbumClassify classify) {
AlbumClassify exitsNameClassify = new AlbumClassify();
exitsNameClassify.setName(classify.getName());
exitsNameClassify.setParentId(classify.getParentId());
exitsNameClassify.setStatus(1);
exitsNameClassify.setSiteId(classify.getSiteId());
int count = exitsNameClassify.selectCount(new EntityWrapper(exitsNameClassify));
// 如果同级下存在相同名称的分类,返回标识符3
if (count > 0) {
return 3;
}
Long id = idGenerator.generate();
classify.setId(id);
Integer sort = classifyMapper.selectSort(classify.getParentId());
classify.setSort(++sort);
if (classify.getParentId() == 0L) {
classify.setLayer(1);
classify.setRootId(id);
classify.setPath("" + id);
} else {
int layer = classifyMapper.selectParentLayer(classify.getParentId());
if (layer > 2) {
logger.error("添加超过三级");
return 0;
}
if (layer == 1) {
classify.setPath(classify.getParentId() + "," + id);
classify.setLayer(++layer);
classify.setRootId(classify.getParentId());
} else {
classify.setLayer(++layer);
Long rootid = classifyMapper.selectRootid(classify.getParentId());
classify.setRootId(rootid);
classify.setPath(rootid + "," + classify.getParentId() + "," + id);
}
}
return classifyMapper.insert(classify);
}
@Override
public List<AlbumClassifyVo> findExistChildNodes(List<Long> classifyIds) {
List<AlbumClassifyVo> data = null;
data = this.baseMapper.findExistChildNodes(classifyIds);
return data;
}
@Override
public int deleteClassify(Long id) {
AlbumClassify classify = new AlbumClassify();
classify.setId(id);
//查找有没有子级分类
Long childid = classifyMapper.selectChild(id);
int i = 0;
if (childid == null) {
//查找有没有挂有专辑
Long i1 = classifyMapper.selectAlbum(id, ContextHolder.get().getSiteId());
if (i1 == null) {
try {
classify.setStatus(0);
i = classifyMapper.updateById(classify);
} catch (Exception e) {
logger.error("删除失败", e);
return 0;
}
}
else{ return -1;} //分类下挂有专辑需要在web进行提示
}
return i;
}
@Override
public int updateClassify(AlbumClassify classify) {
try {
AlbumClassify oldClassify = classify.selectById();
if (oldClassify == null) {
return 0;
}
AlbumClassify existUpdateClassify = new AlbumClassify();
existUpdateClassify.setParentId(oldClassify.getParentId());
existUpdateClassify.setName(classify.getName());
existUpdateClassify.setSiteId(classify.getSiteId());
EntityWrapper<AlbumClassify> ew = new EntityWrapper(existUpdateClassify);
ew.notIn("id", oldClassify.getId());
int count = existUpdateClassify.selectCount(ew);
// 如果同级下存在相同名称的分类,返回标识符3
if (count > 0) {
return 3;
}
return classifyMapper.updateById(classify);
} catch (Exception e) {
logger.error("修改分类失败");
return 0;
}
}
@Override
public Page<AlbumClassify> listClassify(String name, Integer pageNo, Integer pageSize, Long companyId,
List<Long> orgIds, Long siteId, Boolean isStartHQ) {
List<String> list = new ArrayList<String>();
list.add("path");
Page<AlbumClassify> page = new Page<AlbumClassify>(pageNo, pageSize);
AlbumClassify classify = new AlbumClassify();
classify.setStatus(1);
classify.setCompanyId(companyId);
classify.setSiteId(siteId);
EntityWrapper<AlbumClassify> entityWrapper = new EntityWrapper<AlbumClassify>(classify);
entityWrapper.orderAsc(list);
if (StringUtils.isEmpty(name)) {
entityWrapper.like("name", name);
}
// 分级授权修改
if(isStartHQ) HQueryUtil.startHQ(AlbumClassify.class);
page = this.selectPage(page, entityWrapper);
return page;
}
@Override
public List<AlbumClassify> listStuClassify(Long companyId, Long siteId) {
try {
List<String> list = new ArrayList<String>();
list.add("path");
AlbumClassify classify = new AlbumClassify();
classify.setStatus(1);
classify.setCompanyId(companyId);
classify.setSiteId(siteId);
EntityWrapper<AlbumClassify> entityWrapper = new EntityWrapper<AlbumClassify>(classify);
entityWrapper.orderAsc(list);
List<AlbumClassify> classifies1 = classifyMapper.selectList(entityWrapper);
return classifies1;
} catch (Exception e) {
logger.error("", e);
return null;
}
}
@Override
public int updateClassiyfsort(List<AlbumClassify> list) {
if (list.size() == 2) {
AlbumClassify classifyFirst = list.get(0);
AlbumClassify classifyLast = list.get(1);
if(classifyFirst.getSort().equals(classifyLast.getSort())){
classifyLast.setSort(classifyLast.getSort().intValue()-1);
}
classifyMapper.updateById(classifyFirst);
classifyMapper.updateById(classifyLast);
}
return 1;
}
@Override
public Page<ApiAlbumClassifyVo> selectListByCompanyId(Long companyId, String name, List<Long> orgIds, Long siteId,
Integer pageNo, Integer pageSize) {
Page<ApiAlbumClassifyVo> page = new Page<ApiAlbumClassifyVo>(pageNo, pageSize);
// 分级授权修改
HQueryUtil.startHQ(AlbumClassifyServiceImpl.class);
List<ApiAlbumClassifyVo> apiClassifyVos = this.baseMapper.selectListByCompanyId(companyId, name, orgIds,siteId, new RowBounds(page.getOffset(), page.getLimit()));
Integer count = this.baseMapper.selectCountByCompanyId(companyId, name, orgIds,siteId);
page.setTotal(count);
page.setRecords(apiClassifyVos);
return page;
}
@Override
public List<AlbumClassify> selectClassifyByPath(List<Long> ids) {
return this.baseMapper.selectClassifyByRootId(ids);
}
@Override
public List<AlbumClassify> selectClassifyByLayer(Long companyId, Long siteId, Integer layer) {
// 分级授权修改
HQueryUtil.startHQ(AlbumClassifyServiceImpl.class);
return this.baseMapper.selectClassifyByLayer(companyId,siteId,layer);
}
@Override
public Page<DroolsVo> getClassifyNameByDrools(String field, String value, Page<DroolsVo> page) {
if (StringUtils.isEmpty(field)) {
logger.info("列名不能为空!");
return page;
}
RequestContext requestContext = ContextHolder.get();
Long siteId = requestContext.getSiteId();
Long companyId = requestContext.getCompanyId();
List<DroolsVo> voList = null;
AlbumClassify classify = new AlbumClassify();
classify.setSiteId(siteId);
classify.setCompanyId(companyId);
classify.setStatus(1);//0:删除 1:上架
EntityWrapper wrapper = new EntityWrapper(classify);
wrapper.setSqlSelect("distinct(" + field + "),"+"id ")
.isNotNull(field)
.like(field, value)
.addFilter(field+"!=''")
.orderBy("create_time", false);
List<AlbumClassify> list = this.baseMapper.selectPage(page, wrapper);
if (!CollectionUtils.isEmpty(list)){
voList = new ArrayList<>(list.size());
for (AlbumClassify a:list){
DroolsVo vo = new DroolsVo();
vo.setTaskId(a.getId());
vo.setTaskFieldValue(a.getName());
vo.setTaskParamsType(field);
voList.add(vo);
}
}
page.setRecords(voList);
return page;
}
}
package com.yizhi.album.application.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.album.application.domain.AlThemeActivity;
import com.yizhi.album.application.domain.Album;
import com.yizhi.album.application.mapper.AlStudentActivityRecordMapper;
import com.yizhi.album.application.mapper.AlThemeActivityMapper;
import com.yizhi.album.application.mapper.AlbumMapper;
import com.yizhi.album.application.mapper.AlbumVisibleRangeMapper;
import com.yizhi.album.application.service.IAlbumClassifyService;
import com.yizhi.album.application.service.IAlbumService;
import com.yizhi.album.application.vo.*;
import com.yizhi.application.orm.hierarchicalauthorization.HQueryUtil;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.enums.TaskParamsEnums;
import com.yizhi.core.application.vo.DroolsVo;
import com.yizhi.course.application.feign.CoursePcClient;
import com.yizhi.util.application.clazz.ClassUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 专辑表 服务实现类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Service
public class AlbumServiceImpl extends ServiceImpl<AlbumMapper, Album> implements IAlbumService {
private static final Logger LOGGER = LoggerFactory.getLogger(AlbumServiceImpl.class);
@Autowired
IdGenerator idGenerator;
@Autowired
private AlbumVisibleRangeMapper albumVisibleRangeMapper;
@Autowired
private AlStudentActivityRecordMapper alStudentActivityRecordMapper;
@Autowired
private CoursePcClient coursePcClient;
@Autowired
private AlThemeActivityMapper alThemeActivityMapper;
@Autowired
private IAlbumClassifyService albumClassifyService;
@Autowired
private AlbumMapper albumMapper;
@Override
public Page<Album> searchPage(String name, Long alClassifyId, Integer status, Integer overed, Long companyId,
Long siteId, Integer pageNo, Integer pageSize) {
Page<Album> page = new Page<Album>(pageNo, pageSize);
// 分级授权修改
HQueryUtil.startHQ(Album.class);
List<Album> list = this.baseMapper.searchPage(name, alClassifyId, status, overed, companyId, siteId, page);
page.setRecords(list);
return page;
}
@Override
public AlbumVo save(AlbumVo albumVo) {
if (!this.vaidName(albumVo.getId(), albumVo.getName(), albumVo.getSiteId())) {
return null;
}
try {
Album album = null;
if (albumVo.getId()!=null) {
album = this.baseMapper.selectById(albumVo.getId());
}else {
album = new Album();
album.setId(idGenerator.generate());
album.setCompanyId(albumVo.getCompanyId());
album.setSiteId(albumVo.getSiteId());
album.setOrgId(albumVo.getOrgId());
album.setCreateById(albumVo.getCreateById());
album.setCreateByName(albumVo.getCreateByName());
album.setCreateTime(albumVo.getCreateTime());
//专辑规则初始化默认值
album.setShelves(2);
album.setScope(1);
album.setCommentEnable(0);
album.setDocumentEnable(0);
album.setDelFlg(0);
album.setOvered(0);
album.setDisplay(0);
album.setUpdateById(albumVo.getCreateById());
album.setUpdateByName(albumVo.getCreateByName());
album.setUpdateTime(albumVo.getCreateTime());
}
album.setName(albumVo.getName());
album.setClassifyId(albumVo.getClassifyId());
album.setImage(null==albumVo.getImage()||""==albumVo.getImage()?"http://customproject.oss-cn-shanghai.aliyuncs.com/yzphoto/album_defalut_logo.png":albumVo.getImage());
album.setDescription(albumVo.getDescription());
album.setTags(albumVo.getTags());
this.insertOrUpdate(album);
albumVo.setId(album.getId());
albumVo.setOvered(album.getOvered());
return albumVo;
} catch (Exception e) {
LOGGER.info("新增或修改专辑异常" + JSON.toJSONString(e));
System.out.println(e.getLocalizedMessage());
return null;
}
}
@Override
public Boolean vaidName(Long id, String name, Long siteId) {
Integer count = this.baseMapper.vailName(id, name, siteId);
if (count>0) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
@Override
public Boolean update(AlbumVo albumVo) {
try {
Album album = this.baseMapper.selectById(albumVo.getId());
album.setScope(albumVo.getScope());
album.setDocumentEnable(albumVo.getDocumentEnable());
album.setCommentEnable(albumVo.getCommentEnable());
album.setOvered(albumVo.getOvered());
album.setDisplay(albumVo.getDisplay());
album.setEnableTask(albumVo.getEnableTask());
album.setTaskStartDate(albumVo.getTaskStartDate());
album.setTaskEndDate(albumVo.getTaskEndDate());
album.setUpdateById(albumVo.getUpdateById());
album.setUpdateByName(albumVo.getUpdateByName());
album.setUpdateTime(albumVo.getUpdateTime());
this.baseMapper.updateById(album);
} catch (Exception e) {
LOGGER.info("更新错误消息={}",JSON.toJSONString(e));
return Boolean.FALSE;
}
return Boolean.TRUE;
}
@Override
public List<Album> searchlList(String name,List<Long> ids, Long companyId, Long siteId) {
// TODO Auto-generated method stub
return this.baseMapper.selectAlbumList(name,ids, companyId, siteId);
}
@Override
public Page<ApiListAlbumVo> searchPageSubClassify(String name, List<Long> classifyIds, List<Long> relationIds,
Long companyId, Long siteId, int pageNo, int pageSize) {
List<Long> ids = null;
if (relationIds != null && relationIds.size() > 0) {
ids = albumVisibleRangeMapper.selectAlbumIdByRelationId(relationIds);
}
Page<ApiListAlbumVo> page = new Page<ApiListAlbumVo>(pageNo, pageSize);
List<ApiListAlbumVo> data = this.baseMapper.searchPageSubClassify(name, classifyIds, ids,
companyId, siteId, page);
if (CollectionUtils.isNotEmpty(data)) {
for(ApiListAlbumVo vo:data) {
Integer overed = vo.getOvered();
if (null != overed && overed.equals(1)){
//获取已完结状态下的所有课程数量
vo.setCourseNum(0);
Long totalCourseCount = baseMapper.getAlbumTotalCourseCount(vo.getId());
if (null != totalCourseCount){
vo.setCourseNum(totalCourseCount.intValue());
}
}
List<Long> courseIds = this.baseMapper.getCourseIds(vo.getId());
if (CollectionUtils.isNotEmpty(courseIds)) {
Map<Long, Long> durations = coursePcClient.getMaterialTimeByCourseIds(courseIds);
Long duration = (long) 0;
if (null != durations && durations.size() > 0) {
for (Long h : durations.keySet()) {
LOGGER.info("课程时长:" + durations.get(h));
duration = duration + (durations.get(h) != null ? durations.get(h) : 0l);
}
}
vo.setDuration(duration);
}else {
vo.setDuration(0L);
}
}
List<Long> albumIds = data.stream().map(ApiListAlbumVo::getId).collect(Collectors.toList());
List<ApiListAlbumVo> vos = alStudentActivityRecordMapper.getStudentNumByIds(albumIds);
LOGGER.info("专辑学习人数={}", JSON.toJSONString(vos));
if (CollectionUtils.isNotEmpty(vos)) {
Map<Long, Integer> dataMap = vos.stream().collect(Collectors.
toMap(key -> key.getId(), val -> val.getStudyNum()));
for (ApiListAlbumVo itemAlbum : data) {
itemAlbum.setStudyNum(dataMap.get(itemAlbum.getId()));
}
}
}
page.setRecords(data);
return page;
}
@Override
public List<Long> getMyStudyList(Long siteId, Long accountId,Page<Long> page) {
// TODO Auto-generated method stub
return this.baseMapper.getMyStudyList(siteId, accountId,page);
}
@Override
public Integer finished(List<Long> ids,Long albumId, Long accountId, Long siteId) {
// TODO Auto-generated method stub
return this.baseMapper.finished(ids,albumId, accountId, siteId);
}
@Override
public Integer unLockNum(Long albumId) {
// TODO Auto-generated method stub
return this.baseMapper.unLockNum(albumId);
}
@Override
public Integer getStudyNum(Long albumId) {
// TODO Auto-generated method stub
return alStudentActivityRecordMapper.getStudyNum(albumId);
}
@Override
public List<AlbumThemeVo> getThemes(Long albumId, Integer type) {
// TODO Auto-generated method stub
return this.baseMapper.geThemeVos(albumId, type);
}
@Override
public List<AlbumActivityVo> getActivitys(Long themeId, Integer type, Integer display) {
// TODO Auto-generated method stub
return this.baseMapper.getActivityVos(themeId, type, display);
}
@Override
public void unLockCourse() {
Date date = new Date();
List<Long> ids = this.baseMapper.getLockList();
if (CollectionUtils.isNotEmpty(ids)) {
for(Long id : ids) {
AlThemeActivity activity = alThemeActivityMapper.selectById(id);
if (activity.getUnlockTime().before(date)) {
activity.setUnlock(0);
alThemeActivityMapper.updateById(activity);
Album album = this.baseMapper.selectById(activity.getAlbumId());
album.setUpdateTime(date);
this.baseMapper.updateById(album);
}
}
}
}
@Override
public Page<ApiListAlbumVo> getMySubscribePage(List<Long> ids, int pageNo, int pageSize) {
Page<ApiListAlbumVo> page = new Page<ApiListAlbumVo>(pageNo, pageSize);
List<ApiListAlbumVo> data = this.baseMapper.getMySubscribePage(ids,page);
for(ApiListAlbumVo vo:data) {
//获取完结状态的课程数
Integer overed = vo.getOvered();
if (null != overed && overed.equals(1)){
vo.setCourseNum(0);
Long albumTotalCourseCount = baseMapper.getAlbumTotalCourseCount(vo.getId());
if (null != albumTotalCourseCount){
vo.setCourseNum(albumTotalCourseCount.intValue());
}
}
if (vo.getUnLockTime()!=null) {
long day = ((System.currentTimeMillis()-vo.getUnLockTime().getTime())/(3600*24*1000));
vo.setIsNew(day>5?0:1);
}else {
vo.setIsNew(0);
}
}
page.setRecords(data);
return page;
}
@Override
public Page<DroolsVo> getPageByDrools(String field, String value, Page<DroolsVo> page) {
if (StringUtils.isBlank(field)) {
LOGGER.info("列名不能为空!");
return page;
}
if (field.equalsIgnoreCase(TaskParamsEnums.CLASSIFY.getCode())) {
field = "name";
page = albumClassifyService.getClassifyNameByDrools(field, value, page);
} else {
if (field.equalsIgnoreCase(TaskParamsEnums.NAME.getCode())) {
return getPage(field, value, page);
} else if (field.equalsIgnoreCase(TaskParamsEnums.KEYWORD.getCode())) {
field = "tags";
return getPage(field, value, page);
}
}
return page;
}
public Page getPage(String field, String value, Page<DroolsVo> page) {
RequestContext requestContext = ContextHolder.get();
Long siteId = requestContext.getSiteId();
Long companyId = requestContext.getCompanyId();
Album album = new Album();
album.setSiteId(siteId);
album.setCompanyId(companyId);
album.setDelFlg(0);
album.setShelves(1);
EntityWrapper wrapper = new EntityWrapper(album);
wrapper.setSqlSelect("distinct(" + field + "),"+"id ")
.isNotNull(field)
.like(field, value)
.addFilter(field+"!=''")
.orderBy("create_time", false);
String upperField = ClassUtil.getFieldName(field);
List<DroolsVo> voList = null;
List<Album> list = this.baseMapper.selectPage(page, wrapper);
if (!CollectionUtils.isEmpty(list)) {
voList = new ArrayList<>(list.size());
for (Album a : list) {
DroolsVo vo = new DroolsVo();
vo.setTaskId(a.getId());
vo.setTaskFieldValue(ClassUtil.invokeMethod(a, upperField));
vo.setTaskParamsType(field);
voList.add(vo);
}
page.setRecords(voList);
}
return page;
}
@Override
public Page<AlbumCalendarVo> getPageToCalendar(Date date, Page<Album> page) {
RequestContext context = ContextHolder.get();
Long siteId = context.getSiteId();
Long accountId = context.getAccountId();
Page<AlbumCalendarVo> voPage = new Page<>();
BeanUtils.copyProperties(page,voPage);
//获取该时间参数的专辑ds
List<Long> ids = albumMapper.getIdsByDate(date, siteId);
if (CollectionUtils.isEmpty(ids)) {
return voPage;
}
List<Album> albums = this.selectBatchIds(ids);
//获取已完结的达到100%的专辑ids
Set<Long> hasFinishedIds = new HashSet(ids.size());
albums.forEach(a -> {
//只有已完结的专辑需要计算
if (a.getOvered().equals(1)) {
// 计算完成百分比
List<Long> activityIds = albumMapper.getIdsByAlbumId(a.getId());
Integer finished = this.finished(activityIds, a.getId(), accountId, siteId);
Integer unLockNum = this.unLockNum(a.getId());
if (finished != null && unLockNum != null && unLockNum != 0) {
if (finished.equals(unLockNum)) {
hasFinishedIds.add(a.getId());
}
}
}
});
//去除已完结且达到100%的id
ids.removeAll(hasFinishedIds);
//根据可见范围获取专辑ids
List<Long> albumIdsFromVisibeRange = albumVisibleRangeMapper.getUsefulIds(ids, context.getRelationIds(), siteId);
//获取最终数据
List<Album> pageToCalendar = albumMapper.getPageToCalendar(new ArrayList<>(hasFinishedIds), albumIdsFromVisibeRange, date, siteId, page);
voPage.setTotal(albumMapper.getPageToCalendarNum(new ArrayList<>(hasFinishedIds),albumIdsFromVisibeRange,date,siteId));
voPage.setRecords(buildAlbumCalendarVo(pageToCalendar));
return voPage;
}
public List<AlbumCalendarVo> buildAlbumCalendarVo(List<Album> pageToCalendar) {
List<AlbumCalendarVo> albumCalendarVos = null;
if (CollectionUtils.isNotEmpty(pageToCalendar)) {
albumCalendarVos = new ArrayList<>(pageToCalendar.size());
for (Album a : pageToCalendar) {
AlbumCalendarVo vo = new AlbumCalendarVo();
BeanUtils.copyProperties(a,vo);
albumCalendarVos.add(vo);
}
}
return albumCalendarVos;
}
}
package com.yizhi.album.application.service.impl;
import com.yizhi.album.application.domain.AlbumVisibleRange;
import com.yizhi.album.application.mapper.AlbumVisibleRangeMapper;
import com.yizhi.album.application.service.IAlbumVisbleRangeService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
@Service
public class AlbumVisibleRangeServiceImpl extends ServiceImpl<AlbumVisibleRangeMapper, AlbumVisibleRange> implements IAlbumVisbleRangeService {
}
package com.yizhi.album.application.service.impl;
import com.yizhi.album.application.domain.ClassifyStrategy;
import com.yizhi.album.application.mapper.ClassifyStrategyMapper;
import com.yizhi.album.application.service.IClassifyStrategyService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 专辑分类策略 服务实现类
* </p>
*
* @author hc123
* @since 2019-12-30
*/
@Service
public class ClassifyStrategyServiceImpl extends ServiceImpl<ClassifyStrategyMapper, ClassifyStrategy> implements IClassifyStrategyService {
}
package com.yizhi.album.application.task;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.album.application.domain.AlTheme;
import com.yizhi.album.application.domain.AlThemeActivity;
import com.yizhi.album.application.service.IAlThemeActivityService;
import com.yizhi.album.application.service.IAlThemeService;
import com.yizhi.album.application.vo.AlThemeVo;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.core.application.file.constant.FileConstant;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.file.util.OssUpload;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Component
public class ActivityListExport extends AbstractDefaultTask<String, Map<String, Object>> {
private static final Logger logger = LoggerFactory.getLogger(ActivityListExport.class);
@Autowired
private IAlThemeActivityService alThemeActivityService;
@Autowired
private IAlThemeService alThemeService;
@Override
protected String execute(Map<String, Object> arg0) {
Long accountId = (Long) arg0.get("accountId");
Long siteId = (Long) arg0.get("siteId");
Long companyId = (Long) arg0.get("companyId");
Long taskId = (Long) arg0.get("taskId");
Date submitTime = (Date) arg0.get("submitTime");
String serialNo = (String) arg0.get("serialNo");
String taskName = (String) arg0.get("taskName");
String name = (String) arg0.get("name");
Long albumId = (Long) arg0.get("albumId");
/**
* 走异步任务
*/
TaskContext taskContext = new TaskContext(taskId, serialNo, taskName, accountId, submitTime, siteId, companyId);
working(taskContext);
String upLoadUrl = null;
String requestPath = FileConstant.SAVE_PATH;
File fileDir = new File(requestPath);
if (!fileDir.exists()) {
fileDir.mkdir();
}
// 课程清单开始组装
AlTheme theme = new AlTheme();
theme.setAlbumId(albumId);
theme.setDeleted(0);
EntityWrapper<AlTheme> wrapper = new EntityWrapper<AlTheme>(theme);
wrapper.orderBy("sort", true);
List<AlTheme> themes = alThemeService.selectList(wrapper);
List<AlThemeActivity> list = new ArrayList<AlThemeActivity>();
for (AlTheme alTheme : themes) {
AlThemeVo themeVo = new AlThemeVo();
themeVo.setAlbumId(albumId);
themeVo.setId(alTheme.getId());
themeVo.setName(alTheme.getName());
AlThemeActivity activity = new AlThemeActivity();
activity.setThemeId(alTheme.getId());
activity.setDeleted(0);
EntityWrapper<AlThemeActivity> entityWrapper = new EntityWrapper<AlThemeActivity>(activity);
entityWrapper.orderBy("sort", true);
List<AlThemeActivity> activities = alThemeActivityService.selectList(entityWrapper);
activities.forEach(e->e.setThemeName(alTheme.getName()));
list.addAll(activities);
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat ff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
try {
//excel生成过程: excel-->sheet-->row-->cell
// 第一步,创建一个Excel文件
XSSFWorkbook wb = new XSSFWorkbook();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
XSSFSheet sheet = wb.createSheet(name+"-课程清单"+sf.format(submitTime));
sheet.setDefaultColumnWidth(56);
XSSFFont font = wb.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 16);
font.setBold(false);
XSSFCellStyle style = wb.createCellStyle();
style.setFont(font);
style.setAlignment(HorizontalAlignment.LEFT); // 创建一个左对齐格式
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
XSSFRow row = sheet.createRow((int) 0);
row.setHeightInPoints((float) 21);
// 合并单元格
CellRangeAddress cra=new CellRangeAddress(0,0,0,3); // 起始行, 终止行, 起始列, 终止列
sheet.addMergedRegion(cra);
XSSFCell cell = row.createCell((short) 0);
cell.setCellValue(name+"-课程清单"+sf.format(submitTime));
cell.setCellStyle(style);
XSSFRow row1 = sheet.createRow((int) 1);
row1.setHeightInPoints((float) 18);
// 合并单元格
CellRangeAddress cra1=new CellRangeAddress(1,1,0,3); // 起始行, 终止行, 起始列, 终止列
sheet.addMergedRegion(cra1);
XSSFCell cell1 = row1.createCell((short) 0);
cell1.setCellValue("报表生成时间:"+ff.format(submitTime));
XSSFCellStyle style1 = wb.createCellStyle();
XSSFFont font1 = wb.createFont();
font1.setFontName("宋体");
font1.setFontHeightInPoints((short) 14);
font1.setBold(false);
style1.setFont(font1);
style1.setAlignment(HorizontalAlignment.LEFT);
style1.setVerticalAlignment(VerticalAlignment.CENTER);
cell1.setCellStyle(style1);
XSSFRow row2 = sheet.createRow((int) 2);
XSSFCellStyle style2 = wb.createCellStyle();
XSSFFont font2 = wb.createFont();
font2.setFontName("宋体");
font2.setFontHeightInPoints((short) 12);
font2.setBold(true);
style2.setFont(font2);
style2.setAlignment(HorizontalAlignment.CENTER);
style2.setVerticalAlignment(VerticalAlignment.CENTER);
row2.setHeightInPoints((float) 15.6);
row2.createCell((short) 0).setCellValue("课程名称");
row2.getCell(0).setCellStyle(style2);
row2.createCell((short) 1).setCellValue("解锁状态");
row2.getCell(1).setCellStyle(style2);
row2.createCell((short) 2).setCellValue("主题名称");
row2.getCell(2).setCellStyle(style2);
row2.createCell((short) 3).setCellValue("课程编码");
row2.getCell(3).setCellStyle(style2);
AlThemeActivity vo = new AlThemeActivity();
for(int i=0;i<list.size();i++) {
XSSFCellStyle style3 = wb.createCellStyle();
XSSFFont font3 = wb.createFont();
font3.setBold(false);
font3.setFontHeightInPoints((short) 10);
style3.setFont(font3);
style3.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式
style3.setVerticalAlignment(VerticalAlignment.CENTER);
row = sheet.createRow(i + 3);
row.setHeightInPoints((float) 13.2);
// 第四步,创建单元格,并设置值
vo=list.get(i);
if(vo!=null&&vo.getName()!=null) {
row.createCell((short) 0).setCellValue(vo.getName());
row.getCell(0).setCellStyle(style3);
}
if(vo!=null&&vo.getUnlock()!=null) {
String unLock = "";
if (vo.getUnlock().equals(0)) {
unLock="已解锁";
}else if (vo.getUnlock().equals(1)) {
unLock="发布及解锁";
}else {
unLock=ff.format(vo.getUnlockTime());
}
row.createCell((short) 1).setCellValue(unLock);
row.getCell(1).setCellStyle(style3);
}
if(vo!=null&&vo.getThemeName()!=null) {
row.createCell((short) 2).setCellValue(vo.getThemeName());
row.getCell(2).setCellStyle(style3);
}
if(vo!=null&&vo.getRelationCode()!=null) {
row.createCell((short) 3).setCellValue(vo.getRelationCode());
row.getCell(3).setCellStyle(style3);
}
}
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
StringBuffer fileNameSb = new StringBuffer().append(name+"-课程清单").append(sf.format(submitTime)).append(".xlsx");
String fileName = fileNameSb.toString();
String path = new StringBuffer().append(requestPath).append(fileNameSb).toString();
FileOutputStream os=null;
File file=null;
try {
os= new FileOutputStream(path);
wb.write(os);
//阿里云返回url
upLoadUrl = OssUpload.upload(path, fileName);
file=new File(path);
success(taskContext,"成功", upLoadUrl);
} catch (Exception e1) {
logger.error("写入数据到Excel的过程中或者上传到阿里云中发生错误",e1);
fail(taskContext, "写入数据到Excel的过程中或者上传到阿里云中发生错误"+e1.getMessage());
}
finally {
if(os!=null) {
os.close();
}
if(wb!=null) {
wb.close();
}
if(file!=null) {
file.delete();
}
}
} catch (Exception e) {
logger.error(name+"专辑课程清单导出过程中发生错误,请查看日志",e);
fail(taskContext, name+"专辑课程清单导出过程中发生错误,请查看日志"+e.getMessage());
}
return upLoadUrl;
}
}
package com.yizhi.album.application.util;
import com.yizhi.application.job.remote.JobClient;
import com.yizhi.application.job.remote.vo.VmyJobVO;
import com.yizhi.message.application.constans.Constans;
import com.yizhi.util.application.date.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class BuildJob {
@Autowired
private JobClient jobClient;
private static final Logger logger = LoggerFactory.getLogger(BuildJob.class);
/**
* 构建一个定时任务
* @param jobName
* @param sendTime
* @throws Exception
* TODO XXLJOB对应路径
*/
public void buildJob(String jobName,Date sendTime) throws Exception {
VmyJobVO job = new VmyJobVO();
job.setGroup("album");
job.setJobName(jobName);
job.setJobClassName("com.xxl.job.executor.service.job.AlbumUnLockJob");
logger.info("********************************专辑课程定时解锁的发送时间={},时间戳={}",
sendTime, sendTime.getTime());
logger.info("**************************************当前系统时间={}", (new Date()).getTime());
String cron = DateUtil.getCron(sendTime);
logger.info("**************************************cron={}", cron);
String[] cronArr = cron.split(" ");
job.setSecond(cronArr[0]);
job.setMinute(cronArr[1]);
job.setHour(cronArr[2]);
job.setDay(cronArr[3]);
job.setMonth(cronArr[4]);
job.setWeek(cronArr[5]);
job.setYear(cronArr[6]);
jobClient.insert(job);
}
public void buildJobDefault(String jobName) throws Exception {
VmyJobVO job = new VmyJobVO();
job.setGroup(Constans.JOBGROUP);
job.setJobName(jobName);
job.setJobClassName("com.xxl.job.executor.service.job.AlbumUnLockJob");
logger.info("**************************************当前系统时间={}", (new Date()).getTime());
job.setSecond("0");
job.setMinute("0/5");
job.setHour("*");
job.setDay("*");
job.setMonth("*");
job.setWeek("?");
job.setYear("*");
jobClient.insert(job);
}
}
\ No newline at end of file
server.port=39001
spring.application.name=album
ACTIVE=${spring.profiles.active}
spring.profiles.active=dev
# nacos
spring.cloud.nacos.config.shared-dataids=common-${spring.profiles.active}.properties
spring.cloud.nacos.config.namespace=${spring.profiles.active}
spring.cloud.nacos.config.prefix=${spring.application.name}
spring.cloud.nacos.config.file-extension=properties
spring.cloud.nacos.config.server-addr=192.168.1.22:3333,192.168.1.22:4444,192.168.1.22:5555
\ No newline at end of file
package com.yizhi.album.application;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.album.application.controller.remote.AlbumController;
import com.yizhi.album.application.vo.ApiListAlbumVo;
import com.yizhi.album.application.vo.ApiSearchAlbumVo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@SpringBootTest
@RunWith(SpringRunner.class)
public class AlbumTest {
@Autowired
AlbumController albumController;
@Test
public void albumSearchPageTest(){
ApiSearchAlbumVo vo = new ApiSearchAlbumVo();
vo.setAccountId(1314L);
vo.setCompanyId(1314L);
vo.setPageNo(1);
vo.setPageSize(30);
vo.setSiteId(1314L);
Page<ApiListAlbumVo> apiListAlbumVoPage = albumController.searchPage(vo);
System.out.println(apiListAlbumVoPage);
}
//getMySubscribePage
@Test
public void getMySubscribePageTest(){
ApiSearchAlbumVo vo = new ApiSearchAlbumVo();
vo.setAccountId(1314L);
vo.setCompanyId(1314L);
vo.setPageNo(1);
vo.setPageSize(30);
vo.setSiteId(1314L);
vo.setIds(Arrays.asList(1216607438212452352L,1216926258238672896L));
Page<ApiListAlbumVo> apiListAlbumVoPage = albumController.getMySubscribePage(vo);
System.out.println(apiListAlbumVoPage);
}
@Test
public void getPortalListTest(){
ArrayList<Long> longs = new ArrayList<>();
longs.add(1217276859183267840L);
List<ApiListAlbumVo> portalList = albumController.getPortalList(longs);
System.out.println();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>wmy-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath/>
</parent>
<artifactId>cloud-album</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>cloud-album-api</module>
<module>cloud-album-service</module>
</modules>
<repositories>
<repository>
<id>wmy4.0</id>
<url>http://mvn.km365.pw/nexus/content/groups/wmy4.0-group/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
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