# BudgetDatabaseEmailConfigController.java

    package cloud.wconnect.rateshop.controller.budgetdatabase;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.rateshop.pojo.dto.budgetdatabase.BudgetDatabaseEmailConfigDTO;
    import cloud.wconnect.rateshop.service.budgetdatabase.IBudgetDatabaseConfigEmailService;
    import com.google.common.collect.ImmutableMap;
    import jakarta.validation.Valid;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;

    import java.util.Map;

    /**
     * <p>
     * 邮件配置表 前端控制器
     * </p>
     *
     * @author yyt
     * @since 2023-10-26
     */
    @RestController
    @RequestMapping("/budget-database/email-config")
    public class BudgetDatabaseEmailConfigController {

        @Autowired
        private SessionContext sessionContext;
        @Autowired
        private IBudgetDatabaseConfigEmailService budgetDatabaseConfigEmailService;

        /**
         * 1564 - 获取邮件配置
         *
         * @param property 资产标识
         * @param type      1：到期通知
         * @return 邮件配置
         * @author yyt
         * @date 2025/8/16
         */
        @ApiId(1564)
        @GetMapping
        public BudgetDatabaseEmailConfigDTO get(String property, @RequestParam int type) {
            return budgetDatabaseConfigEmailService.getEmailConfigDTO(sessionContext.getPropertyId(property), type);
        }

        /**
         * 1565 - 保存邮件配置
         *
         * @param property  资产标识
         * @param configDTO 邮件配置
         * @return 配置 id
         * @author yyt
         * @date 2025/8/16
         */
        @ApiId(1565)
        @PostMapping
        public Map<String, Object> save(String property, @Valid @RequestBody BudgetDatabaseEmailConfigDTO configDTO) {
            int propertyId = sessionContext.getPropertyId(property);

            return ImmutableMap.of("id", budgetDatabaseConfigEmailService.save(propertyId, configDTO));
        }

    }