svn to git

0 parents
Showing 37 changed files with 1738 additions and 0 deletions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rop</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rop-dj-business-school-miniprogram</artifactId>
<version>1.0-SNAPSHOT</version>
<name>rop-dj-business-school-miniprogram</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rop-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.scrm</groupId>
<artifactId>rpc-scrm-proxy-api</artifactId>
<version>4.50.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-smartcarlife-api</artifactId>
<version>4.51.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-business-school-api</artifactId>
<version>4.51.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.com.glsx.dj.rop.business.school.miniprogram;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* @Title: Main.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.config;
import cn.com.glsx.dj.rop.business.school.miniprogram.interceptor.OperateLogAutoSaveInterceptor;
import cn.com.glsx.dj.rop.business.school.miniprogram.interceptor.ThreadLocalCacheInterceptor;
import cn.com.glsx.dj.smartcarlife.remote.OperationLogRemote;
import com.rop.RopServlet;
import com.rop.config.InterceptorHolder;
import org.oreframework.boot.autoconfigure.rop.metadata.RopProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnClass({RopServlet.class})
@EnableConfigurationProperties({RopProperty.class})
public class OperaeLogAutoConfigure {
@Autowired
private OperationLogRemote operationLogRemote;
@Autowired
private RopProperty ropProperty;
@Bean
public InterceptorHolder threadLocalCacheInterceptor() {
return new InterceptorHolder(new ThreadLocalCacheInterceptor());
}
@Bean
public InterceptorHolder operateLogAutoSaveInterceptor() {
OperateLogAutoSaveInterceptor operateLogAutoSaveInterceptor = new OperateLogAutoSaveInterceptor(
operationLogRemote,ropProperty);
InterceptorHolder interceptorHolder = new InterceptorHolder(operateLogAutoSaveInterceptor);
return interceptorHolder;
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: SystemProperty.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Configuration
@ConfigurationProperties("system")
public class SystemProperty {
// 对应配置项:system.name
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.config.dubbo;
import cn.com.glsx.dj.businessschool.remote.TeachTaskRecordRemote;
import cn.com.glsx.dj.businessschool.remote.staff.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class BusinessSchoolDubboConfig extends DubboConfig{
@Bean
public StaffPerformanceConfigRemote staffPerformanceConfigRemote(){
return factory.builder(StaffPerformanceConfigRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public StaffPerformanceInfoRemote staffPerformanceInfoRemote(){
return factory.builder(StaffPerformanceInfoRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public MentorPerformanceConfigRemote mentorPerformanceConfigRemote(){
return factory.builder(MentorPerformanceConfigRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public StaffPerformanceResultSnapshotRemote staffPerformanceResultSnapshotRemote(){
return factory.builder(StaffPerformanceResultSnapshotRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public StaffOrderPerformanceDetailRemote staffOrderPerformanceDetailRemote(){
return factory.builder(StaffOrderPerformanceDetailRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public TeachTaskRecordRemote TeachTaskRecordRemote(){
return factory.builder(TeachTaskRecordRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.config.dubbo;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
/**
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
@Autowired
protected ReferenceBuilderFactory factory;
protected final boolean check = false;
protected final int timeout = 30000;
/**
* 注册远程服务(示例)
* RpcRemote为需要调用的远程服务
* @return
*/
/*@Bean
public RpcRemote rpcApiMethodRemote(){
return factory.builder(RpcRemote.class).check(false).timeout(30000).build();
}*/
}
package cn.com.glsx.dj.rop.business.school.miniprogram.config.dubbo;
import cn.com.glsx.dj.smartcarlife.remote.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SmartCarLifeDubboConfig extends DubboConfig {
@Bean
public ServiceMerchantRefRemote serviceMerchantRefRemote(){
return factory.builder(ServiceMerchantRefRemote.class).timeout(timeout).check(check).build();
}
@Bean
public SceneMerchantRefRemote sceneMerchantRefRemote(){
return factory.builder(SceneMerchantRefRemote.class).check(check).timeout(timeout).build();
}
@Bean
public YqMerchantConfigRemote yqMerchantConfigRemote(){
return factory.builder(YqMerchantConfigRemote.class).check(check).timeout(timeout).build();
}
@Bean
public MerchantServiceCenterRemote merchantServiceCenterRemote(){
return factory.builder(MerchantServiceCenterRemote.class).protocol("dubbo").check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public MerchantSubRefRemote merchantSubRefRemote(){
return factory.builder(MerchantSubRefRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public OperationLogRemote operationLogRemote(){
return factory.builder(OperationLogRemote.class).timeout(timeout).check(check).version("1.0.0").build();
}
@Bean
public ServiceMerchantStaffAllocationRemote serviceMerchantStaffAllocationRemote(){
return factory.builder(ServiceMerchantStaffAllocationRemote.class).check(check).version("1.0.0").timeout(timeout).build();
}
@Bean
public ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote(){
return factory.builder(ShopMerchantDirectorConfigRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public ServiceMerchantRemote serviceMerchantRemote(){
return factory.builder(ServiceMerchantRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public SalesMerchantRelationRemote salesMerchantRelationRemote(){
return factory.builder(SalesMerchantRelationRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
@Bean
public StaffBaseInfoRemote staffBaseInfoRemote(){
return factory.builder(StaffBaseInfoRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.controller;
import cn.com.glsx.dj.carboutique.response.LoginUserInfoResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.request.ExampleRequest;
import cn.com.glsx.dj.rop.business.school.miniprogram.request.LoginRequest;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.ExampleResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.LoginResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.RopResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.util.CommonUtil;
import com.alibaba.fastjson.JSON;
import com.rop.AbstractRopRequest;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import com.rop.session.SimpleSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.UUID;
/**
* @Title: ExampleController.java
* @Description:
* @author Alvin
* @date 2019年9月2日 下午3:27:41
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class ExampleController
{
/**
* logger
*/
protected final Logger logger = LoggerFactory.getLogger(getClass());
/**
* 接口例子
*
* @param req ExampleRequest
* @return Object
* @throws Exception 异常
*/
@ServiceMethod(method = "org.ore.api.example", needInSession = NeedInSessionType.YES)
public RopResponse<ExampleResponse> getExample(ExampleRequest req)
throws Exception
{
ExampleResponse response = new ExampleResponse();
LoginUserInfoResponse loginUserInfo = CommonUtil.getLoginUserInfo();
System.out.println(JSON.toJSONString(loginUserInfo));
response.setField1("Ni Hao");
response.setField2(CommonUtil.getAccountName());
return RopResponse.success(response);
}
/**
* 会话示例
* @param request
* @return
* @throws Exception
* @author Alvin
* @date 2019年9月22日 下午3:31:25
*/
@ServiceMethod(method = "org.ore.api.example.insession", needInSession = NeedInSessionType.YES)
public RopResponse<ExampleResponse> getExampleInSession(ExampleRequest request) throws Exception{
return getExample(request);
}
/**
* 登录示例
* @param request
* @return
* @author Alvin
* @date 2019年9月22日 下午3:51:53
*/
@ServiceMethod(method = "org.ore.api.example.login", needInSession = NeedInSessionType.NO)
public RopResponse<LoginResponse> login(LoginRequest request){
// 创建会话
SimpleSession session = new SimpleSession();
session.setAttribute("userName", request.getUserName());
String sessionId = UUID.randomUUID().toString();
request.getRopRequestContext().addSession(sessionId, session);
LoginResponse response = new LoginResponse();
response.setSessionId(sessionId);
return RopResponse.success(response);
}
/**
* 登出示例
* @param request
* @return
* @author Alvin
* @date 2019年9月22日 下午3:53:24
*/
@ServiceMethod(method = "org.ore.api.example.logout", needInSession = NeedInSessionType.NO)
public RopResponse<Boolean> logout(AbstractRopRequest request){
// 删除会话
request.getRopRequestContext().removeSession();
return RopResponse.success(true);
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.controller;
import cn.com.glsx.dj.businessschool.dto.TeachTaskRecordDTO;
import cn.com.glsx.dj.businessschool.remote.TeachTaskRecordRemote;
import cn.com.glsx.dj.carboutique.response.LoginUserInfoResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.convert.TeachTaskConvert;
import cn.com.glsx.dj.rop.business.school.miniprogram.request.TeachTaskRecordQueryRequest;
import cn.com.glsx.dj.rop.business.school.miniprogram.request.TeachTaskRecordUpdateRequest;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.TeachTaskNumResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.TeachTaskResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.util.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.rop.AbstractRopRequest;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import javax.annotation.Resource;
/**
* @ClassName TeachTaskRecordMiniController
* @Description 小程序段带教任务管理
* @Author lqWang
* @Date 2025/4/3 11:39
*/
@Slf4j
@Api("小程序带教管理任务")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
public class TeachTaskRecordMiniController {
@Resource
private TeachTaskRecordRemote teachTaskRecordRemote;
@ApiOperation("带教任务数目统计")
@ServiceMethod(method = "dj.api.businessSchool.miniProgram.teachTask.count", needInSession = NeedInSessionType.YES)
public RopResponse<TeachTaskNumResponse> countTeachTask(AbstractRopRequest request) {
TeachTaskRecordDTO condition = CommonUtil.convertRequest(TeachTaskRecordDTO.class);
LoginUserInfoResponse loginUserInfo = CommonUtil.getLoginUserInfo();
if( ObjectUtil.isNotNull(loginUserInfo) && !loginUserInfo.getIsSuper()){
condition.setFlightSupervisorPhone(loginUserInfo.getPhone());
}
return CommonUtil.convertRopResponse(teachTaskRecordRemote.countTeachTask(condition), TeachTaskConvert.INSTANCE::toTeachTaskNumResponse);
}
@ApiOperation("带教任务分页查询")
@ServiceMethod(method = "dj.api.businessSchool.miniProgram.teachTask.page", needInSession = NeedInSessionType.YES)
public RopResponse<RpcPagination<TeachTaskResponse>> teachTaskPage(TeachTaskRecordQueryRequest request) {
RpcPagination<TeachTaskRecordDTO> rpcPagination = CommonUtil.getRpcPagination(TeachTaskRecordDTO.class);
TeachTaskRecordDTO condition = rpcPagination.getCondition();
LoginUserInfoResponse loginUserInfo = CommonUtil.getLoginUserInfo();
if( ObjectUtil.isNotNull(loginUserInfo) && !loginUserInfo.getIsSuper()){
condition.setSupervisorPhone(loginUserInfo.getPhone());
}
return CommonUtil.convertRopResponse(teachTaskRecordRemote.teachTaskPage(rpcPagination),TeachTaskConvert.INSTANCE::toPaginationTeachTaskResponse);
}
@ApiOperation("带教任务指派")
@ServiceMethod(method = "dj.api.businessSchool.miniProgram.teachTask.update", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> updateTeachTask(TeachTaskRecordUpdateRequest request) {
TeachTaskRecordDTO condition = CommonUtil.convertRequest(TeachTaskRecordDTO.class);
LoginUserInfoResponse loginUserInfo = CommonUtil.getLoginUserInfo();
if( ObjectUtil.isNotNull(loginUserInfo) && loginUserInfo.getIsSuper()){
RopResponse.error("管理员不能接受指派");
}
condition.setCreatedBy(loginUserInfo.getAccountName());
condition.setTeachStartTime(DateUtil.parse(request.getTeachStartTime()));
if(StringUtils.isNotBlank(request.getTeachEndTime())){
condition.setTeachEndTime(DateUtil.parse(request.getTeachEndTime()));
}
RpcResponse<Boolean> isUpdate = teachTaskRecordRemote.updateTeachTask(condition);
return RopResponse.result(isUpdate);
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.convert;
import cn.com.glsx.dj.businessschool.dto.TeachTaskAreaOperatorDTO;
import cn.com.glsx.dj.businessschool.dto.TeachTaskRecordDTO;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.TeachTaskAreaOperatorResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.TeachTaskNumResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.response.TeachTaskResponse;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
@Mapper
public interface TeachTaskConvert {
TeachTaskConvert INSTANCE = Mappers.getMapper(TeachTaskConvert.class);
TeachTaskNumResponse toTeachTaskNumResponse(TeachTaskRecordDTO record);
RpcPagination<TeachTaskResponse> toPaginationTeachTaskResponse(RpcPagination<TeachTaskRecordDTO> rpcPagination);
@Mapping(source = "teachTaskAreaOperatorList", target = "areaOperatorList")
@Mapping(source = "id", target = "teachTaskRecordId")
TeachTaskResponse toTeachTaskResponse(TeachTaskRecordDTO record);
TeachTaskAreaOperatorResponse toTeachTaskAreaOperatorResponse(TeachTaskAreaOperatorDTO record);
}
package cn.com.glsx.dj.rop.business.school.miniprogram.interceptor;
import cn.com.glsx.dj.carboutique.response.LoginUserInfoResponse;
import cn.com.glsx.dj.rop.business.school.miniprogram.util.CommonUtil;
import cn.com.glsx.dj.smartcarlife.model.OperationLog;
import cn.com.glsx.dj.smartcarlife.remote.OperationLogRemote;
import com.alibaba.fastjson.JSONObject;
import com.rop.AbstractInterceptor;
import com.rop.RopRequestContext;
import com.rop.ServiceMethodDefinition;
import com.rop.annotation.ServiceMethodBean;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.autoconfigure.rop.metadata.RopProperty;
public class OperateLogAutoSaveInterceptor extends AbstractInterceptor {
private OperationLogRemote operationLogRemote;
private RopProperty ropProperty;
public OperateLogAutoSaveInterceptor() {
}
public OperateLogAutoSaveInterceptor(OperationLogRemote operationLogRemote, RopProperty ropProperty) {
this.operationLogRemote = operationLogRemote;
this.ropProperty = ropProperty;
}
@Override
public void beforeService(RopRequestContext ropRequestContext) {
super.beforeService(ropRequestContext);
ServiceMethodDefinition serviceMethodDefinition = ropRequestContext.getServiceMethodHandler().getServiceMethodDefinition();
String methodTitle = serviceMethodDefinition.getMethodTitle();
//没有title的方法不加入日志记录
if(StringUtils.isBlank(methodTitle)){
return;
}
ServiceMethodBean serviceMethodBean = ropRequestContext.getClass().getAnnotation(ServiceMethodBean.class);
String groupTitle = serviceMethodDefinition.getMethodGroupTitle();
if(StringUtils.isNotBlank(methodTitle) && !ServiceMethodDefinition.DEFAULT_GROUP_TITLE.equals(groupTitle)){
methodTitle = groupTitle.concat("-").concat(methodTitle);
}else if(serviceMethodBean != null && StringUtils.isNotBlank(serviceMethodBean.groupTitle())){
methodTitle = serviceMethodBean.groupTitle().concat("-").concat(methodTitle);
}
OperationLog log = new OperationLog();
log.setAppkey(ropRequestContext.getAppKey());
log.setIpAddress(ropRequestContext.getIp());
log.setMethod(ropRequestContext.getMethod());
log.setCreatedBy("admin");
LoginUserInfoResponse loginUser = CommonUtil.getLoginUserInfo();
if(null != loginUser){
log.setMerchantId(loginUser.getMerchantId());
log.setCreatedBy(loginUser.getAccountName());
}
log.setMethodTitle(methodTitle);
JSONObject json = new JSONObject();
json.putAll(ropRequestContext.getAllParams());
if(ropProperty != null && ropProperty.getSysparams() != null){
json.remove(ropProperty.getSysparams().getAppkeyParamName());
json.remove(ropProperty.getSysparams().getFormatParamName());
json.remove(ropProperty.getSysparams().getJsonpParamName());
json.remove(ropProperty.getSysparams().getLocaleParamName());
json.remove(ropProperty.getSysparams().getMethodParamName());
json.remove(ropProperty.getSysparams().getSessionidParamName());
json.remove(ropProperty.getSysparams().getSignParamName());
json.remove(ropProperty.getSysparams().getTimestampParamName());
json.remove(ropProperty.getSysparams().getVersionParamName());
}
log.setContent(json.toJSONString());
operationLogRemote.insert(log);
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.interceptor;
import cn.com.glsx.dj.rop.business.school.miniprogram.util.ThreadLocalCache;
import com.rop.AbstractInterceptor;
import com.rop.RopRequestContext;
public class ThreadLocalCacheInterceptor extends AbstractInterceptor{
@Override
public void beforeService(RopRequestContext ropRequestContext) {
super.beforeService(ropRequestContext);
ThreadLocalCache.setRopRequestContext(ropRequestContext);
}
@Override
public void beforeResponse(RopRequestContext ropRequestContext) {
super.beforeResponse(ropRequestContext);
ThreadLocalCache.removeRopRequestContext();
}
@Override
public int getOrder() {
return Integer.MIN_VALUE;
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.request;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.rop.AbstractRopRequest;
/**
* 例子参数实体类
*
* @author alvin.zengqi
* @version [版本号, 2019-09-02]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class ExampleRequest extends AbstractRopRequest
{
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* 得到属性字符串
* @return String 属性字符串
*/
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
\ No newline at end of file
package cn.com.glsx.dj.rop.business.school.miniprogram.request;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.rop.AbstractRopRequest;
/**
* @Title: LoginRequest.java
* @Description:
* @author Alvin
* @date 2019年9月22日 下午3:47:04
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
public class LoginRequest extends AbstractRopRequest {
/**
* 用户名
*/
@NotNull
private String userName;
/**
* 密码
*/
@NotNull
private String password;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.request;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName TeachTaskRecordQueryRequest
* @Description 小程序带教任务列表查询request
* @Author lqWang
* @Date 2025/4/3 14:50
*/
@Data
public class TeachTaskRecordQueryRequest extends AbstractRopRequest {
@ApiModelProperty(name = "pageNum", notes = "当前页", dataType = "int")
private Integer pageNum;
@ApiModelProperty(name = "pageSize", notes = "每页数据大小", dataType = "int")
private Integer pageSize;
@ApiModelProperty(notes = "状态(0:待接受,1:进行中,2:已结束)")
private Byte taskStatus;
}
package cn.com.glsx.dj.rop.business.school.miniprogram.request;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @ClassName TeachTaskRecordUpdateRequest
* @Description 带教任务修改入参
* @Author lqWang
* @Date 2025/4/4 9:56
*/
@Data
public class TeachTaskRecordUpdateRequest extends AbstractRopRequest {
@NotNull
@ApiModelProperty(notes = "带教任务id")
private Integer teachTaskRecordId;
@NotNull
@ApiModelProperty(notes = "支援方式(0:线上,1:线下)")
private Byte supportWay;
@NotNull
@ApiModelProperty(notes = "门店类型(0:老店,1:新店)")
private Byte storeType;
@NotNull
@ApiModelProperty(notes = "业务类型(0:权益升级,1:延保升级,2:精品升级)")
private Byte businessType;
@NotBlank
@ApiModelProperty(notes = "销售类型(0:售前,1:售后(多个用,拼接))")
private String saleType;
@NotBlank
@ApiModelProperty(notes = "带教开始时间(yyyy-MM-dd)")
private String teachStartTime;
@ApiModelProperty(notes = "带教结束时间(yyyy-MM-dd)")
private String teachEndTime;
@NotBlank
@ApiModelProperty(notes = "门店现存问题描述")
private String problemDescription;
@NotBlank
@ApiModelProperty(notes = "预估解决方案描述")
private String solutionDescription;
}
package cn.com.glsx.dj.rop.business.school.miniprogram.response;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* ExampleResponse
* @author alvin.zengqi
* @version [版本号, 2019-09-02]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "exampleResponse")
public class ExampleResponse
{
@XmlAttribute
private String field1 = "1";
@XmlAttribute
private String field2 = "2";
public void setField1(String field1) {
this.field1 = field1;
}
public String getField2() {
return field2;
}
public void setField2(String field2) {
this.field2 = field2;
}
/**
* 得到属性字符串
*
* @return String 属性字符串
*/
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
\ No newline at end of file
package cn.com.glsx.dj.rop.business.school.miniprogram.response;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* @Title: LoginResponse.java
* @Description:
* @author Alvin
* @date 2019年9月22日 下午3:48:18
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "response")
public class LoginResponse implements Serializable{
private static final long serialVersionUID = 5224077845643787410L;
/**
* 会话ID
*/
private String sessionId;
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public String toString()
{
return ToStringBuilder.reflectionToString(this);
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.response;
import cn.com.glsx.framework.core.enums.ErrorEnum;
/**
* @Title: RopResponse.java
* @Description: 公共响应
* @author Alvin
* @date 2019年9月5日 下午5:47:32
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
public class RopResponse<T> {
private static final String SUCCESS_CODE = "0";
private static final String FAILED_CODE = "-1";
private String code;
private String errId;
private String message;
private T data;
public String getCode() {
return code;
}
public RopResponse<T> setCode(String code) {
this.code = code;
return this;
}
public String getMessage() {
return message;
}
public RopResponse<T> setMessage(String message) {
this.message = message;
return this;
}
public T getData() {
return data;
}
public RopResponse<T> setData(T data) {
this.data = data;
return this;
}
public String getErrId() {
return errId;
}
public RopResponse<T> setErrId(String errId) {
this.errId = errId;
return this;
}
public static <T> RopResponse<T> error(String message){
return new RopResponse<T>().setCode(FAILED_CODE).setMessage(message);
}
public static <T> RopResponse<T> error(String errId, String message){
return new RopResponse<T>().setCode(FAILED_CODE).setErrId(errId).setMessage(message);
}
public static <T> RopResponse<T> error(ErrorEnum errorEnum){
return new RopResponse<T>().setCode(FAILED_CODE).setErrId(errorEnum.getValue()).setMessage(errorEnum.getDisplayName());
}
public static <T> RopResponse<T> success(T data){
return new RopResponse<T>().setCode(SUCCESS_CODE).setData(data).setMessage("调用服务成功!");
}
@Override
public String toString() {
return "RopResponse [code=" + code + ", errId=" + errId + ", message="
+ message + ", data=" + data + "]";
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.response;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName TeachTaskAreaOperatorResponse
* @Description 带教任务区域运营list
* @Author lqWang
* @Date 2025/4/3 14:54
*/
@Data
public class TeachTaskAreaOperatorResponse {
@ApiModelProperty(notes = "区域运营手机号")
private String areaOperatorPhone;
@ApiModelProperty(notes = "区域运营名称")
private String areaOperatorName;
}
package cn.com.glsx.dj.rop.business.school.miniprogram.response;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName TeachTaskNumResponse
* @Description 带教任务数量统计
* @Author lqWang
* @Date 2025/4/3 13:44
*/
@Data
public class TeachTaskNumResponse implements Serializable {
private static final long serialVersionUID = 7028920319913001537L;
@ApiModelProperty(notes = "进行中数量")
private Integer underWayNum;
@ApiModelProperty(notes = "已结束数量")
private Integer finishedNum;
@ApiModelProperty(notes = "待接受数量")
private Integer toBeAcceptedNum;
}
package cn.com.glsx.dj.rop.business.school.miniprogram.response;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @ClassName TeachTaskResponse
* @Description 小程序带教任务返回
* @Author lqWang
* @Date 2025/4/3 14:53
*/
@Data
public class TeachTaskResponse implements Serializable {
private static final long serialVersionUID = 4835405073040592056L;
@ApiModelProperty(notes = "带教任务id")
private Integer teachTaskRecordId;
@ApiModelProperty(notes = "门店商户号")
private Integer merchantId;
@ApiModelProperty(notes = "门店商户名称")
private String merchantName;
@ApiModelProperty(notes = "飞行督导手机号")
private String flightSupervisorPhone;
@ApiModelProperty(notes = "飞行督导名称")
private String flightSupervisorName;
@ApiModelProperty(notes = "支援类型(0:新店启动,1:老店业绩提升-渗透率过低,2:老店业绩提升-客单价过低)")
private Byte supportType;
@ApiModelProperty(notes = "情况描述")
private String situationDescription;
@ApiModelProperty(notes = "任务状态(0:待接受,1:进行中,2:已结束)")
private Byte taskStatus;
@ApiModelProperty(notes = "支援方式(0:线上,1:线下)")
private Byte supportWay;
@ApiModelProperty(notes = "门店类型(0:老店,1:新店)")
private Byte storeType;
@ApiModelProperty(notes = "业务类型(0:权益升级,1:延保升级,2:精品升级)")
private Byte businessType;
@ApiModelProperty(notes = "销售类型(0:售前,1:售后(多个用,拼接))")
private String saleType;
@ApiModelProperty(notes = "带教开始时间(yyyy-MM-dd)")
private Date teachStartTime;
@ApiModelProperty(notes = "带教结束时间(yyyy-MM-dd)")
private Date teachEndTime;
@ApiModelProperty(notes = "门店现存问题描述")
private String problemDescription;
@ApiModelProperty(notes = "预估解决方案描述")
private String solutionDescription;
@ApiModelProperty(notes = "创建人")
private String createdBy;
@ApiModelProperty(notes = "创建时间")
private Date createdDate;
@ApiModelProperty(notes = "运营人员list")
private List<TeachTaskAreaOperatorResponse> areaOperatorList;
}
package cn.com.glsx.dj.rop.business.school.miniprogram.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* @Title: ApplicationContextRegister.java
* @Description:
* @author caiym
* @date 2021年01月18日 14:14
* @version V1.0.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2021
*/
@Component
public class ApplicationContextRegister implements ApplicationContextAware {
private static Logger logger = LoggerFactory.getLogger(ApplicationContextRegister.class);
private static ApplicationContext APPLICATION_CONTEXT;
/**
* 设置spring上下文
* @param applicationContext spring上下文
* @throws BeansException
* */
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
logger.debug("ApplicationContext registed-->{}", applicationContext);
APPLICATION_CONTEXT = applicationContext;
}
/**
* 获取容器
* @return
*/
public static ApplicationContext getApplicationContext() {
return APPLICATION_CONTEXT;
}
/**
* 获取容器对象
* @param type
* @param <T>
* @return
*/
public static <T> T getBean(Class<T> type) {
return APPLICATION_CONTEXT.getBean(type);
}
}
\ No newline at end of file
package cn.com.glsx.dj.rop.business.school.miniprogram.util;
public interface ConvertHandler<T,V> {
V convert(T source);
}
package cn.com.glsx.dj.rop.business.school.miniprogram.util;
import com.rop.RopRequestContext;
public class ThreadLocalCache {
private static ThreadLocal<RopRequestContext> ropRequestContextCache = new ThreadLocal<RopRequestContext>();
public static void setRopRequestContext(RopRequestContext ropRequestContext){
ropRequestContextCache.set(ropRequestContext);
}
public static RopRequestContext getRopRequestContext(){
return ropRequestContextCache.get();
}
public static void removeRopRequestContext(){
ropRequestContextCache.remove();
}
}
# framework-archetype-rop
开放平台项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─cn.com.glsx.dj.rop.business.school.miniprogram.config 配置层
├─cn.com.glsx.dj.rop.business.school.miniprogram.controller 控制层
├─cn.com.glsx.dj.rop.business.school.miniprogram.request 请求实体
├─cn.com.glsx.dj.rop.business.school.miniprogram.response 响应实体
└─cn.com.glsx.dj.businessschool.Main.java 程序入口
├─resources 资源文件目录
├─config
└─application.properties 应用配置文件
└─logback.xml 日志配置文件
└─webapp web前端文件目录
└─WEB-INF
└─bin shell脚本文件(包含启动、停止、重启等)
└─test 测试目录
├─java
└─cn.com.glsx.dj 测试代码
└─resources 测试资源目录
└─pom.xml pom文件
二、使用说明:
1、运行项目前需在配置中心创建配置信息,配置内容参考三配置说明:
1.1> dataId : application.properties --> ore.diamond.dataId + ore.diamond.env
1.2> group : application.properties --> ore.diamond.group
1.3> content : 参考三配置说明
三、配置说明:
#----------------------------------------------------------------------------------------------------------
# dubbo配置(调用dubbo服务需配置)
# dubbo应用名称
ore.dubbo.application.name=rop-dj-business-school-miniprogram
# dubbo应用所有者
ore.dubbo.application.owner=deployer name
# dubbo服务注册地址
ore.dubbo.registry.address=zookeeper://192.168.3.206:2181
# dubbo服务注册超时时间
ore.dubbo.registry.timeout=30000
# 默认协议:dubbo
ore.dubbo.protocol.name=dubbo
# dubbo服务扫描包路径
ore.dubbo.scan=cn.com.glsx.dj
# dubbo服务监控
ore.dubbo.monitor.protocol=registry
#----------------------------------------------------------------------------------------------------------
# rop 注解驱动配置
ore.rop.annotation-driven.thread-ferry-class=
ore.rop.annotation-driven.sign-enable=true
ore.rop.annotation-driven.ext-error-base-name=i18n/rop/sampleRopError
ore.rop.annotation-driven.core-pool-size=200
ore.rop.annotation-driven.max-pool-size=500
ore.rop.annotation-driven.keep-alive-seconds=300
ore.rop.annotation-driven.queue-capacity=50
ore.rop.annotation-driven.service-timeout-seconds=120
ore.rop.annotation-driven.upload-file-max-size=9999999
ore.rop.annotation-driven.upload-file-types=png,gif,jpg
ore.rop.annotation-driven.formatting-conversion-service=
# 默认本地Map缓存会话,只支持单节点
ore.rop.annotation-driven.session-manager=
# 配置为ropSessionManager,则采用Redis缓存会话,支持集群(另外需要增加redis配置)
#ore.rop.annotation-driven.session-manager=ropSessionManager
ore.rop.annotation-driven.app-secret-manager=
ore.rop.annotation-driven.service-access-controller=
ore.rop.annotation-driven.invoke-times-controller=
# rop 系统参数配置
ore.rop.sysparams.appkey-param-name=appKey
ore.rop.sysparams.sessionid-param-name=sessionId
ore.rop.sysparams.method-param-name=method
ore.rop.sysparams.version-param-name=v
ore.rop.sysparams.format-param-name=format
ore.rop.sysparams.locale-param-name=locale
ore.rop.sysparams.sign-param-name=sign
ore.rop.sysparams.jsonp-param-name=jsonp
# rop 秘钥对(appKey=secret)
48e5e13229b82c1b4e6e8c96151f0637=c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b
# redis缓存
ore.redis.hostName=192.168.0.100
ore.redis.port=6379
ore.redis.password=
ore.redis.pool.maxActive=600
ore.redis.pool.maxWait=10000
ore.redis.pool.maxTotal=300
ore.redis.pool.maxIdle=300
ore.redis.pool.minIdle=0
ore.redis.timeout=30000
# 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1
ore.redis.betweenEvictionRunsMillis=30000
\ No newline at end of file
server.port=3539
server.servlet.context-path=/rop-dj-business-school-miniprogram
server.display-name=rop-dj-business-school-miniprogram
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/rop-dj-business-school-miniprogram/rop-dj-business-school-miniprogram.log
logging.level.root=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=rop-dj-business-school-miniprogram
ore.diamond.env=release
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property resource="config/application.properties" />
<property name="APP_NAME" value="${server.display-name}" />
<property name="LOG_PATH" value="${logging.path}" />
<property name="LOG_LEVEL" value="${logging.level}" />
<contextName>${APP_NAME}</contextName>
<turboFilter class="org.oreframework.boot.logging.logback.OreBootTurboFilter">
<Marker>oreframework</Marker>
</turboFilter>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</pattern>
</layout>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding> Label Old version of this label can not be used -->
<!-- <Encoding>UTF-8</Encoding> -->
<File>${LOG_PATH}</File>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_PATH}.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} ${APP_NAME}] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</layout>
<!-- 根据文件大小滚动,不支持 SizeBasedTriggeringPolicy 这种配置-->
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>200MB</MaxFileSize>
</triggeringPolicy> -->
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/name="LOG_PATH"/!d;s/.*value="\(.*\)".*/\1/g' classes/logback.xml`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
DUMP_DIR=$LOGS_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
./stop.sh
./start.sh $ENV
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
if [ "$1" = "start" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV
else
if [ "$1" = "stop" ]; then
./stop.sh
else
if [ "$1" = "debug" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV debug
else
if [ "$1" = "restart" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./restart.sh $ENV
else
if [ "$1" = "dump" ]; then
./dump.sh
else
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
exit 1
fi
fi
fi
fi
fi
#!/bin/bash
JAVA_HOME="/app/soft/jdk1.8.0_20"
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/server.display-name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
SERVER_PORT=`sed '/server.port/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
LOGS_FILE=`sed '/logging.path/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
echo "server name is $SERVER_NAME"
echo "server port is $SERVER_PORT"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$2" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$2" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
COUNT=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
fi
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
#if [ "$1" != "skip" ]; then
#$BIN_DIR/dump.sh
#fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
package cn.com.glsx.dj;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @Title: IpConfiguration.java
* @Description:
* @author Alvin
* @date 2019年9月3日 上午11:05:17
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Component
public class IpConfiguration implements ApplicationListener<WebServerInitializedEvent> {
private int serverPort;
@Override
public void onApplicationEvent(WebServerInitializedEvent event) {
serverPort = event.getWebServer().getPort();
}
public int getPort(){
return serverPort;
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.controller;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.DefaultUriTemplateHandler;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import cn.com.glsx.dj.IpConfiguration;
import com.rop.utils.RopUtils;
/**
* @Title: BaseControllerTest.java
* @Description:
* @author Alvin
* @date 2019年9月3日 上午9:32:12
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class BaseControllerTest{
String url = "http://localhost:";
@Value("${server.context-path}")
String contextPath;
@Autowired
private IpConfiguration ip;
final String appKey = "48e5e13229b82c1b4e6e8c96151f0637";
final String secret = "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b";
@Before
public void setUp() {
url = url.concat(String.valueOf(ip.getPort())).concat(contextPath).concat("/router");
}
String get(MultiValueMap<String, String> paramsMap) throws Exception{
return get(paramsMap, String.class);
}
<T> T get(MultiValueMap<String, String> paramsMap, Class<T> responseType) throws Exception{
MultiValueMap<String, String> params = getSysParams();
params.putAll(paramsMap);
for(Entry<String, String> entry:params.toSingleValueMap().entrySet()){
if(StringUtils.isEmpty(entry.getValue())){
params.remove(entry.getKey());
}
}
String sign = RopUtils.sign(params.toSingleValueMap(), secret);
params.add("sign", sign);
RestTemplate rest = new RestTemplate();
RopUriTemplateHandler uriTemplateHandler = new RopUriTemplateHandler();
rest.setUriTemplateHandler(uriTemplateHandler);
return rest.getForObject(url, responseType, params.toSingleValueMap());
}
String post(MultiValueMap<String, String> paramsMap) throws Exception{
return post(paramsMap, String.class);
}
<T> T post(MultiValueMap<String, String> paramsMap, Class<T> responseType) throws Exception{
MultiValueMap<String, String> params = getSysParams();
params.putAll(paramsMap);
for(Entry<String, String> entry:params.toSingleValueMap().entrySet()){
if(StringUtils.isEmpty(entry.getValue())){
params.remove(entry.getKey());
}
}
String sign = RopUtils.sign(params.toSingleValueMap(), secret);
params.add("sign", sign);
return new RestTemplate().postForObject(url, params, responseType);
}
MultiValueMap<String, String> getSysParams(){
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(16);
params.add("appKey", appKey);
params.add("format", "json");
params.add("locale", "zh_CN");
return params;
}
class RopUriTemplateHandler extends DefaultUriTemplateHandler{
@Override
protected UriComponents expandAndEncode(UriComponentsBuilder builder,
Map<String, ?> uriVariables) {
if(uriVariables != null && !uriVariables.isEmpty()){
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
for(Entry<String, ?> entry:uriVariables.entrySet()){
params.add(entry.getKey(), entry.getValue().toString());
}
builder.queryParams(params);
}
return super.expandAndEncode(builder, uriVariables);
}
}
}
package cn.com.glsx.dj.rop.business.school.miniprogram.controller;
import org.junit.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* @Title: ExampleControllerTest.java
* @Description:
* @author Alvin
* @date 2019年9月3日 上午9:33:00
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
public class ExampleControllerTest extends BaseControllerTest {
@Test
public void testGetExample() throws Exception{
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "org.ore.api.example");
params.add("name", "alvin");
System.out.println(get(params));
}
@Test
public void testPostExample() throws Exception{
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(4);
params.add("v", "1.0.0");
params.add("method", "org.ore.api.example");
params.add("name", "alvin");
System.out.println(post(params));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!