liuchaojie 4 lat temu
rodzic
commit
54c316caea

+ 0 - 87
src/main/java/com/xc/service/impl/StockCoinServiceImpl.java

@@ -59,178 +59,91 @@ public class StockCoinServiceImpl implements IStockCoinService {
 
 
     private CoinAdminListVO assembleCoinAdminListVO(StockCoin stockCoin) {
-
         CoinAdminListVO coinAdminListVO = new CoinAdminListVO();
-
         coinAdminListVO.setId(stockCoin.getId());
-
         coinAdminListVO.setCoinName(stockCoin.getCoinName());
-
         coinAdminListVO.setCoinCode(stockCoin.getCoinCode());
-
         coinAdminListVO.setCoinGid(stockCoin.getCoinGid());
-
         coinAdminListVO.setDynamicRate(stockCoin.getDynamicRate());
-
         coinAdminListVO.setDefaultRate(stockCoin.getDefaultRate());
-
         coinAdminListVO.setIsUse(stockCoin.getIsUse());
-
         coinAdminListVO.setAddTime(stockCoin.getAddTime());
-
         coinAdminListVO.setTDesc(stockCoin.gettDesc());
-
         coinAdminListVO.setServiceCharge(stockCoin.getServiceCharge());
-
         String nowPrice = "";
-
         ExchangeVO exchangeVO = null;
-
-
         ServerResponse serverResponse = this.iStockFuturesService.queryExchangeVO(stockCoin.getCoinCode());
-
         if (serverResponse.isSuccess()) {
-
             exchangeVO = (ExchangeVO) serverResponse.getData();
-
             if (exchangeVO != null) {
-
                 nowPrice = exchangeVO.getNowPrice();
-
             }
-
         }
-
         coinAdminListVO.setNowPrice(nowPrice);
-
-
         return coinAdminListVO;
-
     }
 
 
     public ServerResponse add(StockCoin stockCoin) {
-
         if (StringUtils.isBlank(stockCoin.getCoinName()) ||
-
                 StringUtils.isBlank(stockCoin.getCoinCode()) ||
-
                 StringUtils.isBlank(stockCoin.getCoinGid())) {
-
             return ServerResponse.createByErrorMsg("参数不能为空");
-
         }
-
-
         StockCoin coinName = this.stockCoinMapper.selectCoinByName(stockCoin.getCoinName());
-
         if (coinName != null) {
-
             return ServerResponse.createByErrorMsg("名称不能重复");
-
         }
-
         StockCoin coinCode = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinCode());
-
         if (coinCode != null) {
-
             return ServerResponse.createByErrorMsg("代码不能重复");
-
         }
-
         StockCoin coinGid = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinGid());
-
         if (coinGid != null) {
-
             return ServerResponse.createByErrorMsg("gid不能重复");
-
         }
-
-
         stockCoin.setAddTime(new Date());
-
-
         int insertCount = this.stockCoinMapper.insert(stockCoin);
-
         if (insertCount > 0) {
-
             return ServerResponse.createBySuccessMsg("添加成功");
-
         }
-
         return ServerResponse.createByErrorMsg("添加失败");
 
     }
 
 
     public ServerResponse update(StockCoin stockCoin) {
-
         if (stockCoin.getId() == null) {
-
             return ServerResponse.createByErrorMsg("修改id不能为空");
-
         }
-
-
         StockCoin dbCoin = this.stockCoinMapper.selectByPrimaryKey(stockCoin.getId());
-
         if (dbCoin == null) {
-
             return ServerResponse.createByErrorMsg("基币不存在");
-
         }
-
-
         if (stockCoin.getCoinName() != null) {
-
             StockCoin coinName = this.stockCoinMapper.selectCoinByName(stockCoin.getCoinName());
-
             if (coinName != null && coinName.getId() != dbCoin.getId()) {
-
                 return ServerResponse.createByErrorMsg("名称已存在");
-
             }
-
         }
-
         if (stockCoin.getCoinCode() != null) {
-
             StockCoin coinCode = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinCode());
-
             if (coinCode != null && coinCode.getId() != dbCoin.getId()) {
-
                 return ServerResponse.createByErrorMsg("代码已存在");
-
             }
-
         }
-
         if (stockCoin.getCoinGid() != null) {
-
             StockCoin coinGid = this.stockCoinMapper.selectCoinByCode(stockCoin.getCoinGid());
-
             if (coinGid != null && coinGid.getId() != dbCoin.getId()) {
-
                 return ServerResponse.createByErrorMsg("gid已存在");
-
             }
-
         }
-
-
         int updateCount = this.stockCoinMapper.updateByPrimaryKeySelective(stockCoin);
-
         if (updateCount > 0) {
-
             return ServerResponse.createBySuccessMsg("修改成功");
-
         }
-
         return ServerResponse.createByErrorMsg("修改失败");
-
     }
-
-
     public StockCoin selectCoinByCode(String coinCode) {
         return this.stockCoinMapper.selectCoinByCode(coinCode);
     }

+ 8 - 7
src/main/java/mappers/StockCoinMapper.xml

@@ -16,11 +16,11 @@
     </constructor>
   </resultMap>
   <sql id="Base_Column_List" >
-    id, coin_name, coin_code, coin_gid, dynamic_rate, default_rate, is_use, add_time, 
+    id, coin_name, coin_code, coin_gid, dynamic_rate, default_rate, is_use, add_time,
     t_desc, service_charge
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
-    select 
+    select
     <include refid="Base_Column_List" />
     from stock_coin
     where id = #{id,jdbcType=INTEGER}
@@ -30,12 +30,12 @@
     where id = #{id,jdbcType=INTEGER}
   </delete>
   <insert id="insert" parameterType="com.xc.pojo.StockCoin" >
-    insert into stock_coin (id, coin_name, coin_code, 
-      coin_gid, dynamic_rate, default_rate, 
+    insert into stock_coin (id, coin_name, coin_code,
+      coin_gid, dynamic_rate, default_rate,
       is_use, add_time, t_desc
       )
-    values (#{id,jdbcType=INTEGER}, #{coinName,jdbcType=VARCHAR}, #{coinCode,jdbcType=VARCHAR}, 
-      #{coinGid,jdbcType=VARCHAR}, #{dynamicRate,jdbcType=INTEGER}, #{defaultRate,jdbcType=DECIMAL}, 
+    values (#{id,jdbcType=INTEGER}, #{coinName,jdbcType=VARCHAR}, #{coinCode,jdbcType=VARCHAR},
+      #{coinGid,jdbcType=VARCHAR}, #{dynamicRate,jdbcType=INTEGER}, #{defaultRate,jdbcType=DECIMAL},
       #{isUse,jdbcType=INTEGER}, #{addTime,jdbcType=TIMESTAMP}, #{tDesc,jdbcType=VARCHAR}
       )
   </insert>
@@ -190,7 +190,8 @@
     SELECT
     <include refid="Base_Column_List"/>
     FROM stock_coin
-    WHERE is_use = 1 and coin_code = 'USD'
+    WHERE is_use = 1
+    limit 1
   </select>