How to use mongodb for ifelse Operation in spring boot

data stores a field type (as an enumeration). When querying, it needs to be processed separately by using ifelse or switch, for example, 1 is converted to normal. I"ve implemented it with the MongoDB statement, but how do I handle it in the springboot framework? The sql statement is as follows:

ifelse:

db.getCollection("Historys").aggregate(
    [
    {
        $project:{
            "count":{
                $cond:{
                        if:{$eq:["$type",1]},then:1*8,else:{
                        $cond:{if:{$eq:["$type",2]},then:2,else:{
                            $cond:[{$eq:["$type",3]},5,0]
                            }}
                        }
                    }
                }
            }
        }
    ]
    )

switch:

db.getCollection("Historys").aggregate([{
    $project:{"type":1,"count":
        {$switch:{
            branches:[
            {case:{$eq:["$type",1]},then:1*9},
            {case:{$eq:["$type",2]},then:"2"},
            {case:{$eq:["$type",3]},then:"3"}
            ],
            default:0
            }}
        }
    }])
Feb.28,2021

spell your sentences into Document@@ of mongodb

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdc875-31313.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdc875-31313.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?