初始代码
This commit is contained in:
20
yunzhupaas-example/pom.xml
Normal file
20
yunzhupaas-example/pom.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-java-boot</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-example</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yunzhupaas-example-entity</module>
|
||||
<module>yunzhupaas-example-biz</module>
|
||||
<module>yunzhupaas-example-controller</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
27
yunzhupaas-example/yunzhupaas-example-biz/pom.xml
Normal file
27
yunzhupaas-example/yunzhupaas-example-biz/pom.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-example</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-example-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-example-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-generater-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yunzhupaas.entity.ContractEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/16 9:47
|
||||
*/
|
||||
public interface ContractMapper extends SuperMapper<ContractEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.entity.ContractEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/16 9:47
|
||||
*/
|
||||
public interface ContractService extends SuperService<ContractEntity> {
|
||||
|
||||
List<ContractEntity> getlist(Pagination pagination);
|
||||
|
||||
ContractEntity getInfo(String id);
|
||||
|
||||
void create(ContractEntity entity);
|
||||
|
||||
void update(String id, ContractEntity entity);
|
||||
|
||||
void delete(ContractEntity entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.yunzhupaas.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.mapper.ContractMapper;
|
||||
import com.yunzhupaas.service.ContractService;
|
||||
import com.yunzhupaas.entity.ContractEntity;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/3/16 9:47
|
||||
*/
|
||||
@Service
|
||||
public class ContractServiceImpl extends SuperServiceImpl<ContractMapper, ContractEntity> implements ContractService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<ContractEntity> getlist(Pagination pagination){
|
||||
//通过UserProvider获取用户信息
|
||||
QueryWrapper<ContractEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (!StringUtil.isEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(ContractEntity::getContractName, pagination.getKeyword())
|
||||
.or().like(ContractEntity::getMytelePhone, pagination.getKeyword())
|
||||
);
|
||||
}
|
||||
//排序
|
||||
if (StringUtil.isEmpty(pagination.getSidx())) {
|
||||
} else {
|
||||
queryWrapper = "asc".equals(pagination.getSort().toLowerCase()) ? queryWrapper.orderByAsc(pagination.getSidx()) : queryWrapper.orderByDesc(pagination.getSidx());
|
||||
}
|
||||
Page<ContractEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<ContractEntity> userPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(userPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractEntity getInfo(String id){
|
||||
QueryWrapper<ContractEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ContractEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void create(ContractEntity entity){
|
||||
entity.setId(RandomUtil.uuId());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void update(String id, ContractEntity entity){
|
||||
entity.setId(id);
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ContractEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
yunzhupaas-example/yunzhupaas-example-controller/pom.xml
Normal file
22
yunzhupaas-example/yunzhupaas-example-controller/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-example</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-example-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-example-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.yunzhupaas.controller;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.entity.ContractEntity;
|
||||
import com.yunzhupaas.model.ContractForm;
|
||||
import com.yunzhupaas.model.ContractInfoVO;
|
||||
import com.yunzhupaas.model.ContractListVO;
|
||||
import com.yunzhupaas.service.ContractService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contract
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2020-12-31
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = "示例接口", description = "Contract")
|
||||
@RequestMapping("/Contract")
|
||||
public class ContractController extends SuperController<ContractService, ContractEntity> {
|
||||
|
||||
@Autowired
|
||||
private ContractService contractService;
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param pagination 分页模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取列表")
|
||||
@GetMapping("/List")
|
||||
public ActionResult<PageListVO<ContractListVO>> list(Pagination pagination) {
|
||||
List<ContractEntity> entity = contractService.getlist(pagination);
|
||||
List<ContractListVO> listVo = JsonUtil.getJsonToList(JsonUtil.getObjectToStringDateFormat(entity, "yyyy-MM-dd HH:mm:ss"), ContractListVO.class);
|
||||
PaginationVO vo = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(listVo, vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取详情")
|
||||
@GetMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<ContractInfoVO> info(@PathVariable("id") String id) {
|
||||
ContractEntity entity = contractService.getInfo(id);
|
||||
ContractInfoVO vo = JsonUtil.getJsonToBean(entity, ContractInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param contractForm 新建模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新建")
|
||||
@PostMapping
|
||||
@Parameters({
|
||||
@Parameter(name = "contractForm", description = "示例模型",required = true),
|
||||
})
|
||||
public ActionResult create(@RequestBody @Valid ContractForm contractForm) {
|
||||
ContractEntity entity = JsonUtil.getJsonToBean(contractForm, ContractEntity.class);
|
||||
contractService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU002.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id 主键
|
||||
* @param contractForm 修改模型
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改")
|
||||
@PutMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "contractForm", description = "示例模型",required = true),
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ContractForm contractForm) {
|
||||
ContractEntity entity = JsonUtil.getJsonToBean(contractForm, ContractEntity.class);
|
||||
contractService.update(id, entity);
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
ContractEntity entity = contractService.getInfo(id);
|
||||
contractService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
22
yunzhupaas-example/yunzhupaas-example-entity/pom.xml
Normal file
22
yunzhupaas-example/yunzhupaas-example-entity/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-example</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-example-entity</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-all</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yunzhupaas.entity;
|
||||
|
||||
import com.yunzhupaas.base.entity.SuperBaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* Contract
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2020-12-31
|
||||
*/
|
||||
@Data
|
||||
@TableName("test_contract")
|
||||
public class ContractEntity extends SuperBaseEntity.SuperTBaseEntity<String> implements Serializable {
|
||||
|
||||
@TableField("F_CONTRACTNAME")
|
||||
private String contractName;
|
||||
|
||||
@TableField("F_MYTELEPHONE")
|
||||
private String mytelePhone;
|
||||
|
||||
@TableField("F_FILEJSON")
|
||||
private String fileJson;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.yunzhupaas.model;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2020-12-31
|
||||
*/
|
||||
@Data
|
||||
public class ContractForm {
|
||||
|
||||
@Schema(description = "姓名")
|
||||
private String contractName;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String mytelePhone;
|
||||
|
||||
@Schema(description = "文件")
|
||||
private String fileJson;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yunzhupaas.model;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2020-12-31
|
||||
*/
|
||||
@Data
|
||||
public class ContractInfoVO {
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "姓名")
|
||||
private String contractName;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String mytelePhone;
|
||||
|
||||
@Schema(description = "文件")
|
||||
private String fileJson;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* 作者: 云筑产品开发平台组
|
||||
* 日期: 2020-12-31
|
||||
*/
|
||||
@Data
|
||||
public class ContractListVO extends ContractInfoVO {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user