Commit e3fa1993 authored by zhangqingle's avatar zhangqingle

修改接口、添加新接口

parent 88d4cb10
......@@ -11,6 +11,7 @@ import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultExceptionEnum;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.business.bbanner.dao.BBannerRepository;
import org.rcisoft.business.bbanner.entity.BBanner;
......@@ -47,14 +48,14 @@ public class BBannerServiceImpl implements BBannerService {
int line = 0;
//外部链接但外部URL为空或长度为0 抛异常
if ("1".equals(model.getIsExternalLink()) && StringUtils.isEmpty(model.getExternalUrl()))
throw new ServiceException(ResultExceptionEnum.MUST_NOT_FILLED);
throw new ServiceException(ResultServiceEnums.MUST_NOT_FILLED);
//内部链接但类型或课程ID为空或长度为0 抛异常
if ("0".equals(model.getIsExternalLink()) && (StringUtils.isEmpty(model.getLineType()) || StringUtils.isEmpty(model.getCourseId())))
throw new ServiceException(ResultExceptionEnum.MUST_NOT_FILLED);
throw new ServiceException(ResultServiceEnums.MUST_NOT_FILLED);
if (model.getBusinessId() != null) {
//按ID查询Banner个数
if (bBannerRepository.selectCountById(model.getBusinessId()) == 0){
throw new ServiceException(ResultExceptionEnum.NO_DATA);
throw new ServiceException(ResultServiceEnums.NO_DATA);
}
UserUtil.setCurrentMergeOperation(model);
line = bBannerRepository.updateById(model);
......@@ -63,7 +64,7 @@ public class BBannerServiceImpl implements BBannerService {
//查询Banner是否大于等于5个,大于等于五个不允许添加
int countBanner = bBannerRepository.selectCountBanner(addOrUpdateDTO);
if(countBanner >= 5){
throw new ServiceException(ResultExceptionEnum.NOT_MORE_COUNT);
throw new ServiceException(ResultServiceEnums.NOT_MORE_COUNT);
}
//查询最大排序值+1后放入Banner中
int sort = bBannerRepository.selectMaxSort();
......@@ -77,7 +78,7 @@ public class BBannerServiceImpl implements BBannerService {
@Override
public PersistModel removeBanner(String id) {
if (bBannerRepository.selectCountById(id) == 0){
throw new ServiceException(ResultExceptionEnum.NO_DATA);
throw new ServiceException(ResultServiceEnums.NO_DATA);
}
return new PersistModel(1, bBannerRepository.deleteBanner(id));
......
......@@ -17,6 +17,7 @@ import org.rcisoft.common.model.GridModel;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.rcisoft.sys.role.service.SysRoleService;
import org.rcisoft.sys.user.bean.CurUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
......@@ -46,6 +47,9 @@ public class BLessonController extends PaginationController<BLesson> {
@Autowired
private BLessonPersonService bLessonPersonService;
@Autowired
private SysRoleService sysRoleService;
@Autowired
private Global global;
......@@ -332,7 +336,8 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiOperation(value = "617课程管理显示的全部课程", notes="课程管理显示的全部课程", response = BLesson.class)
@GetMapping(value = "theLessonManage")
public Result theLessonManage(CurUser curUser, @Valid BLesson bLesson, BindingResult bindingResult){
List<BLesson> bLessons = bLessonService.theLessonMangageByPagination(getPaginationUtility(), curUser, bLesson);
List<RoleTypeDepartDTO> roleList = sysRoleService.queryRoleTypeByUserId(curUser);
List<BLesson> bLessons = bLessonService.theLessonMangageByPagination(getPaginationUtility(), curUser, bLesson ,roleList);
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -469,4 +474,20 @@ public class BLessonController extends PaginationController<BLesson> {
lessonId);
}
// /**
// * @author: zhangqingle
// * @param
// * @return
// */
// @ApiOperation(value="626 收藏课程", notes="收藏课程")
// @ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
// @PostMapping(value = "/addCollect")
// public Result addCollect(CurUser curUser, @Valid String lessonId, BindingResult bindingResult) {
// PersistModel data = bLessonService.addCollect(curUser,lessonId);
// return Result.builder(data,
// MessageConstant.MESSAGE_ALERT_SUCCESS,
// MessageConstant.MESSAGE_ALERT_ERROR,
// lessonId);
// }
}
......@@ -509,20 +509,29 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
ILessonCountDTO iLessonCount(String userId);
/**
* 在学人数加一
* @param BusinessId
* 重新统计在学人数
* @param lessonId
* @return
*/
@Update("update b_lesson set person_number = person_number+1 where business_id = #{BusinessId}")
int personNumberPlusOne(String BusinessId);
@Update("<script>update b_lesson set person_number = " +
"(select count(1) from b_lesson_person where 1=1 " +
" and del_flag != 1 and flag = 1 " +
" and lesson_id = #{lessonId})" +
" where business_id = #{lessonId} </script>" )
int personNumberReCount(String lessonId);
/**
* 在学人数减一
* @param BusinessId
* 重新统计收藏人数
* @param lessonId
* @return
*/
@Update("update b_lesson set person_number = person_number-1 where business_id = #{BusinessId}")
int personNumberMinusOne(String BusinessId);
@Update("<script>update b_lesson set collect_number = " +
"(select count(1) from b_lesson_person where 1=1 " +
" and del_flag != 1 and flag = 1 " +
" and is_collect = '1' " +
" and lesson_id = #{lessonId})" +
" where business_id = #{lessonId} </script>" )
int collectNumberReCount(String lessonId);
/**
* 列表页分页查询全部课程
......@@ -829,7 +838,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"<if test='!isAdmin'>" +
"AND les.lecturer_id IN" +
"<foreach item='item' index='index' collection='CurUserSet' open='(' close=')' separator=','> " +
"#{item.userId} " +
"#{item} " +
"</foreach>" +
"</if> " +
"<if test=\"bLesson.lessonName!=null and bLesson.lessonName!=''\">AND les.lesson_name like '%${bLesson.lessonName}%' </if>" +
......@@ -837,8 +846,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"<if test=\"bLesson.releaseState!=null and bLesson.releaseState!=''\">AND les.release_state = #{bLesson.releaseState} </if>" +
" order by les.release_date desc </script>")
@ResultMap(value = "BaseResultMap")
List<BLesson> selectAllManageLesson(@Param("C" +
"urUserSet") Set<CurUser> CurUserSet, @Param("bLesson") BLesson bLesson, @Param("isAdmin") boolean isAdmin, @Param("corpId") String corpId) ;
List<BLesson> selectAllManageLesson(@Param("CurUserSet") Set<String> CurUserSet, @Param("bLesson") BLesson bLesson, @Param("isAdmin") boolean isAdmin, @Param("corpId") String corpId) ;
@Select("<script>" +
......
package org.rcisoft.business.blesson.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AddMyLearnLessonDTO {
@ApiModelProperty(value = "课程Id",required = true)
......
package org.rcisoft.business.blesson.dto;
import lombok.Data;
import java.util.List;
@Data
public class RoleTypeDepartDTO {
private String type;
private String departs;
private List<String> departList;
}
......@@ -179,7 +179,7 @@ public interface BLessonService{
* @param
* @return
*/
List<BLesson> theLessonMangageByPagination(PageUtil pageUtil,CurUser curUser,BLesson bLesson);
List<BLesson> theLessonMangageByPagination(PageUtil pageUtil,CurUser curUser,BLesson bLesson,List<RoleTypeDepartDTO> roleList);
/**
* 分页查询列表页全部
......@@ -189,4 +189,13 @@ public interface BLessonService{
*/
PersistModel deleteRecommend(String lessonId);
/**
* 分页查询列表页全部
* @author: zhangqingle
* @param curUser
* @param lessonId
* @return
*/
PersistModel addCollect(CurUser curUser,String lessonId);
}
......@@ -47,10 +47,10 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
public PersistModel quit(QuitLessonDTO quitLessonDTO) {
BLessonPerson bLessonPerson = bLessonPersonRepository.selectById(quitLessonDTO.getBusinessId());
if ("1".equals(bLessonPerson.getIsAppoint())){
throw new ServiceException(ResultExceptionEnum.APPOINT_NOT_CLOSE);
throw new ServiceException(ResultServiceEnums.APPOINT_NOT_CLOSE);
}
//课程在学人数-1
bLessonRepository.personNumberMinusOne(quitLessonDTO.getLessonId());
//重新统计在学人数
bLessonRepository.personNumberReCount(quitLessonDTO.getLessonId());
return new PersistModel(1,bLessonPersonRepository.quit(quitLessonDTO.getBusinessId()));
}
......@@ -74,7 +74,7 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
public PersistModel cancelAppoint(CancelAppointDTO cancelAppointDTO) {
String bAppointId = bLessonPersonRepository.selectAppointIdById(cancelAppointDTO);
if (StringUtils.isEmpty(bAppointId)){
throw new ServiceException(ResultExceptionEnum.APPOINT_NOT_CANCEL);
throw new ServiceException(ResultServiceEnums.APPOINT_NOT_CANCEL);
}
BAppoint bAppoint = bAppointRepository.selectById(bAppointId);
......@@ -128,15 +128,16 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
bLessonPerson.setIsFinish("1");
line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
//课程在学人数+1
bLessonRepository.personNumberPlusOne(addMyLearnLessonDTO.getLessonId());
bLessonRepository.personNumberReCount(addMyLearnLessonDTO.getLessonId());
}else if (bLessonPersons == null || bLessonPersons.size() < 1){ //未指派
bLessonPerson = new BLessonPerson();
bLessonPerson.initModel();
bLessonPerson.setIsFinish("1");
bLessonPerson.setLessonId(addMyLearnLessonDTO.getLessonId());
bLessonPerson.setPersonId(addMyLearnLessonDTO.getUserId());
line = bLessonPersonRepository.insertBLessonPerson(bLessonPerson);
//课程在学人数+1
bLessonRepository.personNumberPlusOne(addMyLearnLessonDTO.getLessonId());
bLessonRepository.personNumberReCount(addMyLearnLessonDTO.getLessonId());
}else if (bLessonPersons != null && bLessonPersons.size()>0){
line = 1;
}
......
......@@ -11,6 +11,7 @@ import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.business.blesson.util.recursion;
import org.rcisoft.business.blesson.dao.BViewrangeRepository;
import org.rcisoft.common.util.feignDto.DeptGetRspDTO;
import org.rcisoft.common.util.feignDto.GetAllRspDTO;
import org.rcisoft.common.util.feignDto.MTUserGetsReqDTO;
import org.rcisoft.common.util.feignDto.MTUserInfoRspDTO;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
......@@ -19,6 +20,7 @@ import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultExceptionEnum;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.bean.CurUser;
......@@ -336,7 +338,7 @@ public class BLessonServiceImpl implements BLessonService {
int state = bLessonRepository.findLessonReleaseState(id);
if (state != 0){
throw new ServiceException(ResultExceptionEnum.STATE_NOT_RELEASE);
throw new ServiceException(ResultServiceEnums.STATE_NOT_RELEASE);
}
BLesson bLesson = new BLesson();
......@@ -398,7 +400,7 @@ public class BLessonServiceImpl implements BLessonService {
int line = bRecommendRepository.insertBRecommendSons(bRecommendSons);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}else {
throw new ServiceException(ResultExceptionEnum.INVALID_PARAMETER_VALUE);
throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
}
}
......@@ -435,7 +437,7 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel appointLessonToPerson(AppointLessonDTO appointLessonDTO) {
if (StringUtils.isEmpty(appointLessonDTO.getAppointPerson())){
throw new ServiceException(ResultExceptionEnum.INVALID_PARAMETER_VALUE);
throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
}
//按课程查询指派表是否为空
List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(appointLessonDTO);
......@@ -563,7 +565,7 @@ public class BLessonServiceImpl implements BLessonService {
ListAllLesson = bLessonRepository.queryInterestedListByPagination(model);
break;
default:
throw new ServiceException(ResultExceptionEnum.INVALID_PARAMETER_VALUE);
throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
}
return ListAllLesson;
......@@ -571,25 +573,35 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public List<BLesson> theLessonMangageByPagination(PageUtil pageUtil, CurUser curUser, BLesson bLesson) {
public List<BLesson> theLessonMangageByPagination(PageUtil pageUtil, CurUser curUser, BLesson bLesson,List<RoleTypeDepartDTO> roleList) {
//查询当前登录人所在的企业
String corpId = curUser.getCorpId();
String userId = curUser.getUserId();
//查询当前登录人有什么角色
List<String> roleList = sysUserMapper.queryRoleTypeByUserId(userId);
// List<RoleTypeDepartDTO> roleList = sysUserMapper.queryRoleTypeByUserId(userId);
if (roleList == null || roleList.size()<1){
return new ArrayList<>();
}
boolean isAdmin = false;
Set<CurUser> uids = new HashSet<>();
for (String role : roleList) {
if ("1".equals(role)) {
Set<String> uids = new HashSet<>();
Set<String> departIds = new HashSet<>();
for (RoleTypeDepartDTO role : roleList) {
if ("1".equals(role.getType())) {
isAdmin = true;
break;
} else if ("2".equals(role)) {
} else if ("2".equals(role.getType())) {
List<String> departs = asList(StringUtils.split(role.getDeparts(), ","));
departIds.addAll(departs);
// 调用 feign 获取当前部门及子部门 --->所有人
uids.addAll(Arrays.asList(new CurUser(), new CurUser()));
// uids.addAll(Arrays.asList(new CurUser(), new CurUser()));
}
}
List<GetAllRspDTO> GetAllRspDTOList = cotactApiRequestClient.getUserByDeptIdSet(corpId,departIds);
for (GetAllRspDTO getAllRspDTO : GetAllRspDTOList) {
uids.add(getAllRspDTO.getId());
}
//自己
uids.add(curUser);
uids.add(userId);
//查讯课程的语句
List<BLesson> bLessons = bLessonRepository.selectAllManageLesson(uids,bLesson, isAdmin,corpId);
return bLessons;
......@@ -600,7 +612,7 @@ public class BLessonServiceImpl implements BLessonService {
List<String> recommendIds = bRecommendRepository.selectIdByLessonId(lessonId);
if (recommendIds == null || recommendIds.size()<1){
throw new ServiceException(ResultExceptionEnum.NOT_RECOMMEND);
throw new ServiceException(ResultServiceEnums.NOT_RECOMMEND);
}
//修改推荐表
BRecommend bRecommend = new BRecommend();
......@@ -613,6 +625,20 @@ public class BLessonServiceImpl implements BLessonService {
return new PersistModel(line);
}
@Override
public PersistModel addCollect(CurUser curUser,String lessonId) {
AddMyLearnLessonDTO param = new AddMyLearnLessonDTO(lessonId,curUser.getCorpId(),curUser.getUserId());
List<BLessonPerson> bLessonPersons = bLessonPersonRepository.selectByPersonAndLesson(param);
if (bLessonPersons == null || bLessonPersons.size()<1){
throw new ServiceException(ResultServiceEnums.B_R_SL_STUDENT_NOT_EXISTS);
}
BLessonPerson bLessonPerson = bLessonPersons.get(0);
bLessonPerson.setIsCollect("1");
int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
bLessonRepository.collectNumberReCount(lessonId);
return new PersistModel(line);
}
//遍历标签放入List中
List<BLessonLabel> addLabel(BLesson model){
//标签集合
......
......@@ -476,6 +476,25 @@ public class MTCotactApiRequestClient {
return contactFeignClient.getUserByDeptIds(getUserByDeptIdReqDTO,zxClientType,zxAccountId).getData();
}
/**
* 根据多个部门id的Set集合获取部门内人员
* @param corpId
* @param deptIdSet
* @return
*/
public List<GetAllRspDTO> getUserByDeptIdSet(String corpId,Set<String> deptIdSet){
if(deptIdSet == null || deptIdSet.size() < 1){
return new ArrayList<>();
}
GetUserByDeptIdReqDTO getUserByDeptIdReqDTO = new GetUserByDeptIdReqDTO();
List<Long> deptIdList = new ArrayList<>();
for (String deptId : deptIdSet) {
deptIdList.add(Long.parseLong(deptId));
}
getUserByDeptIdReqDTO.setDeptIds(deptIdList);
return contactFeignClient.getUserByDeptIds(getUserByDeptIdReqDTO,zxClientType,zxAccountId).getData();
}
public List<DeptGetRspDTO> deptListDeptInfoByName(String corpId,String name){
return contactFeignClient.deptListDeptInfoByName(corpId,name,zxClientType,zxAccountId).getData();
}
......
......@@ -24,14 +24,8 @@ public enum ResultExceptionEnum {
OS_HAS_SERVER(4008,"操作系统仍有关联服务器,不可删除"),
START_LXC_SERVER(4009,"启动容器失败"),
EXIST_LXC_SERVER(4010,"已开始其他课程实验,请先关闭其他课程实验"),
NO_DATA(4011,"该数据不存在"),
MUST_NOT_FILLED(4012,"必填未填写"),
NOT_MORE_COUNT(4013,"添加超过规定个数"),
APPOINT_NOT_CLOSE(4014,"必修不能退出"),
STATE_NOT_RELEASE(4015,"该课程状态不能发布"),
APPOINT_NOT_CANCEL(4016,"该课程不能取消指派"),
INVALID_PARAMETER_VALUE(4017,"参数值无效"),
NOT_RECOMMEND(4018,"该课程未推荐")
;
private Integer code;
......
......@@ -210,6 +210,15 @@ public enum ResultServiceEnums {
ZX_FAILED(111,"调用智信接口失败"),
MUST_NOT_FILLED(112,"必填未填写"),
NOT_MORE_COUNT(113,"添加超过规定个数"),
APPOINT_NOT_CLOSE(114,"必修不能退出"),
STATE_NOT_RELEASE(115,"该课程状态不能发布"),
APPOINT_NOT_CANCEL(116,"该课程不能取消指派"),
INVALID_PARAMETER_VALUE(117,"参数值无效"),
NOT_RECOMMEND(118,"该课程未推荐"),
NO_DATA(4011,"该数据不存在"),
;
private Integer code;
......
......@@ -2,6 +2,7 @@ package org.rcisoft.sys.role.service;
import org.rcisoft.business.blesson.dto.RoleTypeDepartDTO;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.sys.dept.entity.DeptRole;
......@@ -82,4 +83,6 @@ public interface SysRoleService {
int addAdminRoleMenuUser(InitAddAdminDTO initAddAdminDTO,List<RoleMenuDTO> roleMenuDTOs,UserRoleDTO userRoleDTO);
List<RoleTypeDepartDTO> queryRoleTypeByUserId(CurUser curUser);
}
......@@ -2,6 +2,7 @@ package org.rcisoft.sys.role.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.blesson.dto.RoleTypeDepartDTO;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
......@@ -181,4 +182,9 @@ public class SysRoleServiceImpl implements SysRoleService {
sysRoleRepository.addRoleMenu(roleMenuDTOs);
return sysRoleRepository.addUserRole(userRoleDTO);
}
@Override
public List<RoleTypeDepartDTO> queryRoleTypeByUserId(CurUser curUser) {
return sysUserMapper.queryRoleTypeByUserId(curUser.getUserId());
}
}
......@@ -2,6 +2,7 @@ package org.rcisoft.sys.user.dao;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.blesson.dto.RoleTypeDepartDTO;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.sys.user.bean.CurUser;
import org.rcisoft.sys.user.dto.MyInfoDTO;
......@@ -169,13 +170,14 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
int deleteCompanyUserRole(List<SysUser> userCompanyList);
@Select("<script>SELECT sr.type AS roleList " +
@Select("<script>SELECT sr.type AS type,sr.depart_ids departs " +
"FROM s_user AS su " +
"LEFT JOIN s_r_user_role AS ru ON su.business_id = ru.user_id " +
"LEFT JOIN tm_admin_role AS sr ON ru.role_id = sr.r_id " +
"WHERE su.del_flag = 0 " +
"and sr.r_status !=0 " +
"AND su.business_id = #{userId}</script>")
List<String> queryRoleTypeByUserId(@Param("userId")String userId);
List<RoleTypeDepartDTO> queryRoleTypeByUserId(@Param("userId")String userId);
/**
* 查询用户 menu 19-09-30
......
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