Explorar o código

微信实体类

trick9191 %!s(int64=6) %!d(string=hai) anos
pai
achega
c37597745c
Modificáronse 22 ficheiros con 1853 adicións e 1854 borrados
  1. 153 153
      svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/ModuleController.java
  2. 39 39
      svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/ModuleFunController.java
  3. 118 118
      svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/SaasController.java
  4. 6 6
      svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/SystemController.java
  5. 152 152
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/FunctionService.java
  6. 80 80
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/ModuleFunService.java
  7. 141 141
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/ModuleService.java
  8. 72 72
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SaasService.java
  9. 11 11
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictListService.java
  10. 11 11
      svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictService.java
  11. 32 32
      svr/svr-base/src/main/java/com/yihu/jw/business/demo/DemoController.java
  12. 18 18
      svr/svr-base/src/main/java/com/yihu/jw/business/sms/dao/SmsDao.java
  13. 178 178
      svr/svr-base/src/main/java/com/yihu/jw/business/sms/service/SmsService.java
  14. 49 49
      svr/svr-base/src/main/java/com/yihu/jw/business/sms/vo/SMSHttpVo.java
  15. 217 217
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseRoleController.java
  16. 180 180
      svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployController.java
  17. 31 31
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseRoleDao.java
  18. 27 27
      svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployDao.java
  19. 182 182
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleService.java
  20. 153 153
      svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployService.java
  21. 3 3
      svr/svr-base/src/main/java/com/yihu/jw/config/jpa/HibernateProperties.java
  22. 0 1
      svr/svr-base/src/main/resources/application.yml

+ 153 - 153
svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/ModuleController.java

@ -1,163 +1,163 @@
package com.yihu.jw.business.base.controller;
import com.yihu.jw.base.base.ModuleDO;
import com.yihu.jw.business.base.service.ModuleService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.base.base.ModuleVO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
@RestController
@RequestMapping(BaseRequestMapping.api_base_common)
@Api(value = "模块模块", description = "模块接口管理")
public class ModuleController extends EnvelopRestController {
    @Autowired
    private ModuleService moduleService;
//    @PostMapping(value = BaseRequestMapping.Module.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建模块", notes = "创建单个模块")
//    public Envelop createModule(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//package com.yihu.jw.business.base.controller;
//
//import com.yihu.jw.base.base.ModuleDO;
//import com.yihu.jw.business.base.service.ModuleService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.base.base.ModuleVO;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/19.
// */
//@RestController
//@RequestMapping(BaseRequestMapping.api_base_common)
//@Api(value = "模块模块", description = "模块接口管理")
//public class ModuleController extends EnvelopRestController {
//    @Autowired
//    private ModuleService moduleService;
//
////    @PostMapping(value = BaseRequestMapping.Module.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "创建模块", notes = "创建单个模块")
////    public Envelop createModule(
////            @ApiParam(name = "json_data", value = "", defaultValue = "")
////            @RequestBody String jsonData) {
////        try {
////            ModuleDO module = toEntity(jsonData, ModuleDO.class);
////            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_create, moduleService.createModule(module));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @PutMapping(value = BaseRequestMapping.Module.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "修改模块", notes = "修改模块")
////    public Envelop updateModule(
////            @ApiParam(name = "json_data", value = "", defaultValue = "")
////            @RequestBody String jsonData) {
////        try {
////            ModuleDO module = toEntity(jsonData, ModuleDO.class);
////            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_update, moduleService.updateModule(module));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
//    @DeleteMapping(value = BaseRequestMapping.Module.api_delete)
//    @ApiOperation(value = "删除模块", notes = "删除模块")
//    public Envelop deleteModule(
//            @ApiParam(name = "codes", value = "codes")
//            @PathVariable(value = "codes", required = true) String codes) {
//        try {
//            ModuleDO module = toEntity(jsonData, ModuleDO.class);
//            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_create, moduleService.createModule(module));
//            moduleService.deleteModule(codes);
//            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_delete );
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @PutMapping(value = BaseRequestMapping.Module.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改模块", notes = "修改模块")
//    public Envelop updateModule(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//
//    @GetMapping(value = BaseRequestMapping.Module.api_getById)
//    @ApiOperation(value = "根据code查找模块", notes = "根据code查找模块")
//    public Envelop findByCode(
//            @ApiParam(name = "id", value = "id")
//            @PathVariable(value = "id", required = true) String id
//    ) {
//        try {
//            ModuleDO module = toEntity(jsonData, ModuleDO.class);
//            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_update, moduleService.updateModule(module));
//            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_find, moduleService.findById(id));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
    @DeleteMapping(value = BaseRequestMapping.Module.api_delete)
    @ApiOperation(value = "删除模块", notes = "删除模块")
    public Envelop deleteModule(
            @ApiParam(name = "codes", value = "codes")
            @PathVariable(value = "codes", required = true) String codes) {
        try {
            moduleService.deleteModule(codes);
            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseRequestMapping.Module.api_getById)
    @ApiOperation(value = "根据code查找模块", notes = "根据code查找模块")
    public Envelop findByCode(
            @ApiParam(name = "id", value = "id")
            @PathVariable(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(BaseRequestMapping.Module.message_success_find, moduleService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseRequestMapping.Module.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取父模块列表(分页)")
    public Envelop getModules(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        if(StringUtils.isBlank(sorts)){
            sorts = "-updateTime";
        }
        if(StringUtils.isBlank(filters)){
            filters = "parentCode=0;";
        }else{
            filters="parentCode=0;"+filters;
        }
        //得到list数据
        List<ModuleDO> list = moduleService.search(fields, filters, sorts, page, size);
        if(list!=null){
            for(ModuleDO module:list){//循环遍历,设置是否有子节点
                List<ModuleDO> children = moduleService.getChildren(module.getId());
                //children长度为0时    state  “open”表示是子节点,“closed”表示为父节点;
                // children长度>0时,  state   “open,closed”表示是节点的打开关闭
                if (children.size()>0){
                    module.setState("closed");
                }else{
                    module.setState("open");
                }
            }
        }
        //获取总数
        long count=moduleService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<ModuleVO> ModuleVOs = convertToModels(list, new ArrayList<>(list.size()), ModuleVO.class, fields);
        return Envelop.getSuccessListWithPage(BaseRequestMapping.Module.message_success_find_Modules,ModuleVOs, page, size,count);
    }
    @GetMapping(value = BaseRequestMapping.Module.api_getListNoPage)
    @ApiOperation(value = "获取模块列表,不分页")
    public Envelop getListNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<ModuleDO> list = moduleService.search(filters, sorts);
        //封装返回格式
        List<ModuleVO> ModuleVOs = convertToModels(list, new ArrayList<>(list.size()), ModuleVO.class, fields);
        return Envelop.getSuccessList(BaseRequestMapping.Module.message_success_find_Modules,ModuleVOs);
    }
    @GetMapping(value =BaseRequestMapping.Module.api_getChildren )
    @ApiOperation(value="查找子节点")
    public Envelop getChildren(@PathVariable String code){
        List<ModuleDO> children = moduleService.getChildren(code);
        return Envelop.getSuccess("查询成功",children);
    }
}
//
//
//    @RequestMapping(value = BaseRequestMapping.Module.api_getList, method = RequestMethod.GET)
//    @ApiOperation(value = "获取父模块列表(分页)")
//    public Envelop getModules(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts,
//            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "size", required = false) int size,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            HttpServletRequest request,
//            HttpServletResponse response) throws Exception {
//        if(StringUtils.isBlank(sorts)){
//            sorts = "-updateTime";
//        }
//        if(StringUtils.isBlank(filters)){
//            filters = "parentCode=0;";
//        }else{
//            filters="parentCode=0;"+filters;
//        }
//
//        //得到list数据
//        List<ModuleDO> list = moduleService.search(fields, filters, sorts, page, size);
//
//        if(list!=null){
//            for(ModuleDO module:list){//循环遍历,设置是否有子节点
//                List<ModuleDO> children = moduleService.getChildren(module.getId());
//                //children长度为0时    state  “open”表示是子节点,“closed”表示为父节点;
//                // children长度>0时,  state   “open,closed”表示是节点的打开关闭
//                if (children.size()>0){
//                    module.setState("closed");
//                }else{
//                    module.setState("open");
//                }
//            }
//        }
//
//        //获取总数
//        long count=moduleService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<ModuleVO> ModuleVOs = convertToModels(list, new ArrayList<>(list.size()), ModuleVO.class, fields);
//
//        return Envelop.getSuccessListWithPage(BaseRequestMapping.Module.message_success_find_Modules,ModuleVOs, page, size,count);
//    }
//
//
//    @GetMapping(value = BaseRequestMapping.Module.api_getListNoPage)
//    @ApiOperation(value = "获取模块列表,不分页")
//    public Envelop getListNoPage(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
//        //得到list数据
//        List<ModuleDO> list = moduleService.search(filters, sorts);
//        //封装返回格式
//        List<ModuleVO> ModuleVOs = convertToModels(list, new ArrayList<>(list.size()), ModuleVO.class, fields);
//        return Envelop.getSuccessList(BaseRequestMapping.Module.message_success_find_Modules,ModuleVOs);
//    }
//
//
//    @GetMapping(value =BaseRequestMapping.Module.api_getChildren )
//    @ApiOperation(value="查找子节点")
//    public Envelop getChildren(@PathVariable String code){
//        List<ModuleDO> children = moduleService.getChildren(code);
//        return Envelop.getSuccess("查询成功",children);
//    }
//
//
//}

+ 39 - 39
svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/ModuleFunController.java

@ -1,39 +1,39 @@
package com.yihu.jw.business.base.controller;
import com.yihu.jw.business.base.service.ModuleFunService;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
@RestController
@RequestMapping(BaseRequestMapping.api_base_common)
@Api(value = "模块功能模块", description = "模块功能模块")
public class ModuleFunController extends EnvelopRestController {
    @Autowired
    private ModuleFunService moduleFunService;
    @GetMapping(value = BaseRequestMapping.ModuleFun.api_getExistFun)
    @ApiOperation(value="查找已存在的功能")
    public Envelop getExistFunc(@PathVariable String id){
        List<String> funcs = moduleFunService.getExistFun(id);
        return Envelop.getSuccess("查询成功",funcs);
    }
    @PutMapping(value =  BaseRequestMapping.ModuleFun.api_changeFun,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "模块更新功能")
    public Envelop changeFun (@RequestBody String jsonData) throws JSONException {
        moduleFunService.changeFun(jsonData);
        return Envelop.getSuccess("更新成功",null);
    }
}
//package com.yihu.jw.business.base.controller;
//
//import com.yihu.jw.business.base.service.ModuleFunService;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.json.JSONException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/19.
// */
//@RestController
//@RequestMapping(BaseRequestMapping.api_base_common)
//@Api(value = "模块功能模块", description = "模块功能模块")
//public class ModuleFunController extends EnvelopRestController {
//    @Autowired
//    private ModuleFunService moduleFunService;
//
//    @GetMapping(value = BaseRequestMapping.ModuleFun.api_getExistFun)
//    @ApiOperation(value="查找已存在的功能")
//    public Envelop getExistFunc(@PathVariable String id){
//        List<String> funcs = moduleFunService.getExistFun(id);
//        return Envelop.getSuccess("查询成功",funcs);
//    }
//
//    @PutMapping(value =  BaseRequestMapping.ModuleFun.api_changeFun,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "模块更新功能")
//    public Envelop changeFun (@RequestBody String jsonData) throws JSONException {
//        moduleFunService.changeFun(jsonData);
//        return Envelop.getSuccess("更新成功",null);
//    }
//}

+ 118 - 118
svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/SaasController.java

@ -1,128 +1,128 @@
package com.yihu.jw.business.base.controller;
import com.yihu.jw.base.base.SaasDO;
import com.yihu.jw.business.base.service.SaasService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
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.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
@RestController
@RequestMapping(BaseRequestMapping.api_base_common)
@Api(value = "Saas配置模块", description = "Saas配置模块接口管理")
public class SaasController extends EnvelopRestController {
    @Autowired
    private SaasService saasService;
//    @PostMapping(value = BaseRequestMapping.Saas.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建Saas配置", notes = "创建单个Saas配置")
//    public Envelop createSaas(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//package com.yihu.jw.business.base.controller;
//
//import com.yihu.jw.base.base.SaasDO;
//import com.yihu.jw.business.base.service.SaasService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//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.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/19.
// */
//@RestController
//@RequestMapping(BaseRequestMapping.api_base_common)
//@Api(value = "Saas配置模块", description = "Saas配置模块接口管理")
//public class SaasController extends EnvelopRestController {
//    @Autowired
//    private SaasService saasService;
//
////    @PostMapping(value = BaseRequestMapping.Saas.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "创建Saas配置", notes = "创建单个Saas配置")
////    public Envelop createSaas(
////            @ApiParam(name = "json_data", value = "", defaultValue = "")
////            @RequestBody String jsonData) {
////        try {
////            SaasDO saas = toEntity(jsonData, SaasDO.class);
////            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_create, saasService.createSaas(saas));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @PutMapping(value = BaseRequestMapping.Saas.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "修改Saas配置", notes = "修改Saas配置")
////    public Envelop updateSaas(
////            @ApiParam(name = "json_data", value = "", defaultValue = "")
////            @RequestBody String jsonData) {
////        try {
////            SaasDO saas = toEntity(jsonData, SaasDO.class);
////            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_update, saasService.updateSaas(saas));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
//    @DeleteMapping(value = BaseRequestMapping.Saas.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "删除Saas配置", notes = "删除Saas配置")
//    public Envelop deleteSaas(
//            @ApiParam(name = "id", value = "id")
//            @RequestParam(value = "id", required = true) String id) {
//        try {
//            SaasDO saas = toEntity(jsonData, SaasDO.class);
//            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_create, saasService.createSaas(saas));
//            saasService.deleteSaas(id);
//            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_delete);
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @PutMapping(value = BaseRequestMapping.Saas.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改Saas配置", notes = "修改Saas配置")
//    public Envelop updateSaas(
//            @ApiParam(name = "json_data", value = "", defaultValue = "")
//            @RequestBody String jsonData) {
//
//    @GetMapping(value = BaseRequestMapping.Saas.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "根据code查找Saas配置", notes = "根据code查找Saas配置")
//    public Envelop findByCode(
//            @ApiParam(name = "id", value = "id")
//            @RequestParam(value = "id", required = true) String id
//    ) {
//        try {
//            SaasDO saas = toEntity(jsonData, SaasDO.class);
//            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_update, saasService.updateSaas(saas));
//            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_find, saasService.findById(id));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
    @DeleteMapping(value = BaseRequestMapping.Saas.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除Saas配置", notes = "删除Saas配置")
    public Envelop deleteSaas(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            saasService.deleteSaas(id);
            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_delete);
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseRequestMapping.Saas.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据code查找Saas配置", notes = "根据code查找Saas配置")
    public Envelop findByCode(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id
    ) {
        try {
            return Envelop.getSuccess(BaseRequestMapping.Saas.message_success_find, saasService.findById(id));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseRequestMapping.Saas.api_getSaass, method = RequestMethod.GET)
    @ApiOperation(value = "获取Saas配置列表(分页)")
    public Envelop getSaass(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<SaasDO> list = saasService.search(fields, filters, sorts, page, size);
        //获取总数
        long count = saasService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<SaasDO> mSaass = convertToModels(list, new ArrayList<>(list.size()), SaasDO.class, fields);
        return Envelop.getSuccessListWithPage(BaseRequestMapping.Saas.message_success_find_saass, mSaass, page, size, count);
    }
    @GetMapping(value = BaseRequestMapping.Saas.api_getSaassNoPage)
    @ApiOperation(value = "获取Saas配置列表,不分页")
    public Envelop getAppsNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,id,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<SaasDO> list = saasService.search(filters, sorts);
        //封装返回格式
        List<SaasDO> mSaass = convertToModels(list, new ArrayList<>(list.size()), SaasDO.class, fields);
        return Envelop.getSuccessList(BaseRequestMapping.Saas.message_success_find_saass, mSaass);
    }
}
//
//
//    @RequestMapping(value = BaseRequestMapping.Saas.api_getSaass, method = RequestMethod.GET)
//    @ApiOperation(value = "获取Saas配置列表(分页)")
//    public Envelop getSaass(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts,
//            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
//            @RequestParam(value = "size", required = false) int size,
//            @ApiParam(name = "page", value = "页码", defaultValue = "1")
//            @RequestParam(value = "page", required = false) int page,
//            HttpServletRequest request,
//            HttpServletResponse response) throws Exception {
//        //得到list数据
//        List<SaasDO> list = saasService.search(fields, filters, sorts, page, size);
//        //获取总数
//        long count = saasService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<SaasDO> mSaass = convertToModels(list, new ArrayList<>(list.size()), SaasDO.class, fields);
//
//        return Envelop.getSuccessListWithPage(BaseRequestMapping.Saas.message_success_find_saass, mSaass, page, size, count);
//    }
//
//
//    @GetMapping(value = BaseRequestMapping.Saas.api_getSaassNoPage)
//    @ApiOperation(value = "获取Saas配置列表,不分页")
//    public Envelop getAppsNoPage(
//            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,id,remark")
//            @RequestParam(value = "fields", required = false) String fields,
//            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
//            @RequestParam(value = "filters", required = false) String filters,
//            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
//            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
//        //得到list数据
//        List<SaasDO> list = saasService.search(filters, sorts);
//        //封装返回格式
//        List<SaasDO> mSaass = convertToModels(list, new ArrayList<>(list.size()), SaasDO.class, fields);
//        return Envelop.getSuccessList(BaseRequestMapping.Saas.message_success_find_saass, mSaass);
//    }
//}

+ 6 - 6
svr/svr-base/src/main/java/com/yihu/jw/business/base/controller/SystemController.java

@ -1,6 +1,6 @@
package com.yihu.jw.business.base.controller;
/**
 * Created by LiTaohong on 2017/11/30.
 */
public class SystemController {
}
//package com.yihu.jw.business.base.controller;
///**
// * Created by LiTaohong on 2017/11/30.
// */
//public class SystemController {
//}

+ 152 - 152
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/FunctionService.java

@ -1,152 +1,152 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.base.base.ModuleFunctionDO;
import com.yihu.jw.business.base.dao.FunctionDao;
import com.yihu.jw.business.base.dao.ModuleFunctionDao;
import com.yihu.jw.base.base.FunctionDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.base.FunctionVO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class FunctionService extends BaseJpaService<FunctionDO, FunctionDao> {
    @Autowired
    private FunctionDao functionDao;
    @Autowired
    private ModuleFunctionDao moduleFunctionDao;
    @Autowired
    private ModuleFunService moduleFunService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public FunctionDO createFunction(FunctionDO function) throws ApiException {
        if (StringUtils.isEmpty(function.getId())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(function.getName())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        FunctionDO functionTmp = functionDao.findByName(function.getName());
        if (functionTmp != null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return functionDao.save(function);
    }
    @Transactional
    public FunctionDO updateFunction(FunctionDO function) {
        if (StringUtils.isEmpty(function.getName())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(function.getId())) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        FunctionDO functionTmp = functionDao.findByNameExcludeId(function.getName(), function.getId());
        if (functionTmp != null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return functionDao.save(function);
    }
    public FunctionDO findById(String id) {
        FunctionDO function = functionDao.findById(id);
        if (function == null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        return function;
    }
    @Transactional
    public void deleteFunction(String id) {
        FunctionDO function = functionDao.findById(id);
        if (function == null) {
            throw new ApiException(BaseRequestMapping.Function.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        function.setStatus(-1);
        functionDao.save(function);
    }
    @Transactional
    public void assignFunction(String moduleId, String functionIds) {
        //先删除原来已经分配好的功能
        moduleFunctionDao.deleteByModuleId(moduleId);
        //分配新的功能
        String [] functionCodeArr=functionIds.split(",");
        List<ModuleFunctionDO> saasModuleList=new ArrayList<>();
        for(String functionId:functionCodeArr){
            ModuleFunctionDO saasModule=new ModuleFunctionDO();
            saasModule.setModuleId(moduleId);
            saasModule.setFunctionId(functionId);
            saasModuleList.add(saasModule);
        }
        moduleFunctionDao.save(saasModuleList);
    }
    public List<FunctionVO> getModuleFunctions(String saasId) {
        String sql=" select m.code,m.parent_code,m.name from base_function f,base_module_function mf where f.code=mf.function_id and f.status=1 and mf.module_id=?";
        return jdbcTemplate.queryForList(sql,FunctionVO.class,saasId);
    }
    /**
     * 根据code获得子节点,并判断是否子节点是否还有孙节点 (treegrid点击查询子节点 用到)
     * @param code
     * @return
     */
    public List<FunctionDO> getChildren(String code){
        List<FunctionDO> childrens = functionDao.getChildren(code);
        for(FunctionDO children:childrens){
            List<FunctionDO> children1 = functionDao.getChildren(children.getId());//判断子节点是否有孙节点
            children.setChildren(children1);
        }
        return childrens;
    }
    public List<FunctionDO> findAll(){
        return functionDao.findAll();
    }
    /**
     * key为code ,value为功能名称
     * @return
     */
    public Map<String,String> getName(){
        List<FunctionDO> functions = findAll();
        Map<String, String> map = new HashMap<>();
        if(null!=functions){
            for(FunctionDO function: functions){
                map.put(function.getId(),function.getName());
            }
        }
        return map;
    }
    /**
     * 根据code获取所有子节点(包括孙节点,曾孙节点....)
     * @param id
     * @return
     */
    public FunctionDO getAllChildren(String id){
        FunctionDO function = functionDao.findById(id);
        List<FunctionDO> childrens = functionDao.getChildren(id);
        for(FunctionDO children:childrens){
            getAllChildren(children.getId());
        }
        function.setChildren(childrens);
        return function;
    }
}
//package com.yihu.jw.business.base.service;
//
//import com.yihu.jw.base.base.ModuleFunctionDO;
//import com.yihu.jw.business.base.dao.FunctionDao;
//import com.yihu.jw.business.base.dao.ModuleFunctionDao;
//import com.yihu.jw.base.base.FunctionDO;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.restmodel.base.base.FunctionVO;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import com.yihu.mysql.query.BaseJpaService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by chenweida on 2017/5/19.
// */
//@Service
//public class FunctionService extends BaseJpaService<FunctionDO, FunctionDao> {
//    @Autowired
//    private FunctionDao functionDao;
//    @Autowired
//    private ModuleFunctionDao moduleFunctionDao;
//    @Autowired
//    private ModuleFunService moduleFunService;
//    @Autowired
//    private JdbcTemplate jdbcTemplate;
//
//    @Transactional
//    public FunctionDO createFunction(FunctionDO function) throws ApiException {
//        if (StringUtils.isEmpty(function.getId())) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(function.getName())) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        FunctionDO functionTmp = functionDao.findByName(function.getName());
//        if (functionTmp != null) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return functionDao.save(function);
//    }
//
//    @Transactional
//    public FunctionDO updateFunction(FunctionDO function) {
//        if (StringUtils.isEmpty(function.getName())) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(function.getId())) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        FunctionDO functionTmp = functionDao.findByNameExcludeId(function.getName(), function.getId());
//        if (functionTmp != null) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return functionDao.save(function);
//    }
//
//    public FunctionDO findById(String id) {
//        FunctionDO function = functionDao.findById(id);
//        if (function == null) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        return function;
//    }
//
//    @Transactional
//    public void deleteFunction(String id) {
//        FunctionDO function = functionDao.findById(id);
//        if (function == null) {
//            throw new ApiException(BaseRequestMapping.Function.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        function.setStatus(-1);
//        functionDao.save(function);
//    }
//    @Transactional
//    public void assignFunction(String moduleId, String functionIds) {
//        //先删除原来已经分配好的功能
//        moduleFunctionDao.deleteByModuleId(moduleId);
//        //分配新的功能
//        String [] functionCodeArr=functionIds.split(",");
//        List<ModuleFunctionDO> saasModuleList=new ArrayList<>();
//        for(String functionId:functionCodeArr){
//            ModuleFunctionDO saasModule=new ModuleFunctionDO();
//            saasModule.setModuleId(moduleId);
//            saasModule.setFunctionId(functionId);
//            saasModuleList.add(saasModule);
//        }
//        moduleFunctionDao.save(saasModuleList);
//    }
//
//    public List<FunctionVO> getModuleFunctions(String saasId) {
//        String sql=" select m.code,m.parent_code,m.name from base_function f,base_module_function mf where f.code=mf.function_id and f.status=1 and mf.module_id=?";
//        return jdbcTemplate.queryForList(sql,FunctionVO.class,saasId);
//    }
//
//    /**
//     * 根据code获得子节点,并判断是否子节点是否还有孙节点 (treegrid点击查询子节点 用到)
//     * @param code
//     * @return
//     */
//    public List<FunctionDO> getChildren(String code){
//        List<FunctionDO> childrens = functionDao.getChildren(code);
//        for(FunctionDO children:childrens){
//            List<FunctionDO> children1 = functionDao.getChildren(children.getId());//判断子节点是否有孙节点
//            children.setChildren(children1);
//        }
//        return childrens;
//    }
//
//    public List<FunctionDO> findAll(){
//        return functionDao.findAll();
//    }
//
//    /**
//     * key为code ,value为功能名称
//     * @return
//     */
//    public Map<String,String> getName(){
//        List<FunctionDO> functions = findAll();
//        Map<String, String> map = new HashMap<>();
//        if(null!=functions){
//            for(FunctionDO function: functions){
//                map.put(function.getId(),function.getName());
//            }
//        }
//        return map;
//    }
//
//    /**
//     * 根据code获取所有子节点(包括孙节点,曾孙节点....)
//     * @param id
//     * @return
//     */
//    public FunctionDO getAllChildren(String id){
//        FunctionDO function = functionDao.findById(id);
//        List<FunctionDO> childrens = functionDao.getChildren(id);
//        for(FunctionDO children:childrens){
//            getAllChildren(children.getId());
//        }
//        function.setChildren(childrens);
//        return function;
//    }
//}

+ 80 - 80
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/ModuleFunService.java

@ -1,80 +1,80 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.base.base.ModuleFunctionDO;
import com.yihu.jw.business.base.dao.ModuleFunctionDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class ModuleFunService extends BaseJpaService<ModuleFunctionDO, ModuleFunctionDao> {
    @Autowired
    private ModuleFunctionDao moduleFunctionDao;
    /**
     * 根据模块code,获取已存在的功能code
     * @param id
     * @return
     */
    public List<String> getExistFun(String id) {
        List<ModuleFunctionDO> moduleFuns = moduleFunctionDao.findByModuleId(id);
        List<String> list = new ArrayList<>();
        for(ModuleFunctionDO moduleFun:moduleFuns){
            list.add(moduleFun.getFunctionId());
        }
        return list;
    }
    /**
     * 更改模块关联的功能
     * @param jsonData
     */
    public void changeFun(String jsonData) throws JSONException {
        JSONObject jsonObject =  new JSONObject(jsonData);
        if(!jsonObject.has("moduleCode")){
            throw new ApiException(BaseRequestMapping.ModuleFun.moduleId_is_null, ExceptionCode.common_error_params_code);
            //filterStr+="saasId="+jsonObject.get("saasId")+";";
        }
        if(!jsonObject.has("funCodes")){
            throw new ApiException(BaseRequestMapping.ModuleFun.funIds_is_null, ExceptionCode.common_error_params_code);
        }
        String moduleCode = jsonObject.get("moduleCode").toString();//模块code
        String funCodes = jsonObject.get("funCodes").toString();//功能code,多个code  ","  分隔
        List<String> existFun = getExistFun(moduleCode);
        List<String> newFunCodes = new ArrayList<String>(Arrays.asList(funCodes.split(",")));//目前的功能code
        List<String> oldFunCodes = new ArrayList<String>(existFun);//构建existFun的副本
        oldFunCodes.removeAll(newFunCodes);// 去除相同元素--->>需要删除的功能code
        newFunCodes.removeAll(existFun);// 去除相同元素---->>需要添加的功能code
        //先删除权限在添加...
        for(String delCode: oldFunCodes){
            moduleFunctionDao.delete(delCode, moduleCode);
        }
        for(String addCode:newFunCodes){
            ModuleFunctionDO moduleFunction = new ModuleFunctionDO();
            moduleFunction.setFunctionId(addCode);
            moduleFunction.setModuleId(moduleCode);
            moduleFunctionDao.save(moduleFunction);
        }
    }
}
//package com.yihu.jw.business.base.service;
//
//import com.yihu.jw.base.base.ModuleFunctionDO;
//import com.yihu.jw.business.base.dao.ModuleFunctionDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import com.yihu.mysql.query.BaseJpaService;
//import org.json.JSONException;
//import org.json.JSONObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/19.
// */
//@Service
//public class ModuleFunService extends BaseJpaService<ModuleFunctionDO, ModuleFunctionDao> {
//
//    @Autowired
//    private ModuleFunctionDao moduleFunctionDao;
//
//    /**
//     * 根据模块code,获取已存在的功能code
//     * @param id
//     * @return
//     */
//    public List<String> getExistFun(String id) {
//        List<ModuleFunctionDO> moduleFuns = moduleFunctionDao.findByModuleId(id);
//        List<String> list = new ArrayList<>();
//        for(ModuleFunctionDO moduleFun:moduleFuns){
//            list.add(moduleFun.getFunctionId());
//        }
//        return list;
//    }
//
//
//
//    /**
//     * 更改模块关联的功能
//     * @param jsonData
//     */
//    public void changeFun(String jsonData) throws JSONException {
//        JSONObject jsonObject =  new JSONObject(jsonData);
//        if(!jsonObject.has("moduleCode")){
//            throw new ApiException(BaseRequestMapping.ModuleFun.moduleId_is_null, ExceptionCode.common_error_params_code);
//            //filterStr+="saasId="+jsonObject.get("saasId")+";";
//        }
//        if(!jsonObject.has("funCodes")){
//            throw new ApiException(BaseRequestMapping.ModuleFun.funIds_is_null, ExceptionCode.common_error_params_code);
//        }
//        String moduleCode = jsonObject.get("moduleCode").toString();//模块code
//        String funCodes = jsonObject.get("funCodes").toString();//功能code,多个code  ","  分隔
//
//        List<String> existFun = getExistFun(moduleCode);
//
//        List<String> newFunCodes = new ArrayList<String>(Arrays.asList(funCodes.split(",")));//目前的功能code
//
//        List<String> oldFunCodes = new ArrayList<String>(existFun);//构建existFun的副本
//        oldFunCodes.removeAll(newFunCodes);// 去除相同元素--->>需要删除的功能code
//
//        newFunCodes.removeAll(existFun);// 去除相同元素---->>需要添加的功能code
//
//        //先删除权限在添加...
//        for(String delCode: oldFunCodes){
//            moduleFunctionDao.delete(delCode, moduleCode);
//        }
//        for(String addCode:newFunCodes){
//            ModuleFunctionDO moduleFunction = new ModuleFunctionDO();
//            moduleFunction.setFunctionId(addCode);
//            moduleFunction.setModuleId(moduleCode);
//            moduleFunctionDao.save(moduleFunction);
//        }
//
//    }
//}

+ 141 - 141
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/ModuleService.java

@ -1,141 +1,141 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.base.base.ModuleDO;
import com.yihu.jw.base.base.SaasModuleDO;
import com.yihu.jw.business.base.dao.ModuleDao;
import com.yihu.jw.business.base.dao.SaasModuleDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.base.ModuleVO;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class ModuleService extends BaseJpaService<ModuleDO, ModuleDao> {
    @Autowired
    private ModuleDao moduleDao;
    @Autowired
    private SaasModuleDao saasModuleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public ModuleDO createModule(ModuleDO module) throws ApiException {
        if (StringUtils.isEmpty(module.getId())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(module.getName())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(module.getSaasId())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        ModuleDO moduleTmp = moduleDao.findByName(module.getName());
        if (moduleTmp != null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return moduleDao.save(module);
    }
    @Transactional
    public ModuleDO updateModule(ModuleDO module) {
        if (StringUtils.isEmpty(module.getName())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(module.getId())) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        ModuleDO moduleTmp = moduleDao.findByNameExcludeId(module.getName(), module.getId());
        if (moduleTmp != null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return moduleDao.save(module);
    }
    public ModuleDO findById(String Id) {
        ModuleDO module = moduleDao.findById(Id);
        if (module == null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        return module;
    }
    @Transactional
    public void deleteModule(String Id) {
        ModuleDO module = moduleDao.findById(Id);
        if (module == null) {
            throw new ApiException(BaseRequestMapping.Module.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        module.setStatus(-1);
    }
    @Transactional
    public void assignModule(String saasCode, String moduleCodes) {
        //先删除原来已经分配好的模块
        saasModuleDao.deleteBySaasCode(saasCode);
        //分配新的模块
        String [] moduleCodeArr=moduleCodes.split(",");
        List<SaasModuleDO> saasModuleList=new ArrayList<>();
        for(String moduleCode:moduleCodeArr){
            SaasModuleDO saasModule=new SaasModuleDO();
            saasModule.setModuleId(moduleCode);
            saasModule.setSaasId(saasCode);
            saasModuleList.add(saasModule);
        }
        saasModuleDao.save(saasModuleList);
    }
    public List<ModuleVO> getSaasModules(String saasCode) {
        String sql=" select m.code,m.parent_code,m.name from base_module m,base_saas_module sm where m.code=sm.module_id and m.status=1 and sm.saas_id=?";
       return jdbcTemplate.queryForList(sql,ModuleVO.class,saasCode);
    }
    public List<ModuleDO> getChildren(String code){
        List<ModuleDO> childrens = moduleDao.getChildren(code);
        for(ModuleDO children:childrens){
            List<ModuleDO> children1 = moduleDao.getChildren(children.getId());//判断子节点是否有孙节点
            //没有children    state
            //“open”表示是子节点,“closed”表示为父节点;
            if (children1.size()>0){
                children.setState("closed");
            }else{
                children.setState("open");
            }
        }
        return childrens;
    }
    public List<ModuleDO> findAll(){
        return moduleDao.findAll();
    }
    /**
     * key为code ,value为模块名称
     * @return
     */
    public Map<String,String> getName(){
        List<ModuleDO> modules = findAll();
        Map<String, String> map = new HashMap<>();
        if(null!=modules){
            for(ModuleDO module: modules){
                map.put(module.getId(),module.getName());
            }
        }
        return map;
    }
}
//package com.yihu.jw.business.base.service;
//
//import com.yihu.jw.base.base.ModuleDO;
//import com.yihu.jw.base.base.SaasModuleDO;
//import com.yihu.jw.business.base.dao.ModuleDao;
//import com.yihu.jw.business.base.dao.SaasModuleDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.restmodel.base.base.ModuleVO;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import com.yihu.mysql.query.BaseJpaService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by chenweida on 2017/5/19.
// */
//@Service
//public class ModuleService extends BaseJpaService<ModuleDO, ModuleDao> {
//    @Autowired
//    private ModuleDao moduleDao;
//    @Autowired
//    private SaasModuleDao saasModuleDao;
//    @Autowired
//    private JdbcTemplate jdbcTemplate;
//
//
//    @Transactional
//    public ModuleDO createModule(ModuleDO module) throws ApiException {
//        if (StringUtils.isEmpty(module.getId())) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(module.getName())) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(module.getSaasId())) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        ModuleDO moduleTmp = moduleDao.findByName(module.getName());
//        if (moduleTmp != null) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return moduleDao.save(module);
//    }
//
//    @Transactional
//    public ModuleDO updateModule(ModuleDO module) {
//        if (StringUtils.isEmpty(module.getName())) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(module.getId())) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        ModuleDO moduleTmp = moduleDao.findByNameExcludeId(module.getName(), module.getId());
//        if (moduleTmp != null) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return moduleDao.save(module);
//    }
//
//    public ModuleDO findById(String Id) {
//        ModuleDO module = moduleDao.findById(Id);
//        if (module == null) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        return module;
//    }
//
//    @Transactional
//    public void deleteModule(String Id) {
//        ModuleDO module = moduleDao.findById(Id);
//        if (module == null) {
//            throw new ApiException(BaseRequestMapping.Module.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        module.setStatus(-1);
//    }
//
//    @Transactional
//    public void assignModule(String saasCode, String moduleCodes) {
//        //先删除原来已经分配好的模块
//        saasModuleDao.deleteBySaasCode(saasCode);
//        //分配新的模块
//        String [] moduleCodeArr=moduleCodes.split(",");
//        List<SaasModuleDO> saasModuleList=new ArrayList<>();
//        for(String moduleCode:moduleCodeArr){
//            SaasModuleDO saasModule=new SaasModuleDO();
//            saasModule.setModuleId(moduleCode);
//            saasModule.setSaasId(saasCode);
//            saasModuleList.add(saasModule);
//        }
//        saasModuleDao.save(saasModuleList);
//    }
//
//    public List<ModuleVO> getSaasModules(String saasCode) {
//        String sql=" select m.code,m.parent_code,m.name from base_module m,base_saas_module sm where m.code=sm.module_id and m.status=1 and sm.saas_id=?";
//       return jdbcTemplate.queryForList(sql,ModuleVO.class,saasCode);
//    }
//
//    public List<ModuleDO> getChildren(String code){
//        List<ModuleDO> childrens = moduleDao.getChildren(code);
//        for(ModuleDO children:childrens){
//            List<ModuleDO> children1 = moduleDao.getChildren(children.getId());//判断子节点是否有孙节点
//            //没有children    state
//            //“open”表示是子节点,“closed”表示为父节点;
//            if (children1.size()>0){
//                children.setState("closed");
//            }else{
//                children.setState("open");
//            }
//        }
//        return childrens;
//    }
//
//    public List<ModuleDO> findAll(){
//        return moduleDao.findAll();
//    }
//
//    /**
//     * key为code ,value为模块名称
//     * @return
//     */
//    public Map<String,String> getName(){
//        List<ModuleDO> modules = findAll();
//        Map<String, String> map = new HashMap<>();
//        if(null!=modules){
//            for(ModuleDO module: modules){
//                map.put(module.getId(),module.getName());
//            }
//        }
//        return map;
//    }
//
//}

+ 72 - 72
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SaasService.java

@ -1,72 +1,72 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.base.base.SaasDO;
import com.yihu.jw.business.base.dao.SaasDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
/**
 * Created by chenweida on 2017/5/19.
 */
@Service
public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
    @Autowired
    private SaasDao saasDao;
    @Transactional
    public SaasDO createSaas(SaasDO saas) throws ApiException {
        if (StringUtils.isEmpty(saas.getId())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(saas.getName())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        SaasDO saasTmp = saasDao.findByName(saas.getName());
        if (saasTmp != null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return saasDao.save(saas);
    }
    @Transactional
    public SaasDO updateSaas(SaasDO saas) {
        if (StringUtils.isEmpty(saas.getName())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(saas.getId())) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        SaasDO saasTmp = saasDao.findByNameExcludeId(saas.getName(), saas.getId());
        if (saasTmp != null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_exist, ExceptionCode.common_error_params_code);
        }
        return saasDao.save(saas);
    }
    public SaasDO findById(String id) {
        SaasDO saas = saasDao.findById(id);
        if (saas == null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        return saas;
    }
    @Transactional
    public void deleteSaas(String id) {
        SaasDO saas = saasDao.findById(id);
        if (saas == null) {
            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
        }
        saas.setStatus(-1);
    }
    public SaasDO findByName(String cityName) {
        return saasDao.findByName(cityName);
    }
}
//package com.yihu.jw.business.base.service;
//
//import com.yihu.jw.base.base.SaasDO;
//import com.yihu.jw.business.base.dao.SaasDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import com.yihu.mysql.query.BaseJpaService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
///**
// * Created by chenweida on 2017/5/19.
// */
//@Service
//public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
//    @Autowired
//    private SaasDao saasDao;
//
//    @Transactional
//    public SaasDO createSaas(SaasDO saas) throws ApiException {
//        if (StringUtils.isEmpty(saas.getId())) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(saas.getName())) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        SaasDO saasTmp = saasDao.findByName(saas.getName());
//        if (saasTmp != null) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return saasDao.save(saas);
//    }
//
//    @Transactional
//    public SaasDO updateSaas(SaasDO saas) {
//        if (StringUtils.isEmpty(saas.getName())) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(saas.getId())) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        SaasDO saasTmp = saasDao.findByNameExcludeId(saas.getName(), saas.getId());
//        if (saasTmp != null) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_name_exist, ExceptionCode.common_error_params_code);
//        }
//        return saasDao.save(saas);
//    }
//
//    public SaasDO findById(String id) {
//        SaasDO saas = saasDao.findById(id);
//        if (saas == null) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        return saas;
//    }
//
//    @Transactional
//    public void deleteSaas(String id) {
//        SaasDO saas = saasDao.findById(id);
//        if (saas == null) {
//            throw new ApiException(BaseRequestMapping.Saas.message_fail_id_no_exist, ExceptionCode.common_error_params_code);
//        }
//        saas.setStatus(-1);
//    }
//
//    public SaasDO findByName(String cityName) {
//        return saasDao.findByName(cityName);
//    }
//}

+ 11 - 11
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictListService.java

@ -1,11 +1,11 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.base.base.SystemDictListDO;
import com.yihu.jw.business.base.dao.SystemDictListDao;
import com.yihu.mysql.query.BaseJpaService;
/**
 * Created by LiTaohong on 2017/12/01.
 */
public class SystemDictListService extends BaseJpaService<SystemDictListDO, SystemDictListDao> {
}
//package com.yihu.jw.business.base.service;
//
//import com.yihu.jw.base.base.SystemDictListDO;
//import com.yihu.jw.business.base.dao.SystemDictListDao;
//import com.yihu.mysql.query.BaseJpaService;
//
///**
// * Created by LiTaohong on 2017/12/01.
// */
//public class SystemDictListService extends BaseJpaService<SystemDictListDO, SystemDictListDao> {
//}

+ 11 - 11
svr/svr-base/src/main/java/com/yihu/jw/business/base/service/SystemDictService.java

@ -1,11 +1,11 @@
package com.yihu.jw.business.base.service;
import com.yihu.jw.base.base.SystemDictDO;
import com.yihu.jw.business.base.dao.SystemDictDao;
import com.yihu.mysql.query.BaseJpaService;
/**
 * Created by LiTaohong on 2017/12/01.
 */
public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDao> {
}
//package com.yihu.jw.business.base.service;
//
//import com.yihu.jw.base.base.SystemDictDO;
//import com.yihu.jw.business.base.dao.SystemDictDao;
//import com.yihu.mysql.query.BaseJpaService;
//
///**
// * Created by LiTaohong on 2017/12/01.
// */
//public class SystemDictService extends BaseJpaService<SystemDictDO, SystemDictDao> {
//}

+ 32 - 32
svr/svr-base/src/main/java/com/yihu/jw/business/demo/DemoController.java

@ -1,32 +1,32 @@
package com.yihu.jw.business.demo;
import com.yihu.jw.business.user.dao.BaseRoleDao;
import com.yihu.jw.restmodel.common.Envelop;
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.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
/**
 * Created by chenweida on 2017/5/10.
 */
@RestController
@RequestMapping("/demo")
@Api(description = "demo例子")
@RefreshScope
public class DemoController {
    @Autowired
    private BaseRoleDao baseRoleDao;
    @ApiOperation(value = "根据code查找患者")
    @GetMapping(value = "findByCode")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "患者code", required = false) @RequestParam(value = "code", required = false) String code) {
        baseRoleDao.findAllByName("管理员");
        return  Envelop.getSuccess("成功");
    }
}
//package com.yihu.jw.business.demo;
//
//import com.yihu.jw.business.user.dao.BaseRoleDao;
//import com.yihu.jw.restmodel.common.Envelop;
//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.cloud.context.config.annotation.RefreshScope;
//import org.springframework.web.bind.annotation.*;
//
//
///**
// * Created by chenweida on 2017/5/10.
// */
//@RestController
//@RequestMapping("/demo")
//@Api(description = "demo例子")
//@RefreshScope
//public class DemoController {
//    @Autowired
//    private BaseRoleDao baseRoleDao;
//
//    @ApiOperation(value = "根据code查找患者")
//    @GetMapping(value = "findByCode")
//    public Envelop findByCode(
//            @ApiParam(name = "code", value = "患者code", required = false) @RequestParam(value = "code", required = false) String code) {
//        baseRoleDao.findAllByName("管理员");
//        return  Envelop.getSuccess("成功");
//    }
//
//}

+ 18 - 18
svr/svr-base/src/main/java/com/yihu/jw/business/sms/dao/SmsDao.java

@ -1,18 +1,18 @@
package com.yihu.jw.business.sms.dao;
import com.yihu.jw.base.sms.BaseSmsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
public interface SmsDao extends PagingAndSortingRepository<BaseSmsDO, String>, JpaSpecificationExecutor<BaseSmsDO> {
    @Query("select count(a.id) from BaseSmsDO a where a.mobile = ?1 and a.createTime  between ?2 and ?3 ")
    int countByMobile(String mobile,Date begin, Date end);
    @Query("select a from BaseSmsDO a where a.mobile = ?1 and a.type = ?2 and a.saasId= ?3 order by a.createTime desc")
    List<BaseSmsDO> findByMobileType(String mobile, int type,String saasId);
}
//package com.yihu.jw.business.sms.dao;
//
//import com.yihu.jw.base.sms.BaseSmsDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.Date;
//import java.util.List;
//
//public interface SmsDao extends PagingAndSortingRepository<BaseSmsDO, String>, JpaSpecificationExecutor<BaseSmsDO> {
//
//    @Query("select count(a.id) from BaseSmsDO a where a.mobile = ?1 and a.createTime  between ?2 and ?3 ")
//    int countByMobile(String mobile,Date begin, Date end);
//
//    @Query("select a from BaseSmsDO a where a.mobile = ?1 and a.type = ?2 and a.saasId= ?3 order by a.createTime desc")
//    List<BaseSmsDO> findByMobileType(String mobile, int type,String saasId);
//}

+ 178 - 178
svr/svr-base/src/main/java/com/yihu/jw/business/sms/service/SmsService.java

@ -1,188 +1,188 @@
package com.yihu.jw.business.sms.service;
import com.yihu.jw.base.sms.BaseSmsDO;
import com.yihu.jw.business.sms.dao.SmsDao;
import com.yihu.jw.business.sms.vo.SMSHttpVo;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.base.BaseEnvelop;
import com.yihu.jw.util.common.SmsValidateCodeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.vo.ValidateCode;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/5/22.
 */
@Service
public class SmsService  extends BaseJpaService<BaseSmsDO, SmsDao> {
    @Autowired
    private SmsDao smsDao;
    @Autowired
    private SMSHttpVo smsHttpVo;
//package com.yihu.jw.business.sms.service;
//
//import com.yihu.jw.base.sms.BaseSmsDO;
//import com.yihu.jw.business.sms.dao.SmsDao;
//import com.yihu.jw.business.sms.vo.SMSHttpVo;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.base.BaseEnvelop;
//import com.yihu.jw.util.common.SmsValidateCodeUtils;
//import com.yihu.jw.util.date.DateUtil;
//import com.yihu.jw.vo.ValidateCode;
//import com.yihu.mysql.query.BaseJpaService;
//import org.apache.http.NameValuePair;
//import org.apache.http.message.BasicNameValuePair;
//import org.json.JSONObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.data.domain.Sort;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.MultiValueMap;
//import org.springframework.web.client.RestTemplate;
//
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.time.LocalDateTime;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/22.
// */
//@Service
//public class SmsService  extends BaseJpaService<BaseSmsDO, SmsDao> {
//    @Autowired
//    private SmsDao smsDao;
//    @Autowired
//    private SMSHttpVo smsHttpVo;
//
//
////    @Transactional
////    public BaseSmsDO createSms(BaseSmsDO sms) throws ApiException {
////
////        return smsDao.save(sms);
////    }
////
////    @Transactional
////    public BaseSmsDO updateSms(BaseSmsDO sms) {
////        return smsDao.save(sms);
////    }
//
//
//    /**
//     * 发送验证码(不走权限判断,包括:注册、找回密码)
//     * @param mobile
//     * @param ip
//     * @param type
//     * @return
//     * @throws Exception
//     */
//    @Transactional
//    public BaseSmsDO createSms(BaseSmsDO sms) throws ApiException {
//    public BaseEnvelop send(String mobile, String ip, int type,String saasId) throws Exception {
//        // 1、同一手机一天不允许超过5条短信
//        //1.1获取一天的开始和结束时间
//        String today = DateUtil.getStringDateShort();
//        Date begin = DateUtil.strToDate(today + " 00:00:00", DateUtil.YYYY_MM_DD_HH_MM_SS);
//        Date end = DateUtil.strToDate(today + " 23:59:59", DateUtil.YYYY_MM_DD_HH_MM_SS);
//        int smsCount = smsDao.countByMobile(mobile,begin,end);
//        if(smsCount>=5){
//            return Envelop.getError("您的验证码次数已用完,请明天再尝试!",-1);
//        }
//        // 2、60秒之内不允许重复发送
////        PageRequest pageRequest = new PageRequest(0, 1, new Sort(Sort.Direction.DESC, "id"));
//        List<BaseSmsDO> page = smsDao.findByMobileType(mobile,type,saasId);
//        if (page.size()>0) {
////            for (BaseSmsDO sms : page) {
////                if (sms == null) {
////                    continue;
////                }
//                // 计算间隔时间
//                Date temp = DateUtil.getNextMin(page.get(0).getCreateTime(), 1);
//                long leftTime = (temp.getTime() - System.currentTimeMillis()) / 1000;
//                if (leftTime > 0) {
//                    return BaseEnvelop.getError("发送短信验证码间隔时间为:60秒!");
//                }
////            }
//        }
//        //3、生成验证码
//        ValidateCode vc = SmsValidateCodeUtils.generate(6,1);
//
//        return smsDao.save(sms);
//        //4、保存验证码(1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录)
//        BaseSmsDO sms = new BaseSmsDO();
//        sms.setMobile(mobile);
//        sms.setIp(ip);
//        sms.setType(type);
//        sms.setCaptcha(vc.getCode());
//        switch (type){
//            case 1:sms.setContent("您的注册验证码为:"+vc.getCode());break;
//            case 2:sms.setContent("您找回密码验证码为:"+vc.getCode());break;
//            case 3:sms.setContent("您找回密码验证码为:"+vc.getCode());break;
//        }
//        SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
//        sms.setDeadline(s.parse(vc.getCreateTimeString()));
//        sms.setStatus(1);
//        sms.setSaasId(saasId);
//        //5、 调用发送信息的接口
////        String result = httpClientUtil.post(smsHttpVo.getUrl(), buildSmsParams(sms.getContent(), mobile), "GBK");
////        JSONObject json = toJson(result);
////        if (json == null) {
////            // 发送失败
////            return BaseEnvelop.getError("短信接口请求失败!");
////        } else if (json.getInt("result") != 0) {
////            return BaseEnvelop.getError(json.getString("description"));
////        } else {
////            //发送成功,保存到数据库
////        }
//        smsDao.save(sms);
//        if(smsCount>=2&&smsCount<=5){
//           return  BaseEnvelop.getSuccess("今日可重发验证码剩余"+(5-smsCount)+"次,请尽快完成验证。!");
//        }
//        return BaseEnvelop.getSuccess("验证码发送成功!");
//    }
//
//    @Transactional
//    public BaseSmsDO updateSms(BaseSmsDO sms) {
//        return smsDao.save(sms);
//    //封装发送短信的参数
//    public  List<NameValuePair> buildSmsParams(String content, String mobile) {
//        List<NameValuePair> params = new ArrayList<NameValuePair>();
//        params.add(new BasicNameValuePair("SpCode", smsHttpVo.getCode()));
//        params.add(new BasicNameValuePair("LoginName", smsHttpVo.getName()));
//        params.add(new BasicNameValuePair("Password", smsHttpVo.getPassword()));
//        params.add(new BasicNameValuePair("MessageContent", content));
//        params.add(new BasicNameValuePair("UserNumber", mobile));
//        params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
//        params.add(new BasicNameValuePair("ScheduleTime", ""));
//        params.add(new BasicNameValuePair("f", "1"));
//        return params;
//    }
    /**
     * 发送验证码(不走权限判断,包括:注册、找回密码)
     * @param mobile
     * @param ip
     * @param type
     * @return
     * @throws Exception
     */
    @Transactional
    public BaseEnvelop send(String mobile, String ip, int type,String saasId) throws Exception {
        // 1、同一手机一天不允许超过5条短信
        //1.1获取一天的开始和结束时间
        String today = DateUtil.getStringDateShort();
        Date begin = DateUtil.strToDate(today + " 00:00:00", DateUtil.YYYY_MM_DD_HH_MM_SS);
        Date end = DateUtil.strToDate(today + " 23:59:59", DateUtil.YYYY_MM_DD_HH_MM_SS);
        int smsCount = smsDao.countByMobile(mobile,begin,end);
        if(smsCount>=5){
            return Envelop.getError("您的验证码次数已用完,请明天再尝试!",-1);
        }
        // 2、60秒之内不允许重复发送
//
//    //校验验证码是否正确
//    public Envelop checkSms(String mobile,String saasId,int type,String captcha){
//        PageRequest pageRequest = new PageRequest(0, 1, new Sort(Sort.Direction.DESC, "id"));
        List<BaseSmsDO> page = smsDao.findByMobileType(mobile,type,saasId);
        if (page.size()>0) {
//            for (BaseSmsDO sms : page) {
//                if (sms == null) {
//        List<BaseSmsDO> page = smsDao.findByMobileType(mobile,type,saasId);
////        if (page != null) {
////            for (BaseSmsDO sms : page) {
//                BaseSmsDO sms = page.get(0);
//                String toCaptcha = sms.getCaptcha();
//                Date deadline = sms.getDeadline();
//                if(new Date().before(deadline)){
//                    //对比校验码是否正确
//                    if(captcha.equals(toCaptcha)){
//                        Envelop.getSuccess("验证码校验成功!");
//                    }else{
//                        return Envelop.getError("验证码错误!");
//                    }
//                }else{
//                    //过期
//                    return Envelop.getError("验证码过期!");
//                }
//
////            }
////        }
//        return Envelop.getError("未发送验证码!");
//    }
//
//    //解析短信返回的json数据
//    public JSONObject toJson(String result) {
//        JSONObject json = new JSONObject();
//        try {
//            String[] temps = result.split("&");
//            for (String temp : temps) {
//                if (temp.split("=").length != 2) {
//                    continue;
//                }
                // 计算间隔时间
                Date temp = DateUtil.getNextMin(page.get(0).getCreateTime(), 1);
                long leftTime = (temp.getTime() - System.currentTimeMillis()) / 1000;
                if (leftTime > 0) {
                    return BaseEnvelop.getError("发送短信验证码间隔时间为:60秒!");
                }
//                String key = temp.split("=")[0];
//                String value = temp.split("=")[1];
//                json.put(key, value);
//            }
        }
        //3、生成验证码
        ValidateCode vc = SmsValidateCodeUtils.generate(6,1);
        //4、保存验证码(1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录)
        BaseSmsDO sms = new BaseSmsDO();
        sms.setMobile(mobile);
        sms.setIp(ip);
        sms.setType(type);
        sms.setCaptcha(vc.getCode());
        switch (type){
            case 1:sms.setContent("您的注册验证码为:"+vc.getCode());break;
            case 2:sms.setContent("您找回密码验证码为:"+vc.getCode());break;
            case 3:sms.setContent("您找回密码验证码为:"+vc.getCode());break;
        }
        SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
        sms.setDeadline(s.parse(vc.getCreateTimeString()));
        sms.setStatus(1);
        sms.setSaasId(saasId);
        //5、 调用发送信息的接口
//        String result = httpClientUtil.post(smsHttpVo.getUrl(), buildSmsParams(sms.getContent(), mobile), "GBK");
//        JSONObject json = toJson(result);
//        if (json == null) {
//            // 发送失败
//            return BaseEnvelop.getError("短信接口请求失败!");
//        } else if (json.getInt("result") != 0) {
//            return BaseEnvelop.getError(json.getString("description"));
//        } else {
//            //发送成功,保存到数据库
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        smsDao.save(sms);
        if(smsCount>=2&&smsCount<=5){
           return  BaseEnvelop.getSuccess("今日可重发验证码剩余"+(5-smsCount)+"次,请尽快完成验证。!");
        }
        return BaseEnvelop.getSuccess("验证码发送成功!");
    }
    //封装发送短信的参数
    public  List<NameValuePair> buildSmsParams(String content, String mobile) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("SpCode", smsHttpVo.getCode()));
        params.add(new BasicNameValuePair("LoginName", smsHttpVo.getName()));
        params.add(new BasicNameValuePair("Password", smsHttpVo.getPassword()));
        params.add(new BasicNameValuePair("MessageContent", content));
        params.add(new BasicNameValuePair("UserNumber", mobile));
        params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
        params.add(new BasicNameValuePair("ScheduleTime", ""));
        params.add(new BasicNameValuePair("f", "1"));
        return params;
    }
    //校验验证码是否正确
    public Envelop checkSms(String mobile,String saasId,int type,String captcha){
        PageRequest pageRequest = new PageRequest(0, 1, new Sort(Sort.Direction.DESC, "id"));
        List<BaseSmsDO> page = smsDao.findByMobileType(mobile,type,saasId);
//        if (page != null) {
//            for (BaseSmsDO sms : page) {
                BaseSmsDO sms = page.get(0);
                String toCaptcha = sms.getCaptcha();
                Date deadline = sms.getDeadline();
                if(new Date().before(deadline)){
                    //对比校验码是否正确
                    if(captcha.equals(toCaptcha)){
                        Envelop.getSuccess("验证码校验成功!");
                    }else{
                        return Envelop.getError("验证码错误!");
                    }
                }else{
                    //过期
                    return Envelop.getError("验证码过期!");
                }
//            }
//        }
        return Envelop.getError("未发送验证码!");
    }
    //解析短信返回的json数据
    public JSONObject toJson(String result) {
        JSONObject json = new JSONObject();
        try {
            String[] temps = result.split("&");
            for (String temp : temps) {
                if (temp.split("=").length != 2) {
                    continue;
                }
                String key = temp.split("=")[0];
                String value = temp.split("=")[1];
                json.put(key, value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
}
//        return json;
//    }
//
//
//}

+ 49 - 49
svr/svr-base/src/main/java/com/yihu/jw/business/sms/vo/SMSHttpVo.java

@ -1,49 +1,49 @@
package com.yihu.jw.business.sms.vo;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
 * Created by 刘文彬 on 2018/4/13.
 */
@Component
@ConfigurationProperties(prefix = "jw.sms")
public class SMSHttpVo {
    private String url;
    private String code;
    private String name;
    private String password;
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
}
//package com.yihu.jw.business.sms.vo;
//
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.stereotype.Component;
//
///**
// * Created by 刘文彬 on 2018/4/13.
// */
//@Component
//@ConfigurationProperties(prefix = "jw.sms")
//public class SMSHttpVo {
//
//    private String url;
//    private String code;
//    private String name;
//    private String password;
//
//    public String getUrl() {
//        return url;
//    }
//
//    public void setUrl(String url) {
//        this.url = url;
//    }
//
//    public String getCode() {
//        return code;
//    }
//
//    public void setCode(String code) {
//        this.code = code;
//    }
//
//    public String getName() {
//        return name;
//    }
//
//    public void setName(String name) {
//        this.name = name;
//    }
//
//    public String getPassword() {
//        return password;
//    }
//
//    public void setPassword(String password) {
//        this.password = password;
//    }
//}

+ 217 - 217
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/BaseRoleController.java

@ -1,231 +1,231 @@
package com.yihu.jw.business.user.contorller;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.base.user.BaseMenuDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.base.user.BaseRoleMenuDO;
import com.yihu.jw.business.user.service.BaseRoleService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.user.BaseEmployVO;
import com.yihu.jw.restmodel.base.user.BaseRoleVO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 */
@RestController
@RequestMapping(BaseUserRequestMapping.api_user_common)
@Api(description = "基础角色")
public class BaseRoleController extends EnvelopRestController {
    @Autowired
    private BaseRoleService baseRoleService;
//package com.yihu.jw.business.user.contorller;
//
//import com.yihu.jw.base.user.BaseEmployRoleDO;
//import com.yihu.jw.base.user.BaseMenuDO;
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.base.user.BaseRoleMenuDO;
//import com.yihu.jw.business.user.service.BaseRoleService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.restmodel.base.user.BaseEmployVO;
//import com.yihu.jw.restmodel.base.user.BaseRoleVO;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.text.ParseException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// */
//@RestController
//@RequestMapping(BaseUserRequestMapping.api_user_common)
//@Api(description = "基础角色")
//public class BaseRoleController extends EnvelopRestController {
//
//    @Autowired
//    private BaseRoleMenuService baseRoleMenuService;
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建角色", notes = "创建单个角色")
//    public Envelop createRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_create,baseRoleService.createBaseRole(baseRoleDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改角色", notes = "修改角色")
//    public Envelop updateBaseRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_update,baseRoleService.updateBaseRole(baseRoleDO));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询单个角色", notes = "根据角色id查询角色信息")
//    public Envelop getOneRoleById(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findById(baseRoleDO.getId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getOne, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询单个角色", notes = "根据平台和角色名称查询角色信息")
//    public Envelop getOneRoleBySaasIdAndName(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findBySaasIdAndName(baseRoleDO.getName(),baseRoleDO.getSaasId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getlistNoPage, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "查询多个角色", notes = "根据平台id查询所有角色信息,不分页")
//    public Envelop getRoleListBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findAllBySaasId(baseRoleDO.getSaasId()));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
    @ApiOperation(value = "根据指定条件查询所有角色列表,分页")
    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getListPage)
    public Envelop getRoleListPage(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,remark") @RequestParam(value = "fields", required = false) String fields,
                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
        if (StringUtils.isBlank(filters)) {
            return Envelop.getError(BaseUserRequestMapping.BaseRole.message_fail_params_not_present, ExceptionCode.common_error_params_code);
        } else {
            filters = "status<>-1;" + filters;
        }
        if (StringUtils.isBlank(sorts)) {
            sorts = "-updateTime";
        }
        //得到list数据
        List<BaseRoleVO> list = baseRoleService.search(fields, filters, sorts, page, size);
        //获取总数
        long count = baseRoleService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<BaseRoleVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseRoleVO.class, fields);
        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseRole.message_success_find, mFunctions, page, size, count);
    }
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "删除角色", notes = "根据角色id删除角色")
//    public Envelop deleteRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            baseRoleService.deleteBaseRole(baseRoleDO);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//    private BaseRoleService baseRoleService;
//
////    @Autowired
////    private BaseRoleMenuService baseRoleMenuService;
//
////    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "创建角色", notes = "创建单个角色")
////    public Envelop createRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_create,baseRoleService.createBaseRole(baseRoleDO));
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "修改角色", notes = "修改角色")
////    public Envelop updateBaseRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_update,baseRoleService.updateBaseRole(baseRoleDO));
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "查询单个角色", notes = "根据角色id查询角色信息")
////    public Envelop getOneRoleById(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findById(baseRoleDO.getId()));
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getOne, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "查询单个角色", notes = "根据平台和角色名称查询角色信息")
////    public Envelop getOneRoleBySaasIdAndName(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findBySaasIdAndName(baseRoleDO.getName(),baseRoleDO.getSaasId()));
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getlistNoPage, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "查询多个角色", notes = "根据平台id查询所有角色信息,不分页")
////    public Envelop getRoleListBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
////            return Envelop.getSuccessList(BaseUserRequestMapping.BaseRole.message_success_find,baseRoleService.findAllBySaasId(baseRoleDO.getSaasId()));
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
//    @ApiOperation(value = "根据指定条件查询所有角色列表,分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseRole.api_getListPage)
//    public Envelop getRoleListPage(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,remark") @RequestParam(value = "fields", required = false) String fields,
//                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
//                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
//                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
//                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
//                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
//        if (StringUtils.isBlank(filters)) {
//            return Envelop.getError(BaseUserRequestMapping.BaseRole.message_fail_params_not_present, ExceptionCode.common_error_params_code);
//        } else {
//            filters = "status<>-1;" + filters;
//        }
//    }
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_deleteBySaasId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "批量删除角色", notes = "删除某一平台下所有角色信息")
//    public Envelop deleteRolesBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
//            baseRoleService.deleteBaseRolesBySaasId(baseRoleDO.getSaasId());
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        if (StringUtils.isBlank(sorts)) {
//            sorts = "-updateTime";
//        }
//    }
    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getRoleByPhoneAndSaasId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据phone和saasid获取role", notes = "根据phone和saasid获取role")
    public Envelop getPhoneAndSaasId(@ApiParam(name = "phone", value = "电话号码(账号)") @RequestParam(value = "phone", required = true) String phone,
                                     @ApiParam(name = "saasId", value = "saasId") @RequestParam(value = "saasId", required = true) String saasId){
        try{
            List<BaseRoleDO> result = baseRoleService.findByPhoneAndSaasId(phone,saasId);
            return Envelop.getSuccess("获取数据成功!",result);
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
//    @ApiOperation(value = "給角色添加菜单", notes = "給角色添加菜单")
//    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Envelop addMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
//                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
//        try{
//            String[] menuIdArray = menuIds.split(",");
//            List<BaseRoleMenuDO> list = new ArrayList<>();
//            for(String menuId:menuIdArray){
//                BaseRoleMenuDO baseRoleMenuDO = new BaseRoleMenuDO();
//                baseRoleMenuDO.setRoleId(roleId);
//                baseRoleMenuDO.setRoleId(menuId);
//            }
//            if(menuIdArray.length < 1){
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBaseRoleMenuDO(list.get(0)));
//            }else{
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBatchBaseRoleMenuDO(list));
//            }
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//
//        //得到list数据
//        List<BaseRoleVO> list = baseRoleService.search(fields, filters, sorts, page, size);
//
//    @ApiOperation(value = "修改角色菜单")
//    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_update)
//    public Envelop updateMenuForRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
//                                    @ApiParam(name = "newMenuId", value = "newMenuId", required = true) @RequestParam(value = "roleId", required = true) String newMenuId) {
//        try {
//            BaseRoleMenuDO baseEmployRoleDO = new BaseRoleMenuDO();
//            baseEmployRoleDO.setId(id);
//            baseEmployRoleDO.setMenuId(newMenuId);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.updateBaseEmployRoleDO(baseEmployRoleDO));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//        //获取总数
//        long count = baseRoleService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<BaseRoleVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseRoleVO.class, fields);
//
//    @ApiOperation(value = "查看角色菜单列表,不分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_getListNoPage)
//    public Envelop findMenuListForRole(@ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String roleId) {
//        try {
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.findAllByRoleId(roleId));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseRole.message_success_find, mFunctions, page, size, count);
//    }
//
//
//    @ApiOperation(value = "删除角色菜单", notes = "删除角色菜单")
//    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public Envelop deleteMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
//                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
////    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "删除角色", notes = "根据角色id删除角色")
////    public Envelop deleteRole(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
////            baseRoleService.deleteBaseRole(baseRoleDO);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_deleteBySaasId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "批量删除角色", notes = "删除某一平台下所有角色信息")
////    public Envelop deleteRolesBySaasId(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseRoleDO baseRoleDO = toEntity(jsonData,BaseRoleDO.class);
////            baseRoleService.deleteBaseRolesBySaasId(baseRoleDO.getSaasId());
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseRole.message_success_delete);
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
//    @PostMapping(value = BaseUserRequestMapping.BaseRole.api_getRoleByPhoneAndSaasId, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "根据phone和saasid获取role", notes = "根据phone和saasid获取role")
//    public Envelop getPhoneAndSaasId(@ApiParam(name = "phone", value = "电话号码(账号)") @RequestParam(value = "phone", required = true) String phone,
//                                     @ApiParam(name = "saasId", value = "saasId") @RequestParam(value = "saasId", required = true) String saasId){
//        try{
//            String[] menuIdArray = menuIds.split(",");
//            if(menuIdArray.length < 1){
//                this.baseRoleMenuService.deleteBaseRoleMenuDO(roleId,menuIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色单个菜单信息");
//            }else{
//                this.baseRoleMenuService.deleteBatchBaseRoleMenuDO(roleId,menuIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色多个菜单信息");
//            }
//            List<BaseRoleDO> result = baseRoleService.findByPhoneAndSaasId(phone,saasId);
//            return Envelop.getSuccess("获取数据成功!",result);
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
}
//
////    @ApiOperation(value = "給角色添加菜单", notes = "給角色添加菜单")
////    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    public Envelop addMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
////                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
////        try{
////            String[] menuIdArray = menuIds.split(",");
////            List<BaseRoleMenuDO> list = new ArrayList<>();
////            for(String menuId:menuIdArray){
////                BaseRoleMenuDO baseRoleMenuDO = new BaseRoleMenuDO();
////                baseRoleMenuDO.setRoleId(roleId);
////                baseRoleMenuDO.setRoleId(menuId);
////            }
////            if(menuIdArray.length < 1){
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBaseRoleMenuDO(list.get(0)));
////            }else{
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_create,this.baseRoleMenuService.createBatchBaseRoleMenuDO(list));
////            }
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
////
////
////    @ApiOperation(value = "修改角色菜单")
////    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_update)
////    public Envelop updateMenuForRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
////                                    @ApiParam(name = "newMenuId", value = "newMenuId", required = true) @RequestParam(value = "roleId", required = true) String newMenuId) {
////        try {
////            BaseRoleMenuDO baseEmployRoleDO = new BaseRoleMenuDO();
////            baseEmployRoleDO.setId(id);
////            baseEmployRoleDO.setMenuId(newMenuId);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.updateBaseEmployRoleDO(baseEmployRoleDO));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
////
////    @ApiOperation(value = "查看角色菜单列表,不分页")
////    @GetMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_getListNoPage)
////    public Envelop findMenuListForRole(@ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String roleId) {
////        try {
////            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.baseRoleMenuService.findAllByRoleId(roleId));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
////
////
////    @ApiOperation(value = "删除角色菜单", notes = "删除角色菜单")
////    @PostMapping(value = BaseUserRequestMapping.BaseRoleMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    public Envelop deleteMenuForRole(@ApiParam(name = "roleId", value = "", defaultValue = "") @RequestBody String roleId,
////                                  @ApiParam(name = "menuIds", value = "", defaultValue = "") @RequestBody String menuIds){
////        try{
////            String[] menuIdArray = menuIds.split(",");
////            if(menuIdArray.length < 1){
////                this.baseRoleMenuService.deleteBaseRoleMenuDO(roleId,menuIds);
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色单个菜单信息");
////            }else{
////                this.baseRoleMenuService.deleteBatchBaseRoleMenuDO(roleId,menuIds);
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseMenu.message_success_delete,"删除角色多个菜单信息");
////            }
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
//}

+ 180 - 180
svr/svr-base/src/main/java/com/yihu/jw/business/user/contorller/EmployController.java

@ -1,199 +1,199 @@
package com.yihu.jw.business.user.contorller;
import com.yihu.jw.base.base.FunctionDO;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseEmployRoleDO;
import com.yihu.jw.business.user.service.EmployService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.base.base.FunctionVO;
import com.yihu.jw.restmodel.base.user.BaseEmployVO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/11.
 */
@RestController
@RequestMapping(BaseUserRequestMapping.api_user_common)
@Api(description = "医生,行政人员等非患者用户(基础用户)")
public class EmployController extends EnvelopRestController {
    @Autowired
    private EmployService employService;
    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建用户", notes = "创建单个用户")
    public Envelop createBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
        try{
            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_create,employService.createBaseEmployDO(baseEmployDO));
        } catch (Exception e){
            return Envelop.getError(e.getMessage());
        }
    }
//    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "修改用户", notes = "修改用户")
//    public Envelop updateBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//package com.yihu.jw.business.user.contorller;
//
//import com.yihu.jw.base.base.FunctionDO;
//import com.yihu.jw.base.user.BaseEmployDO;
//import com.yihu.jw.base.user.BaseEmployRoleDO;
//import com.yihu.jw.business.user.service.EmployService;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.restmodel.base.base.FunctionVO;
//import com.yihu.jw.restmodel.base.user.BaseEmployVO;
//import com.yihu.jw.restmodel.common.Envelop;
//import com.yihu.jw.restmodel.common.EnvelopRestController;
//import com.yihu.jw.rm.base.BaseRequestMapping;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.text.ParseException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/11.
// */
//@RestController
//@RequestMapping(BaseUserRequestMapping.api_user_common)
//@Api(description = "医生,行政人员等非患者用户(基础用户)")
//public class EmployController extends EnvelopRestController {
//    @Autowired
//    private EmployService employService;
//
//    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    @ApiOperation(value = "创建用户", notes = "创建单个用户")
//    public Envelop createBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
//        try{
//            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_update,employService.updateBaseEmployDO(baseEmployDO));
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_create,employService.createBaseEmployDO(baseEmployDO));
//        } catch (Exception e){
//            return Envelop.getError(e.getMessage());
//        }
//    }
//
////    @PostMapping(value = BaseUserRequestMapping.BaseEmploy.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
////    @ApiOperation(value = "修改用户", notes = "修改用户")
////    public Envelop updateBaseEmployDO(@ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData){
////        try{
////            BaseEmployDO baseEmployDO = toEntity(jsonData,BaseEmployDO.class);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_update,employService.updateBaseEmployDO(baseEmployDO));
////        } catch (ApiException e){
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
//    @ApiOperation(value = "根据id查找用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getById)
//    public Envelop getEmployeeById(@ApiParam(name = "id", value = "id", required = true) @RequestParam(value = "id", required = true) String id) {
//        try{
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findById(id));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
    @ApiOperation(value = "根据id查找用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getById)
    public Envelop getEmployeeById(@ApiParam(name = "id", value = "id", required = true) @RequestParam(value = "id", required = true) String id) {
        try{
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findById(id));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据saasId查找所有用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListBySaasId)
    public Envelop getAllEmployeeBySaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
        try{
            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllBySaasId(saasId));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据手机号和saasId查找用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getByPhone)
    public Envelop getEmployeeByPhoneAndSaasId(@ApiParam(name = "phone", value = "phone", required = true) @RequestParam(value = "phone", required = true) String phone,
                                               @ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
        try {
            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employService.findByPhoneAndSaasId(phone,saasId));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据name模糊查询某saasId平台下的所有用户")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListByName)
    public Envelop getListByNameAndSaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId,
                                          @ApiParam(name = "name", value = "name", required = true) @RequestParam(value = "name", required = true) String name) {
        try{
            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllByNameAndSaasId(name,saasId));
        } catch (ApiException e){
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @ApiOperation(value = "根据指定条件查询用户列表,分页")
    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListNoPage)
    public Envelop getListPageByNameAndSaasId(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,sex,photo,skill,email,phone,family_tel,introduction,jxzc,lczc,xlzc,xzzc") @RequestParam(value = "fields", required = false) String fields,
                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
        if (StringUtils.isBlank(filters)) {
            return Envelop.getError(BaseUserRequestMapping.BaseEmploy.message_fail_params_not_present, ExceptionCode.common_error_params_code);
        } else {
            filters = "status<>-1;" + filters;
        }
        if (StringUtils.isBlank(sorts)) {
            sorts = "-updateTime";
        }
        //得到list数据
        List<BaseEmployVO> list = employService.search(fields, filters, sorts, page, size);
        //获取总数
        long count = employService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<BaseEmployVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseEmployVO.class, fields);
        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseEmploy.message_success_find, mFunctions, page, size, count);
    }
//    @ApiOperation(value = "给某一用户新增角色")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_create)
//    public Envelop createEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
//                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
//        try {
//            String[] roleIdArray = roleIds.split(",");
//            List<BaseEmployRoleDO> list = new ArrayList<>();
//            for (String roleId : roleIdArray) {
//                BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
//                baseEmployRoleDO.setEmployId(employId);
//                baseEmployRoleDO.setRoleId(roleId);
//                list.add(baseEmployRoleDO);
//            }
//            if (roleIdArray.length < 1) {
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBaseEmployRoleDO(list.get(0)));
//            }else{
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBatchBaseEmployRoleDO(list));
//            }
//        } catch (ApiException e) {
//
//    @ApiOperation(value = "根据saasId查找所有用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListBySaasId)
//    public Envelop getAllEmployeeBySaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
//        try{
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllBySaasId(saasId));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @ApiOperation(value = "修改用户角色")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_update)
//    public Envelop updateEmployRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
//                                    @ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String newRoleId) {
//
//
//    @ApiOperation(value = "根据手机号和saasId查找用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getByPhone)
//    public Envelop getEmployeeByPhoneAndSaasId(@ApiParam(name = "phone", value = "phone", required = true) @RequestParam(value = "phone", required = true) String phone,
//                                               @ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId) {
//        try {
//            BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
//            baseEmployRoleDO.setId(id);
//            baseEmployRoleDO.setRoleId(newRoleId);
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.updateBaseEmployRoleDO(baseEmployRoleDO));
//            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employService.findByPhoneAndSaasId(phone,saasId));
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @ApiOperation(value = "查看用户角色列表,不分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_getListNoPage)
//    public Envelop findEmployRoleList(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId) {
//        try {
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.findAllByEmployId(employId));
//        } catch (ApiException e) {
//
//    @ApiOperation(value = "根据name模糊查询某saasId平台下的所有用户")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListByName)
//    public Envelop getListByNameAndSaasId(@ApiParam(name = "saasId", value = "saasId", required = true) @RequestParam(value = "saasId", required = true) String saasId,
//                                          @ApiParam(name = "name", value = "name", required = true) @RequestParam(value = "name", required = true) String name) {
//        try{
//            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_find,this.employService.findAllByNameAndSaasId(name,saasId));
//        } catch (ApiException e){
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//        }
//    }
//    @ApiOperation(value = "删除用户角色")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_delete)
//    public Envelop deleteEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
//                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
//        try {
//            String[] idArray = roleIds.split(",");
//            if (idArray.length < 1) {
//                this.employRoleService.deleteBaseEmployRoleDO(employId,roleIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete,"删除单个角色");
//            }else{
//                this.employRoleService.deleteBatchBaseEmployRoleDO(employId,roleIds);
//                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, "删除多个角色");
//            }
//        } catch (ApiException e) {
//            return Envelop.getError(e.getMessage(), e.getErrorCode());
//
//    @ApiOperation(value = "根据指定条件查询用户列表,分页")
//    @GetMapping(value = BaseUserRequestMapping.BaseEmploy.api_getListNoPage)
//    public Envelop getListPageByNameAndSaasId(@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,name,sex,photo,skill,email,phone,family_tel,introduction,jxzc,lczc,xlzc,xzzc") @RequestParam(value = "fields", required = false) String fields,
//                                              @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
//                                              @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime") @RequestParam(value = "sorts", required = false) String sorts,
//                                              @ApiParam(name = "size", value = "分页大小", defaultValue = "15") @RequestParam(value = "size", required = false) int size,
//                                              @ApiParam(name = "page", value = "页码", defaultValue = "1") @RequestParam(value = "page", required = false) int page,
//                                              HttpServletRequest request, HttpServletResponse response) throws ParseException {
//        if (StringUtils.isBlank(filters)) {
//            return Envelop.getError(BaseUserRequestMapping.BaseEmploy.message_fail_params_not_present, ExceptionCode.common_error_params_code);
//        } else {
//            filters = "status<>-1;" + filters;
//        }
//        if (StringUtils.isBlank(sorts)) {
//            sorts = "-updateTime";
//        }
//
//        //得到list数据
//        List<BaseEmployVO> list = employService.search(fields, filters, sorts, page, size);
//
//        //获取总数
//        long count = employService.getCount(filters);
//        //封装头信息
//        pagedResponse(request, response, count, page, size);
//        //封装返回格式
//        List<BaseEmployVO> mFunctions = convertToModels(list, new ArrayList<>(list.size()), BaseEmployVO.class, fields);
//
//        return Envelop.getSuccessListWithPage(BaseUserRequestMapping.BaseEmploy.message_success_find, mFunctions, page, size, count);
//    }
}
//
//
////    @ApiOperation(value = "给某一用户新增角色")
////    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_create)
////    public Envelop createEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
////                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
////        try {
////            String[] roleIdArray = roleIds.split(",");
////            List<BaseEmployRoleDO> list = new ArrayList<>();
////            for (String roleId : roleIdArray) {
////                BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
////                baseEmployRoleDO.setEmployId(employId);
////                baseEmployRoleDO.setRoleId(roleId);
////                list.add(baseEmployRoleDO);
////            }
////            if (roleIdArray.length < 1) {
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBaseEmployRoleDO(list.get(0)));
////            }else{
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_find, this.employRoleService.createBatchBaseEmployRoleDO(list));
////            }
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @ApiOperation(value = "修改用户角色")
////    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_update)
////    public Envelop updateEmployRole(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String id,
////                                    @ApiParam(name = "roleId", value = "roleId", required = true) @RequestParam(value = "roleId", required = true) String newRoleId) {
////        try {
////            BaseEmployRoleDO baseEmployRoleDO = new BaseEmployRoleDO();
////            baseEmployRoleDO.setId(id);
////            baseEmployRoleDO.setRoleId(newRoleId);
////            return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.updateBaseEmployRoleDO(baseEmployRoleDO));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @ApiOperation(value = "查看用户角色列表,不分页")
////    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_getListNoPage)
////    public Envelop findEmployRoleList(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId) {
////        try {
////            return Envelop.getSuccessList(BaseUserRequestMapping.BaseEmploy.message_success_delete, this.employRoleService.findAllByEmployId(employId));
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//
////    @ApiOperation(value = "删除用户角色")
////    @GetMapping(value = BaseUserRequestMapping.BaseEmployRole.api_delete)
////    public Envelop deleteEmployRoles(@ApiParam(name = "employId", value = "employId", required = true) @RequestParam(value = "employId", required = true) String employId,
////                                     @ApiParam(name = "roleIds", value = "roleIds", required = true) @RequestParam(value = "roleIds", required = true) String roleIds) {
////        try {
////            String[] idArray = roleIds.split(",");
////            if (idArray.length < 1) {
////                this.employRoleService.deleteBaseEmployRoleDO(employId,roleIds);
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete,"删除单个角色");
////            }else{
////                this.employRoleService.deleteBatchBaseEmployRoleDO(employId,roleIds);
////                return Envelop.getSuccess(BaseUserRequestMapping.BaseEmploy.message_success_delete, "删除多个角色");
////            }
////        } catch (ApiException e) {
////            return Envelop.getError(e.getMessage(), e.getErrorCode());
////        }
////    }
//}

+ 31 - 31
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/BaseRoleDao.java

@ -1,31 +1,31 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseRoleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 */
public interface BaseRoleDao extends PagingAndSortingRepository<BaseRoleDO, String>, JpaSpecificationExecutor<BaseRoleDO> {
    @Query("from BaseRoleDO b where b.id = ?1")
    BaseRoleDO findOneById(String id);
    //角色与saasId为一对多关系
    @Query("from BaseRoleDO b where b.saasId = ?1")
    List<BaseRoleDO> findAllBySaasId(String saasId);
    @Query("from BaseRoleDO b where b.saasId = ?1 and b.name = ?2")
    BaseRoleDO findOneBySaasIdAndName(String saasId,String name);
    @Query("from BaseRoleDO b where b.name like %?1%")
    List<BaseRoleDO> findAllByName(String name);
    @Query(value="select b.* from base_role b,base_employ e,base_employ_role r where r.role_id=b.id and r.employ_id=e.id and e.phone= ?1 and e.saas_id= ?2",nativeQuery = true)
    List<BaseRoleDO> findByPhoneAndSaasId(String phone,String saasId);
}
//package com.yihu.jw.business.user.dao;
//
//import com.yihu.jw.base.user.BaseRoleDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// */
//public interface BaseRoleDao extends PagingAndSortingRepository<BaseRoleDO, String>, JpaSpecificationExecutor<BaseRoleDO> {
//
//
//    @Query("from BaseRoleDO b where b.id = ?1")
//    BaseRoleDO findOneById(String id);
//
//    //角色与saasId为一对多关系
//    @Query("from BaseRoleDO b where b.saasId = ?1")
//    List<BaseRoleDO> findAllBySaasId(String saasId);
//
//    @Query("from BaseRoleDO b where b.saasId = ?1 and b.name = ?2")
//    BaseRoleDO findOneBySaasIdAndName(String saasId,String name);
//
//    @Query("from BaseRoleDO b where b.name like %?1%")
//    List<BaseRoleDO> findAllByName(String name);
//
//    @Query(value="select b.* from base_role b,base_employ e,base_employ_role r where r.role_id=b.id and r.employ_id=e.id and e.phone= ?1 and e.saas_id= ?2",nativeQuery = true)
//    List<BaseRoleDO> findByPhoneAndSaasId(String phone,String saasId);
//}

+ 27 - 27
svr/svr-base/src/main/java/com/yihu/jw/business/user/dao/EmployDao.java

@ -1,27 +1,27 @@
package com.yihu.jw.business.user.dao;
import com.yihu.jw.base.user.BaseEmployDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/11/28.
 */
/**
 * 基础用户类接口
 */
public interface EmployDao extends PagingAndSortingRepository<BaseEmployDO, String>, JpaSpecificationExecutor<BaseEmployDO> {
    @Query("from BaseEmployDO ba where ba.saasId = ?1")
    List<BaseEmployDO> findAllBySaasId(String saasId);
    @Query("from BaseEmployDO ba where ba.name like ?1 and ba.saasId = ?2")
    List<BaseEmployDO> findAllByNameAndSaasId(String name,String saasId);
    @Query("from BaseEmployDO ba where ba.phone = ?1 and ba.saasId = ?2")
    BaseEmployDO findByPhoneAndSaasId(String phone,String saasId);
}
//package com.yihu.jw.business.user.dao;
//
//import com.yihu.jw.base.user.BaseEmployDO;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by chenweida on 2017/11/28.
// */
//
///**
// * 基础用户类接口
// */
//public interface EmployDao extends PagingAndSortingRepository<BaseEmployDO, String>, JpaSpecificationExecutor<BaseEmployDO> {
//
//    @Query("from BaseEmployDO ba where ba.saasId = ?1")
//    List<BaseEmployDO> findAllBySaasId(String saasId);
//
//    @Query("from BaseEmployDO ba where ba.name like ?1 and ba.saasId = ?2")
//    List<BaseEmployDO> findAllByNameAndSaasId(String name,String saasId);
//
//    @Query("from BaseEmployDO ba where ba.phone = ?1 and ba.saasId = ?2")
//    BaseEmployDO findByPhoneAndSaasId(String phone,String saasId);
//}

+ 182 - 182
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/BaseRoleService.java

@ -1,182 +1,182 @@
package com.yihu.jw.business.user.service;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.dao.BaseRoleDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * Created by LiTaohong on 2017/11/28.
 * 基础角色功能
 */
@Service
public class BaseRoleService extends BaseJpaService<BaseRoleDO,BaseRoleDao> {
    @Autowired
    private BaseRoleDao baseRoleDao;
    /**
     * 创建role
     * @param baseRoleDO
     * @return
     */
    @Transactional
    public BaseRoleDO createBaseRole(BaseRoleDO baseRoleDO){
        if (StringUtils.isEmpty(baseRoleDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getName())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseRoleDao.save(baseRoleDO);
    }
    /**
     * 更新role
     * @param baseRoleDO
     * @return
     */
    @Transactional
    public BaseRoleDO updateBaseRole(BaseRoleDO baseRoleDO){
        if (StringUtils.isEmpty(baseRoleDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        return this.baseRoleDao.save(baseRoleDO);
    }
    /**
     * 根据roleId查询role
     * @param id
     * @return
     */
    public BaseRoleDO findById(String id){
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneById(id);
        if (null == baseRoleDO) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
        }
        return baseRoleDO;
    }
    /**
     * 查询某要saasId平台下的所有role
     * @param saasId
     * @return
     */
    public List<BaseRoleDO> findAllBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 查找某一平台下某一个role
     * @param saasId
     * @param name
     * @return
     */
    public BaseRoleDO findBySaasIdAndName(String saasId,String name){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(name)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null,ExceptionCode.common_error_params_code);
        }
        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneBySaasIdAndName(name,saasId);
        if (null == baseRoleDO) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
        }
        return baseRoleDO;
    }
    /**
     * 根据name查询所有的role,包括不同平台saasid的
     * @param name
     * @return
     */
    public List<BaseRoleDO> getRoleListByName(String name){
        if (StringUtils.isEmpty(name)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_name_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseRoleDO> list = this.baseRoleDao.findAllByName(name);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 根据roleId删除role
     * @param baseRoleDO
     */
    @Transactional
    public void deleteBaseRole(BaseRoleDO baseRoleDO){
        if (StringUtils.isEmpty(baseRoleDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        baseRoleDO.setStatus(-1);
        this.baseRoleDao.save(baseRoleDO);
    }
    /**
     * 删除某一saasId相关的所有role
     * @param saasId
     */
    @Transactional
    public void deleteBaseRolesBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
        for(BaseRoleDO baseRoleDO:list){
            baseRoleDO.setStatus(-1);
        }
        this.baseRoleDao.save(list);
    }
    /**
     * 根据saasId和name删除角色
     * @param saasId
     * @param name
     */
    @Transactional
    public void deleteBaseRoleByNameAndSaasId(String saasId,String name){
        BaseRoleDO baseRoleDO = this.findBySaasIdAndName(saasId,name);
        baseRoleDO.setStatus(-1);
        this.baseRoleDao.save(baseRoleDO);
    }
    /**
     * 根据phone(账号)和saasId查询角色列表
     * @param phone
     * @param saasId
     * @return
     */
    public List<BaseRoleDO> findByPhoneAndSaasId(String phone,String saasId){
        return this.baseRoleDao.findByPhoneAndSaasId(phone,saasId);
    }
}
//package com.yihu.jw.business.user.service;
//
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.business.user.dao.BaseRoleDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import com.yihu.mysql.query.BaseJpaService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.List;
//
///**
// * Created by LiTaohong on 2017/11/28.
// * 基础角色功能
// */
//@Service
//public class BaseRoleService extends BaseJpaService<BaseRoleDO,BaseRoleDao> {
//    @Autowired
//    private BaseRoleDao baseRoleDao;
//
//    /**
//     * 创建role
//     * @param baseRoleDO
//     * @return
//     */
//    @Transactional
//    public BaseRoleDO createBaseRole(BaseRoleDO baseRoleDO){
//        if (StringUtils.isEmpty(baseRoleDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getName())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseRoleDao.save(baseRoleDO);
//    }
//
//    /**
//     * 更新role
//     * @param baseRoleDO
//     * @return
//     */
//    @Transactional
//    public BaseRoleDO updateBaseRole(BaseRoleDO baseRoleDO){
//        if (StringUtils.isEmpty(baseRoleDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.baseRoleDao.save(baseRoleDO);
//    }
//
//    /**
//     * 根据roleId查询role
//     * @param id
//     * @return
//     */
//    public BaseRoleDO findById(String id){
//        if (StringUtils.isEmpty(id)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneById(id);
//        if (null == baseRoleDO) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return baseRoleDO;
//    }
//
//    /**
//     * 查询某要saasId平台下的所有role
//     * @param saasId
//     * @return
//     */
//    public List<BaseRoleDO> findAllBySaasId(String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
//        }
//        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return list;
//    }
//
//    /**
//     * 查找某一平台下某一个role
//     * @param saasId
//     * @param name
//     * @return
//     */
//    public BaseRoleDO findBySaasIdAndName(String saasId,String name){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(name)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_name_is_null,ExceptionCode.common_error_params_code);
//        }
//        BaseRoleDO baseRoleDO = this.baseRoleDao.findOneBySaasIdAndName(name,saasId);
//        if (null == baseRoleDO) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return baseRoleDO;
//    }
//
//    /**
//     * 根据name查询所有的role,包括不同平台saasid的
//     * @param name
//     * @return
//     */
//    public List<BaseRoleDO> getRoleListByName(String name){
//        if (StringUtils.isEmpty(name)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_param_name_is_null,ExceptionCode.common_error_params_code);
//        }
//        List<BaseRoleDO> list = this.baseRoleDao.findAllByName(name);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_role_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return list;
//    }
//
//
//    /**
//     * 根据roleId删除role
//     * @param baseRoleDO
//     */
//    @Transactional
//    public void deleteBaseRole(BaseRoleDO baseRoleDO){
//        if (StringUtils.isEmpty(baseRoleDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(baseRoleDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        baseRoleDO.setStatus(-1);
//        this.baseRoleDao.save(baseRoleDO);
//    }
//
//    /**
//     * 删除某一saasId相关的所有role
//     * @param saasId
//     */
//    @Transactional
//    public void deleteBaseRolesBySaasId(String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseRole.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        List<BaseRoleDO> list = this.baseRoleDao.findAllBySaasId(saasId);
//        for(BaseRoleDO baseRoleDO:list){
//            baseRoleDO.setStatus(-1);
//        }
//        this.baseRoleDao.save(list);
//    }
//
//    /**
//     * 根据saasId和name删除角色
//     * @param saasId
//     * @param name
//     */
//    @Transactional
//    public void deleteBaseRoleByNameAndSaasId(String saasId,String name){
//        BaseRoleDO baseRoleDO = this.findBySaasIdAndName(saasId,name);
//        baseRoleDO.setStatus(-1);
//        this.baseRoleDao.save(baseRoleDO);
//    }
//
//    /**
//     * 根据phone(账号)和saasId查询角色列表
//     * @param phone
//     * @param saasId
//     * @return
//     */
//    public List<BaseRoleDO> findByPhoneAndSaasId(String phone,String saasId){
//        return this.baseRoleDao.findByPhoneAndSaasId(phone,saasId);
//    }
//}

+ 153 - 153
svr/svr-base/src/main/java/com/yihu/jw/business/user/service/EmployService.java

@ -1,154 +1,154 @@
package com.yihu.jw.business.user.service;
import com.yihu.jw.base.user.BaseEmployDO;
import com.yihu.jw.base.user.BaseRoleDO;
import com.yihu.jw.business.user.dao.EmployDao;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.restmodel.common.base.BaseEnvelopStatus;
import com.yihu.jw.rm.base.BaseUserRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.*;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import javax.servlet.Servlet;
import java.util.List;
/**
 * Created by chenweida on 2017/5/11.
 * 用户信息功能
 */
@Service
@EnableCaching
@CacheConfig(cacheNames = "employ")
public class EmployService extends BaseJpaService<BaseEmployDO,EmployDao> {
    @Autowired
    private EmployDao employDao;
    /**
     * 创建用户
     * @param employeeDO
     * @return
     */
    @Cacheable(value = "employ#600#300")
    @Transactional
    public BaseEmployDO createBaseEmployDO(BaseEmployDO employeeDO){
        if (StringUtils.isEmpty(employeeDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(employeeDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        return this.employDao.save(employeeDO);
    }
    /**
     * 更新用户
     * @param employeeDO
     * @return
     */
    @CachePut(value = "employ#600#300",key = "#employeeDO.id")
    @Transactional
    public BaseEmployDO updateBaseEmployDO(BaseEmployDO employeeDO){
        if (StringUtils.isEmpty(employeeDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(employeeDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        return this.employDao.save(employeeDO);
    }
    /**
     * 根据Id查询用户
     * @param id
     * @return
     */
//package com.yihu.jw.business.user.service;
//
//import com.yihu.jw.base.user.BaseEmployDO;
//import com.yihu.jw.base.user.BaseRoleDO;
//import com.yihu.jw.business.user.dao.EmployDao;
//import com.yihu.jw.exception.ApiException;
//import com.yihu.jw.exception.code.ExceptionCode;
//import com.yihu.jw.restmodel.common.base.BaseEnvelopStatus;
//import com.yihu.jw.rm.base.BaseUserRequestMapping;
//import com.yihu.mysql.query.BaseJpaService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cache.annotation.*;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.MultiValueMap;
//import org.springframework.util.StringUtils;
//
//import javax.servlet.Servlet;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/5/11.
// * 用户信息功能
// */
//
//@Service
//@EnableCaching
//@CacheConfig(cacheNames = "employ")
//public class EmployService extends BaseJpaService<BaseEmployDO,EmployDao> {
//    @Autowired
//    private EmployDao employDao;
//
//    /**
//     * 创建用户
//     * @param employeeDO
//     * @return
//     */
//    @Cacheable(value = "employ#600#300")
//    @Transactional
//    public BaseEmployDO createBaseEmployDO(BaseEmployDO employeeDO){
//        if (StringUtils.isEmpty(employeeDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(employeeDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.employDao.save(employeeDO);
//    }
//
//    /**
//     * 更新用户
//     * @param employeeDO
//     * @return
//     */
//    @CachePut(value = "employ#600#300",key = "#employeeDO.id")
//    @Transactional
//    public BaseEmployDO updateBaseEmployDO(BaseEmployDO employeeDO){
//        if (StringUtils.isEmpty(employeeDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(employeeDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        return this.employDao.save(employeeDO);
//    }
//
//    /**
//     * 根据Id查询用户
//     * @param id
//     * @return
//     */
////    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
//    public BaseEmployDO findById(String id){
//        if (StringUtils.isEmpty(id)) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null,ExceptionCode.common_error_params_code);
//        }
//        BaseEmployDO BaseEmployDO = this.employDao.findOne(id);
//        if (null == BaseEmployDO) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return BaseEmployDO;
//    }
//
//
//    /**
//     * 根据手机号和saasId查询用户,一个用户可能注册多个saas平台,所以根据手机号查找要限定saasId
//     * @param phone
//     * @param saasId
//     * @return
//     */
//    public BaseEmployDO findByPhoneAndSaasId(String phone,String saasId) throws ApiException{
//        BaseEmployDO BaseEmployDO = this.employDao.findByPhoneAndSaasId(phone,saasId);
//        if (null == BaseEmployDO) {
//            throw new ApiException(BaseEnvelopStatus.status_10100.getName(), BaseEnvelopStatus.status_10100.getCode());
//        }
//        return BaseEmployDO;
//    }
//
//    /**
//     * 查询某saasId平台下的所有用户
//     * @param saasId
//     * @return
//     */
//    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
    public BaseEmployDO findById(String id){
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null,ExceptionCode.common_error_params_code);
        }
        BaseEmployDO BaseEmployDO = this.employDao.findOne(id);
        if (null == BaseEmployDO) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_no_exist,ExceptionCode.common_error_params_code);
        }
        return BaseEmployDO;
    }
    /**
     * 根据手机号和saasId查询用户,一个用户可能注册多个saas平台,所以根据手机号查找要限定saasId
     * @param phone
     * @param saasId
     * @return
     */
    public BaseEmployDO findByPhoneAndSaasId(String phone,String saasId) throws ApiException{
        BaseEmployDO BaseEmployDO = this.employDao.findByPhoneAndSaasId(phone,saasId);
        if (null == BaseEmployDO) {
            throw new ApiException(BaseEnvelopStatus.status_10100.getName(), BaseEnvelopStatus.status_10100.getCode());
        }
        return BaseEmployDO;
    }
    /**
     * 查询某saasId平台下的所有用户
     * @param saasId
     * @return
     */
    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
    public List<BaseEmployDO> findAllBySaasId(String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseEmployDO> list = this.employDao.findAllBySaasId(saasId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 查询name模糊查询某saasId平台下的所有用户
     * @param saasId
     * @return
     */
    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
    public List<BaseEmployDO> findAllByNameAndSaasId(String name,String saasId){
        if (StringUtils.isEmpty(saasId)) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
        }
        List<BaseEmployDO> list = this.employDao.findAllByNameAndSaasId(name,saasId);
        if (null == list || list.size() == 0) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
        }
        return list;
    }
    /**
     * 根据Id删除用户
     * @param employDO
     */
    @CacheEvict(key = "#employDO.id")
    @Transactional
    public void deleteBaseEmploy(BaseEmployDO employDO){
        if (StringUtils.isEmpty(employDO.getId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
        }
        if (StringUtils.isEmpty(employDO.getSaasId())) {
            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
        }
        employDO.setStatus(-1);
        this.employDao.save(employDO);
    }
}
//    public List<BaseEmployDO> findAllBySaasId(String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
//        }
//        List<BaseEmployDO> list = this.employDao.findAllBySaasId(saasId);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return list;
//    }
//
//    /**
//     * 查询name模糊查询某saasId平台下的所有用户
//     * @param saasId
//     * @return
//     */
//    @Cacheable(value = "employ#600#300",key = "#employeeDO.id")
//    public List<BaseEmployDO> findAllByNameAndSaasId(String name,String saasId){
//        if (StringUtils.isEmpty(saasId)) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_param_saasid_is_null,ExceptionCode.common_error_params_code);
//        }
//        List<BaseEmployDO> list = this.employDao.findAllByNameAndSaasId(name,saasId);
//        if (null == list || list.size() == 0) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_no_exist,ExceptionCode.common_error_params_code);
//        }
//        return list;
//    }
//
//
//    /**
//     * 根据Id删除用户
//     * @param employDO
//     */
//    @CacheEvict(key = "#employDO.id")
//    @Transactional
//    public void deleteBaseEmploy(BaseEmployDO employDO){
//        if (StringUtils.isEmpty(employDO.getId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_id_is_null, ExceptionCode.common_error_params_code);
//        }
//        if (StringUtils.isEmpty(employDO.getSaasId())) {
//            throw new ApiException(BaseUserRequestMapping.BaseEmploy.message_fail_saasid_is_null, ExceptionCode.common_error_params_code);
//        }
//        employDO.setStatus(-1);
//        this.employDao.save(employDO);
//    }
//
//}

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/config/jpa/HibernateProperties.java

@ -26,8 +26,8 @@
//    private String physical_naming_strategy;
//    @Value("${hibernate.implicit_naming_strategy}")
//    private String implicit_naming_strategy;
//    @Autowired
//    private List<Interceptor> interceptors;
////    @Autowired
////    private List<Interceptor> interceptors;
//
//    public Properties hibProperties() {
//        Properties properties = new Properties();
@ -35,7 +35,7 @@
//        properties.put("hibernate.show_sql", show_sql);
//        properties.put("hibernate.physical_naming_strategy", physical_naming_strategy);
//        properties.put("hibernate.implicit_naming_strategy", implicit_naming_strategy);
//        properties.put("hibernate.ejb.interceptor", interceptors.get(0));
//        //properties.put("hibernate.ejb.interceptor", interceptors.get(0));
//        return properties;
//    }
//}

+ 0 - 1
svr/svr-base/src/main/resources/application.yml

@ -26,7 +26,6 @@ spring:
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
#  ejb:
#    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy #springJPA使用驼峰式(hibernate4以下使用)
  physical_naming_strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy #springJPA使用驼峰式(hibernate5以上使用)
  implicit_naming_strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl