提交 9c821bcd authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 1079afbb
package com.zrqx.sysuser.bg.client.recommend;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.form.resource.bg.recommend.DeleteRecommendForm;
import com.zrqx.core.form.resource.bg.recommend.SaveRecommendForm;
import com.zrqx.core.util.response.CallBack;
/**
* 推荐位远程调用
* @author ycw
* @date 2019年1月28日上午9:23:00
*/
@FeignClient(value="resource",fallback=RecommendClientHystric.class)
public interface RecommendClient {
/**
* 删除推荐位----民族主页删除,需要的级联操作
* @param form
* @return
* @author ycw
* @date: 2019年1月28日 上午9:35:34
*/
@PostMapping(value = ResourceRequestPath.BG + ResourceRequestPath.RECOMMEND + ResourceRequestPath.DELETE)
CallBack<Boolean> delete(@RequestBody DeleteRecommendForm form);
/**
* 新增推荐位----民族主页新增,需要级联操作
* @param form
* @return
* @author ycw
* @date: 2019年1月28日 上午10:37:26
*/
@PostMapping(value = ResourceRequestPath.BG + ResourceRequestPath.RECOMMEND + ResourceRequestPath.SAVE)
CallBack<Boolean> save(@RequestBody SaveRecommendForm form);
}
package com.zrqx.sysuser.bg.client.recommend;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.zrqx.core.form.resource.bg.recommend.DeleteRecommendForm;
import com.zrqx.core.form.resource.bg.recommend.SaveRecommendForm;
import com.zrqx.core.util.response.CallBack;
@Component
public class RecommendClientHystric implements RecommendClient {
private static final Logger logger = LoggerFactory.getLogger(RecommendClientHystric.class);
@Override
public CallBack<Boolean> delete(DeleteRecommendForm form){
logger.info("删除推荐位操作失败");
return CallBack.fail();
}
@Override
public CallBack<Boolean> save(SaveRecommendForm form){
logger.info("新增推荐位操作失败");
return CallBack.fail();
}
}
package com.zrqx.sysuser.bg.controller.national;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.constant.sysuser.SysUserRequestPath;
import com.zrqx.core.enums.NationsTypeEnum;
import com.zrqx.core.enums.ResponseCodeEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.sysuser.bg.national.NationalForm;
import com.zrqx.core.form.sysuser.bg.national.UpdateStatusForm;
import com.zrqx.core.model.sysuser.national.National;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.sysuser.bg.service.national.NationalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import tk.mybatis.mapper.entity.Example;
/**
* 民族主页
* @author zzg
* @date 2018年12月18日下午5:48:09
*/
@RestController
@RequestMapping(SysUserRequestPath.BG + SysUserRequestPath.NATIONL_HOME_PAGE)
@Api(description = "网站管理-民族主页")
public class NationalController {
@Autowired
private NationalService nationalService;
@ApiOperation(value = "查询列表" , notes ="查询列表")
@GetMapping(value = SysUserRequestPath.PAGE)
public CallBack<PageInfo<National>> page(PageParam pageParam){
if (null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())) {
pageParam.setOrderBy("sequence asc");
}
return CallBack.success(nationalService.queryAll(pageParam));
}
@ApiOperation(value = "删除", notes = "删除0:成功;1:无该民族;2:操作失败")
@PostMapping(value = SysUserRequestPath.DELETE_OID)
public CallBack<Boolean> deleteById(@PathVariable Integer oid) {
return CallBack.success(nationalService.deleteById(oid));
}
@ApiOperation(value = "验重" , notes ="判断关联民族是否已绑定")
@GetMapping(value = SysUserRequestPath.ISEXIST)
public CallBack<Boolean> isExist(@RequestParam Integer nationsType){
National national = new National();
national.setNationsType(nationsType);
if(nationalService.select(national).size() > 0){
throw new BusinessValidateException(2, "该关联民族已绑定");
}
return CallBack.success(false);
}
@ApiOperation(value = "新增", notes = "新增一个")
@PostMapping(value = SysUserRequestPath.SAVE)
public CallBack<Boolean> saveAdsign(@RequestBody NationalForm form) {
return CallBack.success(nationalService.save(form));
}
@ApiOperation(value = "修改主页", notes = "修改主页")
@PostMapping(value = SysUserRequestPath.UPDATE)
public CallBack<Boolean> update(@RequestBody National national) {
if(national.getId() == null){
throw new ParameterValidateException();
}
National nationalOld = nationalService.selectByPrimaryKey(national.getId());
national.setCreateTime(nationalOld.getCreateTime());
national.setUpdateTime(new Date());
if(!nationalService.updateByPrimaryKeySelective(national)){
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量上下线", notes = "批量上下线")
@PostMapping(value = SysUserRequestPath.BATCH_UPDATE_STATUS)
public CallBack<Boolean> updateStatusById(
@RequestBody UpdateStatusForm form) {
if (form.getIds().length == 0) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "没有选中任何数据,请重新选择");
}
Example example = nationalService.createExample();
example.createCriteria().andIn("id", Arrays.asList(form.getIds()));
National national = new National();
national.setStatus(form.getStatus());
return CallBack.success(nationalService.UpdateByExampleSelective(national,example));
}
@ApiOperation(value = "根据ID查询民族主页", notes = "根据ID查询")
@GetMapping(value = SysUserRequestPath.OID)
public CallBack<National> getById(@PathVariable Integer oid) {
return CallBack.success(nationalService.selectByPrimaryKey(oid));
}
@ApiOperation(value = "民族类型列表" , notes ="1蒙古族 2侗族 3藏族 4朝鲜族 5土家族 6回族 7满族 8汉族")
@GetMapping(value = SysUserRequestPath.TYPE + SysUserRequestPath.LIST)
public CallBack<Map<String,String>> queryNationsTypeList(){
Map<String, String> map = NationsTypeEnum.getAllEnumMap();
sortList(map);
return CallBack.success(map);
}
public Map<String, String> sortList(Map<String, String> map){
List<Map.Entry<String,String>> list = new ArrayList<Map.Entry<String,String>>(map.entrySet());
Collections.sort(list,new Comparator<Map.Entry<String,String>>() {
//升序排序
public int compare(Entry<String, String> o1,
Entry<String, String> o2) {
return Integer.parseInt(o2.getKey()) - (Integer.parseInt(o1.getKey()));
}
});
return map;
}
}
package com.zrqx.sysuser.bg.service.national;
import com.zrqx.core.form.sysuser.bg.national.NationalForm;
import com.zrqx.core.model.sysuser.national.National;
import com.zrqx.core.service.BaseService;
/**
* 民族主页
* @author zzg
* @date 2018年12月18日下午5:47:46
*/
public interface NationalService extends BaseService<National,Integer>{
boolean save(NationalForm form);
boolean deleteById(Integer oid);
}
package com.zrqx.sysuser.bg.service.national;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.enums.sysuser.recommend.RecommendTypeEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.bg.recommend.DeleteRecommendForm;
import com.zrqx.core.form.resource.bg.recommend.SaveRecommendForm;
import com.zrqx.core.form.sysuser.bg.national.NationalForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.sysuser.national.National;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.sysuser.bg.client.recommend.RecommendClient;
import com.zrqx.sysuser.bg.mapper.national.NationalMapper;
/**
* 民族主页
* @author zzg
* @date 2018年12月18日下午5:47:21
*/
@Service
public class NationalServiceImpl extends BaseServiceImpl<National, Integer> implements NationalService{
private static final Logger logger = LoggerFactory.getLogger(NationalServiceImpl.class);
@Autowired
private NationalMapper nationalMapper;
@Autowired
private RecommendClient recommendClient;
@Override
public BaseMapper<National> getMapper() {
return nationalMapper;
}
@Override
public boolean save(NationalForm form) {
if(form.getId() != null){
throw new ParameterValidateException();
}
//关联民族;
National national = new National();
national.setNationsType(form.getNationsType());
if(nationalMapper.select(national).size() > 0){
throw new BusinessValidateException(2,"该关联民族已绑定");
}
//新增推荐位
SaveRecommendForm recommend = new SaveRecommendForm();
if(form.getNationsType().intValue() > 9){
recommend.setCode("NATION_"+form.getNationsType());
}else{
recommend.setCode("NATION_0"+form.getNationsType());
}
recommend.setName("民族主页-"+ form.getNationalName());
recommend.setNationsType(form.getNationsType());
recommend.setRecommendType(RecommendTypeEnum.NATIONPAGH_RECOMMEND.getCode());
recommend.setSort(form.getSequence());
recommend.setStatus(form.getStatus());
CallBack<Boolean> result = recommendClient.save(recommend);
if (result == null || !result.isStatus()) {
logger.info("推荐位服务调用失败");
throw new BusinessValidateException("操作失败");
}
//新增民族主页
BeanUtils.copyProperties(form, national);
national.setCreateTime(new Date());
return nationalMapper.insert(national) > 0;
}
@Override
public boolean deleteById(Integer oid){
National national = nationalMapper.selectByPrimaryKey(oid);
if(national == null){
throw new BusinessValidateException(1,"无该民族");
}
DeleteRecommendForm form = new DeleteRecommendForm();
form.setNationsType(national.getNationsType());
CallBack<Boolean> result = recommendClient.delete(form);
if (result == null || !result.isStatus()) {
logger.info("推荐位服务调用失败");
throw new BusinessValidateException(2,"操作失败");
}
return nationalMapper.deleteByPrimaryKey(oid) > 0;
}
}
package com.zrqx.sysuser.fg.client.annex;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibrary;
import com.zrqx.core.util.response.CallBack;
/**
* 附件远程调用
* @author ycw
* @date 2018年12月19日上午11:33:44
*/
@FeignClient(value="resource",fallback=AnnexClientHystric.class)
public interface AnnexClient {
/**
* 查询附件
* @param ids
* @return
* @author ycw
* @date: 2019年1月28日 下午5:49:11
*/
@GetMapping(value = ResourceRequestPath.FG + ResourceRequestPath.ANNEX_LIBRARY + ResourceRequestPath.IDLIST)
CallBack<List<AnnexLibrary>> getListByIds(@RequestParam(value = "ids") List<String> ids);
/**
* 查询附件
* @param oid
* @return
* @author ycw
* @date: 2019年1月28日 下午5:49:11
*/
@GetMapping(value = ResourceRequestPath.FG + ResourceRequestPath.ANNEX_LIBRARY + ResourceRequestPath.OID)
CallBack<AnnexLibrary> getOneById(@PathVariable(value = "oid") String oid);
}
package com.zrqx.sysuser.fg.client.annex;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibrary;
import com.zrqx.core.util.response.CallBack;
@Component
public class AnnexClientHystric implements AnnexClient {
private static final Logger logger = LoggerFactory.getLogger(AnnexClientHystric.class);
@Override
public CallBack<List<AnnexLibrary>> getListByIds(List<String> ids){
logger.info("通过id集合调用附件服务失败");
return CallBack.fail();
}
@Override
public CallBack<AnnexLibrary> getOneById(String oid){
logger.info("通过id:"+ oid+ "调用附件服务失败");
return CallBack.fail();
}
}
package com.zrqx.sysuser.fg.client.audio;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.model.resource.audiolibrary.AudioLibrary;
import com.zrqx.core.util.response.CallBack;
/**
* 音频远程调用
* @author ycw
* @date 2018年12月19日上午11:33:44
*/
@FeignClient(value="resource",fallback=AudioClientHystric.class)
public interface AudioClient {
/**
* 查询音频
* @param ids
* @return
* @author ycw
* @date: 2019年1月28日 下午5:49:11
*/
@GetMapping(value = ResourceRequestPath.FG + ResourceRequestPath.AUDIO_LIBRARY + ResourceRequestPath.IDLIST)
CallBack<List<AudioLibrary>> getListByIds(@RequestParam(value = "ids") List<String> ids);
/**
* 查询音频
* @param oid
* @return
* @author ycw
* @date: 2019年1月28日 下午5:49:11
*/
@GetMapping(value = ResourceRequestPath.FG + ResourceRequestPath.AUDIO_LIBRARY + ResourceRequestPath.OID)
CallBack<AudioLibrary> getOneById(@PathVariable(value = "oid") String oid);
}
package com.zrqx.sysuser.fg.client.audio;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.zrqx.core.model.resource.audiolibrary.AudioLibrary;
import com.zrqx.core.util.response.CallBack;
@Component
public class AudioClientHystric implements AudioClient {
private static final Logger logger = LoggerFactory.getLogger(AudioClientHystric.class);
@Override
public CallBack<List<AudioLibrary>> getListByIds(List<String> ids){
logger.info("通过id集合调用音频服务失败");
return CallBack.fail();
}
@Override
public CallBack<AudioLibrary> getOneById(String oid){
logger.info("通过id:"+ oid+ "调用音频服务失败");
return CallBack.fail();
}
}
package com.zrqx.sysuser.fg.client.third;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.zrqx.core.constant.third.ThirdRequestPath;
import com.zrqx.core.form.third.sdksms.SdkSmsForm;
import com.zrqx.core.util.response.CallBack;
/**
* 手机短信
*/
@FeignClient(value="third",fallback=SdkSmsHystric.class)
public interface SdkSmsClient {
/**
* 发送手机短信
* @param smsForm
* @return
*/
@GetMapping(ThirdRequestPath.SDKSMS+ThirdRequestPath.SEND)
public CallBack<String> send(@RequestBody SdkSmsForm ssf);
}
package com.zrqx.sysuser.fg.client.third;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import com.zrqx.core.form.third.sdksms.SdkSmsForm;
import com.zrqx.core.util.response.CallBack;
@Component
public class SdkSmsHystric implements SdkSmsClient {
private final Logger logger = LoggerFactory.getLogger(SdkSmsHystric.class);
/**
* 根据id获取图书信息
* @param oid
* @return
* @author lw
* @date: 2018年7月31日 下午5:13:04
*/
@Override
public CallBack<String> send(@RequestBody SdkSmsForm ssf){
logger.info(" 发送: "+ ssf.getMobile() + ssf.getContent()+ ",短信接口不可用");
return null;
}
}
package com.zrqx.sysuser.fg.client.video;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.model.resource.videolibrary.VideoLibrary;
import com.zrqx.core.util.response.CallBack;
/**
* 视频远程调用
* @author ycw
* @date 2018年12月19日上午11:33:44
*/
@FeignClient(value="resource",fallback=VideoClientHystric.class)
public interface VideoClient {
/**
* 查询视频
* @param ids
* @return
* @author ycw
* @date: 2019年1月28日 下午5:49:11
*/
@GetMapping(value = ResourceRequestPath.FG + ResourceRequestPath.VIDEO_LIBRARY + ResourceRequestPath.IDLIST)
CallBack<List<VideoLibrary>> getListByIds(@RequestParam(value = "ids") List<String> ids);
/**
* 查询视频
* @param oid
* @return
* @author ycw
* @date: 2019年1月28日 下午5:49:11
*/
@GetMapping(value = ResourceRequestPath.FG + ResourceRequestPath.VIDEO_LIBRARY + ResourceRequestPath.OID)
CallBack<VideoLibrary> getOneById(@PathVariable(value = "oid") String oid);
}
package com.zrqx.sysuser.fg.client.video;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.zrqx.core.model.resource.videolibrary.VideoLibrary;
import com.zrqx.core.util.response.CallBack;
@Component
public class VideoClientHystric implements VideoClient {
private static final Logger logger = LoggerFactory.getLogger(VideoClientHystric.class);
@Override
public CallBack<List<VideoLibrary>> getListByIds(List<String> ids){
logger.info("通过id集合调用视频服务失败");
return CallBack.fail();
}
@Override
public CallBack<VideoLibrary> getOneById(String oid){
logger.info("通过id:"+ oid+ "调用视频服务失败");
return CallBack.fail();
}
}
package com.zrqx.sysuser.fg.controller.comment;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;
import com.zrqx.core.constant.sysuser.SysUserRequestPath;
import com.zrqx.core.enums.ResponseCodeEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.order.fg.FgSaveOrderInfoCommentForm;
import com.zrqx.core.form.sysuser.fg.comment.FgQueryCommentForm;
import com.zrqx.core.form.sysuser.fg.comment.FgSaveCommentForm;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentDetailsVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentListVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentNumAndScoreVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgMyCommentListVo;
import com.zrqx.sysuser.fg.service.comment.FgCommentAgreeService;
import com.zrqx.sysuser.fg.service.comment.FgCommentService;
@RestController
@RequestMapping(SysUserRequestPath.FG + SysUserRequestPath.COMMENT)
@Api(description = "前台-资源评论")
public class FgCommentController {
@Autowired
private FgCommentService service;
@Autowired
private FgCommentAgreeService commentAgreeService;
@ApiOperation(value = "查询资源评论数量和评分", notes = "查询资源评论数量和评分")
@PostMapping(value = SysUserRequestPath.COUNT)
public CallBack<FgCommentNumAndScoreVo> getCommentNumAndScore(@RequestBody FgQueryCommentForm form) {
return CallBack.success(service.getCommentNumAndScore(form));
}
@ApiOperation(value = "分页查询资源评论", notes = "按条件分页查询资源评论")
@GetMapping(value = SysUserRequestPath.PAGE)
public CallBack<PageInfo<FgCommentListVo>> getPageList(FgQueryCommentForm form, PageParam pageParam) {
PageInfo<FgCommentListVo> list = service.page(form, pageParam);
return CallBack.success(list);
}
@ApiOperation(value = "评论或回复", notes = "0:登录成功;1:登录成功;2:回复时,父级评论用户名不能为空;3:回复时,父级评论id不能为0;4:评论时,父级评论用户名必须为空;5:评论时,父级评论id必须为0;6:必填参数不能为空")
@PostMapping(value = SysUserRequestPath.SAVE)
public CallBack<Boolean> saveComment(@RequestBody FgSaveCommentForm form) {
return service.save(form) ? CallBack.success() : CallBack.fail();
}
@ApiOperation(value = "查看评论详情及回复", notes = "查看评论详情及回复")
@GetMapping(value = SysUserRequestPath.GET_OID)
public CallBack<FgCommentDetailsVo> getById(@PathVariable Integer oid) {
return CallBack.success(service.getById(oid));
}
@ApiOperation(value = "我的评论", notes = "")
@GetMapping(value = SysUserRequestPath.PERSONAL)
public CallBack<PageInfo<FgMyCommentListVo>> getMyCommentList(@ApiParam(value = "电子书:2-1;文章:2-2",required = true)@RequestParam String goodsType, PageParam pageParam) {
List<FgMyCommentListVo> list = service.getMyCommentList(goodsType, pageParam);
return CallBack.success(new PageInfo<FgMyCommentListVo>(list));
}
@ApiOperation(value = "订单评论", notes = "")
@PostMapping(SysUserRequestPath.BATCH_SAVE)
public CallBack<?> saveComments(@ApiParam(value = "电子书:2-1;文章:2-2")@RequestBody List<FgSaveOrderInfoCommentForm> form){
return service.saveComments(form) ? CallBack.success() : CallBack.fail();
}
@ApiOperation(value = "评论点赞", notes = "")
@PostMapping(SysUserRequestPath.AGREE)
public CallBack<?> agreeComments(@ApiParam("评论id")@RequestParam(required = true) Integer commentId){
return commentAgreeService.agreeComments(commentId) ? CallBack.success() : CallBack.fail();
}
@ApiOperation(value = "批量删除", notes = "批量删除")
@PostMapping(value = SysUserRequestPath.BATCH + SysUserRequestPath.DELETE)
public CallBack<Boolean> deleteByIds(@RequestBody Integer[] ids) {
if (ids.length == 0) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "没有选中任何数据,请重新选择");
}
Example example = service.createExample();
example.createCriteria().andIn("id", Arrays.asList(ids));
if (!service.deleteByExample(example)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success(true);
}
@ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = SysUserRequestPath.DELETE_OID)
public CallBack<Boolean> deleteById(@PathVariable Integer oid) {
if (!service.deleteByPrimaryKey(oid)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success(true);
}
}
package com.zrqx.sysuser.fg.controller.procontribution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.constant.sysuser.SysUserRequestPath;
import com.zrqx.core.form.resource.fg.procontribution.FgProContributionForm;
import com.zrqx.core.model.sysuser.manuscript.Manuscript;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.sysuser.fg.service.procontribution.FgProContributionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RestController
@RequestMapping(SysUserRequestPath.FG+SysUserRequestPath.PRO_CONTRIBUTION)
@Api(description = "前台-专家贡献")
public class FgProContributionController {
@Autowired
private FgProContributionService service;
@ApiOperation("新增贡献")
@PostMapping(SysUserRequestPath.SAVE)
public CallBack<Integer> saveProContribution(@RequestBody Manuscript pc){
return CallBack.success(service.saveProContribution(pc));
}
@ApiOperation("更新贡献")
@PostMapping(SysUserRequestPath.UPDATE)
public CallBack<Integer> updateProContribution(@RequestBody Manuscript pc){
return CallBack.success(service.updateProContribution(pc));
}
@ApiOperation("获取贡献详情")
@GetMapping(SysUserRequestPath.OID)
public CallBack<Manuscript> getById(@ApiParam(value = "贡献ID", required = true) @PathVariable Integer oid){
return CallBack.success(service.selectByPrimaryKey(oid));
}
@ApiOperation("专家页-专家贡献")
@GetMapping(SysUserRequestPath.INFO_PAGE)
public CallBack<PageInfo<Manuscript>> getInfoPage(PageParam pageParam,String creater){
return CallBack.success(service.getInfoPage(pageParam,creater));
}
@ApiOperation("个人页-贡献列表")
@GetMapping(SysUserRequestPath.PAGE)
public CallBack<PageInfo<Manuscript>> getPage(PageParam pageParam){
return CallBack.success(service.getPage(pageParam));
}
@ApiOperation("批量删除")
@PostMapping(SysUserRequestPath.BATCH+SysUserRequestPath.DELETE)
public CallBack<Integer> delete(@RequestBody FgProContributionForm form){
return CallBack.success(service.delete(form));
}
}
package com.zrqx.sysuser.fg.service.comment;
import java.util.List;
import com.zrqx.core.form.order.fg.FgSaveOrderInfoCommentForm;
import com.zrqx.core.form.sysuser.fg.comment.FgQueryCommentForm;
import com.zrqx.core.form.sysuser.fg.comment.FgSaveCommentForm;
import com.zrqx.core.model.sysuser.comment.Comment;
import com.zrqx.core.service.BaseService;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentDetailsVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentListVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentNumAndScoreVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgMyCommentListVo;
public interface FgCommentService extends BaseService<Comment, Integer> {
/**
* 查询资源评论数量和评分
* @param form
* @return
* @author ycw
* @date: 2019年1月23日 上午10:19:07
*/
FgCommentNumAndScoreVo getCommentNumAndScore(FgQueryCommentForm form);
/**
* 文章阅读页的评论列表
* @param form
* @param pageParam
* @return
* @author ycw
* @date: 2019年1月22日 上午11:02:57
*/
PageInfo<FgCommentListVo> page(FgQueryCommentForm form, PageParam pageParam);
/**
* 添加评论、回复评论
* @param form
* @return
* @author ycw
* @date: 2019年1月22日 下午4:45:53
*/
boolean save(FgSaveCommentForm form);
/**
* 查看评论的详情(回复列表)
* @param oid
* @return
* @author ycw
* @date: 2019年1月22日 下午6:45:48
*/
FgCommentDetailsVo getById(Integer oid);
/**
* 个人中心-我的评论
* @param goodsType
* @param pageParam
* @return
* @author ycw
* @date: 2019年1月23日 上午10:39:41
*/
List<FgMyCommentListVo> getMyCommentList(String goodsType, PageParam pageParam);
/**
* 订单评论
* @param form
* @return
* @author ycw
* @date: 2019年1月28日 下午5:37:16
*/
boolean saveComments(List<FgSaveOrderInfoCommentForm> form);
}
package com.zrqx.sysuser.fg.service.comment;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.zrqx.core.enums.AllResourceTypeEnum;
import com.zrqx.core.enums.BooleanStatusEnum;
import com.zrqx.core.enums.sysuser.comment.CommentEnum;
import com.zrqx.core.enums.sysuser.comment.UserTypeEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.LoginValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.member.fg.permissions.LoginMemberInfo;
import com.zrqx.core.form.order.fg.FgSaveOrderInfoCommentForm;
import com.zrqx.core.form.sysuser.fg.comment.FgQueryCommentForm;
import com.zrqx.core.form.sysuser.fg.comment.FgSaveCommentForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibrary;
import com.zrqx.core.model.resource.articlelibrary.ArticleLibrary;
import com.zrqx.core.model.resource.audiolibrary.AudioLibrary;
import com.zrqx.core.model.resource.imagelibrary.ImageLibrary;
import com.zrqx.core.model.resource.videolibrary.VideoLibrary;
import com.zrqx.core.model.sysuser.comment.Comment;
import com.zrqx.core.model.sysuser.comment.CommentAgree;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.bean.BeanUtils;
import com.zrqx.core.util.datatype.ArrayUtils;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.vo.resource.fg.ebook.FgEbookVO;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentDetailsVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentListVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgCommentNumAndScoreVo;
import com.zrqx.core.vo.sysuser.fg.comment.FgMyCommentListVo;
import com.zrqx.sysuser.commons.redis.Redis;
import com.zrqx.sysuser.fg.client.annex.AnnexClient;
import com.zrqx.sysuser.fg.client.article.ArticleClient;
import com.zrqx.sysuser.fg.client.audio.AudioClient;
import com.zrqx.sysuser.fg.client.ebook.EbookClient;
import com.zrqx.sysuser.fg.client.image.ImageClient;
import com.zrqx.sysuser.fg.client.video.VideoClient;
import com.zrqx.sysuser.fg.mapper.comment.FgCommentAgreeMapper;
import com.zrqx.sysuser.fg.mapper.comment.FgCommentMapper;
@Service
public class FgCommentServiceImpl extends BaseServiceImpl<Comment, Integer>
implements FgCommentService {
private static final Logger logger = LoggerFactory.getLogger(FgCommentServiceImpl.class);
@Autowired
private FgCommentMapper mapper;
@Autowired
private FgCommentAgreeMapper commentAgreeMapper;
@Autowired
private ArticleClient articleClient;
@Autowired
private EbookClient ebookClient;
@Autowired
private ImageClient imageClient;
@Autowired
private VideoClient videoClient;
@Autowired
private AudioClient audioClient;
@Autowired
private AnnexClient annexClient;
@Autowired
private Redis redisManage;
@Override
public BaseMapper<Comment> getMapper() {
return mapper;
}
@Override
public FgCommentNumAndScoreVo getCommentNumAndScore(FgQueryCommentForm form){
Comment co = new Comment();
BeanUtils.copyProperties(form, co);
co.setStatus(CommentEnum.YES_ADOPT.getCode());
co.setMainId(0);
FgCommentNumAndScoreVo vo = new FgCommentNumAndScoreVo();
vo.setCommentNum(mapper.selectCount(co));
if(redisManage.isExistMember()){
Comment comment = new Comment();
BeanUtils.copyProperties(form, comment);
comment.setStatus(CommentEnum.NOT_REVIEW.getCode());
comment.setMainId(0);
comment.setUserId(redisManage.getMember().getId().toString());
int num = mapper.selectCount(comment);
vo.setCommentNum(vo.getCommentNum() + num);
}
vo.setResourceScore(mapper.getAverageScore(form));
return vo;
}
@Override
public PageInfo<FgCommentListVo> page(FgQueryCommentForm form, PageParam pageParam){
if(redisManage.isExistMember()){
form.setUserId(redisManage.getMember().getId().toString());
}
startPage(pageParam);
List<FgCommentListVo> list = mapper.pageConmment(form);
list.forEach(l -> {
// 设置回复数量
String userId= null;
// 设置是否是本人
l.setIsOwn(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
if(redisManage.isExistMember()){
userId = redisManage.getMember().getId().toString();
// 设置是否是本人
if(userId.equals(l.getUserId())){
l.setIsOwn(Integer.parseInt(BooleanStatusEnum.YES.getCode()));
}
}
l.setReplyNum(mapper.selectReplyNum(l.getId(), userId));
// 设置是否已点赞
l.setIsAgree(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
});
if(redisManage.isExistMember()){
//对每条评论,判断是否已点赞
list.forEach(l -> {
CommentAgree ca = new CommentAgree();
ca.setCommentId(l.getId());
ca.setUserId(redisManage.getMember().getId().toString());
if(!commentAgreeMapper.select(ca).isEmpty()){
l.setIsAgree(Integer.parseInt(BooleanStatusEnum.YES.getCode()));
}
});
}
PageInfo<FgCommentListVo> page = new PageInfo<FgCommentListVo>(list);
return page;
}
@Override
public boolean save(FgSaveCommentForm form){
if(!redisManage.isExistMember()){
throw new LoginValidateException(1, "登录过期或未登录");
}
if(form.getScore() == null || StringUtils.isBlank(form.getContent()) || StringUtils.isBlank(form.getResourceId())
|| StringUtils.isBlank(form.getResourceName()) || form.getResourceType() == null
|| form.getFatherId() == null || form.getMainId() == null){
throw new ParameterValidateException(6, "必填参数不能为空");
}
if(form.getMainId() != 0){
if(StringUtils.isBlank(form.getFatherName())){
throw new ParameterValidateException(2, "回复时,父级评论用户名不能为空");
}
if(form.getFatherId() == 0){
throw new ParameterValidateException(3, "回复时,父级评论id不能为0");
}
}else{
if(StringUtils.isNotBlank(form.getFatherName())){
throw new ParameterValidateException(4, "评论时,父级评论用户名必须为空");
}
if(form.getFatherId() != 0){
throw new ParameterValidateException(5, "评论时,父级评论id和所属主评论id必须为0");
}
}
Comment comment = new Comment();
BeanUtils.copyProperties(form, comment);
LoginMemberInfo member = redisManage.getMember();
comment.setUserId(member.getId().toString());
comment.setUserName(member.getAccount());
comment.setUserImg(member.getImg());
comment.setName(member.getName());
comment.setReleaseTime(new Date());
comment.setStatus(CommentEnum.NOT_REVIEW.getCode());
comment.setEssence(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
comment.setFabulousNum(0);
comment.setUserClass(UserTypeEnum.STATUS_0.getCode());
return mapper.insert(comment) > 0;
}
@Override
public FgCommentDetailsVo getById(Integer oid){
FgCommentDetailsVo vo = new FgCommentDetailsVo();
Comment c = mapper.selectByPrimaryKey(oid);
BeanUtils.copyProperties(c, vo);
// 设置回复数量
String userId= null;
if(redisManage.isExistMember()){
userId = redisManage.getMember().getId().toString();
}
vo.setReplyNum(mapper.selectReplyNum(oid, userId));
// 设置是否已点赞
vo.setIsAgree(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
// 设置是否是本人
vo.setIsOwn(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
if(redisManage.isExistMember()){
//判断是否已点赞
CommentAgree ca = new CommentAgree();
ca.setCommentId(oid);
ca.setUserId(redisManage.getMember().getId().toString());
if(!commentAgreeMapper.select(ca).isEmpty()){
vo.setIsAgree(Integer.parseInt(BooleanStatusEnum.YES.getCode()));
}
// 设置是否是本人
if(userId.equals(vo.getUserId())){
vo.setIsOwn(Integer.parseInt(BooleanStatusEnum.YES.getCode()));
}
}
// 设置回复集合
PageHelper.orderBy("releaseTime desc");
List<FgCommentDetailsVo> vos = mapper.pageReply(oid, userId);
// 设置是否是本人
if(ArrayUtils.isNotEmpty(vos)){
String u = userId;
vos.forEach(li -> {
if(StringUtils.isNotBlank(u) && u.equals(li.getUserId())){
li.setIsOwn(Integer.parseInt(BooleanStatusEnum.YES.getCode()));
}else{
li.setIsOwn(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
}
});
}
vo.setReplyVoList(vos);
return vo;
}
@Override
public List<FgMyCommentListVo> getMyCommentList(String goodsType, PageParam pageParam){
if (null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())) {
pageParam.setOrderBy("essence desc, releaseTime desc");
}
startPage(pageParam);
List<Integer> resourceTypeList = new ArrayList<Integer>();
//文章
if(AllResourceTypeEnum.ARTICLE.getCode().toString().equals(goodsType)){
resourceTypeList.add(AllResourceTypeEnum.ARTICLE.getCode());
}
//电子书
if(AllResourceTypeEnum.BOOK.getCode().toString().equals(goodsType)){
resourceTypeList.add(AllResourceTypeEnum.BOOK.getCode());
}
//图片
if(AllResourceTypeEnum.IMAGE.getCode().toString().equals(goodsType)){
resourceTypeList.add(AllResourceTypeEnum.IMAGE.getCode());
}
//视频
if(AllResourceTypeEnum.VIDEO.getCode().toString().equals(goodsType)){
resourceTypeList.add(AllResourceTypeEnum.VIDEO.getCode());
}
//音频
if(AllResourceTypeEnum.AUDIO.getCode().toString().equals(goodsType)){
resourceTypeList.add(AllResourceTypeEnum.AUDIO.getCode());
}
//附件
if(AllResourceTypeEnum.ANNEX.getCode().toString().equals(goodsType)){
resourceTypeList.add(AllResourceTypeEnum.ANNEX.getCode());
}
//医家
if(AllResourceTypeEnum.AUTHOR.getCode().toString().equals(goodsType)){
resourceTypeList.add(AllResourceTypeEnum.AUTHOR.getCode());
}
String userId = redisManage.getMember().getId().toString();
List<FgMyCommentListVo> vos = mapper.getMyCommentList(userId, resourceTypeList);
/*Map<Integer, List<String>> map = vos.stream().collect(Collectors.groupingBy(FgMyCommentListVo :: getResourceClass,
Collectors.mapping(FgMyCommentListVo :: getResourceId, Collectors.toList())));*/
//获取封面-跨服务
if(vos != null && vos.size() > 0){
List<String> ids = vos.stream().map(li -> {
return li.getResourceId();
}).collect(Collectors.toList());
//文章
if(AllResourceTypeEnum.ARTICLE.getCode().toString().equals(goodsType)){
//文章获取封面信息
CallBack<List<ArticleLibrary>> result = articleClient.getListByIds(ids);
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("通过ids集合查找文章失败");
}else{
vos.forEach(vo -> {
for(ArticleLibrary article : result.getData()){
if(vo.getResourceId().equals(article.getId())){
vo.setImg(article.getImg());
break;
}
}
});
}
return vos;
}
//电子书
if(AllResourceTypeEnum.BOOK.getCode().toString().equals(goodsType)){
//医著获取封面信息
CallBack<List<FgEbookVO>> result = ebookClient.getListByIds(ids);
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("通过ids查找电子书失败");
}else{
vos.forEach(vo -> {
for(FgEbookVO ebook : result.getData()){
if(vo.getResourceId().equals(ebook.getId())){
vo.setImg(ebook.getBookCover());
break;
}
}
});
}
return vos;
}
//图片
if(AllResourceTypeEnum.IMAGE.getCode().toString().equals(goodsType)){
//图片获取封面信息
CallBack<List<ImageLibrary>> result = imageClient.getListByIds(ids);
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("通过ids查找电子书失败");
}else{
vos.forEach(vo -> {
for(ImageLibrary ebook : result.getData()){
if(vo.getResourceId().equals(ebook.getId())){
vo.setImg(ebook.getImage());
break;
}
}
});
}
return vos;
}
//视频
if(AllResourceTypeEnum.VIDEO.getCode().toString().equals(goodsType)){
//视频获取封面信息
CallBack<List<VideoLibrary>> result = videoClient.getListByIds(ids);
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("通过ids查找电子书失败");
}else{
vos.forEach(vo -> {
for(VideoLibrary ebook : result.getData()){
if(vo.getResourceId().equals(ebook.getId())){
vo.setImg(ebook.getCover());
break;
}
}
});
}
return vos;
}
//音频
if(AllResourceTypeEnum.AUDIO.getCode().toString().equals(goodsType)){
//音频获取封面信息
CallBack<List<AudioLibrary>> result = audioClient.getListByIds(ids);
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("通过ids查找电子书失败");
}else{
vos.forEach(vo -> {
for(AudioLibrary ebook : result.getData()){
if(vo.getResourceId().equals(ebook.getId())){
vo.setImg(ebook.getCover());
break;
}
}
});
}
return vos;
}
//附件
if(AllResourceTypeEnum.ANNEX.getCode().toString().equals(goodsType)){
//附件获取封面信息
CallBack<List<AnnexLibrary>> result = annexClient.getListByIds(ids);
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("通过ids查找电子书失败");
}else{
vos.forEach(vo -> {
for(AnnexLibrary ebook : result.getData()){
if(vo.getResourceId().equals(ebook.getId())){
vo.setImg(ebook.getCover());
break;
}
}
});
}
return vos;
}
}
return null;
}
@Override
public boolean saveComments(List<FgSaveOrderInfoCommentForm> form){
if(!redisManage.isExistMember()){
throw new LoginValidateException(1, "登录过期或未登录");
}
List<Comment> list = new ArrayList<Comment>();
form.forEach(f ->{
Comment comment = new Comment();
comment.setFatherId(0);
comment.setMainId(0);
comment.setScore(f.getScore());
comment.setContent(f.getContent());
comment.setResourceId(f.getGoodsForm().getId());
if(AllResourceTypeEnum.ARTICLE.getCode().toString().equals(f.getGoodsForm().getType())){
CallBack<ArticleLibrary> result = articleClient.getOneById(f.getGoodsForm().getId());
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("文章服务调用失败");
throw new BusinessValidateException("操作失败");
}
comment.setResourceType(result.getData().getResourceType());
comment.setResourceName(result.getData().getName());
}
if(AllResourceTypeEnum.BOOK.getCode().toString().equals(f.getGoodsForm().getType())){
CallBack<FgEbookVO> result = ebookClient.getOneById(f.getGoodsForm().getId());
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("电子书服务调用失败");
throw new BusinessValidateException("操作失败");
}
comment.setResourceType(AllResourceTypeEnum.BOOK.getCode());
comment.setResourceName(result.getData().getName());
}
if(AllResourceTypeEnum.IMAGE.getCode().toString().equals(f.getGoodsForm().getType())){
CallBack<ImageLibrary> result = imageClient.getOneById(f.getGoodsForm().getId());
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("图片服务调用失败");
throw new BusinessValidateException("操作失败");
}
comment.setResourceType(AllResourceTypeEnum.IMAGE.getCode());
comment.setResourceName(result.getData().getName());
}
if(AllResourceTypeEnum.VIDEO.getCode().toString().equals(f.getGoodsForm().getType())){
CallBack<VideoLibrary> result = videoClient.getOneById(f.getGoodsForm().getId());
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("视频服务调用失败");
throw new BusinessValidateException("操作失败");
}
comment.setResourceType(AllResourceTypeEnum.VIDEO.getCode());
comment.setResourceName(result.getData().getName());
}
if(AllResourceTypeEnum.AUDIO.getCode().toString().equals(f.getGoodsForm().getType())){
CallBack<AudioLibrary> result = audioClient.getOneById(f.getGoodsForm().getId());
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("音频服务调用失败");
throw new BusinessValidateException("操作失败");
}
comment.setResourceType(AllResourceTypeEnum.AUDIO.getCode());
comment.setResourceName(result.getData().getName());
}
if(AllResourceTypeEnum.ANNEX.getCode().toString().equals(f.getGoodsForm().getType())){
CallBack<AnnexLibrary> result = annexClient.getOneById(f.getGoodsForm().getId());
if (result == null || !result.isStatus() || result.getData() == null) {
logger.info("附件服务调用失败");
throw new BusinessValidateException("操作失败");
}
comment.setResourceType(AllResourceTypeEnum.ANNEX.getCode());
comment.setResourceName(result.getData().getName());
}
LoginMemberInfo member = redisManage.getMember();
comment.setUserId(member.getId().toString());
comment.setUserName(member.getAccount());
comment.setUserImg(member.getImg());
comment.setName(member.getName());
comment.setReleaseTime(new Date());
comment.setStatus(CommentEnum.NOT_REVIEW.getCode());
comment.setEssence(Integer.parseInt(BooleanStatusEnum.NO.getCode()));
comment.setFabulousNum(0);
comment.setUserClass(UserTypeEnum.STATUS_0.getCode());
list.add(comment);
});
return mapper.insertList(list) > 0;
}
}
package com.zrqx.sysuser.fg.service.procontribution;
import com.zrqx.core.form.resource.fg.procontribution.FgProContributionForm;
import com.zrqx.core.model.resource.pro.ProContribution;
import com.zrqx.core.model.sysuser.manuscript.Manuscript;
import com.zrqx.core.service.BaseService;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.resource.fg.procontribution.ProContributionVo;
public interface FgProContributionService extends BaseService<Manuscript, Integer> {
/**
* 保存专家贡献
* @param pc
* @return
*/
Integer saveProContribution(Manuscript pc);
/**
* 更新专家贡献
* @param pc
* @return
*/
Integer updateProContribution(Manuscript pc);
/**
* 专家页-获取贡献列表
* @param pageParam
* @param creater 专家id
* @return
*/
PageInfo<Manuscript> getInfoPage(PageParam pageParam, String creater);
/**
* 个人页-贡献列表
* @param pageParam
* @return
*/
PageInfo<Manuscript> getPage(PageParam pageParam);
/**
* 批量删除
* @param form
* @return
*/
Integer delete(FgProContributionForm form);
}
package com.zrqx.sysuser.fg.service.procontribution;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zrqx.core.enums.AuditStatusEnum;
import com.zrqx.core.form.resource.fg.procontribution.FgProContributionForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.sysuser.manuscript.Manuscript;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.sysuser.commons.redis.Redis;
@Service
public class FgProContributionServiceImpl extends BaseServiceImpl<Manuscript, Integer> implements FgProContributionService {
@Autowired
private com.zrqx.sysuser.fg.mapper.procontribution.FgProContributionMapper mapper;
@Autowired
private Redis fgRedisManage;
@Override
public BaseMapper<Manuscript> getMapper() {
return mapper;
}
@Override
public Integer saveProContribution(Manuscript pc) {
pc.setUploadTime(new Date());
pc.setStatus(AuditStatusEnum.STATUS_0.getCode());
pc.setUserName(fgRedisManage.getMember().getAccount());
pc.setName(fgRedisManage.getMember().getNickName());
pc.setCreater(fgRedisManage.getMember().getId()+"");
if(insert(pc)){
return 1;
}
return 0;
}
@Override
public Integer updateProContribution(Manuscript pc) {
if(updateByPrimaryKey(pc)){
return 1;
}
return 0;
}
@Override
public PageInfo<Manuscript> getInfoPage(PageParam pageParam,String creater) {
startPage(pageParam);
List<Manuscript> list = mapper.getInfoPage(creater);
return new PageInfo<Manuscript>(list);
}
@Override
public PageInfo<Manuscript> getPage(PageParam pageParam) {
String creater = fgRedisManage.getMember().getId()+"";
startPage(pageParam);
List<Manuscript> list = mapper.getPage(creater);
return new PageInfo<Manuscript>(list);
}
@Override
public Integer delete(FgProContributionForm form) {
int result = 0;
List<Integer> list = form.getDelIds();
for (Integer id : list) {
if(deleteByPrimaryKey(id)){
result++;
}
}
return result;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论