Browse Source

Merge branch 'dev' of chenweida/jw2.0 into dev

chenweida 7 years ago
parent
commit
8eea3fc165

+ 0 - 191
svr/svr-base/src/main/java/com/yihu/jw/base/controller/base/FunctionController.java

@ -1,191 +0,0 @@
package com.yihu.jw.base.controller.base;
import com.yihu.jw.base.model.base.Function;
import com.yihu.jw.base.service.base.FunctionService;
import com.yihu.jw.base.service.base.ModuleFunService;
import com.yihu.jw.restmodel.base.base.BaseContants;
import com.yihu.jw.restmodel.base.base.MFunction;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
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(BaseContants.api_common)
@Api(value = "功能模块", description = "功能模块接口管理")
public class FunctionController extends EnvelopRestController {
    @Autowired
    private FunctionService functionService;
    @Autowired
    private ModuleFunService moduleFunService;
    @PostMapping(value = BaseContants.Function.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建功能", notes = "创建单个功能")
    public Envelop createFunction(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            Function function = toEntity(jsonData, Function.class);
            return Envelop.getSuccess(BaseContants.Function.message_success_create, functionService.createFunction(function));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = BaseContants.Function.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改功能", notes = "修改功能")
    public Envelop updateFunction(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            Function function = toEntity(jsonData, Function.class);
            return Envelop.getSuccess(BaseContants.Function.message_success_update, functionService.updateFunction(function));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = BaseContants.Function.api_delete)
    @ApiOperation(value = "删除功能", notes = "删除功能")
    public Envelop deleteFunction(
            @ApiParam(name = "codes", value = "codes")
            @PathVariable(value = "codes", required = true) String codes) {
        try {
            functionService.deleteFunction(codes);
            return Envelop.getSuccess(BaseContants.Function.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseContants.Function.api_getByCode)
    @ApiOperation(value = "根据code查找功能", notes = "根据code查找功能")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @PathVariable(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(BaseContants.Function.message_success_find, functionService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseContants.Function.api_getList, method = RequestMethod.GET)
    @ApiOperation(value = "获取父功能列表(分页)")
    public Envelop getFunctions(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,url,parentCode,status,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<Function> list = functionService.search(fields, filters, sorts, page, size);
        if(list!=null){
            for(Function func:list){//循环遍历,设置是否有子节点
                List<Function> children = functionService.getChildren(func.getCode());
                func.setChildren(children);
            }
        }
        //获取总数
        long count=functionService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MFunction> mFunctions = convertToModels(list, new ArrayList<>(list.size()), MFunction.class, fields);
        return Envelop.getSuccessListWithPage(BaseContants.Function.message_success_find_functions,mFunctions, page, size,count);
    }
    @GetMapping(value = BaseContants.Function.api_getListNoPage)
    @ApiOperation(value = "获取功能列表,并且封装成jstree,不分页")
    public Envelop getAppsNoPage(
            @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<Function> list = functionService.search(fields,filters,sorts);
        List<Object> functions = new ArrayList<>();
        if(list!=null){
            for(Function func:list){
                String code = func.getCode();
                func = functionService.getAllChildren(code);
                functions.add(func);
            }
        }
        //封装返回格式
        List<MFunction> mFunctions = convertToModels(functions, new ArrayList<>(functions.size()), MFunction.class, fields);
        return Envelop.getSuccessList(BaseContants.Function.message_success_find_functions,mFunctions);
    }
    @PutMapping(value = BaseContants.Function.api_assignFunction, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "给对应的模块分配功能")
    public Envelop assignModule(
            @ApiParam(name = "module_code", value = "module_code", defaultValue = "")
            @RequestParam String moduleCode,
            @ApiParam(name = "functionCodes", value = "功能的code,可以传多个,逗号分割", defaultValue = "")
            @RequestParam String functionCodes) {
        try {
            functionService.assignFunction(moduleCode,functionCodes);
            return Envelop.getSuccess(BaseContants.Function.message_success_assign_function);
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseContants.Function.api_getModuleFunctions, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询saas的模块")
    public Envelop getModuleFunctions(
            @ApiParam(name = "saas_code", value = "saas_code", defaultValue = "")
            @RequestParam String saasCode) {
        try {
            return Envelop.getSuccess(BaseContants.Function.message_success_find_functions_module,functionService.getModuleFunctions(saasCode));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =BaseContants.Function.api_getChildren )
    @ApiOperation(value="查找子节点")
    public Envelop getChildren(@PathVariable String code){
        List<Function> children = functionService.getChildren(code);
        return Envelop.getSuccess("查询成功",children);
    }
}

+ 0 - 103
svr/svr-base/src/main/java/com/yihu/jw/base/controller/sms/SmsController.java

@ -1,103 +0,0 @@
package com.yihu.jw.base.controller.sms;
import com.yihu.jw.base.model.sms.BaseSms;
import com.yihu.jw.base.service.sms.SmsService;
import com.yihu.jw.restmodel.base.sms.BaseSmsContants;
import com.yihu.jw.restmodel.base.sms.MSms;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
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(BaseSmsContants.Sms.api_common)
@Api(value = "短信模块", description = "短信模块接口管理")
public class SmsController extends EnvelopRestController {
    @Autowired
    private SmsService smsService;
    @PostMapping(value = BaseSmsContants.Sms.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建短信", notes = "创建单个短信")
    public Envelop createSms(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            BaseSms sms = toEntity(jsonData, BaseSms.class);
            return Envelop.getSuccess(BaseSmsContants.Sms.message_success_create, smsService.createSms(sms));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = BaseSmsContants.Sms.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改短信", notes = "修改短信")
    public Envelop updateSms(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            BaseSms sms = toEntity(jsonData, BaseSms.class);
            return Envelop.getSuccess(BaseSmsContants.Sms.message_success_update, smsService.updateSms(sms));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseSmsContants.Sms.api_getSmss, method = RequestMethod.GET)
    @ApiOperation(value = "获取短信列表(分页)")
    public Envelop getSmss(
            @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<BaseSms> list = smsService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=smsService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MSms> mSmss = convertToModels(list, new ArrayList<>(list.size()), MSms.class, fields);
        return Envelop.getSuccessListWithPage(BaseSmsContants.Sms.message_success_find_smss,mSmss, page, size,count);
    }
    @GetMapping(value = BaseSmsContants.Sms.api_getSmssNoPage)
    @ApiOperation(value = "获取短信列表,不分页")
    public Envelop getAppsNoPage(
            @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<BaseSms> list = smsService.search(fields,filters,sorts);
        //封装返回格式
        List<MSms> mSmss = convertToModels(list, new ArrayList<>(list.size()), MSms.class, fields);
        return Envelop.getSuccessList(BaseSmsContants.Sms.message_success_find_smss,mSmss);
    }
}

+ 0 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/dao/sms/SmsDao.java

@ -1,21 +0,0 @@
package com.yihu.jw.base.dao.sms;
import com.yihu.jw.base.model.sms.BaseSms;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/22.
 */
public interface SmsDao extends PagingAndSortingRepository<BaseSms, Long>, JpaSpecificationExecutor<BaseSms> {
    @Query("from Function f where f.name=?1 and f.status=1")
    BaseSms findByName(String name);
    @Query("from Function f where f.name=?1 and f.status=1 and f.code != ?2")
    BaseSms findByNameExcludeCode(String name, String code);
    @Query("from Function f where f.code=?1 and f.status=1")
    BaseSms findByCode(String code);
}

+ 0 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/dao/sms/SmsGatewayDao.java

@ -1,21 +0,0 @@
package com.yihu.jw.base.dao.sms;
import com.yihu.jw.base.model.sms.BaseSms;
import com.yihu.jw.base.model.sms.BaseSmsGateway;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/22.
 */
public interface SmsGatewayDao extends PagingAndSortingRepository<BaseSmsGateway, Long>, JpaSpecificationExecutor<BaseSmsGateway> {
    @Query("from BaseSmsGateway f where f.name=?1 and f.status=1")
    BaseSmsGateway findByName(String name);
    @Query("from BaseSmsGateway f where f.name=?1 and f.status=1 and f.code != ?2")
    BaseSmsGateway findByNameExcludeCode(String name, String code);
    @Query("from BaseSmsGateway f where f.code=?1 and f.status=1")
    BaseSmsGateway findByCode(String code);
}

+ 0 - 146
svr/svr-base/src/main/java/com/yihu/jw/base/model/sms/BaseSms.java

@ -1,146 +0,0 @@
package com.yihu.jw.base.model.sms;// default package
import com.yihu.jw.base.model.IdEntity;
import java.sql.Timestamp;
import java.util.Date;
import javax.persistence.*;
/**
 * BaseSms entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "base_sms")
public class BaseSms extends IdEntity implements java.io.Serializable {
	// Fields
	private String saasId;	//saasid 关联base_saas code
	private String mobile;	//电话号码
	private String ip;	//发送短信的ip地址
	private Integer type;	//发送短信的类别
	private String captcha;	//验证码 1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录
	private String content;	// 短信内容
	private Date deadline;	//过期时间
	private Integer status;	//短信状态 状态,0未发送,1已发送
	private Date czrq; //操作时间
	// Constructors
	/** default constructor */
	public BaseSms() {
	}
	/** minimal constructor */
	public BaseSms(String mobile, String ip, Integer type, String captcha,
			String content, Timestamp deadline, Integer status, Timestamp czrq) {
		this.mobile = mobile;
		this.ip = ip;
		this.type = type;
		this.captcha = captcha;
		this.content = content;
		this.deadline = deadline;
		this.status = status;
		this.czrq = czrq;
	}
	/** full constructor */
	public BaseSms(String saasId, String mobile, String ip, Integer type,
			String captcha, String content, Timestamp deadline, Integer status,
			Timestamp czrq) {
		this.saasId = saasId;
		this.mobile = mobile;
		this.ip = ip;
		this.type = type;
		this.captcha = captcha;
		this.content = content;
		this.deadline = deadline;
		this.status = status;
		this.czrq = czrq;
	}
	@Column(name = "saas_id", length = 64)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "mobile", nullable = false, length = 20)
	public String getMobile() {
		return this.mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	@Column(name = "ip", nullable = false, length = 20)
	public String getIp() {
		return this.ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	@Column(name = "type", nullable = false)
	public Integer getType() {
		return this.type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	@Column(name = "captcha", nullable = false, length = 10)
	public String getCaptcha() {
		return this.captcha;
	}
	public void setCaptcha(String captcha) {
		this.captcha = captcha;
	}
	@Column(name = "content", nullable = false, length = 500)
	public String getContent() {
		return this.content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "deadline", nullable = false, length = 0)
	public Date getDeadline() {
		return this.deadline;
	}
	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}
	@Column(name = "status", nullable = false)
	public Integer getStatus() {
		return this.status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "czrq", nullable = false, length = 0)
	public Date getCzrq() {
		return this.czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 0 - 133
svr/svr-base/src/main/java/com/yihu/jw/base/model/sms/BaseSmsGateway.java

@ -1,133 +0,0 @@
package com.yihu.jw.base.model.sms;// default package
import com.yihu.jw.base.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * BaseSmsGateway entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "base_sms_gateway")
public class BaseSmsGateway  extends IdEntity implements java.io.Serializable {
	// Fields
	private String code; //业务code
	private String name;//名称
	private String saasId; //关联 base_saas code
	private String orgCode; //机构code
	private String ip; // 短信接口的ip地址
	private String username;  //短信接口的账号
	private String password;	//短信接口的密码
	private String url;	//短信接口的url
	private Integer status;// -1 删除 0 禁用 可用
	// Constructors
	/** default constructor */
	public BaseSmsGateway() {
	}
	/** minimal constructor */
	public BaseSmsGateway(Long id) {
		this.id = id;
	}
	/** full constructor */
	public BaseSmsGateway(Long id, String code, String saasId,
			String orgCode, String ip, String username, String password,
			String url) {
		this.id = id;
		this.code = code;
		this.saasId = saasId;
		this.orgCode = orgCode;
		this.ip = ip;
		this.username = username;
		this.password = password;
		this.url = url;
	}
	@Column(name = "code", length = 64)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "saas_id", length = 64)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "org_code", length = 64)
	public String getOrgCode() {
		return this.orgCode;
	}
	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	@Column(name = "ip", length = 20)
	public String getIp() {
		return this.ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	@Column(name = "username", length = 20)
	public String getUsername() {
		return this.username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	@Column(name = "password", length = 50)
	public String getPassword() {
		return this.password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@Column(name = "url", length = 200)
	public String getUrl() {
		return this.url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
}

+ 0 - 155
svr/svr-base/src/main/java/com/yihu/jw/base/service/base/FunctionService.java

@ -1,155 +0,0 @@
package com.yihu.jw.base.service.base;
import com.yihu.jw.base.dao.base.FunctionDao;
import com.yihu.jw.base.dao.base.ModuleFunctionDao;
import com.yihu.jw.base.model.base.Function;
import com.yihu.jw.base.model.base.ModuleFunction;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.base.base.BaseContants;
import com.yihu.jw.restmodel.base.base.MFunction;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
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<Function, FunctionDao> {
    @Autowired
    private FunctionDao functionDao;
    @Autowired
    private ModuleFunctionDao moduleFunctionDao;
    @Autowired
    private ModuleFunService moduleFunService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public Function createFunction(Function function) throws ApiException {
        if (StringUtils.isEmpty(function.getCode())) {
            throw new ApiException(BaseContants.Function.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(function.getName())) {
            throw new ApiException(BaseContants.Function.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        Function functionTmp = functionDao.findByName(function.getName());
        if (functionTmp != null) {
            throw new ApiException(BaseContants.Function.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return functionDao.save(function);
    }
    @Transactional
    public Function updateFunction(Function function) {
        if (StringUtils.isEmpty(function.getCode())) {
            throw new ApiException(BaseContants.Function.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(function.getName())) {
            throw new ApiException(BaseContants.Function.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(function.getId())) {
            throw new ApiException(BaseContants.Function.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        Function functionTmp = functionDao.findByNameExcludeCode(function.getName(), function.getCode());
        if (functionTmp != null) {
            throw new ApiException(BaseContants.Function.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return functionDao.save(function);
    }
    public Function findByCode(String code) {
        Function function = functionDao.findByCode(code);
        if (function == null) {
            throw new ApiException(BaseContants.Function.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return function;
    }
    @Transactional
    public void deleteFunction(String code) {
        Function function = functionDao.findByCode(code);
        if (function == null) {
            throw new ApiException(BaseContants.Function.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        function.setStatus(-1);
        functionDao.save(function);
    }
    @Transactional
    public void assignFunction(String moduleCode, String functionCodes) {
        //先删除原来已经分配好的功能
        moduleFunctionDao.deleteByModuleCode(moduleCode);
        //分配新的功能
        String [] functionCodeArr=functionCodes.split(",");
        List<ModuleFunction> saasModuleList=new ArrayList<>();
        for(String functionCode:functionCodeArr){
            ModuleFunction saasModule=new ModuleFunction();
            saasModule.setModuleId(moduleCode);
            saasModule.setFunctionId(functionCode);
            saasModuleList.add(saasModule);
        }
        moduleFunctionDao.save(saasModuleList);
    }
    public List<MFunction> getModuleFunctions(String saasCode) {
        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,MFunction.class,saasCode);
    }
    /**
     * 根据code获得子节点,并判断是否子节点是否还有孙节点 (treegrid点击查询子节点 用到)
     * @param code
     * @return
     */
    public List<Function> getChildren(String code){
        List<Function> childrens = functionDao.getChildren(code);
        for(Function children:childrens){
            List<Function> children1 = functionDao.getChildren(children.getCode());//判断子节点是否有孙节点
            children.setChildren(children1);
        }
        return childrens;
    }
    public List<Function> findAll(){
        return functionDao.findAll();
    }
    /**
     * key为code ,value为功能名称
     * @return
     */
    public Map<String,String> getName(){
        List<Function> functions = findAll();
        Map<String, String> map = new HashMap<>();
        if(null!=functions){
            for(Function function: functions){
                map.put(function.getCode(),function.getName());
            }
        }
        return map;
    }
    /**
     * 根据code获取所有子节点(包括孙节点,曾孙节点....)
     * @param code
     * @return
     */
    public Function getAllChildren(String code){
        Function function = functionDao.findByCode(code);
        List<Function> childrens = functionDao.getChildren(code);
        for(Function children:childrens){
            getAllChildren(children.getCode());
        }
        function.setChildren(childrens);
        return function;
    }
}

+ 0 - 71
svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsGatewayService.java

@ -1,71 +0,0 @@
package com.yihu.jw.base.service.sms;
import com.yihu.jw.base.dao.sms.SmsGatewayDao;
import com.yihu.jw.base.model.sms.BaseSmsGateway;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.base.sms.BaseSmsContants;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
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/22.
 */
@Service
public class SmsGatewayService extends BaseJpaService<BaseSmsGateway, SmsGatewayDao> {
    @Autowired
    private SmsGatewayDao smsGatewayDao;
    @Transactional
    public BaseSmsGateway createSmsGateway(BaseSmsGateway smsGateway) throws ApiException {
        if (StringUtils.isEmpty(smsGateway.getCode())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        BaseSmsGateway smsGatewayTmp = smsGatewayDao.findByName(smsGateway.getName());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
    @Transactional
    public BaseSmsGateway updateSmsGateway(BaseSmsGateway smsGateway) {
        if (StringUtils.isEmpty(smsGateway.getCode())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getId())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        BaseSmsGateway smsGatewayTmp = smsGatewayDao.findByNameExcludeCode(smsGateway.getName(), smsGateway.getCode());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
    public BaseSmsGateway findByCode(String code) {
        BaseSmsGateway smsGateway = smsGatewayDao.findByCode(code);
        if (smsGateway == null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return smsGateway;
    }
    @Transactional
    public void deleteSmsGateway(String code) {
        BaseSmsGateway smsGateway = smsGatewayDao.findByCode(code);
        if (smsGateway == null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        smsGateway.setStatus(-1);
    }
}

+ 0 - 29
svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsService.java

@ -1,29 +0,0 @@
package com.yihu.jw.base.service.sms;
import com.yihu.jw.base.dao.sms.SmsDao;
import com.yihu.jw.base.model.sms.BaseSms;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * Created by chenweida on 2017/5/22.
 */
@Service
public class SmsService  extends BaseJpaService<BaseSms, SmsDao>{
    @Autowired
    private SmsDao smsDao;
    @Transactional
    public BaseSms createSms(BaseSms sms) throws ApiException {
        return smsDao.save(sms);
    }
    @Transactional
    public BaseSms updateSms(BaseSms sms) {
        return smsDao.save(sms);
    }
}

+ 0 - 117
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dict/SystemDict.java

@ -1,117 +0,0 @@
package com.yihu.jw.quota.model.jpa.dict;// default package
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
/**
 * SystemDict entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "system_dict")
public class SystemDict implements java.io.Serializable {
	// Fields
	private Integer id;
	private String saasId;
	private String dictName;
	private String code;
	private String value;
	private String pyCode;
	private Integer sort;
	// Constructors
	/** default constructor */
	public SystemDict() {
	}
	/** minimal constructor */
	public SystemDict(String dictName, String code, String value) {
		this.dictName = dictName;
		this.code = code;
		this.value = value;
	}
	/** full constructor */
	public SystemDict(String saasId, String dictName, String code,
			String value, String pyCode, Integer sort) {
		this.saasId = saasId;
		this.dictName = dictName;
		this.code = code;
		this.value = value;
		this.pyCode = pyCode;
		this.sort = sort;
	}
	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "saas_id", length = 100)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "dict_name", nullable = false, length = 50)
	public String getDictName() {
		return this.dictName;
	}
	public void setDictName(String dictName) {
		this.dictName = dictName;
	}
	@Column(name = "code", nullable = false, length = 50)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "value", nullable = false, length = 50)
	public String getValue() {
		return this.value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	@Column(name = "py_code", length = 50)
	public String getPyCode() {
		return this.pyCode;
	}
	public void setPyCode(String pyCode) {
		this.pyCode = pyCode;
	}
	@Column(name = "sort")
	public Integer getSort() {
		return this.sort;
	}
	public void setSort(Integer sort) {
		this.sort = sort;
	}
}

+ 0 - 152
svr/svr-quota/src/main/java/com/yihu/jw/quota/model/jpa/dict/SystemDictList.java

@ -1,152 +0,0 @@
package com.yihu.jw.quota.model.jpa.dict;// default package
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
 * SystemDictList entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "system_dict_list")
public class SystemDictList implements java.io.Serializable {
	// Fields
	private Integer id;
	private String dictName;
	private String chineseName;
	private String pyCode;
	private String pid;
	private String remark;
	private String relationTable;
	private String relationColCode;
	private String relationColValue;
	private String relationColExtend;
	// Constructors
	/** default constructor */
	public SystemDictList() {
	}
	/** minimal constructor */
	public SystemDictList(Integer id, String dictName, String chineseName,
			String pid) {
		this.id = id;
		this.dictName = dictName;
		this.chineseName = chineseName;
		this.pid = pid;
	}
	/** full constructor */
	public SystemDictList(Integer id, String dictName, String chineseName,
			String pyCode, String pid, String remark, String relationTable,
			String relationColCode, String relationColValue,
			String relationColExtend) {
		this.id = id;
		this.dictName = dictName;
		this.chineseName = chineseName;
		this.pyCode = pyCode;
		this.pid = pid;
		this.remark = remark;
		this.relationTable = relationTable;
		this.relationColCode = relationColCode;
		this.relationColValue = relationColValue;
		this.relationColExtend = relationColExtend;
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "dict_name", nullable = false, length = 50)
	public String getDictName() {
		return this.dictName;
	}
	public void setDictName(String dictName) {
		this.dictName = dictName;
	}
	@Column(name = "chinese_name", nullable = false, length = 50)
	public String getChineseName() {
		return this.chineseName;
	}
	public void setChineseName(String chineseName) {
		this.chineseName = chineseName;
	}
	@Column(name = "py_code", length = 50)
	public String getPyCode() {
		return this.pyCode;
	}
	public void setPyCode(String pyCode) {
		this.pyCode = pyCode;
	}
	@Column(name = "pid", nullable = false, length = 50)
	public String getPid() {
		return this.pid;
	}
	public void setPid(String pid) {
		this.pid = pid;
	}
	@Column(name = "remark", length = 200)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	@Column(name = "relation_table", length = 50)
	public String getRelationTable() {
		return this.relationTable;
	}
	public void setRelationTable(String relationTable) {
		this.relationTable = relationTable;
	}
	@Column(name = "relation_col_code", length = 50)
	public String getRelationColCode() {
		return this.relationColCode;
	}
	public void setRelationColCode(String relationColCode) {
		this.relationColCode = relationColCode;
	}
	@Column(name = "relation_col_value", length = 50)
	public String getRelationColValue() {
		return this.relationColValue;
	}
	public void setRelationColValue(String relationColValue) {
		this.relationColValue = relationColValue;
	}
	@Column(name = "relation_col_extend", length = 50)
	public String getRelationColExtend() {
		return this.relationColExtend;
	}
	public void setRelationColExtend(String relationColExtend) {
		this.relationColExtend = relationColExtend;
	}
}

web-gateway/src/main/java/com/yihu/jw/config/mvc/SwaggerConfig.java → web-gateway/src/main/java/com/yihu/jw/config/SwaggerConfig.java