Browse Source

基础资料增加币别

chenw 7 years ago
parent
commit
736d933526

+ 48 - 0
applications/document/document-dto/src/main/java/com.usoftchina.saas.document.dto/CurrencyDTO.java

@@ -0,0 +1,48 @@
+package com.usoftchina.saas.document.dto;
+
+import com.usoftchina.saas.base.dto.CommonBaseDTO;
+
+import java.io.Serializable;
+
+/**
+ * @Author chenwei
+ * @Date 2019/01/04
+ */
+public class CurrencyDTO extends CommonBaseDTO implements Serializable {
+
+    private String name;
+    private Double rate;
+    private Long standard;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getRate() {
+        return rate;
+    }
+
+    public void setRate(Double rate) {
+        this.rate = rate;
+    }
+
+    public Long getStandard() {
+        return standard;
+    }
+
+    public void setStandard(Long standard) {
+        this.standard = standard;
+    }
+}

+ 40 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Currency.java

@@ -0,0 +1,40 @@
+package com.usoftchina.saas.document.entities;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+
+import java.io.Serializable;
+
+/**
+ * @Author chenwei
+ * @Date 2019/01/04
+ */
+public class Currency extends CommonBaseEntity implements Serializable{
+
+    private String name;
+    private Double rate;
+    private Long standard;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Double getRate() {
+        return rate;
+    }
+
+    public void setRate(Double rate) {
+        this.rate = rate;
+    }
+
+    public Long getStandard() {
+        return standard;
+    }
+
+    public void setStandard(Long standard) {
+        this.standard = standard;
+    }
+}

+ 37 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CurrencyController.java

@@ -0,0 +1,37 @@
+package com.usoftchina.saas.document.controller;
+
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.dto.CurrencyDTO;
+import com.usoftchina.saas.document.entities.Currency;
+import com.usoftchina.saas.document.service.CurrencyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+
+/**
+ * @Author chenwei
+ * @Date 2019/01/04
+ */
+@RestController
+@RequestMapping("/currency")
+public class CurrencyController {
+
+    @Autowired
+    private CurrencyService currencyService;
+
+    @GetMapping("/list")
+    public Result getAll(){
+        List<Currency> currencyList = currencyService.findByCompanyId(BaseContextHolder.getCompanyId());
+        return Result.success(currencyList);
+    }
+
+    @PostMapping("/save")
+    public Result save(@RequestBody CurrencyDTO currencyDTO){
+        currencyService.save(currencyDTO);
+        return Result.success();
+    }
+
+}

+ 7 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CurrencyMapper.java

@@ -0,0 +1,7 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.document.entities.Currency;
+
+public interface CurrencyMapper extends CommonBaseMapper<Currency> {
+}

+ 12 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CurrencyService.java

@@ -0,0 +1,12 @@
+package com.usoftchina.saas.document.service;
+
+import com.usoftchina.saas.base.service.CommonBaseService;
+import com.usoftchina.saas.document.dto.CurrencyDTO;
+import com.usoftchina.saas.document.entities.Currency;
+import com.usoftchina.saas.document.mapper.CurrencyMapper;
+
+public interface CurrencyService  extends CommonBaseService<CurrencyMapper, Currency> {
+
+    void save(CurrencyDTO currencyDTO);
+
+}

+ 28 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CurrencyServiceImpl.java

@@ -0,0 +1,28 @@
+package com.usoftchina.saas.document.service.impl;
+
+import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.document.dto.CurrencyDTO;
+import com.usoftchina.saas.document.entities.Currency;
+import com.usoftchina.saas.document.mapper.CurrencyMapper;
+import com.usoftchina.saas.document.service.CurrencyService;
+import com.usoftchina.saas.utils.BeanMapper;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author chenwei
+ * @Date 2019/01/04
+ */
+@Service
+public class CurrencyServiceImpl extends CommonBaseServiceImpl<CurrencyMapper, Currency> implements CurrencyService {
+
+
+    @Override
+    public void save(CurrencyDTO currencyDTO) {
+        if (currencyDTO.getId() == 0){
+
+        }else{
+            Currency currency = BeanMapper.map(currencyDTO, Currency.class);
+            getMapper().updateByPrimaryKeySelective(currency);
+        }
+    }
+}

+ 118 - 0
applications/document/document-server/src/main/resources/mapper/CurrencyMapper.xml

@@ -0,0 +1,118 @@
+<?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.usoftchina.saas.document.mapper.CurrencyMapper" >
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Currency" >
+        <id column="cr_id" property="id" jdbcType="INTEGER" />
+        <result column="cr_name" property="name" jdbcType="VARCHAR" />
+        <result column="cr_rate" property="rate" jdbcType="VARCHAR" />
+        <result column="companyId" property="companyId" jdbcType="INTEGER" />
+        <result column="creatorId" property="creatorId" jdbcType="INTEGER" />
+        <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+        <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+        <result column="creatorName" property="creatorName" jdbcType="INTEGER" />
+        <result column="updaterName" property="updaterName" jdbcType="INTEGER" />
+        <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
+        <result column="cr_standard" property="standard" jdbcType="INTEGER" />
+    </resultMap>
+    <sql id="Base_Column_List" >
+        cr_id, cr_name, cr_rate, companyId, creatorId, updaterId, updateTime, creatorName, updaterName, createTime, cr_standard
+    </sql>
+    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+        select
+        <include refid="Base_Column_List" />
+        from currencys
+        where cr_id = #{id}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+        delete from currencys
+        where cr_id = #{id}
+    </delete>
+    <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Currency" >
+        insert into Currencys
+        <trim prefix="(" suffix=")" suffixOverrides="," >
+            <if test="name != null" >
+                cr_name,
+            </if>
+            <if test="rate != null">
+                cr_rate,
+            </if>
+            <if test="standard != null">
+                cr_standard,
+            </if>
+            <if test="companyId != null" >
+                companyId,
+            </if>
+            <if test="updaterId != null" >
+                updaterId,
+            </if>
+            <if test="updateTime != null" >
+                updateTime,
+            </if>
+            <if test="creatorId != null" >
+                creatorId,
+            </if>
+            <if test="createTime != null" >
+                createTime,
+            </if>
+            <if test="creatorName != null" >
+                creatorName,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
+            <if test="name != null" >
+                #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="rate != null" >
+                #{rate,jdbcType=DOUBLE},
+            </if>
+            <if test="standard != null" >
+                #{standard,jdbcType=INTEGER},
+            </if>
+            <if test="companyId != null" >
+                #{companyId,jdbcType=INTEGER},
+            </if>
+            <if test="updaterId != null" >
+                #{updaterId,jdbcType=INTEGER},
+            </if>
+            <if test="updateTime != null" >
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="creatorId != null" >
+                #{creatorId,jdbcType=INTEGER},
+            </if>
+            <if test="createTime != null" >
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="creatorName != null" >
+                #{creatorName,jdbcType=VARCHAR},
+            </if>
+        </trim>
+    </insert>
+    <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Currency" >
+        update Currencys
+        <set >
+            <if test="name != null" >
+                cr_name = #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="rate != null" >
+                cr_rate = #{rate,jdbcType=DOUBLE},
+            </if>
+            <if test="standard != null" >
+                cr_standard = #{standard,jdbcType=INTEGER},
+            </if>
+            <if test="companyId != null" >
+                companyId = #{companyId,jdbcType=INTEGER},
+            </if>
+            <if test="updaterId != null" >
+                updaterId = #{updaterId,jdbcType=INTEGER},
+            </if>
+            <if test="updateTime != null" >
+                updateTime = #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </set>
+        where cr_id = #{id}
+    </update>
+    <select id="selectByCompanyId" resultMap="BaseResultMap">
+        SELECT * FROM Currencys where companyId=#{companyId} ORDER BY CR_ID DESC
+    </select>
+</mapper>