Commit c52e26f9 by 吴博

feat:[none] getOther

parent 0907a226
package com.pcloud.book.book.biz;
import com.pcloud.book.book.entity.BookOther;
import com.pcloud.common.page.PageBeanNew;
/**
* (BookOther)表服务接口
*
* @author makejava
* @since 2020-12-02 18:56:07
*/
public interface BookOtherBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
BookOther getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param bookOther 实例对象
* @return 主键
*/
Long insert(BookOther bookOther);
/**
* 修改数据
*
* @param bookOther 实例对象
*/
void update(BookOther bookOther);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
/**
* 获取其他权益的书籍
*/
void getOtherBook();
}
\ No newline at end of file
package com.pcloud.book.book.biz.impl;
import com.pcloud.book.book.biz.BookAdviserBiz;
import com.pcloud.book.book.biz.BookOtherBiz;
import com.pcloud.book.book.dao.BookAdviserDao;
import com.pcloud.book.book.dao.BookOtherDao;
import com.pcloud.book.book.entity.BookOther;
import com.pcloud.book.book.vo.PcloudAdviserBookVO;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import static com.pcloud.book.util.common.ThreadPoolUtils.OTHER_POOL;
/**
* (BookOther)表服务实现类
*
* @author makejava
* @since 2020-12-02 18:51:00
*/
@Service("bookOtherBiz")
public class BookOtherBizImpl implements BookOtherBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(BookOtherBizImpl.class);
@Autowired
private BookOtherDao bookOtherDao;
@Autowired
private BookAdviserBiz bookAdviserBiz;
@Autowired
private BookAdviserDao bookAdviserDao;
@Autowired
private RightsSettingBiz rightsSettingBiz;
@Override
@ParamLog("通过ID查询单条数据")
public BookOther getById(Long id) {
return bookOtherDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = bookOtherDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) {
return pageBeanNew;
}
// 加载其它数据
return pageBeanNew;
}
@Override
@ParamLog("新增")
public Long insert(BookOther bookOther) {
bookOtherDao.insert(bookOther);
return bookOther.getId();
}
@Override
@ParamLog("修改")
public void update(BookOther bookOther) {
if (bookOther == null || !NumberUtil.isNumber(bookOther.getId())) {
throw BizException.PARAM_IS_NULL;
}
bookOtherDao.update(bookOther);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
bookOtherDao.deleteById(id);
}
@Override
public void getOtherBook() {
OTHER_POOL.execute(()->{
PageBeanNew<PcloudAdviserBookVO> pcloudAdviserBookVOPageBeanNew = bookAdviserBiz.listAdviserBook4Pcloud(null, 0, 100);
Integer pageCount = pcloudAdviserBookVOPageBeanNew.getPageCount();
List<PcloudAdviserBookVO> pcloudAdviserBookVOS = new ArrayList<>();
for (int i = 0; i < pageCount; i++) {
pcloudAdviserBookVOPageBeanNew = bookAdviserBiz.listAdviserBook4Pcloud(null, i, 100);
if (null == pcloudAdviserBookVOPageBeanNew) {
continue;
}
pcloudAdviserBookVOS = pcloudAdviserBookVOPageBeanNew.getRecordList();
if (ListUtils.isEmpty(pcloudAdviserBookVOS)) {
continue;
}
List<BookOther> bookOthers = new ArrayList<>();
pcloudAdviserBookVOS.stream().forEach(pcloudAdviserBookVO -> {
RightsSettingDto rightsSettingDto = rightsSettingBiz.getRightsSettingByBookId4AppletHome(pcloudAdviserBookVO.getBookId(),
pcloudAdviserBookVO.getAdviserId(), pcloudAdviserBookVO.getChannelId());
if (null == rightsSettingDto || null == rightsSettingDto.getId()) {
BookOther bookOther = new BookOther();
bookOther.setBookId(pcloudAdviserBookVO.getBookId());
bookOther.setAdviserId(pcloudAdviserBookVO.getAdviserId());
bookOther.setChannelId(pcloudAdviserBookVO.getChannelId());
bookOther.setBookName(pcloudAdviserBookVO.getBookName());
bookOthers.add(bookOther);
}
});
if (ListUtils.isEmpty(bookOthers)) {
continue;
}
bookOtherDao.insert(bookOthers);
try {
Thread.sleep(1000 * 2);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
}
\ No newline at end of file
package com.pcloud.book.book.dao;
import com.pcloud.book.book.entity.BookOther;
import com.pcloud.common.core.dao.BaseDao;
/**
* (BookOther)表数据库访问层
*
* @author makejava
* @since 2020-12-02 18:55:58
*/
public interface BookOtherDao extends BaseDao<BookOther> {
}
\ No newline at end of file
package com.pcloud.book.book.dao.impl;
import com.pcloud.book.book.dao.BookOtherDao;
import com.pcloud.book.book.entity.BookOther;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
/**
* (BookOther)表数据库访问层
*
* @author makejava
* @since 2020-12-02 18:56:04
*/
@Repository("bookOtherDaoImpl")
public class BookOtherDaoImpl extends BaseDaoImpl<BookOther> implements BookOtherDao {
}
\ No newline at end of file
package com.pcloud.book.book.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
import java.util.Date;
/**
* (BookOther)实体类
*
* @author makejava
* @since 2020-12-02 18:55:51
*/
@Data
public class BookOther extends BaseEntity {
private static final long serialVersionUID = 288525101077875076L;
private Long id;
private Long bookId;
private Long adviserId;
private Long channelId;
private String bookName;
private Long rightsSettingId;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.book.facade;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookOtherBiz;
import com.pcloud.book.book.entity.BookOther;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* (BookOther)表控制层
*
* @author makejava
* @since 2020-12-02 18:51:00
*/
@RestController("bookOtherFacade")
@RequestMapping("bookOther")
public class BookOtherFacade {
@Autowired
private BookOtherBiz bookOtherBiz;
@ApiOperation("通过主键查询单条数据")
@GetMapping("getById")
public ResponseDto<?> getById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(bookOtherBiz.getById(id));
}
@ApiOperation("分页查询")
@GetMapping("getList")
public ResponseDto<?> getList(@RequestHeader("token") String token,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(bookOtherBiz.getList(currentPage, numPerPage));
}
@ApiOperation("新增")
@PostMapping("insert")
public ResponseDto<?> insert(@RequestHeader("token") String token, @RequestBody BookOther bookOther)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(bookOtherBiz.insert(bookOther));
}
@ApiOperation("更新")
@PostMapping("update")
public ResponseDto<?> update(@RequestHeader("token") String token, @RequestBody BookOther bookOther) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
bookOtherBiz.update(bookOther);
return new ResponseDto<>();
}
@ApiOperation("删除")
@GetMapping("deleteById")
public ResponseDto<?> deleteById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
if (null == id) {
throw BookBizException.PARAM_DELETION;
}
bookOtherBiz.deleteById(id);
return new ResponseDto<>();
}
@ApiOperation("获取保底权益的书")
@GetMapping("getOtherBook")
public ResponseDto<?> getOtherBook() throws BizException, PermissionException {
bookOtherBiz.getOtherBook();
return new ResponseDto<>();
}
}
\ No newline at end of file
...@@ -44,5 +44,8 @@ public class PcloudAdviserBookVO implements Serializable { ...@@ -44,5 +44,8 @@ public class PcloudAdviserBookVO implements Serializable {
@ApiModelProperty("出版社ID") @ApiModelProperty("出版社ID")
private Long agentId; private Long agentId;
@ApiModelProperty("渠道id")
private Long channelId;
} }
...@@ -640,6 +640,7 @@ ...@@ -640,6 +640,7 @@
SELECT SELECT
ba.BOOK_ID bookId, ba.BOOK_ID bookId,
ba.ADVISER_ID adviserId, ba.ADVISER_ID adviserId,
ba.channel_id channelId,
b.BOOK_NAME bookName, b.BOOK_NAME bookName,
b.COVER_IMG coverImg, b.COVER_IMG coverImg,
b.ISBN isbn, b.ISBN isbn,
......
<?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.pcloud.book.book.dao.impl.BookOtherDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.book.entity.BookOther">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<result column="book_name" property="bookName" jdbcType="VARCHAR"/>
<result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_id, adviser_id, channel_id, book_name, rights_setting_id, create_time, update_time
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM book_other
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM book_other
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO book_other(
book_id,
adviser_id,
channel_id,
book_name,
rights_setting_id,
create_time,
update_time
) VALUES (
#{bookId, jdbcType=BIGINT},
#{adviserId, jdbcType=BIGINT},
#{channelId, jdbcType=BIGINT},
#{bookName, jdbcType=VARCHAR},
#{rightsSettingId, jdbcType=BIGINT},
#{createTime, jdbcType=TIMESTAMP},
#{updateTime, jdbcType=TIMESTAMP}
)
</insert>
<insert id="batchInsert">
INSERT INTO book_other (
book_id,
adviser_id,
channel_id,
book_name,
create_time,
update_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.bookId, jdbcType=BIGINT},
#{item.adviserId, jdbcType=BIGINT},
#{item.channelId, jdbcType=BIGINT},
#{item.bookName, jdbcType=VARCHAR},
now(),
now()
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE book_other
<set>
<if test="bookId != null">
book_id = #{bookId},
</if>
<if test="adviserId != null">
adviser_id = #{adviserId},
</if>
<if test="channelId != null">
channel_id = #{channelId},
</if>
<if test="bookName != null and bookName != ''">
book_name = #{bookName},
</if>
<if test="rightsSettingId != null">
rights_setting_id = #{rightsSettingId},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM book_other where id = #{id}
</delete>
</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