liql 4 лет назад
Родитель
Сommit
302115a998

+ 3 - 3
carbon-back/carbon-back-mbg/src/main/resources/generatorConfig.xml

@@ -37,8 +37,8 @@
         <javaClientGenerator type="XMLMAPPER" targetPackage="com.hcloud.microserver.system.mbg.mapper"
                              targetProject="carbon-back\carbon-back-mbg\src\main\java"/>
         <!--生成全部表tableName设为%-->
-        <table tableName="t_transfer_detail">
-            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
-        </table>
+        <table tableName="t_subscription_apply"/>
+<!--            <generatedKey column="id" sqlStatement="MySql" identity="true"/>-->
+<!--        </table>-->
     </context>
 </generatorConfiguration>

+ 84 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/controller/web/SubscriptionApplyController.java

@@ -0,0 +1,84 @@
+package com.hcloud.microserver.h5.controller.web;
+
+
+import com.hcloud.microserver.commoncore.annotation.AuthCarbonValidate;
+import com.hcloud.microserver.commoncore.base.BaseController;
+import com.hcloud.microserver.commoncore.web.domain.AjaxResult;
+import com.hcloud.microserver.commoncore.web.page.TableDataInfo;
+import com.hcloud.microserver.h5.entity.SubscriptionApply;
+import com.hcloud.microserver.h5.forms.SubscriptionApplyForm;
+import com.hcloud.microserver.h5.service.ISubscriptionApplyService;
+import io.swagger.annotations.ApiResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 碳汇认购申请Controller
+ *
+ * @author liql
+ * @date 2020-11-24
+ */
+@RestController
+@RequestMapping("/h5/apply")
+public class SubscriptionApplyController extends BaseController
+{
+    @Autowired
+    private ISubscriptionApplyService subscriptionApplyService;
+
+    /**
+     * 查询碳汇认购申请列表
+     */
+    @ApiResponse(code =0,message = "查询成功")
+    @GetMapping("/list")
+    @AuthCarbonValidate
+    public TableDataInfo list(SubscriptionApply subscriptionApply)
+    {
+        startPage();
+        List<SubscriptionApply> list = subscriptionApplyService.selectSubscriptionApplyList(subscriptionApply);
+        return getDataTable(list);
+    }
+
+    /**
+     * 获取碳汇认购申请详细信息
+     */
+    @GetMapping(value = "/{guid}")
+    @AuthCarbonValidate
+    public AjaxResult getInfo(@PathVariable("guid") String guid)
+    {
+        return AjaxResult.success(subscriptionApplyService.selectSubscriptionApplyById(guid));
+    }
+
+    /**
+     * 新增碳汇认购申请
+     */
+    @PostMapping
+    //@AuthCarbonValidate
+    public AjaxResult add(@RequestBody SubscriptionApplyForm applyForm)
+    {
+        return toAjax(subscriptionApplyService.insertSubscriptionApply(applyForm));
+    }
+
+    /**
+     * 修改碳汇认购申请
+     */
+
+    @PutMapping
+    @AuthCarbonValidate
+    public AjaxResult edit(String guid)
+    {
+        return toAjax(subscriptionApplyService.updateSubscriptionApply(guid));
+    }
+
+    /**
+     * 删除碳汇认购申请
+     */
+
+	@DeleteMapping("/{guids}")
+    @AuthCarbonValidate
+    public AjaxResult remove(@PathVariable String[] guids)
+    {
+        return toAjax(subscriptionApplyService.deleteSubscriptionApplyByIds(guids));
+    }
+}

+ 63 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/dao/SubscriptionApplyMapper.java

@@ -0,0 +1,63 @@
+package com.hcloud.microserver.h5.dao;
+
+import com.hcloud.microserver.h5.entity.SubscriptionApply;
+
+import java.util.List;
+
+
+/**
+ * 碳汇认购申请Mapper接口
+ * 
+ * @author liql
+ * @date 2020-11-24
+ */
+public interface SubscriptionApplyMapper 
+{
+    /**
+     * 查询碳汇认购申请
+     * 
+     * @param guid 碳汇认购申请ID
+     * @return 碳汇认购申请
+     */
+    public SubscriptionApply selectSubscriptionApplyById(String guid);
+
+    /**
+     * 查询碳汇认购申请列表
+     * 
+     * @param subscriptionApply 碳汇认购申请
+     * @return 碳汇认购申请集合
+     */
+    public List<SubscriptionApply> selectSubscriptionApplyList(SubscriptionApply subscriptionApply);
+
+    /**
+     * 新增碳汇认购申请
+     * 
+     * @param subscriptionApply 碳汇认购申请
+     * @return 结果
+     */
+    public int insertSubscriptionApply(SubscriptionApply subscriptionApply);
+
+    /**
+     * 修改碳汇认购申请
+     * 
+     * @param guid 碳汇认购申请
+     * @return 结果
+     */
+    public int updateSubscriptionApply(String guid);
+
+    /**
+     * 删除碳汇认购申请
+     * 
+     * @param guid 碳汇认购申请ID
+     * @return 结果
+     */
+    public int deleteSubscriptionApplyById(String guid);
+
+    /**
+     * 批量删除碳汇认购申请
+     * 
+     * @param guids 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteSubscriptionApplyByIds(String[] guids);
+}

+ 151 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/entity/SubscriptionApply.java

@@ -0,0 +1,151 @@
+package com.hcloud.microserver.h5.entity;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.hcloud.microserver.commoncore.annotation.Excel;
+import com.hcloud.microserver.commoncore.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 碳汇认购申请对象 t_subscription_apply
+ *
+ * @author liql
+ * @date 2020-11-25
+ */
+@ApiModel(value = "碳汇认购申请实体")
+public class SubscriptionApply extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 序列 */
+    private String guid;
+
+    /** 申请客户id */
+    @Excel(name = "申请客户id")
+    @ApiModelProperty(value = "申请客户id")
+    private Long applyCustomerId;
+
+    /** 申请客户名称 */
+    @Excel(name = "申请客户名称")
+    @ApiModelProperty(value = "申请客户名称")
+    private String applyCustomName;
+
+    /** 认购数量 */
+    @Excel(name = "认购数量")
+    @ApiModelProperty(value = "认购数量")
+    private Long amount;
+
+    /** 申请状态(0认购中,1认购成功) */
+    @Excel(name = "申请状态", readConverterExp = "0=认购中,1认购成功")
+    @ApiModelProperty(value = "申请状态(0=认购中,1认购成功)")
+    private Integer applyStatus;
+
+    /** 记录状态(0无效,1有效) */
+    @Excel(name = "记录状态(0无效,1有效)")
+    @ApiModelProperty(value = "记录状态(0无效,1有效)")
+    private Integer recordStatus;
+
+    /** 申请时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty(value = "申请时间")
+    private Date applyDate;
+
+    /** 修改时间  */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "修改时间 ", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty(value = "修改时间 ")
+    private Date modifiedTime;
+
+    public void setGuid(String guid)
+    {
+        this.guid = guid;
+    }
+
+    public String getGuid()
+    {
+        return guid;
+    }
+    public void setApplyCustomerId(Long applyCustomerId)
+    {
+        this.applyCustomerId = applyCustomerId;
+    }
+
+    public Long getApplyCustomerId()
+    {
+        return applyCustomerId;
+    }
+    public void setApplyCustomName(String applyCustomName)
+    {
+        this.applyCustomName = applyCustomName;
+    }
+
+    public String getApplyCustomName()
+    {
+        return applyCustomName;
+    }
+    public void setAmount(Long amount)
+    {
+        this.amount = amount;
+    }
+
+    public Long getAmount()
+    {
+        return amount;
+    }
+    public void setApplyStatus(Integer applyStatus)
+    {
+        this.applyStatus = applyStatus;
+    }
+
+    public Integer getApplyStatus()
+    {
+        return applyStatus;
+    }
+    public void setRecordStatus(Integer recordStatus)
+    {
+        this.recordStatus = recordStatus;
+    }
+
+    public Integer getRecordStatus()
+    {
+        return recordStatus;
+    }
+    public void setApplyDate(Date applyDate)
+    {
+        this.applyDate = applyDate;
+    }
+
+    public Date getApplyDate()
+    {
+        return applyDate;
+    }
+    public void setModifiedTime(Date modifiedTime)
+    {
+        this.modifiedTime = modifiedTime;
+    }
+
+    public Date getModifiedTime()
+    {
+        return modifiedTime;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("guid", getGuid())
+            .append("applyCustomerId", getApplyCustomerId())
+            .append("applyCustomName", getApplyCustomName())
+            .append("amount", getAmount())
+            .append("remark", getRemark())
+            .append("applyStatus", getApplyStatus())
+            .append("recordStatus", getRecordStatus())
+            .append("applyDate", getApplyDate())
+            .append("createTime", getCreateTime())
+            .append("modifiedTime", getModifiedTime())
+            .toString();
+    }
+}

+ 19 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/forms/SubscriptionApplyForm.java

@@ -0,0 +1,19 @@
+package com.hcloud.microserver.h5.forms;
+
+/**
+ *  线下认购
+ * @Author liql
+ * @Date 2020-11-25
+ */
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+@Data
+public class SubscriptionApplyForm implements Serializable {
+    @ApiModelProperty(value = "认购数量")
+    private Long amount;
+    @ApiModelProperty(value = "备注")
+    private String remark;
+}

+ 65 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/ISubscriptionApplyService.java

@@ -0,0 +1,65 @@
+package com.hcloud.microserver.h5.service;
+
+
+import com.hcloud.microserver.h5.entity.SubscriptionApply;
+import com.hcloud.microserver.h5.forms.SubscriptionApplyForm;
+
+import java.util.List;
+
+
+/**
+ * 碳汇认购申请Service接口
+ * 
+ * @author liql
+ * @date 2020-11-24
+ */
+public interface ISubscriptionApplyService 
+{
+    /**
+     * 查询碳汇认购申请
+     * 
+     * @param guid 碳汇认购申请ID
+     * @return 碳汇认购申请
+     */
+    public SubscriptionApply selectSubscriptionApplyById(String guid);
+
+    /**
+     * 查询碳汇认购申请列表
+     * 
+     * @param subscriptionApply 碳汇认购申请
+     * @return 碳汇认购申请集合
+     */
+    public List<SubscriptionApply> selectSubscriptionApplyList(SubscriptionApply subscriptionApply);
+
+    /**
+     * 新增碳汇认购申请
+     * 
+     * @param applyForm 碳汇认购申请
+     * @return 结果
+     */
+    public int insertSubscriptionApply(SubscriptionApplyForm applyForm);
+
+    /**
+     * 修改碳汇认购申请-更新为认购完成
+     * 
+     * @param guid 碳汇认购申请
+     * @return 结果
+     */
+    public int updateSubscriptionApply(String guid);
+
+    /**
+     * 批量删除碳汇认购申请
+     * 
+     * @param guids 需要删除的碳汇认购申请ID
+     * @return 结果
+     */
+    public int deleteSubscriptionApplyByIds(String[] guids);
+
+    /**
+     * 删除碳汇认购申请信息
+     * 
+     * @param guid 碳汇认购申请ID
+     * @return 结果
+     */
+    public int deleteSubscriptionApplyById(String guid);
+}

+ 109 - 0
carbon-h5/carbon-h5-service/src/main/java/com/hcloud/microserver/h5/service/impl/SubscriptionApplyServiceImpl.java

@@ -0,0 +1,109 @@
+package com.hcloud.microserver.h5.service.impl;
+
+import com.hcloud.microserver.commoncore.util.UUIDUtils;
+import com.hcloud.microserver.commoncore.util.reflect.DateUtils;
+import com.hcloud.microserver.h5.dao.SubscriptionApplyMapper;
+import com.hcloud.microserver.h5.entity.SubscriptionApply;
+import com.hcloud.microserver.h5.forms.SubscriptionApplyForm;
+import com.hcloud.microserver.h5.service.ISubscriptionApplyService;
+import com.hcloud.microserver.security.util.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 碳汇认购申请Service业务层处理
+ *
+ * @author liql
+ * @date 2020-11-24
+ */
+@Service
+public class SubscriptionApplyServiceImpl implements ISubscriptionApplyService
+{
+    @Autowired
+    private SubscriptionApplyMapper subscriptionApplyMapper;
+
+    /**
+     * 查询碳汇认购申请
+     *
+     * @param guid 碳汇认购申请ID
+     * @return 碳汇认购申请
+     */
+    @Override
+    public SubscriptionApply selectSubscriptionApplyById(String guid)
+    {
+        return subscriptionApplyMapper.selectSubscriptionApplyById(guid);
+    }
+
+    /**
+     * 查询碳汇认购申请列表
+     *
+     * @param subscriptionApply 碳汇认购申请
+     * @return 碳汇认购申请
+     */
+    @Override
+    public List<SubscriptionApply> selectSubscriptionApplyList(SubscriptionApply subscriptionApply)
+    {
+        return subscriptionApplyMapper.selectSubscriptionApplyList(subscriptionApply);
+    }
+
+    /**
+     * 新增碳汇认购申请
+     *
+     * @param applyForm 碳汇认购申请
+     * @return 结果
+     */
+    @Override
+    public int insertSubscriptionApply(SubscriptionApplyForm applyForm)
+    {
+        SubscriptionApply apply = new SubscriptionApply();
+        apply.setGuid(UUIDUtils.randomUUID());
+
+        apply.setAmount(applyForm.getAmount());
+        apply.setRemark(applyForm.getRemark());
+        apply.setApplyCustomerId(SecurityUtils.getUserId());
+        apply.setApplyCustomName(SecurityUtils.getUsername());
+        apply.setRecordStatus(1);
+
+        apply.setModifiedTime(DateUtils.getNowDate());
+        apply.setCreateTime(DateUtils.getNowDate());
+        return subscriptionApplyMapper.insertSubscriptionApply(apply);
+    }
+
+    /**
+     * 修改碳汇认购申请
+     *
+     * @param guid 碳汇认购申请
+     * @return 结果
+     */
+    @Override
+    public int updateSubscriptionApply(String guid)
+    {
+        return subscriptionApplyMapper.updateSubscriptionApply(guid);
+    }
+
+    /**
+     * 批量删除碳汇认购申请
+     *
+     * @param guids 需要删除的碳汇认购申请ID
+     * @return 结果
+     */
+    @Override
+    public int deleteSubscriptionApplyByIds(String[] guids)
+    {
+        return subscriptionApplyMapper.deleteSubscriptionApplyByIds(guids);
+    }
+
+    /**
+     * 删除碳汇认购申请信息
+     *
+     * @param guid 碳汇认购申请ID
+     * @return 结果
+     */
+    @Override
+    public int deleteSubscriptionApplyById(String guid)
+    {
+        return subscriptionApplyMapper.deleteSubscriptionApplyById(guid);
+    }
+}

+ 61 - 0
common-core/src/main/java/com/hcloud/microserver/commoncore/base/BaseController.java

@@ -1,8 +1,16 @@
 package com.hcloud.microserver.commoncore.base;
 
+import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.hcloud.microserver.commoncore.constant.HttpStatus;
 import com.hcloud.microserver.commoncore.enums.ResultEnum;
+import com.hcloud.microserver.commoncore.sql.SqlUtil;
 import com.hcloud.microserver.commoncore.util.BeanCopyUtil;
+import com.hcloud.microserver.commoncore.util.string.StringUtils;
+import com.hcloud.microserver.commoncore.web.domain.AjaxResult;
+import com.hcloud.microserver.commoncore.web.page.PageDomain;
+import com.hcloud.microserver.commoncore.web.page.TableDataInfo;
+import com.hcloud.microserver.commoncore.web.page.TableSupport;
 import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
@@ -10,6 +18,8 @@ import org.springframework.web.context.request.ServletRequestAttributes;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Collection;
+import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 /**
@@ -310,4 +320,55 @@ public class BaseController {
                 .getRequestAttributes();
         return requestAttributes.getRequest();
     }
+
+    /**
+     * 设置请求分页数据
+     */
+    protected void startPage()
+    {
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum() == null ? 1: pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize() == null ? 10 : pageDomain.getPageSize();
+        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
+        {
+            String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
+            PageHelper.startPage(pageNum, pageSize, orderBy);
+        }
+    }
+
+    /**
+     * 响应请求分页数据
+     */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    protected TableDataInfo getDataTable(List<?> list)
+    {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setRows(list);
+        rspData.setTotal(new PageInfo(list).getTotal());
+        return rspData;
+    }
+
+
+    protected TableDataInfo getDataTableByMap(List<Map<String, Object>> list)
+    {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.SUCCESS);
+        rspData.setRows(list);
+        rspData.setTotal(new PageInfo(list).getTotal());
+        return rspData;
+    }
+
+    /**
+     * 响应返回结果
+     *
+     * @param rows 影响行数
+     * @return 操作结果
+     */
+    protected AjaxResult toAjax(int rows)
+    {
+        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
+    }
+
+
 }