Compare commits
No commits in common. "f09e28830b0ec6d7b9c7cb3749c0e0e492aa15a7" and "40fdb80f5c341f146dd373ba17dd2c20f2452057" have entirely different histories.
f09e28830b
...
40fdb80f5c
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -57,9 +57,9 @@ func (m *Middleware) Register(db *database.Database) {
|
||||||
|
|
||||||
m.App.Use(cors.New(cors.Config{
|
m.App.Use(cors.New(cors.Config{
|
||||||
Next: utilsSvc.IsEnabled(m.Cfg.Middleware.Cors.Enable),
|
Next: utilsSvc.IsEnabled(m.Cfg.Middleware.Cors.Enable),
|
||||||
AllowOrigins: "http://localhost:3000, http://localhost:4000, https://kontenhumas.com, https://mediapool.id, https://polrinews-project.vercel.app, http://127.0.0.1:3000, http://10.200.202.141",
|
AllowOrigins: "http://localhost:3000, http://localhost:4000, https://kontenhumas.com",
|
||||||
AllowMethods: "HEAD, GET, POST, PUT, DELETE, OPTION, PATCH",
|
AllowMethods: "HEAD, GET, POST, PUT, DELETE, OPTION, PATCH",
|
||||||
AllowHeaders: "Origin, Content-Type, Accept, Accept-Language, Authorization, X-Requested-With, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, X-Csrf-Token, Cookie, Set-Cookie",
|
AllowHeaders: "Origin, Content-Type, Accept, Accept-Language, Authorization, X-Requested-With, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Credentials, X-Csrf-Token, Cookie, Set-Cookie",
|
||||||
ExposeHeaders: "Content-Length, Content-Type",
|
ExposeHeaders: "Content-Length, Content-Type",
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
MaxAge: 12,
|
MaxAge: 12,
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ func (_i *ArticlesRouter) RegisterArticlesRoutes() {
|
||||||
// define routes
|
// define routes
|
||||||
_i.App.Route("/articles", func(router fiber.Router) {
|
_i.App.Route("/articles", func(router fiber.Router) {
|
||||||
router.Get("/", articlesController.All)
|
router.Get("/", articlesController.All)
|
||||||
router.Get("/old-id/:id", articlesController.ShowByOldId)
|
|
||||||
router.Get("/:id", articlesController.Show)
|
router.Get("/:id", articlesController.Show)
|
||||||
router.Post("/", articlesController.Save)
|
router.Post("/", articlesController.Save)
|
||||||
router.Put("/:id", articlesController.Update)
|
router.Put("/:id", articlesController.Update)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ type articlesController struct {
|
||||||
type ArticlesController interface {
|
type ArticlesController interface {
|
||||||
All(c *fiber.Ctx) error
|
All(c *fiber.Ctx) error
|
||||||
Show(c *fiber.Ctx) error
|
Show(c *fiber.Ctx) error
|
||||||
ShowByOldId(c *fiber.Ctx) error
|
|
||||||
Save(c *fiber.Ctx) error
|
Save(c *fiber.Ctx) error
|
||||||
SaveThumbnail(c *fiber.Ctx) error
|
SaveThumbnail(c *fiber.Ctx) error
|
||||||
Update(c *fiber.Ctx) error
|
Update(c *fiber.Ctx) error
|
||||||
|
|
@ -112,35 +111,6 @@ func (_i *articlesController) Show(c *fiber.Ctx) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShowByOldId Articles
|
|
||||||
// @Summary Get one Articles
|
|
||||||
// @Description API for getting one Articles
|
|
||||||
// @Tags Articles
|
|
||||||
// @Security Bearer
|
|
||||||
// @Param id path int true "Articles Old ID"
|
|
||||||
// @Success 200 {object} response.Response
|
|
||||||
// @Failure 400 {object} response.BadRequestError
|
|
||||||
// @Failure 401 {object} response.UnauthorizedError
|
|
||||||
// @Failure 500 {object} response.InternalServerError
|
|
||||||
// @Router /articles/old-id/{id} [get]
|
|
||||||
func (_i *articlesController) ShowByOldId(c *fiber.Ctx) error {
|
|
||||||
id, err := strconv.ParseUint(c.Params("id"), 10, 0)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
articlesData, err := _i.articlesService.ShowByOldId(uint(id))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return utilRes.Resp(c, utilRes.Response{
|
|
||||||
Success: true,
|
|
||||||
Messages: utilRes.Messages{"Articles successfully retrieved"},
|
|
||||||
Data: articlesData,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save Articles
|
// Save Articles
|
||||||
// @Summary Create Articles
|
// @Summary Create Articles
|
||||||
// @Description API for create Articles
|
// @Description API for create Articles
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,6 @@ func ArticlesResponseMapper(
|
||||||
ShareCount: articlesReq.ShareCount,
|
ShareCount: articlesReq.ShareCount,
|
||||||
ViewCount: articlesReq.ViewCount,
|
ViewCount: articlesReq.ViewCount,
|
||||||
CommentCount: articlesReq.CommentCount,
|
CommentCount: articlesReq.CommentCount,
|
||||||
OldId: articlesReq.OldId,
|
|
||||||
StatusId: articlesReq.StatusId,
|
StatusId: articlesReq.StatusId,
|
||||||
IsBanner: articlesReq.IsBanner,
|
IsBanner: articlesReq.IsBanner,
|
||||||
IsPublish: articlesReq.IsPublish,
|
IsPublish: articlesReq.IsPublish,
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ type ArticlesRepository interface {
|
||||||
GetAllPublishSchedule() (articless []*entity.Articles, err error)
|
GetAllPublishSchedule() (articless []*entity.Articles, err error)
|
||||||
FindOne(id uint) (articles *entity.Articles, err error)
|
FindOne(id uint) (articles *entity.Articles, err error)
|
||||||
FindByFilename(thumbnailName string) (articleReturn *entity.Articles, err error)
|
FindByFilename(thumbnailName string) (articleReturn *entity.Articles, err error)
|
||||||
FindByOldId(oldId uint) (articles *entity.Articles, err error)
|
|
||||||
Create(articles *entity.Articles) (articleReturn *entity.Articles, err error)
|
Create(articles *entity.Articles) (articleReturn *entity.Articles, err error)
|
||||||
Update(id uint, articles *entity.Articles) (err error)
|
Update(id uint, articles *entity.Articles) (err error)
|
||||||
UpdateSkipNull(id uint, articles *entity.Articles) (err error)
|
UpdateSkipNull(id uint, articles *entity.Articles) (err error)
|
||||||
|
|
@ -126,6 +125,7 @@ func (_i *articlesRepository) FindOne(id uint) (articles *entity.Articles, err e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *articlesRepository) FindByFilename(thumbnailName string) (articles *entity.Articles, err error) {
|
func (_i *articlesRepository) FindByFilename(thumbnailName string) (articles *entity.Articles, err error) {
|
||||||
|
|
||||||
if err := _i.DB.DB.Where("thumbnail_name = ?", thumbnailName).First(&articles).Error; err != nil {
|
if err := _i.DB.DB.Where("thumbnail_name = ?", thumbnailName).First(&articles).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -133,14 +133,6 @@ func (_i *articlesRepository) FindByFilename(thumbnailName string) (articles *en
|
||||||
return articles, nil
|
return articles, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *articlesRepository) FindByOldId(oldId uint) (articles *entity.Articles, err error) {
|
|
||||||
if err := _i.DB.DB.Where("old_id = ?", oldId).First(&articles).Error; err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return articles, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_i *articlesRepository) Create(articles *entity.Articles) (articleReturn *entity.Articles, err error) {
|
func (_i *articlesRepository) Create(articles *entity.Articles) (articleReturn *entity.Articles, err error) {
|
||||||
result := _i.DB.DB.Create(articles)
|
result := _i.DB.DB.Create(articles)
|
||||||
return articles, result.Error
|
return articles, result.Error
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ type ArticlesResponse struct {
|
||||||
ViewCount *int `json:"viewCount"`
|
ViewCount *int `json:"viewCount"`
|
||||||
CommentCount *int `json:"commentCount"`
|
CommentCount *int `json:"commentCount"`
|
||||||
AiArticleId *int `json:"aiArticleId"`
|
AiArticleId *int `json:"aiArticleId"`
|
||||||
OldId *uint `json:"oldId"`
|
|
||||||
StatusId *int `json:"statusId"`
|
StatusId *int `json:"statusId"`
|
||||||
IsBanner *bool `json:"isBanner"`
|
IsBanner *bool `json:"isBanner"`
|
||||||
IsPublish *bool `json:"isPublish"`
|
IsPublish *bool `json:"isPublish"`
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ type articlesService struct {
|
||||||
type ArticlesService interface {
|
type ArticlesService interface {
|
||||||
All(req request.ArticlesQueryRequest) (articles []*response.ArticlesResponse, paging paginator.Pagination, err error)
|
All(req request.ArticlesQueryRequest) (articles []*response.ArticlesResponse, paging paginator.Pagination, err error)
|
||||||
Show(id uint) (articles *response.ArticlesResponse, err error)
|
Show(id uint) (articles *response.ArticlesResponse, err error)
|
||||||
ShowByOldId(oldId uint) (articles *response.ArticlesResponse, err error)
|
|
||||||
Save(req request.ArticlesCreateRequest, authToken string) (articles *entity.Articles, err error)
|
Save(req request.ArticlesCreateRequest, authToken string) (articles *entity.Articles, err error)
|
||||||
SaveThumbnail(c *fiber.Ctx) (err error)
|
SaveThumbnail(c *fiber.Ctx) (err error)
|
||||||
Update(id uint, req request.ArticlesUpdateRequest) (err error)
|
Update(id uint, req request.ArticlesUpdateRequest) (err error)
|
||||||
|
|
@ -131,17 +130,6 @@ func (_i *articlesService) Show(id uint) (articles *response.ArticlesResponse, e
|
||||||
return mapper.ArticlesResponseMapper(_i.Log, host, result, _i.ArticleCategoriesRepo, _i.ArticleCategoryDetailsRepo, _i.ArticleFilesRepo, _i.UsersRepo), nil
|
return mapper.ArticlesResponseMapper(_i.Log, host, result, _i.ArticleCategoriesRepo, _i.ArticleCategoryDetailsRepo, _i.ArticleFilesRepo, _i.UsersRepo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *articlesService) ShowByOldId(oldId uint) (articles *response.ArticlesResponse, err error) {
|
|
||||||
result, err := _i.Repo.FindByOldId(oldId)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
host := _i.Cfg.App.Domain
|
|
||||||
|
|
||||||
return mapper.ArticlesResponseMapper(_i.Log, host, result, _i.ArticleCategoriesRepo, _i.ArticleCategoryDetailsRepo, _i.ArticleFilesRepo, _i.UsersRepo), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_i *articlesService) Save(req request.ArticlesCreateRequest, authToken string) (articles *entity.Articles, err error) {
|
func (_i *articlesService) Save(req request.ArticlesCreateRequest, authToken string) (articles *entity.Articles, err error) {
|
||||||
_i.Log.Info().Interface("data", req).Msg("")
|
_i.Log.Info().Interface("data", req).Msg("")
|
||||||
newReq := req.ToEntity()
|
newReq := req.ToEntity()
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ func (_i *usersRepository) GetAll(req request.UsersQueryRequest) (userss []*user
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *usersRepository) FindOne(id uint) (users *users.Users, err error) {
|
func (_i *usersRepository) FindOne(id uint) (users *users.Users, err error) {
|
||||||
if err := _i.DB.DB.Preload("UserLevel").First(&users, id).Error; err != nil {
|
if err := _i.DB.DB.First(&users, id).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ func (_i *usersRepository) FindByKeycloakId(keycloakId string) (users *users.Use
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *usersRepository) FindByUsername(username string) (users *users.Users, err error) {
|
func (_i *usersRepository) FindByUsername(username string) (users *users.Users, err error) {
|
||||||
if err := _i.DB.DB.Where("username = ?", username).Preload("UserLevel").First(&users).Error; err != nil {
|
if err := _i.DB.DB.Where("username = ?", username).First(&users).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,8 +140,6 @@ func (_i *usersRepository) Create(users *users.Users) (userReturn *users.Users,
|
||||||
|
|
||||||
func (_i *usersRepository) Update(id uint, userReturn *users.Users) (err error) {
|
func (_i *usersRepository) Update(id uint, userReturn *users.Users) (err error) {
|
||||||
userReturnMap, err := StructToMap(userReturn)
|
userReturnMap, err := StructToMap(userReturn)
|
||||||
delete(userReturnMap, "user_levels")
|
|
||||||
_i.Log.Info().Interface("Update", userReturnMap).Msg("")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -459,10 +459,7 @@ func (_i *usersService) SetupEmail(req request.UserEmailValidationRequest) (msgR
|
||||||
return nil, fmt.Errorf("username / password incorrect")
|
return nil, fmt.Errorf("username / password incorrect")
|
||||||
}
|
}
|
||||||
|
|
||||||
_i.Log.Info().Interface("findUser", "").Msg("")
|
|
||||||
findUser, err := _i.Repo.FindByUsername(*req.Username)
|
findUser, err := _i.Repo.FindByUsername(*req.Username)
|
||||||
|
|
||||||
_i.Log.Info().Interface("findUser", findUser).Msg("")
|
|
||||||
if findUser == nil || err != nil {
|
if findUser == nil || err != nil {
|
||||||
return nil, fmt.Errorf("username / password incorrect")
|
return nil, fmt.Errorf("username / password incorrect")
|
||||||
}
|
}
|
||||||
|
|
@ -471,9 +468,7 @@ func (_i *usersService) SetupEmail(req request.UserEmailValidationRequest) (msgR
|
||||||
if findUser.Email == *req.OldEmail {
|
if findUser.Email == *req.OldEmail {
|
||||||
findUser.Email = *req.NewEmail
|
findUser.Email = *req.NewEmail
|
||||||
findUser.IsEmailUpdated = &isTrue
|
findUser.IsEmailUpdated = &isTrue
|
||||||
_i.Log.Info().Interface("Update", "").Msg("")
|
|
||||||
err = _i.Repo.Update(findUser.ID, findUser)
|
err = _i.Repo.Update(findUser.ID, findUser)
|
||||||
_i.Log.Info().Interface("Update", err).Msg("")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,9 @@ max = 20
|
||||||
expiration_seconds = 60
|
expiration_seconds = 60
|
||||||
|
|
||||||
[middleware.csrf]
|
[middleware.csrf]
|
||||||
enable = false
|
enable = true
|
||||||
cookie-name = "csrf_"
|
cookie-name = "csrf_"
|
||||||
cookie-same-site = "Lax"
|
cookie-same-site = "None"
|
||||||
cookie-secure = false
|
cookie-secure = false
|
||||||
cookie-session-only = true
|
cookie-session-only = true
|
||||||
cookie-http-only = true
|
cookie-http-only = true
|
||||||
|
|
@ -77,6 +77,6 @@ admin-password = "P@ssw0rd.1"
|
||||||
host = "smtp-app.polri.go.id"
|
host = "smtp-app.polri.go.id"
|
||||||
port = 465
|
port = 465
|
||||||
username = "webhumas.divhumas@polri.go.id"
|
username = "webhumas.divhumas@polri.go.id"
|
||||||
password = "7ZXBaIyD0HdQ"
|
password = "z0VfYLbaghPc"
|
||||||
from-address = "webhumas.divhumas@polri.go.id"
|
from-address = "webhumas.divhumas@polri.go.id"
|
||||||
from-name = "APLIKASI WEB HUMAS DIVHUMAS POLRI"
|
from-name = "APLIKASI WEB HUMAS DIVHUMAS POLRI"
|
||||||
|
|
@ -3588,55 +3588,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/articles/old-id/{id}": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"Bearer": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "API for getting one Articles",
|
|
||||||
"tags": [
|
|
||||||
"Articles"
|
|
||||||
],
|
|
||||||
"summary": "Get one Articles",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Articles Old ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.Response"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.BadRequestError"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"401": {
|
|
||||||
"description": "Unauthorized",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.UnauthorizedError"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.InternalServerError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/articles/publish-scheduling": {
|
"/articles/publish-scheduling": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
|
||||||
|
|
@ -3577,55 +3577,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/articles/old-id/{id}": {
|
|
||||||
"get": {
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"Bearer": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "API for getting one Articles",
|
|
||||||
"tags": [
|
|
||||||
"Articles"
|
|
||||||
],
|
|
||||||
"summary": "Get one Articles",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Articles Old ID",
|
|
||||||
"name": "id",
|
|
||||||
"in": "path",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.Response"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Bad Request",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.BadRequestError"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"401": {
|
|
||||||
"description": "Unauthorized",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.UnauthorizedError"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"description": "Internal Server Error",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/response.InternalServerError"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/articles/publish-scheduling": {
|
"/articles/publish-scheduling": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|
|
||||||
|
|
@ -3327,37 +3327,6 @@ paths:
|
||||||
summary: Update Banner Articles
|
summary: Update Banner Articles
|
||||||
tags:
|
tags:
|
||||||
- Articles
|
- Articles
|
||||||
/articles/old-id/{id}:
|
|
||||||
get:
|
|
||||||
description: API for getting one Articles
|
|
||||||
parameters:
|
|
||||||
- description: Articles Old ID
|
|
||||||
in: path
|
|
||||||
name: id
|
|
||||||
required: true
|
|
||||||
type: integer
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: OK
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/response.Response'
|
|
||||||
"400":
|
|
||||||
description: Bad Request
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/response.BadRequestError'
|
|
||||||
"401":
|
|
||||||
description: Unauthorized
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/response.UnauthorizedError'
|
|
||||||
"500":
|
|
||||||
description: Internal Server Error
|
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/response.InternalServerError'
|
|
||||||
security:
|
|
||||||
- Bearer: []
|
|
||||||
summary: Get one Articles
|
|
||||||
tags:
|
|
||||||
- Articles
|
|
||||||
/articles/publish-scheduling:
|
/articles/publish-scheduling:
|
||||||
post:
|
post:
|
||||||
description: API for Publish Schedule of Article
|
description: API for Publish Schedule of Article
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue