feat: update approval by articles
This commit is contained in:
parent
517fb748dc
commit
2193afd1ad
|
|
@ -56,6 +56,7 @@ func (_i *ArticleApprovalFlowsRouter) RegisterArticleApprovalFlowsRoutes() {
|
|||
router.Get("/:id/next-steps-preview", articleApprovalFlowsController.GetNextStepsPreview)
|
||||
router.Post("/submit", articleApprovalFlowsController.SubmitForApproval)
|
||||
router.Post("/:id/multi-branch-approve", articleApprovalFlowsController.ProcessMultiBranchApproval)
|
||||
router.Post("/articles/:articleId/approve", articleApprovalFlowsController.ApproveArticleByFlow)
|
||||
router.Put("/:id/approve", articleApprovalFlowsController.Approve)
|
||||
router.Put("/:id/reject", articleApprovalFlowsController.Reject)
|
||||
router.Put("/:id/request-revision", articleApprovalFlowsController.RequestRevision)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ type ArticleApprovalFlowsController interface {
|
|||
// Multi-branch support methods
|
||||
ProcessMultiBranchApproval(c *fiber.Ctx) error
|
||||
GetNextStepsPreview(c *fiber.Ctx) error
|
||||
|
||||
// Simplified approval by article ID
|
||||
ApproveArticleByFlow(c *fiber.Ctx) error
|
||||
}
|
||||
|
||||
func NewArticleApprovalFlowsController(articleApprovalFlowsService service.ArticleApprovalFlowsService, usersRepo usersRepository.UsersRepository, log zerolog.Logger) ArticleApprovalFlowsController {
|
||||
|
|
@ -748,3 +751,70 @@ func (_i *articleApprovalFlowsController) GetNextStepsPreview(c *fiber.Ctx) erro
|
|||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ApproveArticleByFlow approves an article using its active approval flow
|
||||
// @Summary Approve article by its active approval flow
|
||||
// @Description API for approving an article using its currently active approval flow (simplified version)
|
||||
// @Tags ArticleApprovalFlows
|
||||
// @Security Bearer
|
||||
// @Param Authorization header string true "Insert the Authorization"
|
||||
// @Param articleId path int true "Article ID"
|
||||
// @Param payload body request.ApprovalActionRequest true "Required payload"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
// @Failure 401 {object} response.UnauthorizedError
|
||||
// @Failure 500 {object} response.InternalServerError
|
||||
// @Router /article-approval-flows/articles/{articleId}/approve [post]
|
||||
func (_i *articleApprovalFlowsController) ApproveArticleByFlow(c *fiber.Ctx) error {
|
||||
articleId, err := strconv.Atoi(c.Params("articleId"))
|
||||
if err != nil {
|
||||
return utilRes.ErrorBadRequest(c, "Invalid article ID format")
|
||||
}
|
||||
|
||||
req := new(request.ApprovalActionRequest)
|
||||
if err := c.BodyParser(req); err != nil {
|
||||
return utilRes.ErrorBadRequest(c, "Invalid request body")
|
||||
}
|
||||
|
||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get Authorization token from header
|
||||
authToken := c.Get("Authorization")
|
||||
if authToken == "" {
|
||||
return utilRes.ErrorBadRequest(c, "Authorization token required")
|
||||
}
|
||||
|
||||
user := utilSvc.GetUserInfo(_i.Log, _i.UsersRepo, authToken)
|
||||
if user == nil {
|
||||
return utilRes.ErrorBadRequest(c, "Invalid authorization token")
|
||||
}
|
||||
|
||||
// Find active approval flow for the article
|
||||
activeFlow, err := _i.articleApprovalFlowsService.FindActiveByArticleId(uint(articleId))
|
||||
if err != nil {
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: false,
|
||||
Messages: utilRes.Messages{"No active approval flow found for this article"},
|
||||
})
|
||||
}
|
||||
|
||||
// Process approval using multi-branch logic
|
||||
err = _i.articleApprovalFlowsService.ProcessMultiBranchApproval(authToken, activeFlow.ID, user.ID, req.Message)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
Messages: utilRes.Messages{"Article successfully approved through active approval flow"},
|
||||
Data: map[string]interface{}{
|
||||
"article_id": articleId,
|
||||
"flow_id": activeFlow.ID,
|
||||
"current_step": activeFlow.CurrentStep,
|
||||
"current_branch": activeFlow.CurrentBranch,
|
||||
"workflow_id": activeFlow.WorkflowId,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ type ArticleApprovalFlowsService interface {
|
|||
IsStepApplicableForLevel(step *entity.ApprovalWorkflowSteps, submitterLevelId uint) (isApplicable bool, err error)
|
||||
ProcessParallelBranches(authToken string, flow *entity.ArticleApprovalFlows, nextSteps []*entity.ApprovalWorkflowSteps, approvedById uint, message string) (err error)
|
||||
GetUserLevelId(authToken string, userId uint) (userLevelId uint, err error)
|
||||
FindActiveByArticleId(articleId uint) (flow *entity.ArticleApprovalFlows, err error)
|
||||
}
|
||||
|
||||
func NewArticleApprovalFlowsService(
|
||||
|
|
@ -1377,3 +1378,7 @@ func (_i *articleApprovalFlowsService) completeApprovalFlow(flow *entity.Article
|
|||
func (_i *articleApprovalFlowsService) GetUserLevelId(authToken string, userId uint) (userLevelId uint, err error) {
|
||||
return _i.getUserLevelId(authToken, userId)
|
||||
}
|
||||
|
||||
func (_i *articleApprovalFlowsService) FindActiveByArticleId(articleId uint) (flow *entity.ArticleApprovalFlows, err error) {
|
||||
return _i.ArticleApprovalFlowsRepository.FindActiveByArticleId(articleId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,206 @@
|
|||
# API Approve Article by Active Flow
|
||||
|
||||
## 🚀 **Overview**
|
||||
|
||||
API ini adalah versi yang disederhanakan dari approval process. User cukup memasukkan article ID dan sistem akan otomatis menggunakan approval flow yang sedang aktif untuk artikel tersebut. Tidak perlu mengetahui flow ID atau step yang sedang berjalan.
|
||||
|
||||
## 📋 **Endpoint**
|
||||
|
||||
```
|
||||
POST /api/article-approval-flows/articles/{articleId}/approve
|
||||
```
|
||||
|
||||
## 🔧 **Request Body**
|
||||
|
||||
```json
|
||||
{
|
||||
"message": "Article looks good, approved for next level"
|
||||
}
|
||||
```
|
||||
|
||||
## 📝 **Field Descriptions**
|
||||
|
||||
- `message` (optional): Pesan approval yang akan dicatat dalam log
|
||||
|
||||
## 📤 **Response**
|
||||
|
||||
### **Success Response (200):**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"messages": ["Article successfully approved through active approval flow"],
|
||||
"data": {
|
||||
"article_id": 123,
|
||||
"flow_id": 456,
|
||||
"current_step": 2,
|
||||
"current_branch": "Branch_A",
|
||||
"workflow_id": 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### **Error Response (400) - No Active Flow:**
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"messages": ["No active approval flow found for this article"]
|
||||
}
|
||||
```
|
||||
|
||||
### **Error Response (400) - Invalid Article ID:**
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"messages": ["Invalid article ID format"]
|
||||
}
|
||||
```
|
||||
|
||||
## 🧪 **Curl Examples**
|
||||
|
||||
### **1. Approve Article dengan Message:**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"message": "Article content is good, approved for next level"
|
||||
}'
|
||||
```
|
||||
|
||||
### **2. Approve Article tanpa Message:**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
### **3. Approve Article dengan Message Spesifik:**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"message": "Reviewed and approved. Content meets quality standards."
|
||||
}'
|
||||
```
|
||||
|
||||
## 🔄 **How It Works**
|
||||
|
||||
1. **Input**: User hanya perlu memberikan article ID
|
||||
2. **Find Active Flow**: Sistem mencari approval flow yang aktif untuk artikel tersebut
|
||||
3. **Multi-Branch Logic**: Sistem menggunakan multi-branch approval logic yang sudah ada
|
||||
4. **Process Approval**: Approval diproses sesuai dengan workflow yang sedang berjalan
|
||||
5. **Response**: Return informasi tentang approval yang telah diproses
|
||||
|
||||
## 🎯 **Benefits**
|
||||
|
||||
### **Before (Complex):**
|
||||
```bash
|
||||
# User perlu tahu flow ID dan step
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/456/multi-branch-approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
### **After (Simple):**
|
||||
```bash
|
||||
# User hanya perlu tahu article ID
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
## 🔒 **Authentication**
|
||||
|
||||
API ini memerlukan authentication token. Token harus disertakan di header:
|
||||
|
||||
```
|
||||
Authorization: Bearer YOUR_JWT_TOKEN
|
||||
```
|
||||
|
||||
## ⚠️ **Important Notes**
|
||||
|
||||
1. **Active Flow Required**: Artikel harus memiliki approval flow yang aktif
|
||||
2. **Multi-Branch Support**: Menggunakan multi-branch approval logic yang sudah ada
|
||||
3. **Automatic Detection**: Sistem otomatis mendeteksi flow yang sedang aktif
|
||||
4. **User Level Validation**: Approval hanya bisa dilakukan oleh user dengan level yang sesuai
|
||||
5. **Workflow Progression**: Approval akan mengikuti workflow yang sudah dikonfigurasi
|
||||
|
||||
## 🚨 **Error Handling**
|
||||
|
||||
### **Common Errors:**
|
||||
|
||||
1. **No Active Flow (400)**:
|
||||
- Artikel tidak memiliki approval flow yang aktif
|
||||
- Approval flow sudah selesai atau dibatalkan
|
||||
|
||||
2. **Invalid Article ID (400)**:
|
||||
- Article ID tidak valid atau tidak ditemukan
|
||||
|
||||
3. **Authentication Error (401)**:
|
||||
- Invalid atau missing token
|
||||
- Expired token
|
||||
|
||||
4. **Authorization Error (403)**:
|
||||
- User tidak memiliki permission untuk approve artikel ini
|
||||
- User level tidak sesuai dengan step yang sedang berjalan
|
||||
|
||||
5. **Server Error (500)**:
|
||||
- Database error
|
||||
- Workflow processing error
|
||||
|
||||
## 🔄 **Workflow Integration**
|
||||
|
||||
API ini terintegrasi dengan:
|
||||
|
||||
- ✅ **Multi-Branch Approval Logic**
|
||||
- ✅ **User Level Validation**
|
||||
- ✅ **Workflow Step Progression**
|
||||
- ✅ **Approval History Logging**
|
||||
- ✅ **Notification System**
|
||||
|
||||
## 📊 **Use Cases**
|
||||
|
||||
1. **Simple Approval**: User yang tidak perlu tahu detail workflow
|
||||
2. **Mobile App**: Interface yang sederhana untuk mobile
|
||||
3. **Bulk Operations**: Approve multiple articles dengan script
|
||||
4. **Third-party Integration**: API yang mudah digunakan oleh sistem eksternal
|
||||
|
||||
## 🔄 **Comparison with Existing APIs**
|
||||
|
||||
| Feature | Old API | New API |
|
||||
|---------|---------|---------|
|
||||
| **Complexity** | High (need flow ID) | Low (only article ID) |
|
||||
| **User Experience** | Complex | Simple |
|
||||
| **Error Handling** | Manual flow detection | Automatic |
|
||||
| **Multi-Branch** | ✅ Supported | ✅ Supported |
|
||||
| **Workflow Logic** | ✅ Full control | ✅ Automatic |
|
||||
|
||||
## 🎉 **Migration Guide**
|
||||
|
||||
### **From Old API:**
|
||||
```bash
|
||||
# Old way
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/456/multi-branch-approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
### **To New API:**
|
||||
```bash
|
||||
# New way (simpler)
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**🎉 API ini memberikan pengalaman yang lebih sederhana dan user-friendly untuk proses approval artikel!**
|
||||
|
||||
User tidak perlu lagi mengetahui flow ID atau step yang sedang berjalan - cukup masukkan article ID dan sistem akan menangani sisanya secara otomatis. 🚀
|
||||
|
|
@ -0,0 +1,251 @@
|
|||
# Simplified Article Approval API - Usage Guide
|
||||
|
||||
## 🎯 **Overview**
|
||||
|
||||
API baru ini menyederhanakan proses approval artikel. Sebelumnya user perlu mengetahui flow ID dan step yang sedang berjalan, sekarang cukup dengan article ID saja.
|
||||
|
||||
## 🔄 **Before vs After**
|
||||
|
||||
### **❌ Before (Complex):**
|
||||
```bash
|
||||
# User perlu tahu flow ID (456) dan step yang sedang berjalan
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/456/multi-branch-approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
### **✅ After (Simple):**
|
||||
```bash
|
||||
# User hanya perlu tahu article ID (123)
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/123/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
## 🚀 **New Endpoint**
|
||||
|
||||
```
|
||||
POST /api/article-approval-flows/articles/{articleId}/approve
|
||||
```
|
||||
|
||||
## 📋 **Request Format**
|
||||
|
||||
```json
|
||||
{
|
||||
"message": "Your approval message here"
|
||||
}
|
||||
```
|
||||
|
||||
## 🧪 **Practical Examples**
|
||||
|
||||
### **1. Approve Article dari User Level 3 (Branch A):**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/10/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer USER_LEVEL_3_TOKEN" \
|
||||
-d '{
|
||||
"message": "Content reviewed and approved. Ready for final approval."
|
||||
}'
|
||||
```
|
||||
|
||||
**Expected Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"messages": ["Article successfully approved through active approval flow"],
|
||||
"data": {
|
||||
"article_id": 10,
|
||||
"flow_id": 1,
|
||||
"current_step": 2,
|
||||
"current_branch": "Final_Approval",
|
||||
"workflow_id": 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### **2. Approve Article dari User Level 2 (Final Approval):**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/10/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer USER_LEVEL_2_TOKEN" \
|
||||
-d '{
|
||||
"message": "Final approval granted. Article ready for publication."
|
||||
}'
|
||||
```
|
||||
|
||||
**Expected Response:**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"messages": ["Article successfully approved through active approval flow"],
|
||||
"data": {
|
||||
"article_id": 10,
|
||||
"flow_id": 1,
|
||||
"current_step": 3,
|
||||
"current_branch": "Final_Approval",
|
||||
"workflow_id": 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### **3. Approve Article tanpa Message:**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/10/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
## 🔍 **How It Works Internally**
|
||||
|
||||
1. **Input**: Article ID (123)
|
||||
2. **Find Active Flow**:
|
||||
```sql
|
||||
SELECT * FROM article_approval_flows
|
||||
WHERE article_id = 123 AND status_id = 1
|
||||
```
|
||||
3. **Get Flow Info**:
|
||||
- Flow ID: 456
|
||||
- Current Step: 2
|
||||
- Current Branch: "Branch_A"
|
||||
- Workflow ID: 1
|
||||
4. **Process Approval**: Menggunakan multi-branch logic
|
||||
5. **Update Flow**: Step dan branch diupdate sesuai workflow
|
||||
6. **Response**: Return informasi yang relevan
|
||||
|
||||
## 🎯 **Benefits**
|
||||
|
||||
### **1. Simplified User Experience**
|
||||
- ✅ Tidak perlu tahu flow ID
|
||||
- ✅ Tidak perlu tahu step yang sedang berjalan
|
||||
- ✅ Tidak perlu tahu branch yang aktif
|
||||
- ✅ Cukup masukkan article ID
|
||||
|
||||
### **2. Reduced Complexity**
|
||||
- ✅ API call lebih sederhana
|
||||
- ✅ Error handling lebih mudah
|
||||
- ✅ Integration lebih straightforward
|
||||
- ✅ Maintenance lebih mudah
|
||||
|
||||
### **3. Better Error Messages**
|
||||
- ✅ "No active approval flow found" - jelas dan informatif
|
||||
- ✅ "Invalid article ID format" - mudah dipahami
|
||||
- ✅ Automatic flow detection - tidak perlu manual check
|
||||
|
||||
## 🔄 **Integration Examples**
|
||||
|
||||
### **Frontend Integration:**
|
||||
```javascript
|
||||
// Simple approval function
|
||||
async function approveArticle(articleId, message = '') {
|
||||
const response = await fetch(`/api/article-approval-flows/articles/${articleId}/approve`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ message })
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Usage
|
||||
approveArticle(123, 'Content looks good!');
|
||||
```
|
||||
|
||||
### **Mobile App Integration:**
|
||||
```javascript
|
||||
// React Native example
|
||||
const approveArticle = async (articleId) => {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/article-approval-flows/articles/${articleId}/approve`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${userToken}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
message: 'Approved from mobile app'
|
||||
})
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
Alert.alert('Success', 'Article approved successfully!');
|
||||
} else {
|
||||
Alert.alert('Error', result.messages[0]);
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('Error', 'Failed to approve article');
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## 🚨 **Error Scenarios**
|
||||
|
||||
### **1. No Active Flow:**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/999/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"messages": ["No active approval flow found for this article"]
|
||||
}
|
||||
```
|
||||
|
||||
### **2. Invalid Article ID:**
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/api/article-approval-flows/articles/invalid/approve" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{"message": "Approved"}'
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"messages": ["Invalid article ID format"]
|
||||
}
|
||||
```
|
||||
|
||||
## 📊 **Testing Scenarios**
|
||||
|
||||
### **Test Case 1: Normal Approval Flow**
|
||||
1. Create article dengan user level 5
|
||||
2. Article otomatis masuk ke Branch A (Level 2 A Branch)
|
||||
3. User level 3 approve → masuk ke Final Approval
|
||||
4. User level 2 approve → artikel published
|
||||
|
||||
### **Test Case 2: Branch B Flow**
|
||||
1. Create article dengan user level 6
|
||||
2. Article otomatis masuk ke Branch B (Level 2 B Branch)
|
||||
3. User level 4 approve → masuk ke Final Approval
|
||||
4. User level 2 approve → artikel published
|
||||
|
||||
### **Test Case 3: Error Handling**
|
||||
1. Try approve artikel yang tidak ada approval flow
|
||||
2. Try approve dengan user level yang tidak sesuai
|
||||
3. Try approve artikel yang sudah selesai
|
||||
|
||||
## 🎉 **Summary**
|
||||
|
||||
API baru ini memberikan:
|
||||
|
||||
- ✅ **Simplified Interface**: Cukup article ID
|
||||
- ✅ **Automatic Flow Detection**: Sistem otomatis cari flow aktif
|
||||
- ✅ **Multi-Branch Support**: Tetap mendukung multi-branch logic
|
||||
- ✅ **Better UX**: User experience yang lebih baik
|
||||
- ✅ **Easy Integration**: Mudah diintegrasikan dengan frontend/mobile
|
||||
|
||||
**Sekarang user tidak perlu lagi repot dengan flow ID atau step yang sedang berjalan - cukup masukkan article ID dan sistem akan menangani sisanya!** 🚀
|
||||
|
|
@ -2471,6 +2471,71 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/article-approval-flows/articles/{articleId}/approve": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for approving an article using its currently active approval flow (simplified version)",
|
||||
"tags": [
|
||||
"ArticleApprovalFlows"
|
||||
],
|
||||
"summary": "Approve article by its active approval flow",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Insert the Authorization",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Article ID",
|
||||
"name": "articleId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.ApprovalActionRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/article-approval-flows/dashboard-stats": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -9644,6 +9709,64 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/clients/with-user": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for creating a client and its admin user in a single request",
|
||||
"tags": [
|
||||
"Clients"
|
||||
],
|
||||
"summary": "Create client with admin user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.ClientWithUserCreateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/clients/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -16247,6 +16370,59 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.AdminUserCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"fullname",
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
"type": "string"
|
||||
},
|
||||
"dateOfBirth": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullname": {
|
||||
"type": "string"
|
||||
},
|
||||
"genderType": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityGroup": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityGroupNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityType": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastEducation": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phoneNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"workType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.AdvertisementCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -17035,6 +17211,31 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.ClientWithUserCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"adminUser",
|
||||
"client"
|
||||
],
|
||||
"properties": {
|
||||
"adminUser": {
|
||||
"description": "Admin user information",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/request.AdminUserCreateRequest"
|
||||
}
|
||||
]
|
||||
},
|
||||
"client": {
|
||||
"description": "Client information",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/request.ClientsCreateRequest"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.ClientsCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -2460,6 +2460,71 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/article-approval-flows/articles/{articleId}/approve": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for approving an article using its currently active approval flow (simplified version)",
|
||||
"tags": [
|
||||
"ArticleApprovalFlows"
|
||||
],
|
||||
"summary": "Approve article by its active approval flow",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Insert the Authorization",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Article ID",
|
||||
"name": "articleId",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.ApprovalActionRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/article-approval-flows/dashboard-stats": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -9633,6 +9698,64 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/clients/with-user": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for creating a client and its admin user in a single request",
|
||||
"tags": [
|
||||
"Clients"
|
||||
],
|
||||
"summary": "Create client with admin user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.ClientWithUserCreateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/clients/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -16236,6 +16359,59 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.AdminUserCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"fullname",
|
||||
"password",
|
||||
"username"
|
||||
],
|
||||
"properties": {
|
||||
"address": {
|
||||
"type": "string"
|
||||
},
|
||||
"dateOfBirth": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"fullname": {
|
||||
"type": "string"
|
||||
},
|
||||
"genderType": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityGroup": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityGroupNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"identityType": {
|
||||
"type": "string"
|
||||
},
|
||||
"lastEducation": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phoneNumber": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"workType": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.AdvertisementCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -17024,6 +17200,31 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.ClientWithUserCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"adminUser",
|
||||
"client"
|
||||
],
|
||||
"properties": {
|
||||
"adminUser": {
|
||||
"description": "Admin user information",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/request.AdminUserCreateRequest"
|
||||
}
|
||||
]
|
||||
},
|
||||
"client": {
|
||||
"description": "Client information",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/request.ClientsCreateRequest"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.ClientsCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -69,6 +69,42 @@ definitions:
|
|||
- id
|
||||
- url
|
||||
type: object
|
||||
request.AdminUserCreateRequest:
|
||||
properties:
|
||||
address:
|
||||
type: string
|
||||
dateOfBirth:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
fullname:
|
||||
type: string
|
||||
genderType:
|
||||
type: string
|
||||
identityGroup:
|
||||
type: string
|
||||
identityGroupNumber:
|
||||
type: string
|
||||
identityNumber:
|
||||
type: string
|
||||
identityType:
|
||||
type: string
|
||||
lastEducation:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
phoneNumber:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
workType:
|
||||
type: string
|
||||
required:
|
||||
- email
|
||||
- fullname
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
request.AdvertisementCreateRequest:
|
||||
properties:
|
||||
description:
|
||||
|
|
@ -612,6 +648,20 @@ definitions:
|
|||
- id
|
||||
- prov_id
|
||||
type: object
|
||||
request.ClientWithUserCreateRequest:
|
||||
properties:
|
||||
adminUser:
|
||||
allOf:
|
||||
- $ref: '#/definitions/request.AdminUserCreateRequest'
|
||||
description: Admin user information
|
||||
client:
|
||||
allOf:
|
||||
- $ref: '#/definitions/request.ClientsCreateRequest'
|
||||
description: Client information
|
||||
required:
|
||||
- adminUser
|
||||
- client
|
||||
type: object
|
||||
request.ClientsCreateRequest:
|
||||
properties:
|
||||
clientType:
|
||||
|
|
@ -3384,6 +3434,49 @@ paths:
|
|||
summary: Get approval analytics
|
||||
tags:
|
||||
- ArticleApprovalFlows
|
||||
/article-approval-flows/articles/{articleId}/approve:
|
||||
post:
|
||||
description: API for approving an article using its currently active approval
|
||||
flow (simplified version)
|
||||
parameters:
|
||||
- description: Insert the Authorization
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Article ID
|
||||
in: path
|
||||
name: articleId
|
||||
required: true
|
||||
type: integer
|
||||
- description: Required payload
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.ApprovalActionRequest'
|
||||
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: Approve article by its active approval flow
|
||||
tags:
|
||||
- ArticleApprovalFlows
|
||||
/article-approval-flows/dashboard-stats:
|
||||
get:
|
||||
description: API for getting dashboard statistics
|
||||
|
|
@ -7931,6 +8024,43 @@ paths:
|
|||
summary: Bulk create sub-clients
|
||||
tags:
|
||||
- Clients
|
||||
/clients/with-user:
|
||||
post:
|
||||
description: API for creating a client and its admin user in a single request
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
type: string
|
||||
- description: Required payload
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.ClientWithUserCreateRequest'
|
||||
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: Create client with admin user
|
||||
tags:
|
||||
- Clients
|
||||
/custom-static-pages:
|
||||
get:
|
||||
description: API for getting all CustomStaticPages
|
||||
|
|
|
|||
Loading…
Reference in New Issue