Commit 6abc7642 authored by luzhuang's avatar luzhuang

新增发布积分接口

parent ff69bad6
package org.rcisoft.business.bpersonvalue.controller;
/*固定导入*/
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel;
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.result.ResultServiceEnums;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.exception.ServiceException;
import javax.validation.Valid;
import org.rcisoft.business.bpersonvalue.entity.BPersonValue;
import org.rcisoft.business.bpersonvalue.service.BPersonValueService;
import java.util.List;
/**
* Created by on 2019-11-13 13:28:38.
*/
@RestController
@RequestMapping("bpersonvalue")
public class BPersonValueController extends PaginationController<BPersonValue> {
@Autowired
private BPersonValueService bPersonValueServiceImpl;
@ApiOperation(value="添加", notes="添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(@Valid BPersonValue bPersonValue, BindingResult bindingResult) {
PersistModel data = bPersonValueServiceImpl.save(bPersonValue);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bPersonValue);
}
}
package org.rcisoft.business.bpersonvalue.dao;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.bpersonvalue.entity.BPersonValue;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created with on 2019-11-13 13:28:38.
*/
@Repository
public interface BPersonValueRepository extends BaseMapper<BPersonValue> {
/**
* 分页查询 bPersonValue
*
*/
@Select("<script>select * from b_person_value where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BPersonValue> queryBPersonValues(BPersonValue bPersonValue);
}
package org.rcisoft.business.bpersonvalue.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_person_value")
public class BPersonValue extends IdEntity<BPersonValue> {
private String event;
private Integer value;
private String type;
}
package org.rcisoft.business.bpersonvalue.service;
import org.rcisoft.business.bpersonvalue.entity.BPersonValue;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil;
import java.util.List;
/**
* Created by on 2019-11-13 13:28:38.
*/
public interface BPersonValueService {
/**
* 保存
* @param bPersonValue
* @return
*/
PersistModel save(BPersonValue bPersonValue);
}
package org.rcisoft.business.bpersonvalue.service.impl;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.bpersonvalue.dao.BPersonValueRepository;
import org.rcisoft.business.bpersonvalue.entity.BPersonValue;
import org.rcisoft.business.bpersonvalue.service.BPersonValueService;
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.util.List;
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 BPersonValueServiceImpl implements BPersonValueService {
@Autowired
private BPersonValueRepository bPersonValueRepository;
@Override
public PersistModel save(BPersonValue bPersonValue) {
return null;
}
}
package org.rcisoft.business.breleasevalue.controller;
/*固定导入*/
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.bbanner.dto.FindBannerPaginDTO;
import org.rcisoft.business.bbanner.entity.BBanner;
import org.rcisoft.business.breleasevalue.dto.BReleaseValueDto;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel;
import org.rcisoft.sys.user.bean.CurUser;
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.result.ResultServiceEnums;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.exception.ServiceException;
import javax.validation.Valid;
import org.rcisoft.business.breleasevalue.entity.BReleaseValue;
import org.rcisoft.business.breleasevalue.service.BReleaseValueService;
import java.util.List;
/**
* Created by on 2019-11-13 13:28:39.
*/
@Api(tags = "发布积分")
@RestController
@RequestMapping("breleasevalue")
@Slf4j
public class BReleaseValueController extends PaginationController<BReleaseValue> {
@Autowired
private BReleaseValueService bReleaseValueServiceImpl;
@ApiOperation(value = "分页查询", notes = "根据条件分页查询", response = BBanner.class)
@GetMapping(value = "/queryByPagination")
public Result queryByPagination(CurUser curUser) {
bReleaseValueServiceImpl.queryByPagination(getPaginationUtility(), curUser.getCorpId());
GridModel gridModel = getGridModelResponse();
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
gridModel);
}
@ApiOperation(value="添加", notes="添加")
@PostMapping(value = "/add")
public Result add(CurUser user, @Valid BReleaseValueDto bReleaseValueDto, BindingResult bindingResult) {
PersistModel data = bReleaseValueServiceImpl.save(bReleaseValueDto);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bReleaseValueDto);
}
@ApiOperation(value="删除", notes="删除")
@ApiImplicitParam(name = "businessId", value = "主键id", required = true, dataType = "varchar")
@PostMapping(value = "/delete")
public Result delete(CurUser curUser, String businessId ) {
PersistModel data = bReleaseValueServiceImpl.delete(businessId,curUser.getCorpId());
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
}
}
package org.rcisoft.business.breleasevalue.dao;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.breleasevalue.entity.BReleaseValueSon;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.breleasevalue.entity.BReleaseValue;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created with on 2019-11-13 13:28:38.
*/
@Repository
public interface BReleaseValueRepository extends BaseMapper<BReleaseValue> {
/**
* 分页查询 bReleaseValue
*
*/
@Select("select * from b_release_value where del_flag != 1 and flag = 1 and corp_id = #{corpId}")
@ResultMap(value = "BaseResultMap" )
List<BReleaseValue> queryBReleaseValues(String corpId);
@Insert("<script>" +
"insert into b_release_value_son (business_id,release_id,user_id) VALUES " +
"<foreach collection=\"list\" item=\"item\" separator=\",\">" +
" (#{item.businessId},#{item.releaseId},#{item.userId}) " +
"</foreach></script>")
int insertIntoSon (@Param("list") List<BReleaseValueSon> list);
@Update("update b_release_value set del_flag= 1 where business_id = #{releaseId} and corp_id = #{corpId}")
int remove(@Param("releaseId") String releaseId,@Param("corpId") String corpId);
@Delete("delete from b_release_value_son where user_id = #{userId}")
int deleteSonForUserId(@Param("userId") String userId);
@Delete("delete from b_release_value_son where release_id = #{releaseId}")
int deleteSonForReleaseId(@Param("releaseId") String releaseId);
@Select(" select su.name " +
" from b_release_value_son rvs " +
" left join s_user su on su.business_id = rvs.user_id " +
" where rvs.release_id = #{releaseId} ")
List<String> getNameforReleaseId(@Param("releaseId")String releaseId);
}
package org.rcisoft.business.breleasevalue.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class BReleaseValueDto {
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "主键id")
private String businessId;
@ApiModelProperty(value = "发布课程积分")
private Integer lessonValue;
@ApiModelProperty(value = "发布培训积分")
private Integer trainValue;
@ApiModelProperty(value = "用户ids(用 , 隔开)")
private String userIds;
}
package org.rcisoft.business.breleasevalue.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_release_value")
public class BReleaseValue extends IdEntity<BReleaseValue> {
private String title;
private Integer lessonValue;
private Integer trainValue;
private String corpId;
@Transient
private List<String> userList;
}
package org.rcisoft.business.breleasevalue.entity;
import lombok.*;
import javax.persistence.*;
/**
* Created with on 2019-11-13 13:28:39.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "b_release_value_son")
public class BReleaseValueSon {
private String businessId;
private String releaseId;
private String userId;
}
package org.rcisoft.business.breleasevalue.service;
import org.rcisoft.business.bbanner.dto.FindBannerPaginDTO;
import org.rcisoft.business.bbanner.entity.BBanner;
import org.rcisoft.business.breleasevalue.dto.BReleaseValueDto;
import org.rcisoft.business.breleasevalue.entity.BReleaseValue;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil;
import java.util.List;
/**
* Created by on 2019-11-13 13:28:38.
*/
public interface BReleaseValueService {
PersistModel save (BReleaseValueDto bReleaseValueDto);
List<BReleaseValue> queryByPagination(PageUtil pageUtil, String corpId);
PersistModel delete (String businessId ,String corpId);
}
package org.rcisoft.business.breleasevalue.service.impl;
import org.rcisoft.business.breleasevalue.dto.BReleaseValueDto;
import org.rcisoft.business.breleasevalue.entity.BReleaseValueSon;
import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.breleasevalue.dao.BReleaseValueRepository;
import org.rcisoft.business.breleasevalue.entity.BReleaseValue;
import org.rcisoft.business.breleasevalue.service.BReleaseValueService;
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.util.ArrayList;
import java.util.List;
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 BReleaseValueServiceImpl implements BReleaseValueService {
@Autowired
private BReleaseValueRepository bReleaseValueRepository;
@Override
public PersistModel save(BReleaseValueDto bReleaseValueDto) {
if(bReleaseValueDto.getBusinessId() != null){
// 编辑
BReleaseValue bReleaseValue = new BReleaseValue();
BeanUtils.copyProperties(bReleaseValueDto, bReleaseValue);
UserUtil.setCurrentMergeOperation(bReleaseValue);
}
//新增
BReleaseValue bReleaseValue = new BReleaseValue();
BeanUtils.copyProperties(bReleaseValueDto, bReleaseValue);
UserUtil.setCurrentPersistOperation(bReleaseValue);
String [] ids = bReleaseValueDto.getUserIds().split(",");
List<BReleaseValueSon> list = new ArrayList<>();
if(ids.length > 0){
for (String id : ids){
BReleaseValueSon bReleaseValueSon = new BReleaseValueSon();
bReleaseValueSon.setBusinessId(IdGen.uuid());
bReleaseValueSon.setReleaseId(bReleaseValue.getBusinessId());
bReleaseValueSon.setUserId(id);
list.add(bReleaseValueSon);
}
bReleaseValueRepository.insertIntoSon(list);
}
int line = bReleaseValueRepository.insert(bReleaseValue);
return new PersistModel(line);
}
@Override
public List<BReleaseValue> queryByPagination(PageUtil pageUtil, String corpId) {
List<BReleaseValue> list = bReleaseValueRepository.queryBReleaseValues(corpId);
return list;
}
@Override
public PersistModel delete(String businessId ,String corpId) {
// 删除发布积分表中的数据 del_flag = 1
int line = bReleaseValueRepository.remove(businessId,corpId) ;
// 删除发布积分子表中与ReleaseId有关的数据
bReleaseValueRepository.deleteSonForReleaseId(businessId);
return new PersistModel(line);
}
}
<?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.bpersonvalue.dao.BPersonValueRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.bpersonvalue.entity.BPersonValue">
<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="event" jdbcType="VARCHAR" property="event"/>
<result column="value" jdbcType="INTEGER" property="value"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
<?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.breleasevalue.dao.BReleaseValueRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.breleasevalue.entity.BReleaseValue">
<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="lesson_value" jdbcType="INTEGER" property="lessonValue"/>
<result column="train_value" jdbcType="INTEGER" property="trainValue"/>
<result column="corp_id" jdbcType="VARCHAR" property="corpId"/>
<collection property="userList" ofType="org.rcisoft.business.breleasevalue.entity.BReleaseValue"
javaType="java.util.ArrayList" select="org.rcisoft.business.breleasevalue.dao.BReleaseValueRepository.getNameforReleaseId"
column="business_id">
</collection>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
<?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.breleasevalue.dao.BReleaseValueSonRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.breleasevalue.entity.BReleaseValueSon">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="release_id" jdbcType="VARCHAR" property="releaseId"/>
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ 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