|
@@ -0,0 +1,151 @@
|
|
|
+package com.miaxis.app.controller.gan;
|
|
|
+
|
|
|
+import com.miaxis.common.annotation.Log;
|
|
|
+import com.miaxis.common.constant.Constants;
|
|
|
+import com.miaxis.common.core.controller.BaseController;
|
|
|
+import com.miaxis.common.core.domain.Response;
|
|
|
+import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
+import com.miaxis.common.enums.BusinessTypeEnum;
|
|
|
+import com.miaxis.common.utils.poi.ExcelUtil;
|
|
|
+import com.miaxis.gan.domain.GanZhi;
|
|
|
+import com.miaxis.gan.dto.GanZhiDto;
|
|
|
+import com.miaxis.gan.service.IGanZhiService;
|
|
|
+import com.miaxis.gan.vo.GanZhiRowVo;
|
|
|
+import com.miaxis.gan.vo.GanZhiVo;
|
|
|
+import com.nlf.calendar.Lunar;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 【天干地支】Controller
|
|
|
+ *
|
|
|
+ * @author miaxis
|
|
|
+ * @date 2023-11-16
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping(Constants.OPEN_PREFIX+"/gan/zhi")
|
|
|
+@Api(tags={"【app-天干地支】"})
|
|
|
+public class GanZhiController extends BaseController{
|
|
|
+ @Autowired
|
|
|
+ private IGanZhiService ganZhiService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询天干地支列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperation("查询天干地支列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
|
|
|
+ })
|
|
|
+ public ResponsePageInfo<GanZhi> list(@ModelAttribute GanZhi ganZhi){
|
|
|
+ startPage();
|
|
|
+ List<GanZhi> list = ganZhiService.selectGanZhiList(ganZhi);
|
|
|
+ return toResponsePageInfo(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询天干地支列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get8ziByDate")
|
|
|
+ @ApiOperation("干支查询8字")
|
|
|
+ public Response<GanZhiVo> get8ziByDate(@ModelAttribute GanZhiDto ganZhiDto){
|
|
|
+
|
|
|
+ Date birthDay = ganZhiDto.getBirthDay();
|
|
|
+ Lunar lunar = Lunar.fromDate(birthDay);
|
|
|
+
|
|
|
+ System.out.println("农历:"+lunar.getYear()+"年(生肖"+lunar.getYearShengXiao()+")"+lunar.getMonth()+"月"+lunar.getDay()+"日"+lunar.getTime()+"时");
|
|
|
+
|
|
|
+ // 获取干支纪年
|
|
|
+ ganZhiDto.setYearGan(lunar.getYearGan());
|
|
|
+ ganZhiDto.setYearZhi(lunar.getYearZhi());
|
|
|
+
|
|
|
+ ganZhiDto.setMonthGan(lunar.getMonthGan());
|
|
|
+ ganZhiDto.setMonthZhi(lunar.getMonthZhi());
|
|
|
+
|
|
|
+ ganZhiDto.setDayGan(lunar.getDayGan());
|
|
|
+ ganZhiDto.setDayZhi(lunar.getDayZhi());
|
|
|
+
|
|
|
+ ganZhiDto.setTimeGan(lunar.getTimeGan());
|
|
|
+ ganZhiDto.setTimeZhi(lunar.getTimeZhi());
|
|
|
+
|
|
|
+ List<GanZhiRowVo> ganZhiRowVoList = ganZhiService.selectGanZhiRowVoList(ganZhiDto);
|
|
|
+ List<GanZhiRowVo> ganZhiRowVoCountList = ganZhiService.selectGanZhiRowVoList(ganZhiDto);
|
|
|
+
|
|
|
+
|
|
|
+ GanZhiVo ganZhiVo = new GanZhiVo();
|
|
|
+ ganZhiVo.setNongDay(lunar.getYear()+"年(生肖"+lunar.getYearShengXiao()+")"+lunar.getMonth()+"月"+lunar.getDay()+"日"+lunar.getTime()+"时");
|
|
|
+ ganZhiVo.setBirthDay(ganZhiDto.getBirthDay());
|
|
|
+ ganZhiVo.setGanZhiRowVoList(ganZhiRowVoList);
|
|
|
+ ganZhiVo.setUsername(ganZhiDto.getUsename());
|
|
|
+ ganZhiVo.setSex(ganZhiDto.getSex());
|
|
|
+
|
|
|
+ // 输出结果
|
|
|
+ return Response.success(ganZhiVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出天干地支列表
|
|
|
+ */
|
|
|
+ @GetMapping("/export")
|
|
|
+ @ApiOperation("导出天干地支列表Excel")
|
|
|
+ public Response<String> export(@ModelAttribute GanZhi ganZhi){
|
|
|
+ List<GanZhi> list = ganZhiService.selectGanZhiList(ganZhi);
|
|
|
+ ExcelUtil<GanZhi> util = new ExcelUtil<GanZhi>(GanZhi.class);
|
|
|
+ return util.exportExcel(list, "zhi");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取天干地支详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ @ApiOperation("获取天干地支详细信息")
|
|
|
+ public Response<GanZhi> getInfo(
|
|
|
+ @ApiParam(name = "id", value = "天干地支参数", required = true)
|
|
|
+ @PathVariable("id") Long id
|
|
|
+ ){
|
|
|
+ return Response.success(ganZhiService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增天干地支
|
|
|
+ */
|
|
|
+ @Log(title = "天干地支", businessType = BusinessTypeEnum.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation("新增天干地支")
|
|
|
+ public Response<Integer> add(@RequestBody GanZhi ganZhi){
|
|
|
+ return toResponse(ganZhiService.save(ganZhi) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改天干地支
|
|
|
+ */
|
|
|
+ @Log(title = "天干地支", businessType = BusinessTypeEnum.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation("修改天干地支")
|
|
|
+ public Response<Integer> edit(@RequestBody GanZhi ganZhi){
|
|
|
+ return toResponse(ganZhiService.updateById(ganZhi) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除天干地支
|
|
|
+ */
|
|
|
+ @Log(title = "天干地支", businessType = BusinessTypeEnum.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ @ApiOperation("删除天干地支")
|
|
|
+ public Response<Integer> remove(
|
|
|
+ @ApiParam(name = "ids", value = "天干地支ids参数", required = true)
|
|
|
+ @PathVariable Long[] ids
|
|
|
+ ){
|
|
|
+ return toResponse(ganZhiService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
|
|
+ }
|
|
|
+}
|