zhuyifan

删除test

package com.tianting.infoloop.mapper;
import com.tianting.infoloop.inject.MyBaseMapper;
import com.tianting.infoloop.model.db.TestExampleDb;
public interface TestExampleDbMapper extends MyBaseMapper<TestExampleDb> {
}
package com.tianting.infoloop.model.db;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 例子DB
* @TableName test_example_db
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@TableName(value ="test_example_db")
public class TestExampleDb extends Model<TestExampleDb> implements Serializable {
/**
*
*/
@TableId(type = IdType.AUTO)
private Integer id;
/**
* 企业 ID
*/
private Integer enterpriseId;
/**
* 用户昵称
*/
private String name;
/**
* 用户状态;启用:1;停用:2
*/
private Integer status;
/**
* 创建人 ID
*/
@TableField(fill = FieldFill.INSERT)
private Integer createdBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/**
* 创建来源
*/
@TableField(fill = FieldFill.INSERT)
private Integer creationSource;
/**
* 修改人 ID
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Integer updatedBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
/**
* 修改来源
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Integer updateSource;
/**
* 是否删除;0:未删除,1:已删除
*/
@TableLogic
private Boolean isDeleted;
}
\ No newline at end of file
package com.tianting.infoloop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tianting.infoloop.grpc.exampleservice.TestExampleDbCreation;
import com.tianting.infoloop.grpc.exampleservice.TestExampleDbModification;
import com.tianting.infoloop.model.db.TestExampleDb;
import java.util.List;
/**
* @author zhuyf
* @description 针对表【 test_example_db(例子DB)】的数据库操作Service
* @createDate 2024-10-12 13:53:16
*/
public interface TestExampleDbService extends IService<TestExampleDb> {
TestExampleDb createTestExampleDb(TestExampleDbCreation creation);
List<TestExampleDb> batchCreateTestExampleDb(List<TestExampleDbCreation> creationsList);
boolean updateTestExampleDb(TestExampleDbModification modification);
boolean batchUpdateTestExampleDb(List<TestExampleDbModification> modificationsList);
}
package com.tianting.infoloop.service.impl;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tianting.infoloop.grpc.exampleservice.TestExampleDbCreation;
import com.tianting.infoloop.grpc.exampleservice.TestExampleDbModification;
import com.tianting.infoloop.mapper.TestExampleDbMapper;
import com.tianting.infoloop.model.db.TestExampleDb;
import com.tianting.infoloop.service.TestExampleDbService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zhuyf
* @description 针对表【 test_example_db(例子DB)】的数据库操作Service实现
* @createDate 2024-10-12 13:53:16
*/
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TestExampleDbServiceImpl extends ServiceImpl<TestExampleDbMapper, TestExampleDb> implements TestExampleDbService {
private final TestExampleDbMapper testExampleDbMapper;
@Override
@Nullable
public TestExampleDb createTestExampleDb(TestExampleDbCreation creation) {
TestExampleDb testExampleDb = new TestExampleDb();
testExampleDb.setName(creation.getName());
testExampleDb.setStatus(creation.getStatusValue());
final var insert = testExampleDbMapper.insert(testExampleDb);
return insert > 0 ? testExampleDb : null;
}
@Override
public List<TestExampleDb> batchCreateTestExampleDb(List<TestExampleDbCreation> creationsList) {
var list = creationsList.stream().map(creation -> new TestExampleDb()
.setName(creation.getName())
.setStatus(creation.getStatusValue())).collect(Collectors.toList());
return SpringUtil.getBean(TestExampleDbServiceImpl.class).saveBatch(list) ? list : Collections.emptyList();
}
@Override
public boolean updateTestExampleDb(TestExampleDbModification modification) {
var testExampleDb = new TestExampleDb();
testExampleDb.setId(modification.getId());
if (modification.hasName()) {
testExampleDb.setName(modification.getName());
}
if (modification.hasStatus()) {
testExampleDb.setStatus(modification.getStatusValue());
}
return testExampleDbMapper.updateById(testExampleDb) > 0;
}
@Override
public boolean batchUpdateTestExampleDb(List<TestExampleDbModification> modificationsList) {
final var list = modificationsList.stream().map(modification -> {
var testExampleDb = new TestExampleDb();
testExampleDb.setId(modification.getId());
if (modification.hasName()) {
testExampleDb.setName(modification.getName());
}
if (modification.hasStatus()) {
testExampleDb.setStatus(modification.getStatusValue());
}
return testExampleDb;
}).collect(Collectors.toList());
return SpringUtil.getBean(TestExampleDbServiceImpl.class).updateBatchById(list);
}
}
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.tianting.infoloop.grpc.exampleservice";
option java_outer_classname = "ExampleServiceProto";
option objc_class_prefix = "OP";
package com.tianting.infoloop.grpc.exampleservice;
service ExampleServiceRpc {
rpc GetTestExampleDbById (GetTestExampleDbByIdRpcRequest) returns (GetTestExampleDbByIdRpcResponse) {}
rpc GetTestExampleDbByIds (GetTestExampleDbByIdsRpcRequest) returns (GetTestExampleDbByIdsRpcResponse) {}
rpc GetAllTestExampleDb (GetAllTestExampleDbRpcRequest) returns (GetAllTestExampleDbRpcResponse) {}
rpc QueryTestExampleDbByCondition (QueryTestExampleDbByConditionRpcRequest) returns (QueryTestExampleDbByConditionRpcResponse) {}
rpc QueryTestExampleDbByPagination (QueryTestExampleDbByPaginationRpcRequest) returns (QueryTestExampleDbByPaginationRpcResponse) {}
rpc CreateTestExampleDb (CreateTestExampleDbRpcRequest) returns (CreateTestExampleDbRpcResponse) {}
rpc BatchCreateTestExampleDb (BatchCreateTestExampleDbRpcRequest) returns (BatchCreateTestExampleDbRpcResponse) {}
rpc UpdateTestExampleDb (UpdateTestExampleDbRpcRequest) returns (UpdateTestExampleDbRpcResponse) {}
rpc BatchUpdateTestExampleDb (BatchUpdateTestExampleDbRpcRequest) returns (BatchUpdateTestExampleDbRpcResponse) {}
rpc DeleteTestExampleDbByIds (DeleteTestExampleDbByIdsRpcRequest) returns (DeleteTestExampleDbRpcResponse) {}
}
enum TestExampleDbStatusEnum {
STATUS_UNKNOWN = 0;
STATUS_ENABLED = 1;
STATUS_DISABLED = 2;
}
message SingleTestExampleDbRpcResponse {
int32 id = 1;
int32 enterpriseId = 2;
string name = 3;
TestExampleDbStatusEnum status = 4;
int32 createdBy = 5;
int64 createdAt = 6;
int32 creationSource = 7;
int32 updatedBy = 8;
int64 updatedAt = 9;
int32 updateSource = 10;
bool isDeleted = 11;
}
message GetTestExampleDbByIdRpcRequest {
int32 id = 1;
}
message GetTestExampleDbByIdRpcResponse {
SingleTestExampleDbRpcResponse response = 1;
}
message GetTestExampleDbByIdsRpcRequest {
repeated int32 ids = 1;
}
message GetTestExampleDbByIdsRpcResponse {
repeated SingleTestExampleDbRpcResponse responses = 1;
}
message GetAllTestExampleDbRpcRequest {
}
message GetAllTestExampleDbRpcResponse {
repeated SingleTestExampleDbRpcResponse responses = 1;
}
message QueryTestExampleDbByConditionRpcRequest {
optional string name = 1;
optional TestExampleDbStatusEnum status = 2;
}
message QueryTestExampleDbByConditionRpcResponse {
repeated SingleTestExampleDbRpcResponse responses = 1;
}
message QueryTestExampleDbByPaginationRpcRequest {
optional string name = 1;
optional TestExampleDbStatusEnum status = 2;
int32 pageNo = 3;
int32 pageSize = 4;
}
message QueryTestExampleDbByPaginationRpcResponse {
int64 total = 1;
int64 pages = 2;
repeated SingleTestExampleDbRpcResponse responses = 3;
}
message TestExampleDbCreation{
string name = 1;
TestExampleDbStatusEnum status = 2;
}
message CreateTestExampleDbRpcRequest {
TestExampleDbCreation creation = 1;
}
message CreateTestExampleDbRpcResponse {
int32 id = 1;
bool isCreated = 2;
}
message BatchCreateTestExampleDbRpcRequest {
repeated TestExampleDbCreation creations = 1;
}
message BatchCreateTestExampleDbRpcResponse {
repeated int32 ids = 1;
bool isCreated = 2;
}
message TestExampleDbModification {
int32 id = 1;
optional string name = 2;
optional TestExampleDbStatusEnum status = 3;
}
message UpdateTestExampleDbRpcRequest {
TestExampleDbModification modification = 1;
}
message UpdateTestExampleDbRpcResponse {
bool isUpdated = 1;
}
message BatchUpdateTestExampleDbRpcRequest {
repeated TestExampleDbModification modifications = 1;
}
message BatchUpdateTestExampleDbRpcResponse {
bool isUpdated = 1;
}
message DeleteTestExampleDbByIdsRpcRequest {
repeated int32 ids = 1;
}
message DeleteTestExampleDbRpcResponse {
bool isDeleted = 1;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tianting.infoloop.mapper.TestExampleDbMapper">
<resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.TestExampleDb">
<id property="id" column="id" jdbcType="INTEGER"/>
<id property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
<result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
<result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
<result property="updatedBy" column="updatedBy" jdbcType="INTEGER"/>
<result property="updatedAt" column="updatedAt" jdbcType="TIMESTAMP"/>
<result property="updateSource" column="updateSource" jdbcType="INTEGER"/>
<result property="isDeleted" column="isDeleted" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id,enterpriseId,name,status,
createdBy,createdAt,creationSource,
updatedBy,updatedAt,updateSource,
isDeleted
</sql>
</mapper>