Commit 238f4aef by 裴大威

Merge branch 'feat-1002766' into 'master'

1002766 add cookie check

See merge request rays/pcloud-book!634
parents 0335d905 3ce16fbb
...@@ -9,6 +9,7 @@ import io.swagger.annotations.Api; ...@@ -9,6 +9,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -58,6 +59,7 @@ public interface SearchFacade { ...@@ -58,6 +59,7 @@ public interface SearchFacade {
@ApiOperation("创建搜索记录H5") @ApiOperation("创建搜索记录H5")
@PostMapping("createSearchRecord4H5") @PostMapping("createSearchRecord4H5")
ResponseDto<?> createSearchRecord4H5( ResponseDto<?> createSearchRecord4H5(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody SearchRecord searchRecord @RequestBody SearchRecord searchRecord
) throws PermissionException; ) throws PermissionException;
...@@ -100,6 +102,7 @@ public interface SearchFacade { ...@@ -100,6 +102,7 @@ public interface SearchFacade {
@ApiOperation("获取用户最近搜索列表H5") @ApiOperation("获取用户最近搜索列表H5")
@GetMapping("getUserSearchList4H5") @GetMapping("getUserSearchList4H5")
ResponseDto<?> getUserSearchList4H5( ResponseDto<?> getUserSearchList4H5(
@CookieValue(value = "userInfo") String userInfo,
@RequestParam(value = "wxId", required = false) @ApiParam("用户id") String wxId, @RequestParam(value = "wxId", required = false) @ApiParam("用户id") String wxId,
@RequestParam(value = "wechatUserId", required = false) @ApiParam("微信id") Long wechatUserId, @RequestParam(value = "wechatUserId", required = false) @ApiParam("微信id") Long wechatUserId,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage, @RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
......
...@@ -9,11 +9,13 @@ import com.pcloud.common.dto.ResponseDto; ...@@ -9,11 +9,13 @@ import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException; import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil; import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.wechatgroup.message.enums.IsSystem; import com.pcloud.wechatgroup.message.enums.IsSystem;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -95,8 +97,10 @@ public class SearchFacadeImpl implements SearchFacade { ...@@ -95,8 +97,10 @@ public class SearchFacadeImpl implements SearchFacade {
@PostMapping("createSearchRecord4H5") @PostMapping("createSearchRecord4H5")
@Override @Override
public ResponseDto<?> createSearchRecord4H5( public ResponseDto<?> createSearchRecord4H5(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody SearchRecord searchRecord @RequestBody SearchRecord searchRecord
) throws PermissionException { ) throws PermissionException {
Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
searchBiz.createSearchRecord4H5(searchRecord); searchBiz.createSearchRecord4H5(searchRecord);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -177,12 +181,13 @@ public class SearchFacadeImpl implements SearchFacade { ...@@ -177,12 +181,13 @@ public class SearchFacadeImpl implements SearchFacade {
@GetMapping("getUserSearchList4H5") @GetMapping("getUserSearchList4H5")
@Override @Override
public ResponseDto<?> getUserSearchList4H5( public ResponseDto<?> getUserSearchList4H5(
@CookieValue(value = "userInfo") String userInfo,
@RequestParam(value = "wxId", required = false) @ApiParam("用户id") String wxId, @RequestParam(value = "wxId", required = false) @ApiParam("用户id") String wxId,
@RequestParam(value = "wechatUserId", required = false) @ApiParam("微信id") Long wechatUserId, @RequestParam(value = "wechatUserId", required = false) @ApiParam("微信id") Long wechatUserId,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage, @RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage @RequestParam("numPerPage") @ApiParam("每页条数") Integer numPerPage
) throws BizException, PermissionException { ) throws BizException, PermissionException {
return new ResponseDto<>(searchBiz.getUserSearchList4H5(wxId, wechatUserId, currentPage,numPerPage)); return new ResponseDto<>(searchBiz.getUserSearchList4H5(wxId, Cookie.getId(userInfo, Cookie._WECHAT_USER_ID), currentPage,numPerPage));
} }
@ApiOperation("删除用户搜索记录H5") @ApiOperation("删除用户搜索记录H5")
......
...@@ -343,7 +343,7 @@ public class WechatGroupConsr { ...@@ -343,7 +343,7 @@ public class WechatGroupConsr {
try { try {
selfRobotDTO = ResponseHandleUtil.parseResponse(selfRobotService.getAvailableRobot(wechatUserId, largeTemplet, classifyId), SelfRobotDTO.class); selfRobotDTO = ResponseHandleUtil.parseResponse(selfRobotService.getAvailableRobot(wechatUserId, largeTemplet, classifyId), SelfRobotDTO.class);
} catch (Exception e) { } catch (Exception e) {
log.error("获取可用机器人.[getAvailableRobot]:" + e.getMessage(), e); log.error("获取可用机器人.[getAvailableRobot]:wechatUserId:{},largeTemplet:{},classifyId:{}",wechatUserId,largeTemplet,classifyId);
} }
return selfRobotDTO; return selfRobotDTO;
} }
...@@ -368,7 +368,7 @@ public class WechatGroupConsr { ...@@ -368,7 +368,7 @@ public class WechatGroupConsr {
try { try {
selfRobotDTO = ResponseHandleUtil.parseResponse(selfRobotService.getAvailableRobotByBookGroup(availableRobotParamDTO), SelfRobotDTO.class); selfRobotDTO = ResponseHandleUtil.parseResponse(selfRobotService.getAvailableRobotByBookGroup(availableRobotParamDTO), SelfRobotDTO.class);
} catch (Exception e) { } catch (Exception e) {
log.error("获取可用机器人.[getAvailableRobotByBookGroup]:" + e.getMessage(), e); log.error("获取可用机器人.[getAvailableRobotByBookGroup]获取参数为:{}",availableRobotParamDTO);
} }
return selfRobotDTO; return selfRobotDTO;
} }
......
...@@ -43,17 +43,19 @@ public class CultivateFacade { ...@@ -43,17 +43,19 @@ public class CultivateFacade {
@ApiOperation("新增养成") @ApiOperation("新增养成")
@PostMapping("/createCultivate") @PostMapping("/createCultivate")
public ResponseDto<?> createCultivate( public ResponseDto<?> createCultivate(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody CreateCultivateDTO createCultivateDTO @RequestBody CreateCultivateDTO createCultivateDTO
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(cultivateBiz.createCultivate(createCultivateDTO)); return new ResponseDto<>(cultivateBiz.createCultivate(createCultivateDTO));
} }
@ApiOperation("获取养成") @ApiOperation("获取养成")
@GetMapping("/getCultivate") @GetMapping("/getCultivate")
public ResponseDto<?> getCultivate( public ResponseDto<?> getCultivate(
@RequestParam("wechatUserId") @ApiParam("用户id") Long wechatUserId @CookieValue(value = "userInfo") String userInfo
) throws BizException, PermissionException { ) throws BizException, PermissionException {
return new ResponseDto<>(cultivateBiz.getCultivate(wechatUserId)); return new ResponseDto<>(cultivateBiz.getCultivate(Cookie.getId(userInfo, Cookie._WECHAT_USER_ID)));
} }
@ApiOperation("新增养成分类关联") @ApiOperation("新增养成分类关联")
...@@ -68,8 +70,10 @@ public class CultivateFacade { ...@@ -68,8 +70,10 @@ public class CultivateFacade {
@ApiOperation("能量消耗") @ApiOperation("能量消耗")
@PostMapping("/energyConsumption") @PostMapping("/energyConsumption")
public ResponseDto<?> getCultivate( public ResponseDto<?> getCultivate(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody @ApiParam("养成分类关联")EnergyConsumptionDTO energyConsumptionDTO @RequestBody @ApiParam("养成分类关联")EnergyConsumptionDTO energyConsumptionDTO
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
cultivateBiz.energyConsumption(energyConsumptionDTO); cultivateBiz.energyConsumption(energyConsumptionDTO);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -77,8 +81,10 @@ public class CultivateFacade { ...@@ -77,8 +81,10 @@ public class CultivateFacade {
@ApiOperation("银两兑换") @ApiOperation("银两兑换")
@PostMapping("/fishBallConversion") @PostMapping("/fishBallConversion")
public ResponseDto<?> fishBallConversion( public ResponseDto<?> fishBallConversion(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody @ApiParam("银两兑换") FishBallConversionDTO fishBallConversionDTO @RequestBody @ApiParam("银两兑换") FishBallConversionDTO fishBallConversionDTO
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
cultivateBiz.fishBallConversion(fishBallConversionDTO); cultivateBiz.fishBallConversion(fishBallConversionDTO);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -86,9 +92,10 @@ public class CultivateFacade { ...@@ -86,9 +92,10 @@ public class CultivateFacade {
@ApiOperation("新增技能使用记录") @ApiOperation("新增技能使用记录")
@PostMapping("/addUseSkillRecord") @PostMapping("/addUseSkillRecord")
public ResponseDto<?> addUseSkillRecord( public ResponseDto<?> addUseSkillRecord(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody @ApiParam("技能使用") SkillUseDTO skillUseDTO @RequestBody @ApiParam("技能使用") SkillUseDTO skillUseDTO
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Long wechatUserId=skillUseDTO.getWechatUserId(); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
cultivateBiz.addUseSkillRecord(wechatUserId,skillUseDTO); cultivateBiz.addUseSkillRecord(wechatUserId,skillUseDTO);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -97,8 +104,10 @@ public class CultivateFacade { ...@@ -97,8 +104,10 @@ public class CultivateFacade {
@ApiOperation("银两摘取") @ApiOperation("银两摘取")
@PostMapping("/fishBallPick") @PostMapping("/fishBallPick")
public ResponseDto<?> fishBallPick( public ResponseDto<?> fishBallPick(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody @ApiParam("银两摘取") FishBallPickDTO fishBallPickDTO @RequestBody @ApiParam("银两摘取") FishBallPickDTO fishBallPickDTO
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
cultivateBiz.fishBallPick(fishBallPickDTO); cultivateBiz.fishBallPick(fishBallPickDTO);
return new ResponseDto<>(); return new ResponseDto<>();
} }
...@@ -114,43 +123,35 @@ public class CultivateFacade { ...@@ -114,43 +123,35 @@ public class CultivateFacade {
@ApiOperation("获取动态记录列表") @ApiOperation("获取动态记录列表")
@GetMapping("/getCultivateRecordList") @GetMapping("/getCultivateRecordList")
public ResponseDto<?> getCultivateRecordList( public ResponseDto<?> getCultivateRecordList(
@RequestParam Long wechatUserId, @CookieValue(value = "userInfo") String userInfo,
@RequestParam("cultivateId") @ApiParam("养成id") Long cultivateId, @RequestParam(value = "currentPage", required = false) Integer currentPage, @RequestParam("cultivateId") @ApiParam("养成id") Long cultivateId, @RequestParam(value = "currentPage", required = false) Integer currentPage,
@RequestParam(value = "numPerPage", required = false) Integer numPerPage @RequestParam(value = "numPerPage", required = false) Integer numPerPage
) throws BizException, PermissionException { ) throws BizException, PermissionException {
if (currentPage == null || numPerPage == null || currentPage < 0 || numPerPage < 0) { if (currentPage == null || numPerPage == null || currentPage < 0 || numPerPage < 0) {
throw BookBizException.PAGE_PARAM_DELETION; throw BookBizException.PAGE_PARAM_DELETION;
} }
if(!NumberUtil.isNumber(wechatUserId)){ Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(cultivateBiz.getCultivateRecordList(cultivateId,wechatUserId,currentPage,numPerPage)); return new ResponseDto<>(cultivateBiz.getCultivateRecordList(cultivateId,wechatUserId,currentPage,numPerPage));
} }
@ApiOperation("获取陪伴天数") @ApiOperation("获取陪伴天数")
@GetMapping("/getLoginDays") @GetMapping("/getLoginDays")
public ResponseDto<?> getLoginDays(@RequestParam Long wechatUserId){ public ResponseDto<?> getLoginDays(@CookieValue(value = "userInfo") String userInfo){
if(!NumberUtil.isNumber(wechatUserId)){ Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(cultivateBiz.getLoginDays(wechatUserId)); return new ResponseDto<>(cultivateBiz.getLoginDays(wechatUserId));
} }
@ApiOperation("获取排名") @ApiOperation("获取排名")
@GetMapping("/getRanking") @GetMapping("/getRanking")
public ResponseDto<?> getRanking(@RequestParam Long wechatUserId){ public ResponseDto<?> getRanking(@CookieValue(value = "userInfo") String userInfo){
if(!NumberUtil.isNumber(wechatUserId)){ Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(cultivateBiz.getRanking(wechatUserId)); return new ResponseDto<>(cultivateBiz.getRanking(wechatUserId));
} }
@ApiOperation("分享") @ApiOperation("分享")
@GetMapping("shareMedal") @GetMapping("shareMedal")
public ResponseDto<?> shareMedal(@RequestParam Long wechatUserId){ public ResponseDto<?> shareMedal(@CookieValue(value = "userInfo") String userInfo){
if(!NumberUtil.isNumber(wechatUserId)){ Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
}
return new ResponseDto<>(cultivateBiz.shareMedal(wechatUserId)); return new ResponseDto<>(cultivateBiz.shareMedal(wechatUserId));
} }
...@@ -165,8 +166,10 @@ public class CultivateFacade { ...@@ -165,8 +166,10 @@ public class CultivateFacade {
@ApiOperation("小睿养成读者喜好书籍") @ApiOperation("小睿养成读者喜好书籍")
@PostMapping("/createCultivateBookUser") @PostMapping("/createCultivateBookUser")
public ResponseDto<?> createCultivateBookUser( public ResponseDto<?> createCultivateBookUser(
@CookieValue(value = "userInfo") String userInfo,
@RequestBody CultivateBookUser cultivateBookUser @RequestBody CultivateBookUser cultivateBookUser
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(cultivateBiz.createCultivateBookUser(cultivateBookUser)); return new ResponseDto<>(cultivateBiz.createCultivateBookUser(cultivateBookUser));
} }
...@@ -181,14 +184,13 @@ public class CultivateFacade { ...@@ -181,14 +184,13 @@ public class CultivateFacade {
@ApiOperation("获取搜索书籍记录列表") @ApiOperation("获取搜索书籍记录列表")
@GetMapping("/getBookSearchRecord") @GetMapping("/getBookSearchRecord")
public ResponseDto<?> getBookSearchRecord( public ResponseDto<?> getBookSearchRecord(
@CookieValue(value = "userInfo" ,required = false) String userInfo,@RequestParam(value = "currentPage", required = false) Integer currentPage, @CookieValue(value = "userInfo") String userInfo,@RequestParam(value = "currentPage", required = false) Integer currentPage,
@RequestParam(value = "numPerPage", required = false) Integer numPerPage @RequestParam(value = "numPerPage", required = false) Integer numPerPage
) throws BizException, PermissionException { ) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID); Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){ if(!NumberUtil.isNumber(wechatUserId)){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空"); throw new BizException(BizException.PARAM_IS_NULL.getCode(), "wechatUserId 不能为空");
} }
return new ResponseDto<>(cultivateBiz.getBookSearchRecord(wechatUserId,currentPage,numPerPage)); return new ResponseDto<>(cultivateBiz.getBookSearchRecord(wechatUserId,currentPage,numPerPage));
} }
......
...@@ -97,7 +97,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -97,7 +97,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
throw new BookBizException(BookBizException.ERROR,"已存在相同的权益设置"); throw new BookBizException(BookBizException.ERROR,"已存在相同的权益设置");
} }
rightsSetting.setUpdateTime(new Date()); rightsSetting.setUpdateTime(new Date());
rightsSettingDAO.updateByPrimaryKeySelective(rightsSetting); rightsSettingDAO.updateByPrimaryKey(rightsSetting);
} }
@Override @Override
......
...@@ -28,7 +28,7 @@ public class RightsSettingDAOImpl extends BaseDaoImpl<RightsSetting> implement ...@@ -28,7 +28,7 @@ public class RightsSettingDAOImpl extends BaseDaoImpl<RightsSetting> implement
@Override @Override
public int updateByPrimaryKey(RightsSetting record) { public int updateByPrimaryKey(RightsSetting record) {
return super.getSqlSession().update(getStatement("updateByPrimaryKeySelective"),record); return super.getSqlSession().update(getStatement("updateByPrimaryKey"),record);
} }
@Override @Override
......
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
second_classify = #{secondClassify,jdbcType=BIGINT}, second_classify = #{secondClassify,jdbcType=BIGINT},
grade_label_id = #{gradeLabelId,jdbcType=BIGINT}, grade_label_id = #{gradeLabelId,jdbcType=BIGINT},
subject_label_id = #{subjectLabelId,jdbcType=BIGINT}, subject_label_id = #{subjectLabelId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
......
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