Skip to content

Commit 5afaee9

Browse files
authored
[type:fix] fix db (#116)
* [type:fix] fix db * [type:fix] fix db
1 parent c7530e4 commit 5afaee9

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

internal/core/openapi/dictionary.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ func (openapi *Openapi) createDictionary(ginCtx *gin.Context) {
9494
dictionary := entity.Dictionary{
9595
UserId: dictParams.UserId,
9696
ScopeSpaceId: dictParams.ScopeSpaceId,
97-
DictKey: dictParams.DictKey + "@" + dictParams.Version,
97+
DictKey: dictParams.DictKey,
98+
Version: dictParams.Version,
9899
DictValue: dictParams.DictValue,
99100
State: dictParams.State,
100101
CreatedAt: time.Now(),

internal/core/storage/xml/scopespace_mapper.xml

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
SELECT <include refid="columns_id"> </include> FROM scopespace
2424
<where>
2525
<if test="{ScopeSpace.id} != nil and {ScopeSpace.id} != 0">AND id = #{ScopeSpace.id} </if>
26+
<if test="{ScopeSpace.user_id} != nil and {ScopeSpace.user_id} != 0">AND user_id = #{ScopeSpace.user_id} </if>
2627
<if test="{ScopeSpace.name} != nil">AND name = #{ScopeSpace.name} </if>
2728
<if test="{ScopeSpace.note} != nil">AND note = #{ScopeSpace.note} </if>
2829
<if test="{ScopeSpace.state} != nil">AND state = #{ScopeSpace.state} </if>
@@ -35,6 +36,7 @@
3536
SELECT COUNT(*) FROM scopespace
3637
<where>
3738
<if test="{ScopeSpace.id} != nil and {ScopeSpace.id} != 0">AND id = #{ScopeSpace.id} </if>
39+
<if test="{ScopeSpace.user_id} != nil and {ScopeSpace.user_id} != 0">AND user_id = #{ScopeSpace.user_id} </if>
3840
<if test="{ScopeSpace.name} != nil">AND name = #{ScopeSpace.name} </if>
3941
<if test="{ScopeSpace.note} != nil">AND note = #{ScopeSpace.note} </if>
4042
<if test="{ScopeSpace.state} != nil">AND state = #{ScopeSpace.state} </if>
@@ -44,9 +46,10 @@
4446
</select>
4547

4648
<insert id="insertScopeSpace">
47-
INSERT INTO scopespace (id,name,note,state,created_at,updated_at)
49+
INSERT INTO scopespace (id,user_id,name,note,state,created_at,updated_at)
4850
VALUES(
4951
#{ScopeSpace.id},
52+
#{ScopeSpace.user_id},
5053
#{ScopeSpace.name},
5154
#{ScopeSpace.note},
5255
#{ScopeSpace.state},
@@ -56,10 +59,10 @@
5659
</insert>
5760

5861
<insert id="insertBatchScopeSpace">
59-
INSERT INTO scopespace (id,name,note,state,created_at,updated_at)
62+
INSERT INTO scopespace (id,user_id,name,note,state,created_at,updated_at)
6063
VALUES
6164
<foreach item="item" index="index" collection="{0}" open="" separator="," close="">
62-
(#{item.ScopeSpace.id},#{item.ScopeSpace.name},#{item.ScopeSpace.note},#{item.ScopeSpace.state},#{item.ScopeSpace.created_at},#{item.ScopeSpace.updated_at})
65+
(#{item.ScopeSpace.id},#{item.ScopeSpace.user_id},#{item.ScopeSpace.name},#{item.ScopeSpace.note},#{item.ScopeSpace.state},#{item.ScopeSpace.created_at},#{item.ScopeSpace.updated_at})
6366
</foreach>
6467
</insert>
6568

@@ -95,6 +98,7 @@
9598
DELETE FROM scopespace
9699
<where>
97100
<if test="{ScopeSpace.id} != nil and {ScopeSpace.id} != 0">AND id = #{ScopeSpace.id} </if>
101+
<if test="{ScopeSpace.user_id} != nil and {ScopeSpace.user_id} != 0">AND user_id = #{ScopeSpace.user_id} </if>
98102
<if test="{ScopeSpace.name} != nil">AND name = #{ScopeSpace.name} </if>
99103
<if test="{ScopeSpace.note} != nil">AND note = #{ScopeSpace.note} </if>
100104
<if test="{ScopeSpace.state} != nil">AND state = #{ScopeSpace.state} </if>

internal/pkg/entity/scopespace.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ import (
2323

2424
type ScopeSpace struct {
2525
//TableName gobatis.TableName `scopespace`
26-
Id int `column:"id"`
27-
Name string `column:"name"`
28-
Note string `column:"note"`
29-
State string `column:"state"`
30-
CreatedAt time.Time `column:"created_at"`
31-
UpdatedAt time.Time `column:"updated_at"`
26+
Id int `column:"id" json:"id"`
27+
UserId int `column:"user_id" json:"userId"`
28+
Name string `column:"name" json:"name"`
29+
Note string `column:"note" json:"note"`
30+
State string `column:"state" json:"state"`
31+
CreatedAt time.Time `column:"created_at" json:"createdAt"`
32+
UpdatedAt time.Time `column:"updated_at" json:"updatedAt"`
3233
}

0 commit comments

Comments
 (0)