zhuyifan

删除test

1 -package com.tianting.infoloop.mapper;
2 -
3 -import com.tianting.infoloop.inject.MyBaseMapper;
4 -import com.tianting.infoloop.model.db.TestExampleDb;
5 -
6 -public interface TestExampleDbMapper extends MyBaseMapper<TestExampleDb> {
7 -
8 -}
9 -
10 -
11 -
12 -
1 -package com.tianting.infoloop.model.db;
2 -
3 -import com.baomidou.mybatisplus.annotation.FieldFill;
4 -import com.baomidou.mybatisplus.annotation.IdType;
5 -import com.baomidou.mybatisplus.annotation.TableField;
6 -import com.baomidou.mybatisplus.annotation.TableId;
7 -import com.baomidou.mybatisplus.annotation.TableLogic;
8 -import com.baomidou.mybatisplus.annotation.TableName;
9 -import com.baomidou.mybatisplus.extension.activerecord.Model;
10 -import lombok.Data;
11 -import lombok.EqualsAndHashCode;
12 -import lombok.experimental.Accessors;
13 -
14 -import java.io.Serializable;
15 -import java.time.LocalDateTime;
16 -
17 -/**
18 - * 例子DB
19 - * @TableName test_example_db
20 - */
21 -@Data
22 -@Accessors(chain = true)
23 -@EqualsAndHashCode(callSuper = true)
24 -@TableName(value ="test_example_db")
25 -public class TestExampleDb extends Model<TestExampleDb> implements Serializable {
26 - /**
27 - *
28 - */
29 - @TableId(type = IdType.AUTO)
30 - private Integer id;
31 -
32 - /**
33 - * 企业 ID
34 - */
35 - private Integer enterpriseId;
36 -
37 - /**
38 - * 用户昵称
39 - */
40 - private String name;
41 -
42 - /**
43 - * 用户状态;启用:1;停用:2
44 - */
45 - private Integer status;
46 -
47 - /**
48 - * 创建人 ID
49 - */
50 - @TableField(fill = FieldFill.INSERT)
51 - private Integer createdBy;
52 -
53 - /**
54 - * 创建时间
55 - */
56 - @TableField(fill = FieldFill.INSERT)
57 - private LocalDateTime createdAt;
58 -
59 - /**
60 - * 创建来源
61 - */
62 - @TableField(fill = FieldFill.INSERT)
63 - private Integer creationSource;
64 -
65 - /**
66 - * 修改人 ID
67 - */
68 - @TableField(fill = FieldFill.INSERT_UPDATE)
69 - private Integer updatedBy;
70 -
71 - /**
72 - * 修改时间
73 - */
74 - @TableField(fill = FieldFill.INSERT_UPDATE)
75 - private LocalDateTime updatedAt;
76 -
77 - /**
78 - * 修改来源
79 - */
80 - @TableField(fill = FieldFill.INSERT_UPDATE)
81 - private Integer updateSource;
82 -
83 - /**
84 - * 是否删除;0:未删除,1:已删除
85 - */
86 - @TableLogic
87 - private Boolean isDeleted;
88 -
89 -}
...\ No newline at end of file ...\ No newline at end of file
1 -package com.tianting.infoloop.service;
2 -
3 -import com.baomidou.mybatisplus.extension.service.IService;
4 -import com.tianting.infoloop.grpc.exampleservice.TestExampleDbCreation;
5 -import com.tianting.infoloop.grpc.exampleservice.TestExampleDbModification;
6 -import com.tianting.infoloop.model.db.TestExampleDb;
7 -
8 -import java.util.List;
9 -
10 -/**
11 -* @author zhuyf
12 -* @description 针对表【 test_example_db(例子DB)】的数据库操作Service
13 -* @createDate 2024-10-12 13:53:16
14 -*/
15 -public interface TestExampleDbService extends IService<TestExampleDb> {
16 -
17 - TestExampleDb createTestExampleDb(TestExampleDbCreation creation);
18 -
19 - List<TestExampleDb> batchCreateTestExampleDb(List<TestExampleDbCreation> creationsList);
20 -
21 - boolean updateTestExampleDb(TestExampleDbModification modification);
22 -
23 - boolean batchUpdateTestExampleDb(List<TestExampleDbModification> modificationsList);
24 -}
1 -package com.tianting.infoloop.service.impl;
2 -
3 -
4 -import cn.hutool.extra.spring.SpringUtil;
5 -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6 -import com.tianting.infoloop.grpc.exampleservice.TestExampleDbCreation;
7 -import com.tianting.infoloop.grpc.exampleservice.TestExampleDbModification;
8 -import com.tianting.infoloop.mapper.TestExampleDbMapper;
9 -import com.tianting.infoloop.model.db.TestExampleDb;
10 -import com.tianting.infoloop.service.TestExampleDbService;
11 -import lombok.RequiredArgsConstructor;
12 -import lombok.extern.slf4j.Slf4j;
13 -import org.springframework.beans.factory.annotation.Autowired;
14 -import org.springframework.lang.Nullable;
15 -import org.springframework.stereotype.Service;
16 -
17 -import java.util.Collections;
18 -import java.util.List;
19 -import java.util.stream.Collectors;
20 -
21 -/**
22 -* @author zhuyf
23 -* @description 针对表【 test_example_db(例子DB)】的数据库操作Service实现
24 -* @createDate 2024-10-12 13:53:16
25 -*/
26 -@Slf4j
27 -@Service
28 -@RequiredArgsConstructor(onConstructor_ = @Autowired)
29 -public class TestExampleDbServiceImpl extends ServiceImpl<TestExampleDbMapper, TestExampleDb> implements TestExampleDbService {
30 -
31 - private final TestExampleDbMapper testExampleDbMapper;
32 -
33 - @Override
34 - @Nullable
35 - public TestExampleDb createTestExampleDb(TestExampleDbCreation creation) {
36 - TestExampleDb testExampleDb = new TestExampleDb();
37 - testExampleDb.setName(creation.getName());
38 - testExampleDb.setStatus(creation.getStatusValue());
39 - final var insert = testExampleDbMapper.insert(testExampleDb);
40 - return insert > 0 ? testExampleDb : null;
41 - }
42 -
43 - @Override
44 - public List<TestExampleDb> batchCreateTestExampleDb(List<TestExampleDbCreation> creationsList) {
45 - var list = creationsList.stream().map(creation -> new TestExampleDb()
46 - .setName(creation.getName())
47 - .setStatus(creation.getStatusValue())).collect(Collectors.toList());
48 - return SpringUtil.getBean(TestExampleDbServiceImpl.class).saveBatch(list) ? list : Collections.emptyList();
49 - }
50 -
51 - @Override
52 - public boolean updateTestExampleDb(TestExampleDbModification modification) {
53 - var testExampleDb = new TestExampleDb();
54 - testExampleDb.setId(modification.getId());
55 - if (modification.hasName()) {
56 - testExampleDb.setName(modification.getName());
57 - }
58 - if (modification.hasStatus()) {
59 - testExampleDb.setStatus(modification.getStatusValue());
60 - }
61 - return testExampleDbMapper.updateById(testExampleDb) > 0;
62 - }
63 -
64 - @Override
65 - public boolean batchUpdateTestExampleDb(List<TestExampleDbModification> modificationsList) {
66 - final var list = modificationsList.stream().map(modification -> {
67 - var testExampleDb = new TestExampleDb();
68 - testExampleDb.setId(modification.getId());
69 - if (modification.hasName()) {
70 - testExampleDb.setName(modification.getName());
71 - }
72 - if (modification.hasStatus()) {
73 - testExampleDb.setStatus(modification.getStatusValue());
74 - }
75 - return testExampleDb;
76 - }).collect(Collectors.toList());
77 - return SpringUtil.getBean(TestExampleDbServiceImpl.class).updateBatchById(list);
78 - }
79 -}
80 -
81 -
82 -
83 -
1 -syntax = "proto3";
2 -
3 -option java_multiple_files = true;
4 -option java_package = "com.tianting.infoloop.grpc.exampleservice";
5 -option java_outer_classname = "ExampleServiceProto";
6 -option objc_class_prefix = "OP";
7 -
8 -package com.tianting.infoloop.grpc.exampleservice;
9 -
10 -service ExampleServiceRpc {
11 - rpc GetTestExampleDbById (GetTestExampleDbByIdRpcRequest) returns (GetTestExampleDbByIdRpcResponse) {}
12 - rpc GetTestExampleDbByIds (GetTestExampleDbByIdsRpcRequest) returns (GetTestExampleDbByIdsRpcResponse) {}
13 - rpc GetAllTestExampleDb (GetAllTestExampleDbRpcRequest) returns (GetAllTestExampleDbRpcResponse) {}
14 - rpc QueryTestExampleDbByCondition (QueryTestExampleDbByConditionRpcRequest) returns (QueryTestExampleDbByConditionRpcResponse) {}
15 - rpc QueryTestExampleDbByPagination (QueryTestExampleDbByPaginationRpcRequest) returns (QueryTestExampleDbByPaginationRpcResponse) {}
16 - rpc CreateTestExampleDb (CreateTestExampleDbRpcRequest) returns (CreateTestExampleDbRpcResponse) {}
17 - rpc BatchCreateTestExampleDb (BatchCreateTestExampleDbRpcRequest) returns (BatchCreateTestExampleDbRpcResponse) {}
18 - rpc UpdateTestExampleDb (UpdateTestExampleDbRpcRequest) returns (UpdateTestExampleDbRpcResponse) {}
19 - rpc BatchUpdateTestExampleDb (BatchUpdateTestExampleDbRpcRequest) returns (BatchUpdateTestExampleDbRpcResponse) {}
20 - rpc DeleteTestExampleDbByIds (DeleteTestExampleDbByIdsRpcRequest) returns (DeleteTestExampleDbRpcResponse) {}
21 -}
22 -
23 -enum TestExampleDbStatusEnum {
24 - STATUS_UNKNOWN = 0;
25 - STATUS_ENABLED = 1;
26 - STATUS_DISABLED = 2;
27 -}
28 -
29 -message SingleTestExampleDbRpcResponse {
30 - int32 id = 1;
31 - int32 enterpriseId = 2;
32 - string name = 3;
33 - TestExampleDbStatusEnum status = 4;
34 - int32 createdBy = 5;
35 - int64 createdAt = 6;
36 - int32 creationSource = 7;
37 - int32 updatedBy = 8;
38 - int64 updatedAt = 9;
39 - int32 updateSource = 10;
40 - bool isDeleted = 11;
41 -}
42 -
43 -message GetTestExampleDbByIdRpcRequest {
44 - int32 id = 1;
45 -}
46 -
47 -message GetTestExampleDbByIdRpcResponse {
48 - SingleTestExampleDbRpcResponse response = 1;
49 -}
50 -
51 -message GetTestExampleDbByIdsRpcRequest {
52 - repeated int32 ids = 1;
53 -}
54 -
55 -message GetTestExampleDbByIdsRpcResponse {
56 - repeated SingleTestExampleDbRpcResponse responses = 1;
57 -}
58 -
59 -message GetAllTestExampleDbRpcRequest {
60 -}
61 -
62 -message GetAllTestExampleDbRpcResponse {
63 - repeated SingleTestExampleDbRpcResponse responses = 1;
64 -}
65 -
66 -message QueryTestExampleDbByConditionRpcRequest {
67 - optional string name = 1;
68 - optional TestExampleDbStatusEnum status = 2;
69 -}
70 -
71 -message QueryTestExampleDbByConditionRpcResponse {
72 - repeated SingleTestExampleDbRpcResponse responses = 1;
73 -}
74 -
75 -message QueryTestExampleDbByPaginationRpcRequest {
76 - optional string name = 1;
77 - optional TestExampleDbStatusEnum status = 2;
78 - int32 pageNo = 3;
79 - int32 pageSize = 4;
80 -}
81 -
82 -message QueryTestExampleDbByPaginationRpcResponse {
83 - int64 total = 1;
84 - int64 pages = 2;
85 - repeated SingleTestExampleDbRpcResponse responses = 3;
86 -}
87 -
88 -message TestExampleDbCreation{
89 - string name = 1;
90 - TestExampleDbStatusEnum status = 2;
91 -}
92 -
93 -message CreateTestExampleDbRpcRequest {
94 - TestExampleDbCreation creation = 1;
95 -}
96 -
97 -message CreateTestExampleDbRpcResponse {
98 - int32 id = 1;
99 - bool isCreated = 2;
100 -}
101 -
102 -message BatchCreateTestExampleDbRpcRequest {
103 - repeated TestExampleDbCreation creations = 1;
104 -}
105 -
106 -message BatchCreateTestExampleDbRpcResponse {
107 - repeated int32 ids = 1;
108 - bool isCreated = 2;
109 -}
110 -
111 -message TestExampleDbModification {
112 - int32 id = 1;
113 - optional string name = 2;
114 - optional TestExampleDbStatusEnum status = 3;
115 -}
116 -
117 -message UpdateTestExampleDbRpcRequest {
118 - TestExampleDbModification modification = 1;
119 -}
120 -
121 -message UpdateTestExampleDbRpcResponse {
122 - bool isUpdated = 1;
123 -}
124 -
125 -message BatchUpdateTestExampleDbRpcRequest {
126 - repeated TestExampleDbModification modifications = 1;
127 -}
128 -
129 -message BatchUpdateTestExampleDbRpcResponse {
130 - bool isUpdated = 1;
131 -}
132 -
133 -message DeleteTestExampleDbByIdsRpcRequest {
134 - repeated int32 ids = 1;
135 -}
136 -
137 -message DeleteTestExampleDbRpcResponse {
138 - bool isDeleted = 1;
139 -}
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!DOCTYPE mapper
3 - PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 - "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 -<mapper namespace="com.tianting.infoloop.mapper.TestExampleDbMapper">
6 -
7 - <resultMap id="BaseResultMap" type="com.tianting.infoloop.model.db.TestExampleDb">
8 - <id property="id" column="id" jdbcType="INTEGER"/>
9 - <id property="enterpriseId" column="enterpriseId" jdbcType="INTEGER"/>
10 - <result property="name" column="name" jdbcType="VARCHAR"/>
11 - <result property="status" column="status" jdbcType="TINYINT"/>
12 - <result property="createdBy" column="createdBy" jdbcType="INTEGER"/>
13 - <result property="createdAt" column="createdAt" jdbcType="TIMESTAMP"/>
14 - <result property="creationSource" column="creationSource" jdbcType="INTEGER"/>
15 - <result property="updatedBy" column="updatedBy" jdbcType="INTEGER"/>
16 - <result property="updatedAt" column="updatedAt" jdbcType="TIMESTAMP"/>
17 - <result property="updateSource" column="updateSource" jdbcType="INTEGER"/>
18 - <result property="isDeleted" column="isDeleted" jdbcType="TINYINT"/>
19 - </resultMap>
20 -
21 - <sql id="Base_Column_List">
22 - id,enterpriseId,name,status,
23 - createdBy,createdAt,creationSource,
24 - updatedBy,updatedAt,updateSource,
25 - isDeleted
26 - </sql>
27 -
28 -</mapper>