浏览代码

1、新增公共分享信息详情

Administrator 4 年之前
父节点
当前提交
6823101915

+ 13 - 0
src/main/java/com/kede/common/controller/PublicApiController.java

@@ -34,6 +34,7 @@ import com.kede.project.service.ProjectTypeService;
 import com.kede.recruitment.bo.InputRecruitment;
 import com.kede.recruitment.service.RecruitmentService;
 import com.kede.visitingCustomers.service.VisitingCustomersService;
+import com.kede.wechat.service.WeChatShareService;
 import com.kede.wxsdk.service.WxService;
 
 
@@ -61,6 +62,8 @@ public class PublicApiController extends BaseController {
 	private ProjectService	projectService;
 	@Resource
 	private WxService	wxService;
+	@Resource
+	private WeChatShareService 	weChatShareService;
 	
 	/**
 	 * 微信支付,通知--- 成功结果
@@ -201,6 +204,16 @@ public class PublicApiController extends BaseController {
 		return res.data(wxService.pushNativePay(p,"MWEB"));
 	}
 	
+	@RequestMapping(value = "/weChatDetails", method = RequestMethod.GET)
+	public Result weChatDetails(Integer type,Integer pid) {
+		Result res=new Result();
+		if (type==null&&pid==null) {	
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"编号","编号"));
+			return res;
+		}
+		return res.data(weChatShareService.openDetails(type,pid));
+	}
+	
 
 	
 	

+ 1 - 1
src/main/java/com/kede/common/dao/WechatShareMapper.java

@@ -43,5 +43,5 @@ public interface WechatShareMapper {
 	 */
 	int updateByPrimaryKey(WechatShare record);
 
-	WechatShareBo selectByPid(@Param("id") Integer id,@Param("pid") Integer pid);
+	WechatShareBo selectByPid(@Param("id") Integer id,@Param("pid") Integer pid,@Param("type") Integer type);
 }

+ 3 - 0
src/main/java/com/kede/common/mapper/WechatShareMapper.xml

@@ -165,6 +165,9 @@
 		<if test="id !=null">
 		and a.id = #{id,jdbcType=INTEGER}
 		</if>
+		<if test="type !=null">
+		and a.type = #{type,jdbcType=INTEGER}
+		</if>
 	</select>
 
 	<select id="ListWechatShare"

+ 17 - 0
src/main/java/com/kede/wechat/controller/weChatShareApiController.java

@@ -11,6 +11,7 @@ import com.kede.common.bo.Result;
 import com.kede.common.constant.ErrorConstants;
 import com.kede.common.controller.BaseController;
 import com.kede.common.model.WechatShare;
+import com.kede.wechat.bo.WechatShareBo;
 import com.kede.wechat.service.WeChatShareService;
 
 @RestController
@@ -34,6 +35,14 @@ public class weChatShareApiController extends BaseController{
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"分类或者标题","分类或者标题"));
 			return res;
 		}
+		if (in.getType()>0) {
+			WechatShareBo use=(WechatShareBo) weChatShareService.openDetails(in.getType(), in.getPid());
+			if (use!=null) {
+				String str=new StringBuffer().append("分类").append(in.getType()).append("已存在").toString();
+				res.getError().add(buildError(str,str));
+				return res;
+			}
+		}
 		return res.data(weChatShareService.add(in));
 	}
 	
@@ -49,6 +58,14 @@ public class weChatShareApiController extends BaseController{
 			res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"分类或者标题","分类或者标题"));
 			return res;
 		}
+		if (in.getType()>0) {
+			WechatShareBo use=(WechatShareBo) weChatShareService.openDetails(in.getType(), in.getPid());
+			if (use!=null&&use.getId()!=in.getId()) {
+				String str=new StringBuffer().append("分类").append(in.getType()).append("已存在").toString();
+				res.getError().add(buildError(str,str));
+				return res;
+			}
+		}
 		return res.data(weChatShareService.update(in));
 	}
 	

+ 2 - 0
src/main/java/com/kede/wechat/service/WeChatShareService.java

@@ -16,4 +16,6 @@ public interface WeChatShareService {
 
 	Pagination<WechatShareBo> pageList(String name, Integer type, Integer pageSize, Integer pageSize2);
 
+	Object openDetails(Integer type, Integer pid);
+
 }

+ 9 - 1
src/main/java/com/kede/wechat/service/impl/WeChatShareServiceImpl.java

@@ -36,7 +36,7 @@ public class WeChatShareServiceImpl extends BaseMybatisDao<WechatShareMapper> im
 
 	@Override
 	public Object details(Integer id, Integer pid) {
-			return wechatShareMapper.selectByPid(id,pid);
+			return wechatShareMapper.selectByPid(id,pid,null);
 	}
 
 	@SuppressWarnings("unchecked")
@@ -52,4 +52,12 @@ public class WeChatShareServiceImpl extends BaseMybatisDao<WechatShareMapper> im
 		return (Pagination<WechatShareBo>) findPage("ListWechatShare","CountWechatShare",map,pageNo, pageSize);
 	}
 
+	@Override
+	public Object openDetails(Integer type, Integer pid) {
+		if (type>0) {
+			pid=null;
+		}
+		return wechatShareMapper.selectByPid(null,pid,type);
+	}
+
 }