Преглед на файлове

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

zdm преди 6 години
родител
ревизия
e1296fd00a

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/saas/SaasDO.java

@ -52,6 +52,8 @@ public class SaasDO extends UuidIdentityEntityWithOperator {
    List<BaseOrgDO> orgList;
    List<BaseOrgDO> orgList;
    //业务模块
    //业务模块
    List<SaasModuleDO> saasModuleList;
    List<SaasModuleDO> saasModuleList;
    //主题风格
    List<SaasThemeDO> saasThemeList;
	@Column(name = "name", nullable = false, length = 200)
	@Column(name = "name", nullable = false, length = 200)
	public String getName() {
	public String getName() {
@ -205,4 +207,13 @@ public class SaasDO extends UuidIdentityEntityWithOperator {
    public void setThemeColor(String themeColor) {
    public void setThemeColor(String themeColor) {
        this.themeColor = themeColor;
        this.themeColor = themeColor;
    }
    }
    @Transient
    public List<SaasThemeDO> getSaasThemeList() {
        return saasThemeList;
    }
    public void setSaasThemeList(List<SaasThemeDO> saasThemeList) {
        this.saasThemeList = saasThemeList;
    }
}
}

+ 8 - 0
common/common-exception/src/main/java/com/yihu/jw/exception/code/BaseErrorCode.java

@ -47,6 +47,14 @@ public class BaseErrorCode {
         * 该名称已被占用
         * 该名称已被占用
         */
         */
        public static final String NAME_IS_EXIST = "-101003";
        public static final String NAME_IS_EXIST = "-101003";
        /**
         * 验证码错误
         */
        public static final String CAPTCHA_IS_ERROR = "-101004";
        /**
         * 该租户已注册过,请直接
         */
        public static final String NAME_IS_EXIST2 = "-101005";
    }
    }
    /**
    /**

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

@ -31,6 +31,18 @@ public class BaseRequestMapping {
        public static final String AUDIT  = "/audit";
        public static final String AUDIT  = "/audit";
    }
    }
    /**
     * 注册saas
     */
    public static class RegisterSaas extends Basic {
        public static final String PREFIX  = "/open/saas";
        public static final String REGISTER  = "/register";
        public static final String SEND_EMAIL  = "/sendEmail";
        public static final String NAME_IS_EXIST  = "/nameIsExist";
        public static final String SAAS_TYPE_DICT  = "/saasTypeDict";
    }
    /**
    /**
     * SAAS默认模块
     * SAAS默认模块
     */
     */
@ -178,6 +190,7 @@ public class BaseRequestMapping {
     */
     */
    public static class ErrorCode extends Basic {
    public static class ErrorCode extends Basic {
        public static final String PREFIX  = "/error";
        public static final String PREFIX  = "/error";
        public static final String INIT_WITHOUT_CONDITION  = "/initWithoutCondition";
    }
    }
    /**
    /**
@ -199,7 +212,7 @@ public class BaseRequestMapping {
     * 文件上传
     * 文件上传
     */
     */
    public static class FileUpload extends Basic {
    public static class FileUpload extends Basic {
        public static final String PREFIX  = "/fileUpload";
        public static final String PREFIX  = "/open/fileUpload";
        public static final String UPLOAD_STREAM_IMG  = "/upload_stream_img";
        public static final String UPLOAD_STREAM_IMG  = "/upload_stream_img";
        public static final String UPLOAD_STREAM  = "/upload_stream";
        public static final String UPLOAD_STREAM  = "/upload_stream";
        public static final String UPLOAD_STRING  = "/upload_string";
        public static final String UPLOAD_STRING  = "/upload_string";

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/saas/SaasVO.java

@ -56,6 +56,8 @@ public class SaasVO extends UuidIdentityVOWithOperator {
	List<BaseOrgVO> orgList;
	List<BaseOrgVO> orgList;
	@ApiModelProperty(value = "业务模块", example = "业务模块")
	@ApiModelProperty(value = "业务模块", example = "业务模块")
	List<SaasModuleVO> saasModuleList;
	List<SaasModuleVO> saasModuleList;
	@ApiModelProperty(value = "主题风格", example = "主题风格")
	List<SaasThemeVO> saasThemeList;
	public String getOrgCode() {
	public String getOrgCode() {
@ -209,4 +211,12 @@ public class SaasVO extends UuidIdentityVOWithOperator {
	public void setThemeColor(String themeColor) {
	public void setThemeColor(String themeColor) {
		this.themeColor = themeColor;
		this.themeColor = themeColor;
	}
	}
	public List<SaasThemeVO> getSaasThemeList() {
		return saasThemeList;
	}
	public void setSaasThemeList(List<SaasThemeVO> saasThemeList) {
		this.saasThemeList = saasThemeList;
	}
}
}

+ 1 - 1
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -61,7 +61,7 @@ public class BasicZuulFilter extends ZuulFilter {
        String url = request.getRequestURI();
        String url = request.getRequestURI();
        //内部微服务有不需要认证的地址请在URL上追加/open/来进行过滤,如/api/v1.0/open/**,不要在此继续追加!!!
        //内部微服务有不需要认证的地址请在URL上追加/open/来进行过滤,如/api/v1.0/open/**,不要在此继续追加!!!
        if (url.contains("/auth/")//验证服务
        if (url.contains("/auth/")//验证服务
                || url.contains("/wechat/")//微信
                || url.contains("/wechat")//微信
                || url.contains("/open/")) {//开发接口
                || url.contains("/open/")) {//开发接口
            return true;
            return true;
        }
        }

+ 12 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/errorCode/ErrorCodeEndpoint.java

@ -5,6 +5,7 @@ import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.entity.base.dict.ErrorCodeDO;
import com.yihu.jw.entity.base.dict.ErrorCodeDO;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.restmodel.base.dict.ErrorCodeVO;
import com.yihu.jw.restmodel.base.dict.ErrorCodeVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -31,7 +32,7 @@ public class ErrorCodeEndpoint extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private ErrorCodeUtil errorCodeUtil;
    private ErrorCodeUtil errorCodeUtil;
    @PostMapping(value = BaseRequestMapping.Menu.CREATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = BaseRequestMapping.ErrorCode.CREATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建")
    @ApiOperation(value = "创建")
    public ObjEnvelop<ErrorCodeVO> create (
    public ObjEnvelop<ErrorCodeVO> create (
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @ApiParam(name = "json_data", value = "Json数据", required = true)
@ -44,7 +45,14 @@ public class ErrorCodeEndpoint extends EnvelopRestEndpoint {
        return success(errorCodeDO, ErrorCodeVO.class);
        return success(errorCodeDO, ErrorCodeVO.class);
    }
    }
    @PostMapping(value = BaseRequestMapping.Menu.UPDATE)
    @PostMapping(value = BaseRequestMapping.ErrorCode.INIT_WITHOUT_CONDITION,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "初始化")
    public Envelop initWithoutCondition () throws Exception {
        errorCodeService.initWithoutCondition();
        return success("初始化成功");
    }
    @PostMapping(value = BaseRequestMapping.ErrorCode.UPDATE)
    @ApiOperation(value = "更新")
    @ApiOperation(value = "更新")
    public ObjEnvelop<ErrorCodeVO> update (
    public ObjEnvelop<ErrorCodeVO> update (
            @ApiParam(name = "id", value = "id")
            @ApiParam(name = "id", value = "id")
@ -59,7 +67,7 @@ public class ErrorCodeEndpoint extends EnvelopRestEndpoint {
        return success(errorCodeDO, ErrorCodeVO.class);
        return success(errorCodeDO, ErrorCodeVO.class);
    }
    }
    @GetMapping(value = BaseRequestMapping.Menu.PAGE)
    @GetMapping(value = BaseRequestMapping.ErrorCode.PAGE)
    @ApiOperation(value = "获取分页")
    @ApiOperation(value = "获取分页")
    public PageEnvelop<ErrorCodeVO> page (
    public PageEnvelop<ErrorCodeVO> page (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
@ -77,7 +85,7 @@ public class ErrorCodeEndpoint extends EnvelopRestEndpoint {
        return success(errorCodeDOS, count, page, size, ErrorCodeVO.class);
        return success(errorCodeDOS, count, page, size, ErrorCodeVO.class);
    }
    }
    @GetMapping(value = BaseRequestMapping.Menu.LIST)
    @GetMapping(value = BaseRequestMapping.ErrorCode.LIST)
    @ApiOperation(value = "获取列表")
    @ApiOperation(value = "获取列表")
    public ListEnvelop<ErrorCodeVO> list (
    public ListEnvelop<ErrorCodeVO> list (
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")

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

@ -0,0 +1,132 @@
package com.yihu.jw.base.endpoint.open.register;
import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.entity.base.saas.SaasDO;
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.restmodel.base.saas.SaasTypeDictVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
 * @author yeshijie on 2018/10/16.
 */
@RestController
@RequestMapping(value = BaseRequestMapping.RegisterSaas.PREFIX)
@Api(value = "注册Saas管理", description = "注册Saas管理服务接口", tags = {"wlyy基础服务 - 注册Saas管理服务接口"})
public class RegisterEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private SaasService saasService;
    @Autowired
    private UserService userService;
    @Autowired
    private ErrorCodeUtil errorCodeUtil;
    @Autowired
    private JavaMailSender jms;
    @Value("${spring.mail.username}")
    private String username;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private SaasTypeDictService saasTypeDictService;
    /**
     * 验证码redis前缀
     */
    private final String redisPrefix = "verificationCode:";
    @PostMapping(value = BaseRequestMapping.RegisterSaas.REGISTER, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "注册租户")
    public Envelop create (
            @ApiParam(name = "jsonSaas", value = "租户数据", required = true)
            @RequestParam String jsonSaas,
            @ApiParam(name = "captcha", value = "验证码", required = true)
            @RequestParam String captcha) throws Exception {
        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 verificationCode = redisTemplate.opsForValue().get(redisKey);
        if(!captcha.equals(verificationCode)){
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.CAPTCHA_IS_ERROR), Envelop.class);
        }
        if (saasService.search("name=" + saasDO.getName()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
        }
        if (userService.search("mobile=" + userDO.getMobile()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
        }
        if (userService.search("username=" + userDO.getEmail()).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
        }
        saasService.save(saasDO, userDO);
        //注册成功后 吧key删除
        redisTemplate.delete(redisKey);
        return success("注册成功");
    }
    @GetMapping(value = BaseRequestMapping.RegisterSaas.SAAS_TYPE_DICT)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<SaasTypeDictVO> list() throws Exception {
        List<SaasTypeDictDO> saasTypeDictDOS = saasTypeDictService.search(null, "status="+SaasTypeDictDO.Status.effective, null);
        return success(saasTypeDictDOS, SaasTypeDictVO.class);
    }
    @PostMapping(value = BaseRequestMapping.RegisterSaas.NAME_IS_EXIST)
    @ApiOperation(value = "租户名称是否存在")
    public Envelop create (
            @ApiParam(name = "name", value = "租户名称", required = true)
            @RequestParam String name) throws Exception {
        if (saasService.search("name=" + name).size() > 0) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST2), Envelop.class);
        }
        return success("查询成功");
    }
    @PostMapping(value = BaseRequestMapping.RegisterSaas.SEND_EMAIL)
    @ApiOperation(value = "邮件发送")
    public Envelop send(@ApiParam(name = "email", value = "邮箱地址", required = true)
                         @RequestParam String email) throws Exception {
        //建立邮件消息
        SimpleMailMessage mainMessage = new SimpleMailMessage();
        //发送者
        mainMessage.setFrom(username);
        //接收者
        mainMessage.setTo(email);
        //发送的标题
        mainMessage.setSubject("租户注册-验证码");
        //发送的内容
        StringBuilder content =  new StringBuilder("您好!\n感谢您注册健康之路城市i健康。\n");
        String captcha = String.valueOf(Math.random()).substring(2, 8);
        content.append("您的验证码是:").append(captcha);
        content.append("。 (验证码10分钟内有效)");
        mainMessage.setText(content.toString());
        jms.send(mainMessage);
        redisTemplate.opsForValue().set(redisPrefix + email, captcha, 10, TimeUnit.MINUTES);
        return success("发送成功");
    }
}

+ 9 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java

@ -25,7 +25,6 @@ import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.List;
/**
/**
@ -53,11 +52,15 @@ 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 = "saasDO", value = "Json数据", required = true)
            @RequestParam(value = "saasDO") SaasDO saasDO,
            @ApiParam(name = "userDO", value = "Json数据", required = true)
            @RequestParam(value = "userDO") UserDO userDO) throws Exception {
        if (saasService.search("name=" + userDO.getName()).size() > 0) {
            @ApiParam(name = "jsonSaas", value = "租户数据", required = true)
            @RequestParam String jsonSaas) throws Exception {
        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) {
            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=" + userDO.getMobile()).size() > 0) {
@ -66,7 +69,6 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
        if (userService.search("username=" + userDO.getEmail()).size() > 0) {
        if (userService.search("username=" + userDO.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);
        }
        }
        userDO.setUsername(userDO.getEmail());
        saasService.save(saasDO, userDO);
        saasService.save(saasDO, userDO);
        return success("创建成功");
        return success("创建成功");
    }
    }

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

@ -99,11 +99,13 @@ public class WechatController extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取图文素材分组", notes = "获取图文素材分组")
    @ApiOperation(value = "获取图文素材分组", notes = "获取图文素材分组")
    public MixEnvelop<WxGraphicSceneVO,WxGraphicSceneVO> findWechatImgGroup(@ApiParam(name = "wechatId", value = "微信ID")
    public MixEnvelop<WxGraphicSceneVO,WxGraphicSceneVO> findWechatImgGroup(@ApiParam(name = "wechatId", value = "微信ID")
                                                                            @RequestParam(value = "wechatId", required = true)String wechatId,
                                                                            @RequestParam(value = "wechatId", required = true)String wechatId,
                                                                            @ApiParam(name = "scene", value = "分组名称(场景值)")
                                                                            @RequestParam(value = "scene", required = false)String scene,
                                                                            @ApiParam(name = "page", value = "第几页")
                                                                            @ApiParam(name = "page", value = "第几页")
                                                                            @RequestParam(value = "page", required = false)Integer page,
                                                                            @RequestParam(value = "page", required = false)Integer page,
                                                                            @ApiParam(name = "size", value = "每页条数")
                                                                            @ApiParam(name = "size", value = "每页条数")
                                                                            @RequestParam(value = "size", required = false)Integer size) {
                                                                            @RequestParam(value = "size", required = false)Integer size) {
        return wechatService.findWechatImgGroup(wechatId,page,size);
        return wechatService.findWechatImgGroup(wechatId,scene,page,size);
    }
    }
    @PostMapping(value = BaseRequestMapping.WeChat.createImgGroup)
    @PostMapping(value = BaseRequestMapping.WeChat.createImgGroup)

+ 13 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatCoreController.java

@ -116,9 +116,20 @@ public class WechatCoreController extends EnvelopRestEndpoint {
     */
     */
    private boolean validate(String signature, String timestamp, String nonce) throws NoSuchAlgorithmException {
    private boolean validate(String signature, String timestamp, String nonce) throws NoSuchAlgorithmException {
        logger.info("validate:");
        logger.info("signature:"+signature);
        logger.info("timestamp:"+timestamp);
        logger.info("nonce:"+nonce);
        //查询平台所有微信token
        //查询平台所有微信token
        List<WxWechatDO> wxs =  wechatCoreService.findAll();
        List<WxWechatDO> wxs =  wechatCoreService.findAll();
        try{
            logger.info("validate:wxs.size:"+wxs.size());
        }catch (Exception e){
            e.printStackTrace();
        }
        if(wxs!=null&&wxs.size()>0){
        if(wxs!=null&&wxs.size()>0){
            for(WxWechatDO wx :wxs){
            for(WxWechatDO wx :wxs){
@ -137,6 +148,8 @@ public class WechatCoreController extends EnvelopRestEndpoint {
                String decodeStr = "";
                String decodeStr = "";
                byte[] bytes = md.digest(content.getBytes());
                byte[] bytes = md.digest(content.getBytes());
                decodeStr = byteToStr(bytes);
                decodeStr = byteToStr(bytes);
                logger.info("decodeStr:"+decodeStr);
                //验证
                //验证
                if (StringUtils.isNotEmpty(decodeStr) && decodeStr.equals(signature.toUpperCase())) {
                if (StringUtils.isNotEmpty(decodeStr) && decodeStr.equals(signature.toUpperCase())) {
                    return true;
                    return true;

+ 10 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/errorCode/ErrorCodeService.java

@ -34,6 +34,16 @@ public class ErrorCodeService extends BaseJpaService<ErrorCodeDO, ErrorCodeDao>
        }
        }
    }
    }
    /**
     * 初始化错误码(无条件)
     */
    public void initWithoutCondition(){
        Iterable<ErrorCodeDO> list = errorCodeDao.findAll();
        list.forEach(code->{
            redisTemplate.opsForValue().set(BaseErrorCode.PREFIX + code.getErrorCode(),code.getErrorMsg());
        });
    }
    /**
    /**
     * 新增
     * 新增
     * @param errorCodeDO
     * @param errorCodeDO

+ 37 - 17
svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasService.java

@ -16,6 +16,8 @@ import com.yihu.jw.entity.base.module.SaasModuleDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.saas.SaasThemeDO;
import com.yihu.jw.entity.base.saas.SaasThemeExtendDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
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;
@ -82,17 +84,11 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
     */
     */
    private final String roleCode = "saasAdmin";
    private final String roleCode = "saasAdmin";
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public SaasDO save(SaasDO saas, UserDO user) {
    public SaasDO save(SaasDO saas, UserDO user) {
        //初始化租户信息
        String saasId = getCode();
        String userId = getCode();
        saas.setId(saasId);
        saas.setManager(userId);
        //初始化角色
        //初始化角色
        RoleDO roleDO = roleDao.findByCode(roleCode);
        RoleDO roleDO = roleDao.findByCode(roleCode);
        //初始化租户管理员
        //初始化租户管理员
        user.setId(userId);
        user.setEnabled(true);
        user.setEnabled(true);
        user.setLocked(false);
        user.setLocked(false);
        user.setSalt(randomString(5));
        user.setSalt(randomString(5));
@ -104,12 +100,21 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
        user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
        user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
        //初始化管理员角色
        //初始化管理员角色
        UserRoleDO userRoleDO = new UserRoleDO();
        UserRoleDO userRoleDO = new UserRoleDO();
        userRoleDO.setUserId(user.getId());
        userRoleDO.setRoleId(roleDO.getId());
        userRoleDO.setRoleId(roleDO.getId());
        List<BaseOrgDO> orgDOList = saas.getOrgList();
        List<BaseOrgDO> orgDOList = saas.getOrgList();
        orgDOList.forEach(org->{
            org.setSaasid(saasId);
        });
        userDao.save(user);
        userRoleDO.setUserId(user.getId());
        userRoleDao.save(userRoleDO);
        saas.setManager(user.getId());
        saas.setStatus(SaasDO.Status.auditWait);
        saas = saasDao.save(saas);
        String saasId = saas.getId();
        if(orgDOList!=null&&orgDOList.size()>0){
            orgDOList.forEach(org->{
                org.setSaasid(saasId);
            });
        }
        //字典配置(由于需要支持租户对字典的crud,目前考虑直接复制一套字典给租户单独使用)
        //字典配置(由于需要支持租户对字典的crud,目前考虑直接复制一套字典给租户单独使用)
//        List<SystemDictDO> systemDictDOList = systemDictDao.findBySaasId(defaultSaasId);
//        List<SystemDictDO> systemDictDOList = systemDictDao.findBySaasId(defaultSaasId);
@ -216,8 +221,6 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
        });
        });
        //保存数据
        //保存数据
        saas.setStatus(SaasDO.Status.auditWait);
        saas = saasDao.save(saas);
//        systemDictDao.save(dictDOList);
//        systemDictDao.save(dictDOList);
        systemDictEntryDao.save(dictEntryDOList);
        systemDictEntryDao.save(dictEntryDOList);
        dictMedicineDao.save(medicineDOList);
        dictMedicineDao.save(medicineDOList);
@ -227,9 +230,7 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
        dictDiseaseDao.save(diseaseDOList);
        dictDiseaseDao.save(diseaseDOList);
        dictHospitalDeptDao.save(hospitalDeptDOList);
        dictHospitalDeptDao.save(hospitalDeptDOList);
        baseOrgDao.save(orgDOList);
        baseOrgDao.save(orgDOList);
        userDao.save(user);
        userRoleDao.save(userRoleDO);
//        roleModuleFunctionDao.save(roleModuleFunctionDOS);
        return saas;
        return saas;
    }
    }
@ -237,7 +238,7 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
     * 系统配置
     * 系统配置
     * @param saasDO
     * @param saasDO
     */
     */
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public void saveSystemConfig(SaasDO saasDO){
    public void saveSystemConfig(SaasDO saasDO){
        SaasDO oldSaas = saasDao.findById(saasDO.getId());
        SaasDO oldSaas = saasDao.findById(saasDO.getId());
@ -256,8 +257,27 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
     * 主题风格
     * 主题风格
     * @param saasDO
     * @param saasDO
     */
     */
    @Transactional(rollbackFor = Exception.class)
    public void createThemeConfig(SaasDO saasDO){
    public void createThemeConfig(SaasDO saasDO){
        SaasDO oldSaas = saasDao.findById(saasDO.getId());
        oldSaas.setThemeColor(saasDO.getThemeColor());
        List<SaasThemeDO> themeDOList = saasDO.getSaasThemeList();
        List<SaasThemeExtendDO> themeExtendDOList = new ArrayList<>(16);
        themeDOList.forEach(saasThemeDO -> {
            String themeId = getCode();
            saasThemeDO.setSaasId(saasDO.getId());
            saasThemeDO.setId(themeId);
            if(saasThemeDO.getThemeExtendList()!=null&&saasThemeDO.getThemeExtendList().size()>0){
                saasThemeDO.getThemeExtendList().forEach(saasThemeExtendDO -> {
                    saasThemeExtendDO.setThemeId(themeId);
                    themeExtendDOList.add(saasThemeExtendDO);
                });
            }
        });
        saasDao.save(oldSaas);
        saasThemeDao.save(themeDOList);
        saasThemeExtendDao.save(themeExtendDOList);
    }
    }
    @Transactional
    @Transactional

+ 19 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -122,7 +122,7 @@ public class WechatService {
                " bs.id AS saasid" +
                " bs.id AS saasid" +
                " FROM " +
                " FROM " +
                " wx_wechat_saas s " +
                " wx_wechat_saas s " +
                " JOIN base_saas bs ON s.saas_id = s.saas_id " +
                " JOIN base_saas bs ON bs.id = s.saas_id " +
                " WHERE " +
                " WHERE " +
                " s.wechat_id = '"+id+"'";
                " s.wechat_id = '"+id+"'";
        List<WxSaasVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxSaasVO.class));
        List<WxSaasVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxSaasVO.class));
@ -130,13 +130,12 @@ public class WechatService {
    }
    }
    public Envelop saveWxAndSaas(WxWechatDO wxWechatDO, List<WxWechatSaasDO> wxWechatSaasDOs){
    public Envelop saveWxAndSaas(WxWechatDO wxWechatDO, List<WxWechatSaasDO> wxWechatSaasDOs){
        String uuid = UUID.randomUUID().toString();
        wxWechatDO.setId(uuid);
        wechatDao.save(wxWechatDO);
        WxWechatDO wechat = wechatDao.save(wxWechatDO);
        if(wxWechatSaasDOs!=null&&wxWechatSaasDOs.size()>0){
        if(wxWechatSaasDOs!=null&&wxWechatSaasDOs.size()>0){
            for(WxWechatSaasDO wxs:wxWechatSaasDOs){
            for(WxWechatSaasDO wxs:wxWechatSaasDOs){
                wxs.setWechatId(uuid);
                wxs.setWechatId(wechat.getId());
            }
            }
            wxWechatSaasDao.save(wxWechatSaasDOs);
            wxWechatSaasDao.save(wxWechatSaasDOs);
        }
        }
@ -183,21 +182,33 @@ public class WechatService {
        return MixEnvelop.getSuccessList(BaseRequestMapping.WeChat.api_success,list);
        return MixEnvelop.getSuccessList(BaseRequestMapping.WeChat.api_success,list);
    }
    }
    public MixEnvelop findWechatImgGroup(String wechatId,Integer page,Integer size){
    public MixEnvelop findWechatImgGroup(String wechatId,String scene,Integer page,Integer size){
        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)){
            totalSql+=" AND g.scene ='"+scene+"' ";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
            count = (Long) rstotal.get(0).get("total");
        }
        }
        String sql = "SELECT " +
        String sql = "SELECT " +
                " g.id,g.wechat_id AS wechatId,g.scene " +
                " g.id,g.wechat_id AS wechatId,g.scene " +
                " FROM " +
                " FROM " +
                " wx_graphic_scene g " +
                " wx_graphic_scene g " +
                " WHERE " +
                " WHERE " +
                " g.wechat_id = '"+wechatId+"' " +
                " LIMIT  " + (page - 1) * size + "," + size + "";
                " g.wechat_id = '"+wechatId+"' ";
        if(StringUtils.isNotBlank(scene)){
            sql+= " AND g.scene='"+scene+"'" ;
        }
        sql+= " LIMIT  " + (page - 1) * size + "," + size + "";
        List<WxGraphicSceneVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxGraphicSceneVO.class));
        List<WxGraphicSceneVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxGraphicSceneVO.class));
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);