|
@@ -1,16 +1,64 @@
|
|
|
package com.yaoxiang.planning.action
|
|
|
|
|
|
+import com.yaoxiang.planning.domain.AnnualPlan
|
|
|
+import com.yaoxiang.planning.model.Reply
|
|
|
import com.yaoxiang.planning.service.AnnualPlanService
|
|
|
import io.swagger.annotations.Api
|
|
|
+import io.swagger.annotations.ApiImplicitParam
|
|
|
+import io.swagger.annotations.ApiImplicitParams
|
|
|
+import io.swagger.annotations.ApiOperation
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
|
+import org.springframework.web.bind.annotation.GetMapping
|
|
|
+import org.springframework.web.bind.annotation.PostMapping
|
|
|
import org.springframework.web.bind.annotation.RequestMapping
|
|
|
+import org.thymeleaf.util.DateUtils
|
|
|
+import java.util.*
|
|
|
|
|
|
@Api(tags = ["年度计划"])
|
|
|
@RequestMapping("annual")
|
|
|
-class AnnualAction{
|
|
|
+class AnnualAction {
|
|
|
|
|
|
@Autowired
|
|
|
private lateinit var annualPlanService: AnnualPlanService
|
|
|
|
|
|
+ @ApiOperation("添加年度计划")
|
|
|
+ @ApiImplicitParams(ApiImplicitParam(name = "name", value = "名称", paramType = "query"),
|
|
|
+ ApiImplicitParam(name = "content", value = "计划内容", paramType = "query"),
|
|
|
+ ApiImplicitParam(name = "year", value = "年份", paramType = "query"))
|
|
|
+ @PostMapping("add")
|
|
|
+ fun add(name: String, content: String, year: Int): Reply<Any> {
|
|
|
+ val result = annualPlanService.add(name, content, year)
|
|
|
+ return Reply(result)
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("更新年度计划")
|
|
|
+ @ApiImplicitParams(ApiImplicitParam(name = "id", value = "年度计划id", paramType = "query"),
|
|
|
+ ApiImplicitParam(name = "name", value = "名称", paramType = "query"),
|
|
|
+ ApiImplicitParam(name = "content", value = "计划内容", paramType = "query"),
|
|
|
+ ApiImplicitParam(name = "year", value = "年份", paramType = "query"))
|
|
|
+ @PostMapping("update")
|
|
|
+ fun update(id: Long, name: String, content: String, status: Int): Reply<Any> {
|
|
|
+ val result = annualPlanService.update(id, name, content, status)
|
|
|
+ return Reply(result)
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("delete")
|
|
|
+ fun delete(id: Long): Reply<Any> {
|
|
|
+ val result = annualPlanService.delete(id)
|
|
|
+ return Reply(result)
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("current")
|
|
|
+ fun get(year: Int? = null): Reply<AnnualPlan?> {
|
|
|
+ val y: Int = year ?: DateUtils.year(Date())
|
|
|
+ val optional = annualPlanService.findByYear(y)
|
|
|
+ return Reply(optional.isPresent, "", optional.orElse(null))
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("list")
|
|
|
+ fun list(): Reply<List<AnnualPlan>> {
|
|
|
+ val list = annualPlanService.list()
|
|
|
+ return Reply.ok(list)
|
|
|
+ }
|
|
|
|
|
|
}
|