zhangbin 1 gadu atpakaļ
vecāks
revīzija
124eff9b01

+ 151 - 0
xpgx-admin/src/main/java/com/miaxis/app/controller/gan/GanZhiController.java

@@ -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);
+    }
+}

+ 59 - 0
xpgx-service/src/main/java/com/miaxis/gan/domain/GanZhi.java

@@ -0,0 +1,59 @@
+package com.miaxis.gan.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.miaxis.common.annotation.Excel;
+import com.miaxis.common.core.domain.BaseBusinessEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+/**
+ * 天干地支对象 gan_zhi
+ *
+ * @author miaxis
+ * @date 2023-11-16
+ */
+@Data
+@TableName("gan_zhi")
+@ApiModel(value = "GanZhiDto", description = "天干地支对象 gan_zhi")
+public class GanZhi extends BaseBusinessEntity{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    @TableId(value = "id")
+    @ApiModelProperty(value = "$column.columnComment")
+    private Long id;
+
+    /** 天干地支名   */
+    @Excel(name = "天干地支名  ")
+    @TableField("name")
+    @ApiModelProperty(value = "天干地支名  ")
+    private String name;
+
+    /** 颜色 */
+    @Excel(name = "颜色")
+    @TableField("color")
+    @ApiModelProperty(value = "颜色")
+    private String color;
+
+    /** 五行 */
+    @Excel(name = "五行")
+    @TableField("five")
+    @ApiModelProperty(value = "五行")
+    private String five;
+
+    /** 喜用 */
+    @Excel(name = "喜用")
+    @TableField("xi")
+    @ApiModelProperty(value = "喜用")
+    private String xi;
+
+    /** 忌用 */
+    @Excel(name = "忌用")
+    @TableField("ji")
+    @ApiModelProperty(value = "忌用")
+    private String ji;
+
+
+}

+ 58 - 0
xpgx-service/src/main/java/com/miaxis/gan/dto/GanZhiDto.java

@@ -0,0 +1,58 @@
+package com.miaxis.gan.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 天干地支对象 gan_zhi
+ *
+ * @author miaxis
+ * @date 2023-11-16
+ */
+@Data
+public class GanZhiDto {
+
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty(value = "姓名")
+    private String usename;
+
+    @ApiModelProperty(value = "性别")
+    private Integer sex;
+
+    @ApiModelProperty(value = "出生日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
+    private Date birthDay;
+
+    @ApiModelProperty(value = "是否保存 0:不保存 1保存")
+    private Integer isSave;
+
+    @ApiModelProperty(value = "年干",hidden = true)
+    private String yearGan;
+
+    @ApiModelProperty(value = "年支",hidden = true)
+    private String yearZhi;
+
+    @ApiModelProperty(value = "月干",hidden = true)
+    private String monthGan;
+
+    @ApiModelProperty(value = "月支",hidden = true)
+    private String monthZhi;
+
+    @ApiModelProperty(value = "日干",hidden = true)
+    private String dayGan;
+
+    @ApiModelProperty(value = "日支",hidden = true)
+    private String dayZhi;
+
+    @ApiModelProperty(value = "时干",hidden = true)
+    private String timeGan;
+
+    @ApiModelProperty(value = "时支",hidden = true)
+    private String timeZhi;
+
+}

+ 25 - 0
xpgx-service/src/main/java/com/miaxis/gan/mapper/GanZhiMapper.java

@@ -0,0 +1,25 @@
+package com.miaxis.gan.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.miaxis.gan.domain.GanZhi;
+import com.miaxis.gan.dto.GanZhiDto;
+import com.miaxis.gan.vo.GanZhiRowVo;
+
+/**
+ * 天干地支Mapper接口
+ *
+ * @author miaxis
+ * @date 2023-11-16
+ */
+public interface GanZhiMapper extends BaseMapper<GanZhi> {
+    /**
+     * 查询天干地支列表
+     *
+     * @param ganZhi 天干地支
+     * @return 天干地支集合
+     */
+    List<GanZhi> selectGanZhiList(GanZhi ganZhi);
+
+    List<GanZhiRowVo> selectGanZhiRowVoList(GanZhiDto ganZhiDto);
+}

+ 26 - 0
xpgx-service/src/main/java/com/miaxis/gan/service/IGanZhiService.java

@@ -0,0 +1,26 @@
+package com.miaxis.gan.service;
+
+import java.util.List;
+import com.miaxis.gan.domain.GanZhi;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.miaxis.gan.dto.GanZhiDto;
+import com.miaxis.gan.vo.GanZhiRowVo;
+
+/**
+ * 天干地支Service接口
+ *
+ * @author miaxis
+ * @date 2023-11-16
+ */
+public interface IGanZhiService extends IService<GanZhi>{
+    /**
+     * 查询天干地支列表
+     *
+     * @param ganZhi 天干地支
+     * @return 天干地支集合
+     */
+    public List<GanZhi> selectGanZhiList(GanZhi ganZhi);
+
+
+    public List<GanZhiRowVo> selectGanZhiRowVoList(GanZhiDto ganZhiDto);
+}

+ 43 - 0
xpgx-service/src/main/java/com/miaxis/gan/service/impl/GanZhiServiceImpl.java

@@ -0,0 +1,43 @@
+package com.miaxis.gan.service.impl;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.miaxis.common.utils.DateUtils;
+import com.miaxis.gan.dto.GanZhiDto;
+import com.miaxis.gan.vo.GanZhiRowVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.apache.commons.lang3.StringUtils;
+import com.miaxis.gan.mapper.GanZhiMapper;
+import com.miaxis.gan.domain.GanZhi;
+import com.miaxis.gan.service.IGanZhiService;
+
+/**
+ * 天干地支Service业务层处理
+ *
+ * @author miaxis
+ * @date 2023-11-16
+ */
+@Service
+public class GanZhiServiceImpl extends ServiceImpl<GanZhiMapper, GanZhi> implements IGanZhiService {
+    @Autowired
+    private GanZhiMapper ganZhiMapper;
+
+    /**
+     * 查询天干地支列表
+     *
+     * @param ganZhi 天干地支
+     * @return 天干地支
+     */
+    @Override
+    public List<GanZhi> selectGanZhiList(GanZhi ganZhi){
+        return ganZhiMapper.selectGanZhiList(ganZhi);
+    }
+
+    @Override
+    public List<GanZhiRowVo> selectGanZhiRowVoList(GanZhiDto ganZhiDto) {
+        return ganZhiMapper.selectGanZhiRowVoList(ganZhiDto);
+    }
+}

+ 17 - 0
xpgx-service/src/main/java/com/miaxis/gan/vo/GanZhiFiveVo.java

@@ -0,0 +1,17 @@
+package com.miaxis.gan.vo;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class GanZhiFiveVo {
+
+    @ApiModelProperty(value = "五行")
+    private String five;
+    @ApiModelProperty(value = "数量")
+    private Integer xi;
+
+
+
+}

+ 23 - 0
xpgx-service/src/main/java/com/miaxis/gan/vo/GanZhiRowVo.java

@@ -0,0 +1,23 @@
+package com.miaxis.gan.vo;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class GanZhiRowVo {
+
+    @ApiModelProperty(value = "干支名")
+    private String name;
+    @ApiModelProperty(value = "颜色")
+    private String color;
+    @ApiModelProperty(value = "五行")
+    private String five;
+    @ApiModelProperty(value = "喜用")
+    private String xi;
+    @ApiModelProperty(value = "忌用")
+    private String ji;
+
+
+
+}

+ 37 - 0
xpgx-service/src/main/java/com/miaxis/gan/vo/GanZhiVo.java

@@ -0,0 +1,37 @@
+package com.miaxis.gan.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 天干地支对象 gan_zhi
+ *
+ * @author miaxis
+ * @date 2023-11-16
+ */
+@Data
+public class GanZhiVo {
+
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty(value = "姓名")
+    private String username;
+
+    @ApiModelProperty(value = "性别")
+    private Integer sex;
+
+    @ApiModelProperty(value = "(公历)出生日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
+    private Date birthDay;
+
+    @ApiModelProperty(value = "(农历)出生日期")
+    private String nongDay;
+
+    private List<GanZhiRowVo> ganZhiRowVoList;
+
+}

+ 64 - 0
xpgx-service/src/main/resources/mapper/gan/GanZhiMapper.xml

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.miaxis.gan.mapper.GanZhiMapper">
+
+    <resultMap type="com.miaxis.gan.domain.GanZhi" id="GanZhiResult">
+        <result property="id"    column="id"    />
+        <result property="name"    column="name"    />
+        <result property="color"    column="color"    />
+        <result property="five"    column="five"    />
+        <result property="xi"    column="xi"    />
+        <result property="ji"    column="ji"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+
+    <resultMap type="com.miaxis.gan.vo.GanZhiRowVo" id="GanZhiRowVoResult">
+        <result property="name"    column="name"    />
+        <result property="color"    column="color"    />
+        <result property="five"    column="five"    />
+        <result property="xi"    column="xi"    />
+        <result property="ji"    column="ji"    />
+    </resultMap>
+
+
+    <sql id="selectGanZhiVo">
+        select * from gan_zhi
+    </sql>
+
+    <select id="selectGanZhiList" parameterType="com.miaxis.gan.domain.GanZhi" resultMap="GanZhiResult">
+        <include refid="selectGanZhiVo"/>
+        <where>
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="color != null  and color != ''"> and color = #{color}</if>
+            <if test="five != null  and five != ''"> and five = #{five}</if>
+            <if test="xi != null  and xi != ''"> and xi = #{xi}</if>
+            <if test="ji != null  and ji != ''"> and ji = #{ji}</if>
+        </where>
+    </select>
+
+
+    <select id="selectGanZhiRowVoList" parameterType="com.miaxis.gan.dto.GanZhiDto" resultMap="GanZhiRowVoResult">
+        SELECT name,color,five,xi,ji FROM gan_zhi g
+        <where>
+            g.name IN (#{yearGan}, #{yearZhi}, #{monthGan}, #{monthZhi}, #{dayGan}, #{dayZhi}, #{timeGan}, #{timeZhi})
+            ORDER BY FIELD(g.name, #{yearGan}, #{yearZhi}, #{monthGan}, #{monthZhi}, #{dayGan}, #{dayZhi}, #{timeGan}, #{timeZhi})
+        </where>
+    </select>
+
+
+
+    <select id="selectGanZhiRowVoCount" parameterType="com.miaxis.gan.dto.GanZhiDto" resultMap="GanZhiRowVoResult">
+        SELECT five,count(1) FROM gan_zhi g
+        <where>
+            g.name IN (#{yearGan}, #{yearZhi}, #{monthGan}, #{monthZhi}, #{dayGan}, #{dayZhi}, #{timeGan}, #{timeZhi})
+            ORDER BY FIELD(g.name, #{yearGan}, #{yearZhi}, #{monthGan}, #{monthZhi}, #{dayGan}, #{dayZhi}, #{timeGan}, #{timeZhi})
+        </where>
+    </select>
+
+
+
+</mapper>