中控协议

This commit is contained in:
attiya 2025-10-13 15:45:03 +08:00
parent 87ed202257
commit 0716ebb135
7 changed files with 141 additions and 7 deletions

View File

@ -0,0 +1,38 @@
package com.cdzy.operations.controller;
import com.cdzy.common.model.response.JsonResult;
import com.cdzy.operations.model.entity.EbikeAgreement;
import com.cdzy.operations.service.EbikeAgreementService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 中控协议控制层
*
* @author attiya
* @since 2025-10-13
*/
@RestController
@RequestMapping("/ebikeAgreement")
public class EbikeAgreementController {
@Resource
private EbikeAgreementService ebikeAgreementService;
/**
* 协议列表
*
* @return 所有数据
*/
@GetMapping("list")
public JsonResult<?> list() {
List<EbikeAgreement> list = ebikeAgreementService.list();
return JsonResult.success(list);
}
}

View File

@ -0,0 +1,14 @@
package com.cdzy.operations.mapper;
import com.mybatisflex.core.BaseMapper;
import com.cdzy.operations.model.entity.EbikeAgreement;
/**
* 映射层
*
* @author attiya
* @since 2025-10-13
*/
public interface EbikeAgreementMapper extends BaseMapper<EbikeAgreement> {
}

View File

@ -0,0 +1,46 @@
package com.cdzy.operations.model.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 实体类
*
* @author attiya
* @since 2025-10-13
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("ebike_agreement")
public class EbikeAgreement implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 协议id
*/
@Id
private Long agreementId;
/**
* 协议名称
*/
private String agreementName;
/**
* 协议标识
*/
private String agreementCode;
}

View File

@ -0,0 +1,14 @@
package com.cdzy.operations.service;
import com.mybatisflex.core.service.IService;
import com.cdzy.operations.model.entity.EbikeAgreement;
/**
* 服务层
*
* @author attiya
* @since 2025-10-13
*/
public interface EbikeAgreementService extends IService<EbikeAgreement> {
}

View File

@ -0,0 +1,18 @@
package com.cdzy.operations.service.impl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.cdzy.operations.model.entity.EbikeAgreement;
import com.cdzy.operations.mapper.EbikeAgreementMapper;
import com.cdzy.operations.service.EbikeAgreementService;
import org.springframework.stereotype.Service;
/**
* 服务层实现
*
* @author attiya
* @since 2025-10-13
*/
@Service
public class EbikeAgreementServiceImpl extends ServiceImpl<EbikeAgreementMapper, EbikeAgreement> implements EbikeAgreementService{
}

View File

@ -1,13 +1,23 @@
package com.cdzy.operations;
import com.cdzy.operations.model.entity.EbikeAgreement;
import com.cdzy.operations.service.EbikeAgreementService;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class EbikeOperationsApplicationTests {
@Resource
EbikeAgreementService agreementService;
@Test
void contextLoads() {
EbikeAgreement agreement = new EbikeAgreement();
agreement.setAgreementName("默认协议");
agreement.setAgreementCode("default");
agreementService.save(agreement);
}
}

View File

@ -2,7 +2,6 @@ package com.cdzy.staff;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.mybatisflex.core.keygen.impl.SnowFlakeIDKeyGenerator;
import com.zaxxer.hikari.HikariDataSource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@ -13,14 +12,9 @@ class EbikeStaffApplicationTests {
private static final String mapperPath="D:/ebike_plus/ebike-operations/resources/mapper";
private static final String packageName ="com.cdzy.operations";
private static final String[] tables= new String[]{
"ebike_battery_info"
"ebike_agreement"
};
public static void main(String[] args) {
SnowFlakeIDKeyGenerator snowFlakeIDKeyGenerator = new SnowFlakeIDKeyGenerator();
long dataCenterId = snowFlakeIDKeyGenerator.nextId();
System.out.println(dataCenterId);
}
@Test
void gen_mybatis_code() {
//配置数据源