Commit 1e992948 authored by luzhuang's avatar luzhuang

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents 3cca5819 236851f9
......@@ -31,10 +31,10 @@ public interface BBannerRepository extends BaseMapper<BBanner> {
@Select("<script>select bb.* , bl.lesson_name lessonName,bl.default_url lessonDefaultUrl from b_banner bb " +
" left join b_lesson bl on bb.course_id = bl.business_id " +
" where bb.del_flag='0' and bb.flag = '1' " +
" <if test=\"businessId!=null and businessId != ''\">and bb.business_id = #{businessId}</if>" +
" <if test=\"title!=null and title != ''\">and bb.title like CONCAT('%',#{title},'%')</if>" +
" <if test=\"isExternalLink!=null and isExternalLink != ''\">and bb.is_external_link=#{isExternalLink}</if>" +
" <if test=\"lineType!=null and lineType != ''\">and bb.line_type=#{lineType}</if>" +
" <if test=\"businessId !=null and businessId != ''\">and bb.business_id = #{businessId}</if>" +
" <if test=\"title !=null and title != ''\">and bb.title like CONCAT('%',#{title},'%')</if>" +
" <if test=\"isExternalLink !=null and isExternalLink != ''\">and bb.is_external_link=#{isExternalLink}</if>" +
" <if test=\"lineType !=null and lineType != ''\">and bb.line_type=#{lineType}</if>" +
" and bb.corp_id = #{corpId} "+
......
package org.rcisoft.business.bexternallink.controller;
/*固定导入*/
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.rcisoft.business.bexternallink.dto.AddOrUpdateDTO;
import org.rcisoft.business.bexternallink.dto.FindListDTO;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel;
import org.rcisoft.sys.user.bean.CurUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.util.UserUtil;
import javax.validation.Valid;
import org.rcisoft.business.bexternallink.entity.BExternalLink;
import org.rcisoft.business.bexternallink.service.BExternalLinkService;
import java.util.List;
/**
* Created by on 2019-11-13 13:28:38.
*/
@Api(tags = "14 外部链接")
@RestController
@RequestMapping("bexternallink")
public class BExternalLinkController extends PaginationController<BExternalLink> {
@Autowired
private BExternalLinkService bExternalLinkServiceImpl;
@ApiOperation(value = "1401 添加", notes = "添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(CurUser curUser, @Valid AddOrUpdateDTO addOrUpdateDTO, BindingResult bindingResult) {
PersistModel data = bExternalLinkServiceImpl.save(addOrUpdateDTO);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
addOrUpdateDTO);
}
@ApiOperation(value = "1402 逻辑删除", notes = "逻辑删除")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "varchar")})
@PostMapping("/delete")
public Result delete(CurUser curUser, @Valid String businessId, BindingResult bindingResult) {
PersistModel data = bExternalLinkServiceImpl.remove(businessId);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
}
@ApiOperation(value = "1403 查单一查询", notes = "查单一查询")
@GetMapping("/detail")
public Result detail(CurUser curUser, @Valid String businessId, BindingResult bindingResult) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bExternalLinkServiceImpl.findById(businessId));
}
@ApiOperation(value = "1404 分页查询外链", notes = "分页查询外链")
@GetMapping(value = "/queryBExternalLinkByPagination")
public Result listByPagination(CurUser curUser, @Valid FindListDTO findListDTO, BindingResult bindingResult) {
bExternalLinkServiceImpl.findAllByPagination(getPaginationUtility(), findListDTO);
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
gridModel);
}
@ApiOperation(value = "1405 外链重新排序", notes = "外链重新排序")
@PostMapping(value = "/updateExternalLinkOrder")
public Result updateExternalLinkOrder(CurUser curUser, @Param("bannerOrderMap") String orderMap, BindingResult bindingResult){
int data = bExternalLinkServiceImpl.updateExternalLinkOrder(orderMap);
return Result.builder(new PersistModel(data),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
orderMap);
}
}
package org.rcisoft.business.bexternallink.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.rcisoft.business.bexternallink.dto.FindListDTO;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.bexternallink.entity.BExternalLink;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.sys.user.bean.CurUser;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* Created with on 2019-11-13 13:28:38.
*/
@Repository
public interface BExternalLinkRepository extends BaseMapper<BExternalLink> {
/**
* 分页查询 bExternalLink
*/
@Select("<script>select * from b_external_link where 1=1 " +
" and del_flag = 0 and flag = 1 " +
" and corp_id = #{param.corpId} " +
" <if test=\"param.type !=null and param.type != ''\">and type = #{param.type}</if>" +
" <if test=\"param.title !=null and param.title != ''\">and title like CONCAT('%',#{param.title},'%')</if>" +
" order by CAST(sort AS UNSIGNED) asc " +
"</script>")
@ResultMap(value = "BaseResultMap")
List<BExternalLink> queryBExternalLinks(@Param("param") FindListDTO findListDTO);
/**
* 按id查询个数
*
* @param id
* @return
*/
@Select("<script>select count(business_id) from b_external_link where del_flag='0' and flag = '1' and business_id=#{id} " +
"</script>")
int selectCountById(String id);
/**
* 根据企业id查询外链个数
*
* @return
*/
@Select("<script>select count(1) from b_external_link where " +
" del_flag = 0 and flag = 1 " +
" and corp_id = #{corpId} " +
"</script>")
int selectCountExternalLink(String corpId);
/**
* 获取sort最大值 +1
*
* @return
*/
@Select("<script>select DISTINCT IFNULL((select max(sort) from b_external_link where " +
"del_flag = 0 and flag = 1 ),0)+1 as sort</script>")
int selectMaxSort();
//重新排序
@Update("<script> <foreach collection=\"orderMap.entrySet()\" index=\"key\" item=\"value\" separator=\";\"> " +
"update b_banner " +
"set banner_sort = #{value} " +
" WHERE business_id = #{key} " +
"</foreach></script>")
int updateExternalLinkOrder(@Param("orderMap") Map<String,Object> orderMap);
}
package org.rcisoft.business.bexternallink.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AddOrUpdateDTO {
@ApiModelProperty(value = "主键id" ,required = false, dataType = "varchar")
private String businessId;
@NotBlank(message = "标题不能为空")
@ApiModelProperty(value = "标题" ,required = true, dataType = "varchar")
private String title;
@ApiModelProperty(value = "外部URL",required = true, dataType = "varchar")
private String externalUrl;
@ApiModelProperty(value = "图标",required = true, dataType = "varchar")
private String logo;
@ApiModelProperty(value = "备注",required = false, dataType = "varchar")
private String remarks;
@ApiModelProperty(value = "类型(0:手机,1:跨平台,2: PC)",required = true, dataType = "varchar")
private String type;
private String userId;
private String corpId;
}
package org.rcisoft.business.bexternallink.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class FindListDTO {
@ApiModelProperty(value = "类型(0:手机,1:跨平台,2: PC)",required = false, dataType = "varchar")
private String type;
@ApiModelProperty(value = "标题" ,required = false, dataType = "varchar")
private String title;
private String corpId;
private String userId;
}
package org.rcisoft.business.bexternallink.entity;
import lombok.*;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created with on 2019-11-13 13:28:38.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "b_external_link")
public class BExternalLink extends IdEntity<BExternalLink> {
private String title;
private String logo;
private String externalUrl;
private String type;
private Integer sort;
private String corpId;
public BExternalLink(String businessId){
this.businessId = businessId;
}
}
package org.rcisoft.business.bexternallink.service;
import org.rcisoft.business.bexternallink.dto.AddOrUpdateDTO;
import org.rcisoft.business.bexternallink.dto.FindListDTO;
import org.rcisoft.business.bexternallink.entity.BExternalLink;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.sys.user.bean.CurUser;
import java.util.List;
/**
* Created by on 2019-11-13 13:28:38.
*/
public interface BExternalLinkService {
/**
* 保存
* @param addOrUpdateDTO
* @return
*/
PersistModel save(AddOrUpdateDTO addOrUpdateDTO);
/**
* 逻辑删除
* @param id
* @return
*/
PersistModel remove(String id);
/**
* 根据id查询
* @param id
* @return
*/
BExternalLink findById(String id);
/**
* 分页查询
* @param findListDTO
* @return
*/
List<BExternalLink> findAllByPagination(PageUtil<BExternalLink> paginationUtility,
FindListDTO findListDTO);
/**
* 重新排序
* @param orderMap
* @return
*/
int updateExternalLinkOrder(String orderMap);
}
package org.rcisoft.business.bexternallink.service.impl;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.bbanner.entity.BBanner;
import org.rcisoft.business.bexternallink.dto.AddOrUpdateDTO;
import org.rcisoft.business.bexternallink.dto.FindListDTO;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.bexternallink.dao.BExternalLinkRepository;
import org.rcisoft.business.bexternallink.entity.BExternalLink;
import org.rcisoft.business.bexternallink.service.BExternalLinkService;
import org.rcisoft.sys.user.bean.CurUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* Created by on 2019-11-13 13:28:38.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class BExternalLinkServiceImpl implements BExternalLinkService {
@Autowired
private BExternalLinkRepository bExternalLinkRepository;
/**
* 保存 bExternalLink
* @param addOrUpdateDTO
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(AddOrUpdateDTO addOrUpdateDTO){
BExternalLink bExternalLink = new BExternalLink();
BeanUtils.copyProperties(addOrUpdateDTO, bExternalLink);
int line = 0;
//外部链接但外部URL为空或长度为0 抛异常
if (StringUtils.isEmpty(bExternalLink.getExternalUrl()))
throw new ServiceException(ResultServiceEnums.JUMP_ADDRESS_NULL);
else if (StringUtils.isNotBlank(bExternalLink.getExternalUrl())){
try {
URL url = new URL(bExternalLink.getExternalUrl());
InputStream in = ((URL) url).openStream();
} catch (Exception e1) {
throw new ServiceException(ResultServiceEnums.ILLEGAL_URL);
}
}
if (bExternalLink.getBusinessId() != null) {
//按ID查询Banner个数
if (bExternalLinkRepository.selectCountById(bExternalLink.getBusinessId()) == 0){
throw new ServiceException(ResultServiceEnums.NO_DATA);
}
UserUtil.setCurrentMergeOperation(bExternalLink);
line = bExternalLinkRepository.updateByPrimaryKeySelective(bExternalLink);
} else {
UserUtil.setCurrentPersistOperation(bExternalLink);
//查询Banner是否大于等于10个,大于等于十个不允许添加
int countBanner = bExternalLinkRepository.selectCountExternalLink(bExternalLink.getCorpId());
if(countBanner >= 10){
throw new ServiceException(ResultServiceEnums.NOT_MORE_COUNT);
}
//查询最大排序值+1后放入Banner中
int sort = bExternalLinkRepository.selectMaxSort();
bExternalLink.setSort(sort);
line = bExternalLinkRepository.insertSelective(bExternalLink);
}
return new PersistModel(line);
}
/**
* 逻辑删除
* @param id
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(String id){
BExternalLink bExternalLink = new BExternalLink(id);
UserUtil.setCurrentMergeOperation(bExternalLink);
bExternalLink.setDeleted();
int line = bExternalLinkRepository.logicalDelete(bExternalLink);
return new PersistModel(line);
}
/**
* 根据id查询 bExternalLink
* @param id
* @return
*/
public BExternalLink findById(String id){
return bExternalLinkRepository.selectByPrimaryKey(id);
}
/**
* 分页查询 bExternalLink
* @param findListDTO
* @return
*/
public List<BExternalLink> findAllByPagination(PageUtil<BExternalLink> paginationUtility,
FindListDTO findListDTO){
return bExternalLinkRepository.queryBExternalLinks(findListDTO);
}
@Override
public int updateExternalLinkOrder(String bannerOrderMap) {
//获取将字符串中的主键和位置对应关系转成Map
Map parse = (Map) JSON.parse(bannerOrderMap);
int i = bExternalLinkRepository.updateExternalLinkOrder(parse);
return i;
}
}
......@@ -672,6 +672,15 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" and del_flag != 1 and flag = 1 " +
" and lesson_id = #{lessonId} </script>" )
int personNumberCount(String lessonId);
/**
* 在学人数
* @param lessonId
* @return
*/
@Select("<script>select count(1) from b_lesson_person where 1=1 " +
" and del_flag != 1 and flag = 1 " +
" and lesson_id = #{lessonId} </script>" )
String lessonPersonCount(String lessonId);
/**
* 重新统计收藏人数
......@@ -1012,7 +1021,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"<if test=\"bLesson.lecturerId!=null and bLesson.lecturerId!=''\">AND u1.name like '%${bLesson.lecturerId}%' </if>" +
"<if test=\"bLesson.releaseState!=null and bLesson.releaseState!=''\">AND les.release_state = #{bLesson.releaseState} </if>" +
"</script>")
@ResultMap(value = "BaseResultMap")
@ResultMap(value = "AllManageResultMap")
List<BLesson> selectAllManageLesson(@Param("CurUserSet") Set<String> CurUserSet, @Param("bLesson") BLesson bLesson, @Param("isAdmin") boolean isAdmin, @Param("corpId") String corpId) ;
......
<?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="org.rcisoft.business.bexternallink.dao.BExternalLinkRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.bexternallink.entity.BExternalLink">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="title" jdbcType="VARCHAR" property="title"/>
<result column="logo" jdbcType="VARCHAR" property="logo"/>
<result column="external_url" jdbcType="VARCHAR" property="externalUrl"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="sort" jdbcType="INTEGER" property="sort"/>
<result column="corp_id" jdbcType="VARCHAR" property="corpId"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
......@@ -132,6 +132,52 @@
<result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
</resultMap>
<resultMap id="AllManageResultMap" type="org.rcisoft.business.blesson.entity.BLesson">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="code" jdbcType="VARCHAR" property="code"/>
<result column="lesson_name" jdbcType="VARCHAR" property="lessonName"/>
<result column="default_url" jdbcType="VARCHAR" property="defaultUrl"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="class_hour" jdbcType="VARCHAR" property="classHour"/>
<result column="lecturer_id" jdbcType="VARCHAR" property="lecturerId"/>
<result column="release_state" jdbcType="VARCHAR" property="releaseState"/>
<result column="course_id" jdbcType="VARCHAR" property="courseId"/>
<!--<result column="person_number" jdbcType="VARCHAR" property="personNumber"/>-->
<result column="course_time" jdbcType="VARCHAR" property="courseTime"/>
<result column="course_description" jdbcType="VARCHAR" property="courseDescription"/>
<result column="view_range" jdbcType="VARCHAR" property="viewRange"/>
<result column="release_date" jdbcType="TIMESTAMP" property="releaseDate"/>
<result column="close_date" jdbcType="TIMESTAMP" property="closeDate"/>
<result column="lesson_type" jdbcType="VARCHAR" property="lessonType"/>
<result column="discuss_number" jdbcType="VARCHAR" property="discussNumber"/>
<result column="recommend" jdbcType="VARCHAR" property="recommend"/>
<result column="collect_number" jdbcType="VARCHAR" property="collectNumber"/>
<result column="hot_number" jdbcType="VARCHAR" property="hotNumber"/>
<!--培训-->
<result column="apply_start_date" jdbcType="TIMESTAMP" property="applyStartDate"/>
<result column="apply_over_date" jdbcType="TIMESTAMP" property="applyOverDate"/>
<result column="train_start_date" jdbcType="TIMESTAMP" property="trainStartDate"/>
<result column="train_over_date" jdbcType="TIMESTAMP" property="trainOverDate"/>
<result column="max_apply_person" jdbcType="VARCHAR" property="maxApplyPerson"/>
<result column="train_address" jdbcType="VARCHAR" property="trainAddress"/>
<result column="train_sign_time" jdbcType="VARCHAR" property="trainSignTime"/>
<result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
<!---->
<!--<collection property="labelList" ofType="org.rcisoft.business.blabel.dto.QueryLabelResDTO"-->
<!--javaType="java.util.ArrayList" select="org.rcisoft.business.blesson.dao.BLessonRepository.queryLabelByLessonId"-->
<!--column="business_id">-->
<!--</collection>-->
<association property="personNumber" select="org.rcisoft.business.blesson.dao.BLessonRepository.lessonPersonCount"
column="business_id">
</association>
</resultMap>
<!--<resultMap id="SupperChildListResultMap" type="org.rcisoft.business.blesson.entity.BLesson" extends="BaseResultMap">-->
<!--<association column="business_id" property="labelList" select="org.rcisoft.business.blesson.dao.BLessonRepository.queryLabelByLessonId"></association>-->
<!--</resultMap>-->
......
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