作者 tangxuhui

添加接口 根据code 获取字典

@@ -45,3 +45,12 @@ func (controller *DictionaryController) ListDictionary() { @@ -45,3 +45,12 @@ func (controller *DictionaryController) ListDictionary() {
45 data, err := dictionaryService.ListDictionary(listDictionaryQuery) 45 data, err := dictionaryService.ListDictionary(listDictionaryQuery)
46 controller.Response(data, err) 46 controller.Response(data, err)
47 } 47 }
  48 +
  49 +func (controller *DictionaryController) GetDictionaryByCode() {
  50 + dictionaryService := service.NewDictionaryService(nil)
  51 + getDictionaryQuery := &query.GetDictionaryQuery{}
  52 + dictionaryCode := controller.GetString(":dictionaryCode")
  53 + getDictionaryQuery.DictCode = dictionaryCode
  54 + data, err := dictionaryService.GetDictionary(getDictionaryQuery)
  55 + controller.Response(data, err)
  56 +}
@@ -10,4 +10,5 @@ func init() { @@ -10,4 +10,5 @@ func init() {
10 web.Router("/dictionarys/:dictionaryId", &controllers.DictionaryController{}, "Put:UpdateDictionary") 10 web.Router("/dictionarys/:dictionaryId", &controllers.DictionaryController{}, "Put:UpdateDictionary")
11 web.Router("/dictionarys/:dictionaryId", &controllers.DictionaryController{}, "Get:GetDictionary") 11 web.Router("/dictionarys/:dictionaryId", &controllers.DictionaryController{}, "Get:GetDictionary")
12 web.Router("/dictionarys/search", &controllers.DictionaryController{}, "Post:ListDictionary") 12 web.Router("/dictionarys/search", &controllers.DictionaryController{}, "Post:ListDictionary")
  13 + web.Router("/dictionarys/dictionary-code/:dictionaryCode", &controllers.DictionaryController{}, "Get:GetDictionaryByCode")
13 } 14 }
@@ -4,31 +4,22 @@ import ( @@ -4,31 +4,22 @@ import (
4 "net/http" 4 "net/http"
5 5
6 "github.com/gavv/httpexpect" 6 "github.com/gavv/httpexpect"
7 - "github.com/go-pg/pg/v10"  
8 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/ginkgo"
9 . "github.com/onsi/gomega" 8 . "github.com/onsi/gomega"
10 pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg" 9 pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/infrastructure/pg"
11 ) 10 )
12 11
13 -var _ = Describe("设置消息:共创申请审核通过", func() {  
14 - var noticePersonalId int64  
15 - BeforeEach(func() {  
16 - _, err := pG.DB.QueryOne(  
17 - pg.Scan(&noticePersonalId),  
18 - "INSERT INTO notice_personals (created_at, deleted_at, updated_at, extend, company_id, content, is_read, module, module_action, notice_personal_id, org_id, sys_code, user_id, user_base_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING notice_personal_id",  
19 - "testCreatedAt", "testDeletedAt", "testUpdatedAt", "testExtend", "testCompanyId", "testContent", "testIsRead", "testModule", "testModuleAction", "testNoticePersonalId", "testOrgId", "testSysCode", "testUserId", "testUserBaseId")  
20 - Expect(err).NotTo(HaveOccurred())  
21 - }) 12 +var _ = FDescribe("设置消息:共创申请审核通过", func() {
22 Describe("设置消息:共创申请审核通过", func() { 13 Describe("设置消息:共创申请审核通过", func() {
23 Context("", func() { 14 Context("", func() {
24 It("", func() { 15 It("", func() {
25 httpExpect := httpexpect.New(GinkgoT(), server.URL) 16 httpExpect := httpexpect.New(GinkgoT(), server.URL)
26 body := map[string]interface{}{ 17 body := map[string]interface{}{
27 - "userId": "int64",  
28 - "userBaseId": "int64",  
29 - "orgId": "int64",  
30 - "companyId": "int64",  
31 - "creationProjectId": "int64", 18 + "userId": 1,
  19 + "userBaseId": 2,
  20 + "orgId": 11,
  21 + "companyId": 13,
  22 + "creationProjectId": 111,
32 "creationProjectName": "string", 23 "creationProjectName": "string",
33 "creationProjectNumber": "string", 24 "creationProjectNumber": "string",
34 } 25 }
@@ -39,8 +30,7 @@ var _ = Describe("设置消息:共创申请审核通过", func() { @@ -39,8 +30,7 @@ var _ = Describe("设置消息:共创申请审核通过", func() {
39 JSON(). 30 JSON().
40 Object(). 31 Object().
41 ContainsKey("code").ValueEqual("code", 0). 32 ContainsKey("code").ValueEqual("code", 0).
42 - ContainsKey("msg").ValueEqual("msg", "ok").  
43 - ContainsKey("data").Value("data").Object() 33 + ContainsKey("msg").ValueEqual("msg", "ok")
44 }) 34 })
45 }) 35 })
46 }) 36 })