No Description

Jacky Wong e1efa1a429 服务器停机重启后ip发生变化,修改ip 4 years ago
.mvn 397a5909f1 '会员积分不分表' 4 years ago
lib 80cd7a9681 first commit 5 years ago
member-common 9192517b5d delete packaged files 4 years ago
member-services e1efa1a429 服务器停机重启后ip发生变化,修改ip 4 years ago
member-services-models 0d3d0cde03 修复会员列表条件查询BUG 4 years ago
member-web e1efa1a429 服务器停机重启后ip发生变化,修改ip 4 years ago
member-web-common 0631e7dad3 添加了简单CRUD的自动实现 4 years ago
member-weixin-service 483316b01a Merge branch 'master' of http://192.168.20.122:3000/root/MemberCenter_DW.git 4 years ago
.gitignore 4332a2865f - 4 years ago
README.md 0631e7dad3 添加了简单CRUD的自动实现 4 years ago
derby.log a31de6c9bf 1 4 years ago
mvnw 80cd7a9681 first commit 5 years ago
mvnw.cmd 80cd7a9681 first commit 5 years ago
pom.xml 3b31d7a3cc 清掉无用代码、依赖、配置 4 years ago
updateAndStart.sh f8d7bb26a1 try test chage take 5 5 years ago

README.md

会员系统的Java端API接口服务器


使用Spring Boot + Spring-data-jpa 构建 接口文档使用swagger-ui管理, 文档url /doc.html

mvn启动命令mvn -f ./member-web/pom.xml spring-boot:run

服务器部署、启动命令:

screen -r MemberCenter (进入名为MemberCenter的screen)
(如果没有就用 screen -S MemberCenter 创建一个)
cd /usr/local/src/MemberCenter_DW/
git pull origin master
mvn clean package install
export workerid=0
export datacenterid=0
java -Dhttps.proxyHost=192.168.50.32 -Dhttps.proxyPort=1808 -Dhttp.proxyHost=192.168.50.32 -Dhttp.proxyPort=1808 -jar member-web/target/member-web-0.0.1-SNAPSHOT.jar
ctrl + a (松开后按 d) 退出当前screen,让其后台运行

2019-11-5 更新

在使用新添加的sql查询导出excel的接口时,因为不知道为什么使用react框架的request来请求时,post不行,使用了blob也不行,就改成了get的方式,参数从sessionStorge里去取,然后编码提交,如下:

{
	title:"测试表格",
	url:{
		read:"/japi/birdgird/readSql?dsId=4028b2a26daf6c2d016db34bc5ca00a5&sqlId=40288ad66df10dc9016df1101fe40001",
		add:"/japi/birdgird/add?dsId=4028b2a26daf6c2d016db34bc5ca00a5&tableName=contract",
		edit:"/japi/birdgird/edit?dsId=4028b2a26daf6c2d016db34bc5ca00a5&tableName=contract&pkColumn=id",
		delete:"/japi/birdgird/delete?dsId=4028b2a26daf6c2d016db34bc5ca00a5&tableName=contract&pkColumn=id"
	},
	checkable:true,
	actions:[{
		name:"导出excel", onClick: function() {
			let dtoStr = sessionStorage.getItem('queryDto');
			dtoStr = encodeURI(dtoStr);
			window.location = "http://localhost:8090/sqlExport/export?dsId=4028b2a26daf6c2d016db34bc5ca00a5&sqlId=40288a9d6e357e33016e3598b42a0000&requestStr="+dtoStr;
		}
	}],
	columns:[
		{title:"主编号", data:"t.id", type:"text",hide:true},
		{title:"名称",data:"t.name", type:"text",editor: {}, query: true},
		{title:"个人电话",data:"t.personal_phone", type:"text",editor: {}, query: true},
		{title:"个人手机",data:"t.personal_cellphone", type:"text",editor: {}, query: true},
		{title:"组名称",data:"t2.name",type:"text"},
		{title:"操作",type:"command",actions:[{
			name: '行内按钮',
            onClick: (data) => {
              console.log(data);
            }
		}]}
	],
}

2019-11-15 更新

启动时需要添加proxy代理信息:

java -Dhttps.proxyHost=192.168.50.32 -Dhttps.proxyPort=1808 -Dhttp.proxyHost=192.168.50.32 -Dhttp.proxyPort=1808 -jar xxxx.jar

2019-12-06 更新

启动时需要添加机器编号和数据中心编号,为了使部分对象生成分布式ID

export workerid=0
export datacenterid=0 
java -Dhttps.proxyHost=192.168.50.32 -Dhttps.proxyPort=1808 -Dhttp.proxyHost=192.168.50.32 -Dhttp.proxyPort=1808 -jar xxxx.jar

2019-12-17 develop 更新

添加了动态请求查询参数,格式如下:

  • 基本分页: GET {url}?page=1&size=10
  • 基本分页排序: GET {url}?page=1&size=10&sortField=crtDate&sortDirection=DESC sortField 是需要排序的字段 sortDirection 是升降序
  • 基本带参数查询: GET {url}?name=yourname&age=20&... 非关键字(上面两条中的)的参数,直接视为等于的操作。
  • 不同类型的参数查询: GET {url}?age=20&ageOperate=LessEqual&... 使用 字段名+Operate 的参数来表示判断类型:
操作类型 说明
Equal 等于(默认)
NotEqual 不等于
Less (数字类型)小于
LessEqual (数字类型)不大于
Greater (数字类型)大于
GreaterEqual (数字类型)不小于
Contains (字符串)包含
StartWith (字符串)以开头
EndWith (字符串)以结尾
  • 代码中使用: 已经在拦截器中添加了GET请求解析参数的功能,解析完参数后放到ThreadLocal中,若需要取param参数值, 可以直接去com.liangjian.dataplatform.member.entity.token.DynamicParamGetter取:

Service层:

//...
@Service
public class YourService extends DynamicQueryService<YourEntity> implements  IYourService {
    @Autowired
    private YourRepository yourRepository;
    
    @Overrive
    public JpaSpecificationExecutor<YourEntity> getJpaRepository() {
        return yourRepository;
    }
    
    //父类已经包含了动态查询返回Page和返回List的方法
}

Controller层:

@Controller
public class YourController {
    //...
    
    @Autowired
    private IYourService iYourService;
    
    //例子:
    @GetMapping("/page")
    public Page<YourEntity> page() {
        var params = DynamicParamGetter.DynamicParams.get();
        return iYourService.queryPageByCondition(params);
    }
    
    @GetMapping("/page")
    public List<YourEntity> list() {
        var params = DynamicParamGetter.DynamicParams.get();
        return iYourService.queryListByCondition(params);
    }
}

2019-12-26更新

这次直接增加CRUD的逻辑,直接restful风格。

  • GET /rest/api/model/{model}/{id} 根据Id获取
  • GET /rest/api/model/{model}/dynamic/page 根据动态条件分页获取
  • GET /rest/api/model/{model}/dynamic/list 根据动态条件获取列表
  • POST /rest/api/model/{model} 添加
  • PUT /rest/api/model/{model} 更新
  • DELETE /rest/api/model/{model}/{id} 删除

步骤:

  • 数据库映射类:
@Entity
@Table(name = "test_table")
public class TestTable {
    //...
}
  • 准备dao层(这里是jpa)
public interface TestTableRepository<TestTable,String> 
    extends JpaRepository<TestTable,String>,
            JpaSpecificationExecutor<TestTable> {
    //...
}
  • 实现Service层接口
@Service
public class TestTableService<TestTable> extends DynamicApiService<TestTable> {
    //返回model的映射名,在url中需要使用到
    @Override
    public String getMappedName() { ... }
    
    //获取数据库映射对象的类名,json序列化/反序列化需要
    @Override
    public Class<TestTable> getModelClass() { ... }
    
    //获取dao层的repository
    @Override
    public JpaRepository<TestTable,String> getJpaRepository() {...}
    
    //获取dao层复杂查询构造器
    @Override
    public JpaSpecificationExecutor<TestTable> getJpaSpecificationExecutor(){...}
    
    //下面两个可选实现,因为jpa的save是insert、update一起的,可能需要对id处理
    //添加前处理
    @Override
    public void onAdd(TestTable testTable) { ... }
    //更新前处理
    @Override
    public void onUpdate(TestTable testTable) { ... }
}