Quellcode durchsuchen

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

zdm vor 6 Jahren
Ursprung
Commit
aaf86a5422
20 geänderte Dateien mit 308 neuen und 259 gelöschten Zeilen
  1. 11 25
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxGraphicMessageDO.java
  2. 4 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  3. 11 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxComboVO.java
  4. 5 14
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxGraphicMessageVO.java
  5. 4 4
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  6. 2 2
      server/svr-configuration/src/main/resources/bootstrap.yml
  7. 6 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/org/BaseOrgDao.java
  8. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/saas/BaseEmailTemplateConfigDao.java
  9. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxGraphicSceneDao.java
  10. 28 16
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java
  11. 13 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/org/BaseOrgEndpoint.java
  12. 40 21
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java
  13. 5 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WeChatQrcodeController.java
  14. 19 3
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java
  15. 24 11
      svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java
  16. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/org/tree/SimpleTreeNode.java
  17. 46 144
      svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasService.java
  18. 59 3
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WeChatQrcodeService.java
  19. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatCoreService.java
  20. 22 9
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

+ 11 - 25
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxGraphicMessageDO.java

@ -15,14 +15,22 @@ import java.util.Date;
@Table(name = "wx_graphic_message")
@Table(name = "wx_graphic_message")
public class WxGraphicMessageDO extends UuidIdentityEntityWithOperator implements java.io.Serializable {
public class WxGraphicMessageDO extends UuidIdentityEntityWithOperator implements java.io.Serializable {
    private String code;
    private String wechatId;//微信id
    private String title;//标题
    private String title;//标题
    private String description;//描述
    private String description;//描述
    private String url;//图文消息url值
    private String url;//图文消息url值
    private String picUrl;//图片地址
    private String picUrl;//图片地址
    private String remark;//备注
    private Integer status;  //状态 -1删除 0 冻结 1可用
    private Integer status;  //状态 -1删除 0 冻结 1可用
    @Column(name = "wechat_id", length = 50)
    public String getWechatId() {
        return wechatId;
    }
    public void setWechatId(String wechatId) {
        this.wechatId = wechatId;
    }
    @Column(name = "title", length = 200)
    @Column(name = "title", length = 200)
    public String getTitle() {
    public String getTitle() {
        return title;
        return title;
@ -59,21 +67,7 @@ public class WxGraphicMessageDO extends UuidIdentityEntityWithOperator implement
        this.picUrl = picUrl;
        this.picUrl = picUrl;
    }
    }
    @Column(name = "remark", length = 1000)
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    @Column(name = "remark", length = 1000)
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "status", length = 2000)
    public Integer getStatus() {
    public Integer getStatus() {
        return status;
        return status;
    }
    }
@ -82,12 +76,4 @@ public class WxGraphicMessageDO extends UuidIdentityEntityWithOperator implement
        this.status = status;
        this.status = status;
    }
    }
    @Column(name = "code", length = 50)
    public String getCode() {
        return code;
    }
    @Column(name = "code", length = 50)
    public void setCode(String code) {
        this.code = code;
    }
}
}

+ 4 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -19,6 +19,7 @@ public class BaseRequestMapping {
        public static final String PAGE = "/page";
        public static final String PAGE = "/page";
        public static final String LIST = "/list";
        public static final String LIST = "/list";
        public static final String FINDBYID = "/findById";
        public static final String FINDBYID = "/findById";
        public static final String STATUS = "/status";
    }
    }
    /**
    /**
@ -243,10 +244,12 @@ public class BaseRequestMapping {
        public static final String findWechatImgGroup ="/findWechatImgGroup";
        public static final String findWechatImgGroup ="/findWechatImgGroup";
        public static final String createImgGroup ="/createImgGroup";
        public static final String createImgGroup ="/createImgGroup";
        public static final String findImgGroupExist ="/findImgGroupExist";
        public static final String updateImgGroup ="/updateImgGroup";
        public static final String updateImgGroup ="/updateImgGroup";
        public static final String deleteImgGroup ="/deleteImgGroup";
        public static final String deleteImgGroup ="/deleteImgGroup";
        public static final String saveImg ="/saveImg";
        public static final String saveImg ="/saveImg";
        public static final String findImg ="/findImg";
        public static final String findImg ="/findImg";
        public static final String findGraphicMessageSingle ="/findGraphicMessageSingle";
        public static final String saveImgGroup ="/saveImgGroup";
        public static final String saveImgGroup ="/saveImgGroup";
        public static final String saveWxReplyScene ="/saveWxReplyScene";
        public static final String saveWxReplyScene ="/saveWxReplyScene";
@ -396,6 +399,7 @@ public class BaseRequestMapping {
        public static final String PREFIX  = "/baseOrg";
        public static final String PREFIX  = "/baseOrg";
        public static final String baseInfoList  = "/baseInfoList";
        public static final String baseInfoList  = "/baseInfoList";
        public static final String check_code  = "/check_code";
        public static final String check_code  = "/check_code";
        public static final String getOrgAreaTree  = "/getOrgAreaTree";
    }
    }

+ 11 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxComboVO.java

@ -6,12 +6,15 @@ import io.swagger.annotations.ApiModelProperty;
 * Created by Administrator on 2018/10/9.
 * Created by Administrator on 2018/10/9.
 */
 */
public class WxComboVO {
public class WxComboVO {
    @ApiModelProperty(value = "微信id")
    @ApiModelProperty(value = "微信id")
    private String id;
    private String id;
    @ApiModelProperty(value = "微信公众号")
    @ApiModelProperty(value = "微信公众号")
    private String name;
    private String name;
    @ApiModelProperty(value = "原始id")
    @ApiModelProperty(value = "原始id")
    private String appOriginId;
    private String appOriginId;
    @ApiModelProperty(value="公众号类型")
    private String publicType;
    public String getId() {
    public String getId() {
        return id;
        return id;
@ -36,4 +39,12 @@ public class WxComboVO {
    public void setAppOriginId(String appOriginId) {
    public void setAppOriginId(String appOriginId) {
        this.appOriginId = appOriginId;
        this.appOriginId = appOriginId;
    }
    }
    public String getPublicType() {
        return publicType;
    }
    public void setPublicType(String publicType) {
        this.publicType = publicType;
    }
}
}

+ 5 - 14
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxGraphicMessageVO.java

@ -7,7 +7,7 @@ import java.util.Date;
 */
 */
public class WxGraphicMessageVO {
public class WxGraphicMessageVO {
    private String id;
    private String id;
    private String saasId;
    private String wechatId;//微信id
    private String title;//标题
    private String title;//标题
    private String description;//描述
    private String description;//描述
    private String url;//图文消息url值
    private String url;//图文消息url值
@ -18,7 +18,6 @@ public class WxGraphicMessageVO {
    private String updateUser;//修改人
    private String updateUser;//修改人
    private String updateUserName;//修改人名称
    private String updateUserName;//修改人名称
    private Date updateTime;//修改时间
    private Date updateTime;//修改时间
    private String remark;//备注
    private Integer status;  //状态 -1删除 0 冻结 1可用
    private Integer status;  //状态 -1删除 0 冻结 1可用
    public String getId() {
    public String getId() {
@ -109,12 +108,12 @@ public class WxGraphicMessageVO {
        this.updateTime = updateTime;
        this.updateTime = updateTime;
    }
    }
    public String getRemark() {
        return remark;
    public String getWechatId() {
        return wechatId;
    }
    }
    public void setRemark(String remark) {
        this.remark = remark;
    public void setWechatId(String wechatId) {
        this.wechatId = wechatId;
    }
    }
    public Integer getStatus() {
    public Integer getStatus() {
@ -124,12 +123,4 @@ public class WxGraphicMessageVO {
    public void setStatus(Integer status) {
    public void setStatus(Integer status) {
        this.status = status;
        this.status = status;
    }
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
}
}

+ 4 - 4
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -118,10 +118,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            parameters.put("grant_type", "password");
            //解密密码
            //解密密码
//            if (parameters.get("password") != null) {
//                RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)httpSession.getAttribute("privateKey");
//                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(Base64.decodeBase64(parameters.get("password"))), rsaPrivateKey));
//            }
            if (parameters.get("password") != null) {
                RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)httpSession.getAttribute("privateKey");
                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(Base64.decodeBase64(parameters.get("password"))), rsaPrivateKey));
            }
        } else {
        } else {
            parameters.put("grant_type", "captcha");
            parameters.put("grant_type", "captcha");
        }
        }

+ 2 - 2
server/svr-configuration/src/main/resources/bootstrap.yml

@ -10,7 +10,7 @@ spring:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
      server:
        git:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.1.220:10080/jiwei/wlyy2.0.config.git}
          uri: ${wlyy.spring.config.git.uri:http://192.168.1.220:10080/Amoy2/wlyy2.0.config.git}
          basedir: /usr/local/wlyy2.0-config
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:jwdev}
        default-label: ${wlyy.spring.config.git.label:jwdev}
@ -23,7 +23,7 @@ spring:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
      server:
        git:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.1.220:10080/jiwei/wlyy2.0.config.git}
          uri: ${wlyy.spring.config.git.uri:http://192.168.1.220:10080/Amoy2/wlyy2.0.config.git}
          basedir: /usr/local/wlyy2.0-config
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:jwdev}
        default-label: ${wlyy.spring.config.git.label:jwdev}

+ 6 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/org/BaseOrgDao.java

@ -1,12 +1,12 @@
package com.yihu.jw.base.dao.org;
package com.yihu.jw.base.dao.org;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -46,4 +46,8 @@ public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String
    List<BaseOrgDO> findOrgByArea();
    List<BaseOrgDO> findOrgByArea();
    boolean existsByCode(String code);
    boolean existsByCode(String code);
    @Modifying
    @Query("delete from BaseOrgDO p where p.saasid=?1 ")
    void deleteBySaasId(String saasId);
}
}

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/saas/BaseEmailTemplateConfigDao.java

@ -10,5 +10,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface BaseEmailTemplateConfigDao extends PagingAndSortingRepository<BaseEmailTemplateConfigDO, String> {
public interface BaseEmailTemplateConfigDao extends PagingAndSortingRepository<BaseEmailTemplateConfigDO, String> {
    BaseEmailTemplateConfigDO findById(String id);
    BaseEmailTemplateConfigDO findById(String id);
    BaseEmailTemplateConfigDO findByTemplateName(String templateName);
    BaseEmailTemplateConfigDO findByCode(String code);
    BaseEmailTemplateConfigDO findByCode(String code);
}
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/wx/WxGraphicSceneDao.java

@ -4,8 +4,12 @@ import com.yihu.jw.entity.base.wx.WxGraphicSceneDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
/**
 * Created by Administrator on 2018/10/9.
 * Created by Administrator on 2018/10/9.
 */
 */
public interface WxGraphicSceneDao extends PagingAndSortingRepository<WxGraphicSceneDO, String>, JpaSpecificationExecutor<WxGraphicSceneDO> {
public interface WxGraphicSceneDao extends PagingAndSortingRepository<WxGraphicSceneDO, String>, JpaSpecificationExecutor<WxGraphicSceneDO> {
    List<WxGraphicSceneDO> findByWechatIdAndScene(String wechatId,String scene);
}
}

+ 28 - 16
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java

@ -1,12 +1,13 @@
package com.yihu.jw.base.endpoint.open.register;
package com.yihu.jw.base.endpoint.open.register;
import com.yihu.jw.base.dao.saas.BaseEmailTemplateConfigDao;
import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.entity.base.saas.BaseEmailTemplateConfigDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.restmodel.base.saas.SaasTypeDictVO;
import com.yihu.jw.restmodel.base.saas.SaasTypeDictVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
@ -49,6 +50,8 @@ public class RegisterEndpoint extends EnvelopRestEndpoint {
    private StringRedisTemplate redisTemplate;
    private StringRedisTemplate redisTemplate;
    @Autowired
    @Autowired
    private SaasTypeDictService saasTypeDictService;
    private SaasTypeDictService saasTypeDictService;
    @Autowired
    private BaseEmailTemplateConfigDao emailTemplateConfigDao;
    /**
    /**
     * 验证码redis前缀
     * 验证码redis前缀
@ -63,13 +66,8 @@ public class RegisterEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "captcha", value = "验证码", required = true)
            @ApiParam(name = "captcha", value = "验证码", required = true)
            @RequestParam String captcha) throws Exception {
            @RequestParam String captcha) throws Exception {
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        UserDO userDO = new UserDO();
        userDO.setEmail(saasDO.getEmail());
        userDO.setMobile(saasDO.getMobile());
        userDO.setName(saasDO.getManagerName());
        userDO.setUsername(userDO.getEmail());
        String redisKey = redisPrefix + userDO.getEmail();
        String redisKey = redisPrefix + saasDO.getEmail();
        String verificationCode = redisTemplate.opsForValue().get(redisKey);
        String verificationCode = redisTemplate.opsForValue().get(redisKey);
        if(!captcha.equals(verificationCode)){
        if(!captcha.equals(verificationCode)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.CAPTCHA_IS_ERROR), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.CAPTCHA_IS_ERROR), Envelop.class);
@ -77,16 +75,16 @@ public class RegisterEndpoint extends EnvelopRestEndpoint {
        if (saasService.search("name=" + saasDO.getName()).size() > 0) {
        if (saasService.search("name=" + saasDO.getName()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
        }
        }
        if (userService.search("mobile=" + userDO.getMobile()).size() > 0) {
        if (userService.search("mobile=" + saasDO.getMobile()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
        }
        }
        if (userService.search("username=" + userDO.getEmail()).size() > 0) {
        if (userService.search("username=" + saasDO.getEmail()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
        }
        }
        saasService.save(saasDO, userDO);
        saasService.create(saasDO);
        //注册成功后 吧key删除
        //注册成功后 吧key删除
        redisTemplate.delete(redisKey);
        redisTemplate.delete(redisKey);
        return success("注册成功");
        return success("注册申请成功");
    }
    }
    @GetMapping(value = BaseRequestMapping.RegisterSaas.SAAS_TYPE_DICT)
    @GetMapping(value = BaseRequestMapping.RegisterSaas.SAAS_TYPE_DICT)
@ -118,12 +116,26 @@ public class RegisterEndpoint extends EnvelopRestEndpoint {
        //接收者
        //接收者
        mainMessage.setTo(email);
        mainMessage.setTo(email);
        //发送的标题
        //发送的标题
        mainMessage.setSubject("租户注册-验证码");
        //发送的内容
        StringBuilder content =  new StringBuilder("您好!\n感谢您注册健康之路城市i健康。\n");
        //查找发送模板
        BaseEmailTemplateConfigDO emailTemplateConfigDO = emailTemplateConfigDao.findByTemplateName("租户注册-验证码");
        StringBuilder content = null;
        String captcha = String.valueOf(Math.random()).substring(2, 8);
        String captcha = String.valueOf(Math.random()).substring(2, 8);
        content.append("您的验证码是:").append(captcha);
        content.append("。 (验证码10分钟内有效)");
        if(emailTemplateConfigDO == null){
            //发送的内容
            content =  new StringBuilder("您好!\n感谢您注册健康之路城市i健康。\n");
            content.append("您的验证码是:").append(captcha);
            content.append("。 (验证码10分钟内有效)");
        }else {
            //发送的内容
            content =  new StringBuilder(emailTemplateConfigDO.getFirst());
            content.append("\n").append(emailTemplateConfigDO.getKeyword1()).append("\n")
                    .append(emailTemplateConfigDO.getKeyword2()).append(captcha)
                    .append(emailTemplateConfigDO.getKeyword3()).append("\n")
                    .append(emailTemplateConfigDO.getKeyword5()).append(emailTemplateConfigDO.getUrl())
                    .append("\n").append("\n").append(emailTemplateConfigDO.getRemark());
        }
        mainMessage.setSubject("租户注册-验证码");
        mainMessage.setText(content.toString());
        mainMessage.setText(content.toString());
        jms.send(mainMessage);
        jms.send(mainMessage);
        redisTemplate.opsForValue().set(redisPrefix + email, captcha, 10, TimeUnit.MINUTES);
        redisTemplate.opsForValue().set(redisPrefix + email, captcha, 10, TimeUnit.MINUTES);

+ 13 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/org/BaseOrgEndpoint.java

@ -3,6 +3,7 @@ package com.yihu.jw.base.endpoint.org;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.service.org.BaseOrgService;
import com.yihu.jw.base.service.org.BaseOrgService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.restmodel.base.org.BaseOrgVO;
import com.yihu.jw.restmodel.base.org.BaseOrgVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -21,8 +22,6 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
import com.yihu.jw.entity.base.org.BaseOrgDO;
/**
/**
 * 机构信息控制器
 * 机构信息控制器
 *
 *
@ -108,6 +107,18 @@ public class BaseOrgEndpoint extends EnvelopRestEndpoint {
        return success(baseOrgs, BaseOrgVO.class);
        return success(baseOrgs, BaseOrgVO.class);
    }
    }
    @GetMapping(value = BaseRequestMapping.BaseOrg.getOrgAreaTree)
    @ApiOperation(value = "获取机构树")
    public Envelop getOrgAreaTree (
            @ApiParam(name = "saasId", value = "saasId")
            @RequestParam(value = "saasId", required = false) String saasId) throws Exception {
       if(StringUtils.isEmpty(saasId)){
           return success(baseOrgService.getOrgAreaTree());
       }else {
           return success(baseOrgService.getOrgAreaTree(saasId));
       }
    }
    @PostMapping(value = BaseRequestMapping.BaseOrg.baseInfoList)
    @PostMapping(value = BaseRequestMapping.BaseOrg.baseInfoList)
    @ApiOperation(value = "获取机构基础信息列表")
    @ApiOperation(value = "获取机构基础信息列表")

+ 40 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java

@ -26,7 +26,6 @@ import org.springframework.http.MediaType;
import org.springframework.mail.MailException;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.List;
@ -57,31 +56,27 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.Saas.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Saas.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建-基本信息")
    @ApiOperation(value = "创建-基本信息")
    public Envelop create(
    public Envelop create (
            @ApiParam(name = "jsonSaas", value = "租户数据", required = true)
            @ApiParam(name = "jsonSaas", value = "租户数据", required = true)
            @RequestParam String jsonSaas) throws Exception {
            @RequestParam String jsonSaas) throws Exception {
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        SaasDO saasDO = toEntity(jsonSaas, SaasDO.class);
        UserDO userDO = new UserDO();
        userDO.setEmail(saasDO.getEmail());
        userDO.setMobile(saasDO.getMobile());
        userDO.setName(saasDO.getManagerName());
        userDO.setUsername(userDO.getEmail());
        if (saasService.search("name=" + saasDO.getName()).size() > 0) {
        if (saasService.search("name=" + saasDO.getName()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
        }
        }
        if (userService.search("mobile=" + userDO.getMobile()).size() > 0) {
        if (userService.search("mobile=" + saasDO.getMobile()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
        }
        }
        if (userService.search("username=" + userDO.getEmail()).size() > 0) {
        if (userService.search("username=" + saasDO.getEmail()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
        }
        }
        saasService.save(saasDO, userDO);
        return success("创建成功");
        saasService.create(saasDO);
        saasDO.setStatus(SaasDO.Status.auditPassed);
        return send(saasDO);
    }
    }
    @PostMapping(value = BaseRequestMapping.Saas.SYSTEM_CONFIGURATION, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Saas.SYSTEM_CONFIGURATION, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建-系统配置")
    @ApiOperation(value = "创建-系统配置")
    public Envelop createSystemConfig(
    public Envelop createSystemConfig (
            @ApiParam(name = "saasDO", value = "Json数据", required = true)
            @ApiParam(name = "saasDO", value = "Json数据", required = true)
            @RequestParam(value = "saasDO") SaasDO saasDO) throws Exception {
            @RequestParam(value = "saasDO") SaasDO saasDO) throws Exception {
@ -91,7 +86,7 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.Saas.THEME_STYLE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Saas.THEME_STYLE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建-主题风格")
    @ApiOperation(value = "创建-主题风格")
    public Envelop createThemeConfig(
    public Envelop createThemeConfig (
            @ApiParam(name = "saasDO", value = "Json数据", required = true)
            @ApiParam(name = "saasDO", value = "Json数据", required = true)
            @RequestParam(value = "saasDO") SaasDO saasDO) throws Exception {
            @RequestParam(value = "saasDO") SaasDO saasDO) throws Exception {
@ -109,22 +104,46 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
        return success("删除成功");
        return success("删除成功");
    }
    }
    @PostMapping(value = BaseRequestMapping.Saas.STATUS)
    @ApiOperation(value = "修改状态")
    public Envelop status(
            @ApiParam(name = "id", value = "saas类型Json数据")
            @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "status", value = "status")
            @RequestParam(value = "status", required = true) SaasDO.Status status) throws Exception {
        saasService.updateStatus(id, status);
        return success("修改成功");
    }
    @PostMapping(value = BaseRequestMapping.Saas.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.Saas.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    @ApiOperation(value = "更新")
    public Envelop update(
            @ApiParam(name = "json", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
    public Envelop update (
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        SaasDO saasDO = toEntity(jsonData, SaasDO.class);
        SaasDO saasDO = toEntity(jsonData, SaasDO.class);
        if (null == saasDO.getId()) {
        if (null == saasDO.getId()) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), Envelop.class);
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), Envelop.class);
        }
        }
        saasDO = saasService.save(saasDO);
        return success(saasDO);
        SaasDO oldSaas = saasService.findById(saasDO.getId());
        UserDO userDO = userService.findById(oldSaas.getManager());
        if (!oldSaas.getName().equals(saasDO.getName())&&saasService.search("name=" + saasDO.getName()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
        }
        if (!userDO.getMobile().equals(saasDO.getMobile())&&userService.search("mobile=" + saasDO.getMobile()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
        }
        if (!userDO.getEmail().equals(saasDO.getEmail())&&userService.search("username=" + saasDO.getEmail()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
        }
        saasService.updateSaas(saasDO,oldSaas,userDO);
        return success("修改成功");
    }
    }
    @GetMapping(value = BaseRequestMapping.Saas.PAGE)
    @GetMapping(value = BaseRequestMapping.Saas.PAGE)
    @ApiOperation(value = "获取分页")
    @ApiOperation(value = "获取分页")
    public PageEnvelop<SaasVO> page(
    public PageEnvelop<SaasVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
@ -136,13 +155,13 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
            @RequestParam(value = "size") int size) throws Exception {
        List<SaasDO> saasDOS = saasService.search(fields, filters, sorts, page, size);
        List<SaasDO> saasDOS = saasService.search(fields, filters, sorts, page, size);
        int count = (int) saasService.getCount(filters);
        int count = (int)saasService.getCount(filters);
        return success(saasDOS, count, page, size, SaasVO.class);
        return success(saasDOS, count, page, size, SaasVO.class);
    }
    }
    @GetMapping(value = BaseRequestMapping.Saas.LIST)
    @GetMapping(value = BaseRequestMapping.Saas.LIST)
    @ApiOperation(value = "获取列表")
    @ApiOperation(value = "获取列表")
    public ListEnvelop<SaasVO> list(
    public ListEnvelop<SaasVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")

+ 5 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WeChatQrcodeController.java

@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
/**
 * Created by Trick on 2018/9/7.
 * Created by Trick on 2018/9/7.
 */
 */
@ -31,8 +33,9 @@ public class WeChatQrcodeController extends EnvelopRestEndpoint {
    public Envelop getQrcode(@ApiParam(name = "wxId", value = "微信id")
    public Envelop getQrcode(@ApiParam(name = "wxId", value = "微信id")
                             @RequestParam(value = "wxId", required = true)String wxId,
                             @RequestParam(value = "wxId", required = true)String wxId,
                             @ApiParam(name = "scene", value = "场景值")
                             @ApiParam(name = "scene", value = "场景值")
                             @RequestParam(value = "scene", required = true)String scene) throws Exception{
        return success(weChatQrcodeService.getQrcode(wxId,scene));
                             @RequestParam(value = "scene", required = true)String scene,
                             HttpServletRequest request) throws Exception{
        return success(weChatQrcodeService.getQrcode(request,wxId,scene));
    }
    }
}
}

+ 19 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java

@ -82,7 +82,7 @@ public class WechatController extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.WeChat.findWxWechatExist)
    @GetMapping(value = BaseRequestMapping.WeChat.findWxWechatExist)
    @ApiOperation(value = "判断微信名称是否存在", notes = "判断微信名称是否存在")
    @ApiOperation(value = "判断微信名称是否存在", notes = "判断微信名称是否存在")
    public Envelop findWxWechatExist(String name) {
    public Envelop findWxWechatExist(String name) {
       return success("success", wechatService.findWxWechatExist(name));
       return success(BaseRequestMapping.WeChat.api_success, wechatService.findWxWechatExist(name));
    }
    }
@ -116,6 +116,15 @@ public class WechatController extends EnvelopRestEndpoint {
        return wechatService.createImgGroup(wxWechatScene);
        return wechatService.createImgGroup(wxWechatScene);
    }
    }
    @GetMapping(value = BaseRequestMapping.WeChat.findImgGroupExist)
    @ApiOperation(value = "验证图文素材分组是否存在", notes = "验证图文素材分组是否存在")
    public Envelop findImgGroupExist(@ApiParam(name = "wechatId", value = "微信id")
                                     @RequestParam(value = "wechatId", required = true)String wechatId,
                                     @ApiParam(name = "scene", value = "场景值")
                                     @RequestParam(value = "scene", required = true)String scene) {
        return success(BaseRequestMapping.WeChat.api_success,wechatService.findImgGroupExist(wechatId,scene));
    }
    @PostMapping(value = BaseRequestMapping.WeChat.updateImgGroup)
    @PostMapping(value = BaseRequestMapping.WeChat.updateImgGroup)
    @ApiOperation(value = "修改图文素材分组", notes = "修改图文素材分组")
    @ApiOperation(value = "修改图文素材分组", notes = "修改图文素材分组")
    public Envelop updateImgGroup(@ApiParam(name = "id", value = "id")
    public Envelop updateImgGroup(@ApiParam(name = "id", value = "id")
@ -134,8 +143,8 @@ public class WechatController extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.WeChat.saveImg)
    @PostMapping(value = BaseRequestMapping.WeChat.saveImg)
    @ApiOperation(value = "保存图文素材", notes = "保存图文素材")
    @ApiOperation(value = "保存图文素材", notes = "保存图文素材")
    public Envelop saveImg(@ApiParam(name = "id", value = "id")
                           @RequestParam(value = "id", required = true)String wxGraphicMessageJson)throws Exception {
    public Envelop saveImg(@ApiParam(name = "wxGraphicMessageJson", value = "保存图文素材")
                           @RequestParam(value = "wxGraphicMessageJson", required = true)String wxGraphicMessageJson)throws Exception {
        WxGraphicMessageDO WxGraphicMessage = toEntity(wxGraphicMessageJson, WxGraphicMessageDO.class);
        WxGraphicMessageDO WxGraphicMessage = toEntity(wxGraphicMessageJson, WxGraphicMessageDO.class);
        return wechatService.saveImg(WxGraphicMessage);
        return wechatService.saveImg(WxGraphicMessage);
    }
    }
@ -155,6 +164,13 @@ public class WechatController extends EnvelopRestEndpoint {
        return wechatService.findImg(wechatId, title, scene, page, size);
        return wechatService.findImg(wechatId, title, scene, page, size);
    }
    }
    @GetMapping(value = BaseRequestMapping.WeChat.findGraphicMessageSingle)
    @ApiOperation(value = "获取图文素材(单条)", notes = "获取图文素材(单条)")
    public ObjEnvelop<WxGraphicMessageVO> findGraphicMessageSingle(@ApiParam(name = "id", value = "图文id")
                                                       @RequestParam(value = "id", required = true)String id) {
        return success(wechatService.findGraphicMessageSingle(id),WxGraphicMessageVO.class);
    }
    @PostMapping(value = BaseRequestMapping.WeChat.saveImgGroup)
    @PostMapping(value = BaseRequestMapping.WeChat.saveImgGroup)
    @ApiOperation(value = "分组图文素材", notes = "分组图文素材")
    @ApiOperation(value = "分组图文素材", notes = "分组图文素材")
    public Envelop saveImgGroup(@ApiParam(name = "groups", value = "微信id")
    public Envelop saveImgGroup(@ApiParam(name = "groups", value = "微信id")

+ 24 - 11
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java

@ -1,32 +1,28 @@
package com.yihu.jw.base.service.org;
package com.yihu.jw.base.service.org;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.google.gson.JsonObject;
import com.yihu.jw.base.dao.org.BaseOrgDao;
import com.yihu.jw.base.dao.org.BaseOrgDao;
import com.yihu.jw.base.dao.org.OrgTreeDao;
import com.yihu.jw.base.dao.org.OrgTreeDao;
import com.yihu.jw.base.dao.user.UserDao;
import com.yihu.jw.base.dao.user.UserRoleDao;
import com.yihu.jw.base.service.org.tree.SimpleTree;
import com.yihu.jw.base.service.org.tree.SimpleTree;
import com.yihu.jw.base.service.org.tree.SimpleTreeNode;
import com.yihu.jw.base.service.org.tree.SimpleTreeNode;
import com.yihu.jw.base.service.org.tree.Tree;
import com.yihu.jw.base.service.org.tree.TreeNode;
import com.yihu.jw.base.service.org.tree.TreeNode;
import com.yihu.jw.base.service.user.UserRoleService;
import com.yihu.jw.base.service.user.UserRoleService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.base.user.UserRoleDO;
import com.yihu.jw.entity.base.user.UserRoleDO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
/**
 * 
 * 
@ -54,7 +50,8 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
    @Autowired
    @Autowired
    private UserRoleService userRoleService;
    private UserRoleService userRoleService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
    /**
@ -161,4 +158,20 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
        return JSONObject.toJSONString(treeNode, filter);
        return JSONObject.toJSONString(treeNode, filter);
    }
    }
    public String getOrgAreaTree(String saasId){
        StringBuffer sql = new StringBuffer("SELECT t.* from base_org b,org_tree t ")
                .append("WHERE b.saasid='").append(saasId).append("' AND ")
                .append("(b.`code`= t.`code` or b.city_code=t.`code` or b.province_code = t.`code` or b.town_code=t.`code`)");
        List<TreeNode> treeNodes = new ArrayList<>();
        treeNodes.addAll(jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(OrgTree.class)));
        SimpleTree tree = new SimpleTree(treeNodes);
        List<SimpleTreeNode> treeNode = tree.getRoot();
        SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
        filter.getExcludes().add("parent");
        filter.getExcludes().add("allChildren");
        return JSONObject.toJSONString(treeNode, filter);
    }
}
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/tree/SimpleTreeNode.java

@ -32,7 +32,7 @@ public class SimpleTreeNode {
        this.nodeId = obj.extractNodeId();
        this.nodeId = obj.extractNodeId();
        this.nodeName = obj.extractNodeName();
        this.nodeName = obj.extractNodeName();
        this.parentNodeId = obj.extractNodeParentId();
        this.parentNodeId = obj.extractNodeParentId();
        this.orderNum = obj.extractOrderNum();
//        this.orderNum = obj.extractOrderNum();
    }
    }
    public void addChild(SimpleTreeNode treeNode){
    public void addChild(SimpleTreeNode treeNode){
        this.children.add(treeNode);
        this.children.add(treeNode);

+ 46 - 144
svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasService.java

@ -84,156 +84,59 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
     */
     */
    private final String roleCode = "saasAdmin";
    private final String roleCode = "saasAdmin";
    /**
     * 注册新增
     * @param saas
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Transactional(rollbackFor = Exception.class)
    public SaasDO save(SaasDO saas, UserDO user) {
        //初始化角色
        RoleDO roleDO = roleDao.findByCode(roleCode);
        //初始化租户管理员
        user.setEnabled(true);
        user.setLocked(false);
        user.setSalt(randomString(5));
        String password = user.getPassword();
        //密码默认手机号后6位
        if (StringUtils.isEmpty(password)) {
            password = user.getMobile().substring(0, 6);
        }
        user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
        //初始化管理员角色
        UserRoleDO userRoleDO = new UserRoleDO();
        userRoleDO.setRoleId(roleDO.getId());
        List<BaseOrgDO> orgDOList = saas.getOrgList();
        userDao.save(user);
        userRoleDO.setUserId(user.getId());
        userRoleDao.save(userRoleDO);
        saas.setManager(user.getId());
    public SaasDO create(SaasDO saas){
        saas.setStatus(SaasDO.Status.auditWait);
        saas.setStatus(SaasDO.Status.auditWait);
        saas = saasDao.save(saas);
        saas = saasDao.save(saas);
        String saasId = saas.getId();
        List<BaseOrgDO> orgDOList = saas.getOrgList();
        if(orgDOList!=null&&orgDOList.size()>0){
        if(orgDOList!=null&&orgDOList.size()>0){
            String saasId = saas.getId();
            orgDOList.forEach(org->{
            orgDOList.forEach(org->{
                org.setSaasid(saasId);
                org.setSaasid(saasId);
            });
            });
        }
        }
        baseOrgDao.save(orgDOList);
        return saas;
    }
        //字典配置(由于需要支持租户对字典的crud,目前考虑直接复制一套字典给租户单独使用)
//        List<SystemDictDO> systemDictDOList = systemDictDao.findBySaasId(defaultSaasId);
//        List<SystemDictDO> dictDOList = new ArrayList<>(systemDictDOList.size());
//        systemDictDOList.forEach(dict->{
//            SystemDictDO systemDictDO = new SystemDictDO();
//            systemDictDO.setSaasId(saasId);
//            systemDictDO.setName(dict.getName());
//            systemDictDO.setCode(dict.getCode());
//            systemDictDO.setPyCode(dict.getPyCode());
//            systemDictDO.setType(dict.getType());
//            dictDOList.add(systemDictDO);
//        });
        //系统字典项
        List<SystemDictEntryDO> systemDictEntryDOList = systemDictEntryDao.findBySaasId(defaultSaasId);
        List<SystemDictEntryDO> dictEntryDOList = new ArrayList<>(systemDictEntryDOList.size());
        systemDictEntryDOList.forEach(dict->{
            SystemDictEntryDO systemDictEntryDO = new SystemDictEntryDO();
            systemDictEntryDO.setCode(dict.getCode());
            systemDictEntryDO.setSort(dict.getSort());
            systemDictEntryDO.setSaasId(saasId);
            systemDictEntryDO.setPyCode(dict.getPyCode());
            systemDictEntryDO.setDictCode(dict.getDictCode());
            systemDictEntryDO.setRemark(dict.getRemark());
            systemDictEntryDO.setValue(dict.getValue());
            dictEntryDOList.add(systemDictEntryDO);
        });
        //药品字典
        List<DictMedicineDO> dictMedicineDOList = dictMedicineDao.findBySaasId(defaultSaasId);
        List<DictMedicineDO> medicineDOList = new ArrayList<>(dictMedicineDOList.size());
        dictMedicineDOList.forEach(dict->{
            DictMedicineDO dictMedicineDO = new DictMedicineDO();
            dictMedicineDO.setCode(dict.getCode());
            dictMedicineDO.setDosageForm(dict.getDosageForm());
            dictMedicineDO.setIndication(dict.getIndication());
            dictMedicineDO.setName(dict.getName());
            dictMedicineDO.setPackingSpecification(dict.getPackingSpecification());
            dictMedicineDO.setSequence(dict.getSequence());
            dictMedicineDO.setSpecification(dict.getSpecification());
            dictMedicineDO.setSpellCode(dict.getSpellCode());
            dictMedicineDO.setSubjectCode(dict.getSubjectCode());
            dictMedicineDO.setWbzxCode(dict.getWbzxCode());
            dictMedicineDO.setSaasId(saasId);
            dictMedicineDO.setStorageConditions(dict.getStorageConditions());
            medicineDOList.add(dictMedicineDO);
        });
        //职称字典
        List<DictJobTitleDO> dictJobTitleDOList = dictJobTitleDao.findBySaasId(defaultSaasId);
        List<DictJobTitleDO> jobTitleDOList = new ArrayList<>(dictJobTitleDOList.size());
        dictJobTitleDOList.forEach(dict->{
            DictJobTitleDO jobTitleDO = new DictJobTitleDO();
            jobTitleDO.setSaasId(saasId);
            jobTitleDO.setName(dict.getName());
            jobTitleDO.setCode(dict.getCode());
            jobTitleDO.setCreateTime(new Date());
            jobTitleDOList.add(jobTitleDO);
        });
        //icd10字典
        List<DictIcd10DO> dictIcd10DOList = dictIcd10Dao.findBySaasId(defaultSaasId);
        List<DictIcd10DO> icd10DOList = new ArrayList<>(dictIcd10DOList.size());
        dictIcd10DOList.forEach(dict->{
            DictIcd10DO icd10DO = new DictIcd10DO();
            icd10DO.setSaasId(saasId);
            icd10DO.setName(dict.getName());
            icd10DO.setCode(dict.getCode());
            icd10DO.setCreateTime(new Date());
            icd10DO.setDescription(dict.getDescription());
            icd10DOList.add(icd10DO);
        });
        //健康问题字典
        List<DictHealthProblemDO> dictHealthProblemDOList = dictHealthProblemDao.findBySaasId(defaultSaasId);
        List<DictHealthProblemDO> healthProblemDOList = new ArrayList<>(dictHealthProblemDOList.size());
        dictHealthProblemDOList.forEach(dict->{
            DictHealthProblemDO healthProblemDO = new DictHealthProblemDO();
            healthProblemDO.setSaasId(saasId);
            healthProblemDO.setName(dict.getName());
            healthProblemDO.setCode(dict.getCode());
            healthProblemDO.setCreateTime(new Date());
            healthProblemDO.setDescription(dict.getDescription());
            healthProblemDO.setChronicFlag(dict.getChronicFlag());
            healthProblemDOList.add(healthProblemDO);
        });
        //病种字典
        List<DictDiseaseDO> dictDiseaseDOList = dictDiseaseDao.findBySaasId(defaultSaasId);
        List<DictDiseaseDO> diseaseDOList = new ArrayList<>(dictDiseaseDOList.size());
        dictDiseaseDOList.forEach(dict->{
            DictDiseaseDO diseaseDO = new DictDiseaseDO();
            diseaseDO.setSaasId(saasId);
            diseaseDO.setName(dict.getName());
            diseaseDO.setCode(dict.getCode());
            diseaseDO.setCreateTime(new Date());
            diseaseDOList.add(diseaseDO);
        });
        //科室字典
        List<DictHospitalDeptDO> dictHospitalDeptDOList = dictHospitalDeptDao.findBySaasId(defaultSaasId);
        List<DictHospitalDeptDO> hospitalDeptDOList = new ArrayList<>(dictHospitalDeptDOList.size());
        dictHospitalDeptDOList.forEach(dict->{
            DictHospitalDeptDO deptDO = new DictHospitalDeptDO();
            deptDO.setSaasId(saasId);
            deptDO.setName(dict.getName());
            deptDO.setCode(dict.getCode());
            deptDO.setCreateTime(new Date());
            hospitalDeptDOList.add(deptDO);
        });
    /**
     * 修改
     * @param saas
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public SaasDO updateSaas(SaasDO saas,SaasDO oldSaas,UserDO userDO){
        String saasId = saas.getId();
        oldSaas.setEmail(saas.getEmail());
        oldSaas.setMobile(saas.getMobile());
        oldSaas.setManagerName(saas.getManagerName());
        oldSaas.setName(saas.getName());
        oldSaas.setStatus(saas.getStatus());
        oldSaas.setOrganizationCode(saas.getOrganizationCode());
        oldSaas.setBusinessLicense(saas.getBusinessLicense());
        //保存数据
//        systemDictDao.save(dictDOList);
        systemDictEntryDao.save(dictEntryDOList);
        dictMedicineDao.save(medicineDOList);
        dictJobTitleDao.save(jobTitleDOList);
        dictIcd10Dao.save(icd10DOList);
        dictHealthProblemDao.save(healthProblemDOList);
        dictDiseaseDao.save(diseaseDOList);
        dictHospitalDeptDao.save(hospitalDeptDOList);
        userDO.setEmail(saas.getEmail());
        userDO.setMobile(saas.getMobile());
        userDO.setName(saas.getManagerName());
        baseOrgDao.deleteBySaasId(saasId);
        List<BaseOrgDO> orgDOList = saas.getOrgList();
        if(orgDOList!=null&&orgDOList.size()>0){
            orgDOList.forEach(org->{
                org.setSaasid(saasId);
            });
        }
        baseOrgDao.save(orgDOList);
        baseOrgDao.save(orgDOList);
        return saas;
        saasDao.save(oldSaas);
        userDao.save(userDO);
        return oldSaas;
    }
    }
    /**
    /**
     * 系统配置
     * 系统配置
     * @param saasDO
     * @param saasDO
@ -253,6 +156,12 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
        saasModuleDao.save(saasModuleDOList);
        saasModuleDao.save(saasModuleDOList);
    }
    }
    public void updateStatus(String id,SaasDO.Status status){
        SaasDO saasDO = findById(id);
        saasDO.setStatus(status);
        saasDao.save(saasDO);
    }
    /**
    /**
     * 主题风格
     * 主题风格
     * @param saasDO
     * @param saasDO
@ -320,18 +229,12 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
        //初始化管理员角色
        //初始化管理员角色
        UserRoleDO userRoleDO = new UserRoleDO();
        UserRoleDO userRoleDO = new UserRoleDO();
        userRoleDO.setRoleId(roleDO.getId());
        userRoleDO.setRoleId(roleDO.getId());
        List<BaseOrgDO> orgDOList = saas.getOrgList();
        userDao.save(user);
        userDao.save(user);
        userRoleDO.setUserId(user.getId());
        userRoleDO.setUserId(user.getId());
        userRoleDao.save(userRoleDO);
        userRoleDao.save(userRoleDO);
        saas.setManager(user.getId());
        saas.setManager(user.getId());
        saas = saasDao.save(saas);
        saas = saasDao.save(saas);
        String saasId = saas.getId();
        String saasId = saas.getId();
        if (orgDOList != null && orgDOList.size() > 0) {
            orgDOList.forEach(org -> {
                org.setSaasid(saasId);
            });
        }
        //系统字典项
        //系统字典项
        List<SystemDictEntryDO> systemDictEntryDOList = systemDictEntryDao.findBySaasId(defaultSaasId);
        List<SystemDictEntryDO> systemDictEntryDOList = systemDictEntryDao.findBySaasId(defaultSaasId);
        List<SystemDictEntryDO> dictEntryDOList = new ArrayList<>(systemDictEntryDOList.size());
        List<SystemDictEntryDO> dictEntryDOList = new ArrayList<>(systemDictEntryDOList.size());
@ -433,7 +336,6 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
        dictHealthProblemDao.save(healthProblemDOList);
        dictHealthProblemDao.save(healthProblemDOList);
        dictDiseaseDao.save(diseaseDOList);
        dictDiseaseDao.save(diseaseDOList);
        dictHospitalDeptDao.save(hospitalDeptDOList);
        dictHospitalDeptDao.save(hospitalDeptDOList);
        baseOrgDao.save(orgDOList);
        return saas;
        return saas;
    }
    }

+ 59 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WeChatQrcodeService.java

@ -4,10 +4,14 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpRequest;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URL;
@ -25,7 +29,7 @@ public class WeChatQrcodeService {
    @Autowired
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    private WxAccessTokenService wxAccessTokenService;
    public String getQrcode(String wechatId,String scene) throws Exception{
    public String getQrcode(HttpServletRequest request, String wechatId, String scene) throws Exception{
        String token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken();
        String token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken();
        String params = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"" + scene + "\"}}}";
        String params = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"" + scene + "\"}}}";
        //服务号必须是通过腾讯认证,每年是300元,如果没有认证而导致的错误提示,那就去认证
        //服务号必须是通过腾讯认证,每年是300元,如果没有认证而导致的错误提示,那就去认证
@ -43,11 +47,63 @@ public class WeChatQrcodeService {
                HttpURLConnection connection = (HttpURLConnection) urlGet.openConnection();
                HttpURLConnection connection = (HttpURLConnection) urlGet.openConnection();
                connection.connect();
                connection.connect();
                inputStream = connection.getInputStream();
                inputStream = connection.getInputStream();
                ObjectNode objectNode = fastDFSHelper.upload(inputStream,"png","微信二维码");
                String pathFile = request.getSession().getServletContext().getRealPath("/")
                        + File.separator + "qrcode" + File.separator + wechatId+"_"+scene+".png";
                File file = new File(pathFile);
                if(!file.exists()){
                    file.mkdir();
                }
                // 保存文件
                FileOutputStream outputStream = new FileOutputStream(file);
                byte[] data = new byte[1024];
                int len = 0;
                while ((len = inputStream.read(data)) != -1) {
                    outputStream.write(data, 0, len);
                }
                InputStream input = new FileInputStream(file);
                ObjectNode objectNode = fastDFSHelper.upload(input,"png","");
                if(file.exists()){
                    file.delete();
                }
                if (outputStream != null) {
                    outputStream.close();
                }
                if (inputStream != null) {
                    inputStream.close();
                }
                return objectNode.get("fileId").toString().replaceAll("\"", "");
                return objectNode.get("fileId").toString().replaceAll("\"", "");
            }
            }
        }
        }
        return "";
        return "";
    }
    }
//    public void write(InputStream inputStream)throws Exception{
//        String file = "D:\\workspace\\file\\test.png";
//        // 保存文件
//        FileOutputStream outputStream = new FileOutputStream(file);
//
//        byte[] data = new byte[1024];
//        int len = 0;
//
//        while ((len = inputStream.read(data)) != -1) {
//            outputStream.write(data, 0, len);
//        }
//
//        if (outputStream != null) {
//            outputStream.close();
//        }
//
//    }
}
}

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatCoreService.java

@ -15,6 +15,7 @@ import org.dom4j.io.SAXReader;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
@ -33,6 +34,7 @@ public class WechatCoreService {
    private Logger logger = LoggerFactory.getLogger(WechatCoreService.class);
    private Logger logger = LoggerFactory.getLogger(WechatCoreService.class);
    @Autowired
    @Autowired
    private WechatDao wechatDao;
    private WechatDao wechatDao;

+ 22 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -177,7 +177,10 @@ public class WechatService {
    //====================图文素材管理============================
    //====================图文素材管理============================
    public MixEnvelop findWechatCombo(){
    public MixEnvelop findWechatCombo(){
        String sql ="SELECT t.id,t.`name`,t.app_origin_id AS appOriginId from wx_wechat t";
        String sql ="SELECT t.id,t.`name`," +
                "t.app_origin_id AS appOriginId," +
                "t.public_type AS publicType " +
                "from wx_wechat t";
        List<WxComboVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxComboVO.class));
        List<WxComboVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxComboVO.class));
        return MixEnvelop.getSuccessList(BaseRequestMapping.WeChat.api_success,list);
        return MixEnvelop.getSuccessList(BaseRequestMapping.WeChat.api_success,list);
    }
    }
@ -187,7 +190,7 @@ public class WechatService {
        String totalSql ="SELECT COUNT(1) AS total from wx_graphic_scene g WHERE g.wechat_id ='"+wechatId+"'";
        String totalSql ="SELECT COUNT(1) AS total from wx_graphic_scene g WHERE g.wechat_id ='"+wechatId+"'";
        if(StringUtils.isNotBlank(scene)){
        if(StringUtils.isNotBlank(scene)){
            totalSql+=" AND g.scene ='"+scene+"' ";
            totalSql+=" AND g.scene like'%"+scene+"%' ";
        }
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
@ -204,7 +207,7 @@ public class WechatService {
                " g.wechat_id = '"+wechatId+"' ";
                " g.wechat_id = '"+wechatId+"' ";
        if(StringUtils.isNotBlank(scene)){
        if(StringUtils.isNotBlank(scene)){
            sql+= " AND g.scene='"+scene+"'" ;
            sql+= " AND g.scene like'%"+scene+"%'" ;
        }
        }
        sql+= " LIMIT  " + (page - 1) * size + "," + size + "";
        sql+= " LIMIT  " + (page - 1) * size + "," + size + "";
@ -219,6 +222,14 @@ public class WechatService {
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
    }
    }
    public Boolean findImgGroupExist(String wechatId,String scene){
        List<WxGraphicSceneDO> list = wxGraphicSceneDao.findByWechatIdAndScene(wechatId,scene);
        if(list!=null&&list.size()>0){
            return true;
        }
        return false;
    }
    public Envelop updateImgGroup(String id,String scene){
    public Envelop updateImgGroup(String id,String scene){
        WxGraphicSceneDO wxGraphicSceneDO = wxGraphicSceneDao.findOne(id);
        WxGraphicSceneDO wxGraphicSceneDO = wxGraphicSceneDao.findOne(id);
        List<WxGraphicSceneGroupDO> list = wxGraphicSceneGroupDao.findByWechatIdAndScene(wxGraphicSceneDO.getWechatId(),wxGraphicSceneDO.getScene());
        List<WxGraphicSceneGroupDO> list = wxGraphicSceneGroupDao.findByWechatIdAndScene(wxGraphicSceneDO.getWechatId(),wxGraphicSceneDO.getScene());
@ -260,12 +271,12 @@ public class WechatService {
                }
                }
        sqlTotal+= " WHERE " +
        sqlTotal+= " WHERE " +
                " m.wechat_id = '"+wechatId+"' " +
                " m.wechat_id = '"+wechatId+"' " +
                " m.status =1" ;
                " AND m.status =1" ;
                if(StringUtils.isNotBlank(title)){
                if(StringUtils.isNotBlank(title)){
                    sqlTotal += " AND m.title LIKE '%"+title+"%' " ;
                    sqlTotal += " AND m.title LIKE '%"+title+"%' " ;
                }
                }
                if(StringUtils.isNotBlank(scene)){
                if(StringUtils.isNotBlank(scene)){
                    sqlTotal+= "AND g.scene = '"+scene+"'";
                    sqlTotal+= " AND g.scene = '"+scene+"'";
                }
                }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sqlTotal);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sqlTotal);
        Long count = 0L;
        Long count = 0L;
@ -276,12 +287,10 @@ public class WechatService {
        String sql = "SELECT " +
        String sql = "SELECT " +
                " m.id, " +
                " m.id, " +
                " m.wechat_id AS wechatId, " +
                " m.wechat_id AS wechatId, " +
                " m.`code` AS code, " +
                " m.title, " +
                " m.title, " +
                " m.description, " +
                " m.description, " +
                " m.url, " +
                " m.url, " +
                " m.pic_url AS picUrl, " +
                " m.pic_url AS picUrl, " +
                " m.remark, " +
                " m.`status` " +
                " m.`status` " +
                " FROM " +
                " FROM " +
                " wx_graphic_message m ";
                " wx_graphic_message m ";
@ -289,18 +298,22 @@ public class WechatService {
            sql+= " JOIN wx_graphic_scene_group g ON g.graphic_id = m.id ";
            sql+= " JOIN wx_graphic_scene_group g ON g.graphic_id = m.id ";
        }
        }
        sql+=" WHERE m.wechat_id = '"+wechatId+"' " +
        sql+=" WHERE m.wechat_id = '"+wechatId+"' " +
                " m.status =1" ;
                " AND m.status =1" ;
        if(StringUtils.isNotBlank(title)){
        if(StringUtils.isNotBlank(title)){
            sql += " AND m.title LIKE '%"+title+"%' " ;
            sql += " AND m.title LIKE '%"+title+"%' " ;
        }
        }
        if(StringUtils.isNotBlank(scene)){
        if(StringUtils.isNotBlank(scene)){
            sql+= "AND g.scene = '"+scene+"'";
            sql+= " AND g.scene = '"+scene+"'";
        }
        }
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        List<WxGraphicMessageVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxGraphicMessageVO.class));
        List<WxGraphicMessageVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxGraphicMessageVO.class));
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
    }
    }
    public WxGraphicMessageDO findGraphicMessageSingle(String id){
        return wxGraphicMessageDao.findOne(id);
    }
    public Envelop saveImgGroup(List<WxGraphicSceneGroupDO> groups){
    public Envelop saveImgGroup(List<WxGraphicSceneGroupDO> groups){
        List<WxGraphicSceneGroupDO> gs = wxGraphicSceneGroupDao.findByWechatIdAndScene(groups.get(0).getWechatId(),groups.get(0).getScene());
        List<WxGraphicSceneGroupDO> gs = wxGraphicSceneGroupDao.findByWechatIdAndScene(groups.get(0).getWechatId(),groups.get(0).getScene());
        if(gs!=null&&gs.size()>0){
        if(gs!=null&&gs.size()>0){