|
|
@@ -0,0 +1,79 @@
|
|
|
+package com.cyksj.service.corp.kf.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.cyksj.config.corp.YHLXWxCorpConfig;
|
|
|
+import com.cyksj.mapper.corp.kf.CorpKfAccountFollowMapper;
|
|
|
+import com.cyksj.mapper.corp.kf.CorpKfAccountMapper;
|
|
|
+import com.cyksj.mapper.corp.kf.CorpKfAccountSessionMapper;
|
|
|
+import com.cyksj.model.entity.CorpKfAccount;
|
|
|
+import com.cyksj.model.entity.CorpKfAccountFollow;
|
|
|
+import com.cyksj.model.entity.CorpKfAccountSession;
|
|
|
+import com.cyksj.model.kf.WxCpKfAccountAdd;
|
|
|
+import com.cyksj.model.kf.WxCpKfAccountAddResp;
|
|
|
+import com.cyksj.model.kf.WxCpKfAccountDel;
|
|
|
+import com.cyksj.model.kf.WxCpKfAccountUpd;
|
|
|
+import com.cyksj.service.corp.WxCorpOps;
|
|
|
+import com.cyksj.service.corp.kf.CorpKfService;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 项目名: yhlxj2
|
|
|
+ * 文件名: CorpKfServiceImpl
|
|
|
+ * 创建者: JavaZou
|
|
|
+ * 创建时间:2024/12/30 18:10
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class CorpKfServiceImpl implements CorpKfService {
|
|
|
+ private final CorpKfAccountMapper corpKfAccountMapper;
|
|
|
+
|
|
|
+ private final WxCorpOps wxCorpOps;
|
|
|
+
|
|
|
+ private final YHLXWxCorpConfig yhlxWxCorpConfig;
|
|
|
+
|
|
|
+ private final CorpKfAccountFollowMapper corpKfAccountFollowMapper;
|
|
|
+
|
|
|
+ private final CorpKfAccountSessionMapper corpKfAccountSessionMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addKfAccount(CorpKfAccount corpKfAccount) throws Exception {
|
|
|
+ WxCpKfAccountAdd wxCpKfAccountAdd = new WxCpKfAccountAdd();
|
|
|
+ wxCpKfAccountAdd.setName(corpKfAccount.getName());
|
|
|
+ wxCpKfAccountAdd.setMediaId(wxCorpOps.getMediaIdByFileName("image", corpKfAccount.getImg(), yhlxWxCorpConfig.getCorpId()));
|
|
|
+ WxCpKfAccountAddResp resp = wxCorpOps.addAccount(yhlxWxCorpConfig.getCorpId(), wxCpKfAccountAdd);
|
|
|
+ corpKfAccount.setOpenKfId(resp.getOpenKfid());
|
|
|
+ corpKfAccountMapper.insert(corpKfAccount);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delKfAccount(Long id) throws Exception {
|
|
|
+ CorpKfAccount corpKfAccount = corpKfAccountMapper.selectById(id);
|
|
|
+ WxCpKfAccountDel wxCpKfAccountDel = new WxCpKfAccountDel();
|
|
|
+ wxCpKfAccountDel.setOpenKfid(corpKfAccount.getOpenKfId());
|
|
|
+ wxCorpOps.delAccount(yhlxWxCorpConfig.getCorpId(),wxCpKfAccountDel);
|
|
|
+ corpKfAccountMapper.deleteById(id);
|
|
|
+ //删除人员
|
|
|
+ corpKfAccountFollowMapper.delete(Wrappers.lambdaQuery(CorpKfAccountFollow.class).eq(CorpKfAccountFollow::getOpenKfId, corpKfAccount.getOpenKfId()));
|
|
|
+ //删除session设置
|
|
|
+ corpKfAccountSessionMapper.delete(Wrappers.lambdaQuery(CorpKfAccountSession.class).eq(CorpKfAccountSession::getOpenKfId, corpKfAccount.getOpenKfId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateKfAccount(CorpKfAccount corpKfAccount) {
|
|
|
+ if(StringUtils.isNotBlank(corpKfAccount.getName()) && StringUtils.isNotBlank(corpKfAccount.getImg())){
|
|
|
+ CorpKfAccount kfAccount = corpKfAccountMapper.selectById(corpKfAccount.getId());
|
|
|
+ WxCpKfAccountUpd wxCpKfAccountUpd = new WxCpKfAccountUpd();
|
|
|
+ wxCpKfAccountUpd.setOpenKfid(kfAccount.getOpenKfId());
|
|
|
+ if (StringUtils.isNotBlank(corpKfAccount.getName())) {
|
|
|
+ wxCpKfAccountUpd.setName(corpKfAccount.getName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(corpKfAccount.getImg())) {
|
|
|
+ wxCpKfAccountUpd.setMediaId(wxCorpOps.getMediaIdByFileName("image", corpKfAccount.getImg(), yhlxWxCorpConfig.getCorpId()));
|
|
|
+ }
|
|
|
+ wxCorpOps.updAccount(yhlxWxCorpConfig.getCorpId(),wxCpKfAccountUpd);
|
|
|
+ }
|
|
|
+ corpKfAccountMapper.updateById(corpKfAccount);
|
|
|
+ }
|
|
|
+}
|