Browse Source

fix 货币增删改查,bug

pengzhenggao 1 month ago
parent
commit
d0d1722e35
18 changed files with 306 additions and 300 deletions
  1. 13 10
      fuintBackend/fuint-application/src/main/java/com/fuint/common/config/MybatisPlusConfig.java
  2. 38 0
      fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/ext/CurrencyDto.java
  3. 6 2
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/CountryService.java
  4. 9 47
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/CurrencyService.java
  5. 50 7
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CountryServiceImpl.java
  6. 54 99
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CurrencyServiceImpl.java
  7. 32 0
      fuintBackend/fuint-application/src/main/java/com/fuint/common/vo/CountryVo.java
  8. 15 0
      fuintBackend/fuint-application/src/main/java/com/fuint/common/vo/CurrencyVo.java
  9. 4 5
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendAccountController.java
  10. 13 11
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCountryController.java
  11. 44 111
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCurrencyController.java
  12. 3 3
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendDutyController.java
  13. 2 0
      fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtCountryMapper.java
  14. 3 1
      fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtCurrencyMapper.java
  15. 6 0
      fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtCountry.java
  16. 7 3
      fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtCurrency.java
  17. 3 0
      fuintBackend/fuint-repository/src/main/resources/mapper/MtCountryMapper.xml
  18. 4 1
      fuintBackend/fuint-repository/src/main/resources/mapper/MtCurrencyMapper.xml

+ 13 - 10
fuintBackend/fuint-application/src/main/java/com/fuint/common/config/MybatisPlusConfig.java

@@ -1,5 +1,6 @@
 package com.fuint.common.config;
 
+import com.baomidou.mybatisplus.annotation.DbType;
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
 import com.baomidou.mybatisplus.core.injector.ISqlInjector;
 import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
@@ -28,6 +29,7 @@ public class MybatisPlusConfig implements MetaObjectHandler {
 
     /**
      * 分页插件
+     *
      * @return PaginationInterceptor
      */
     @Bean
@@ -49,6 +51,7 @@ public class MybatisPlusConfig implements MetaObjectHandler {
 
     /**
      * 乐观锁插件
+     *
      * @return
      */
     @Bean
@@ -58,32 +61,32 @@ public class MybatisPlusConfig implements MetaObjectHandler {
 
     /**
      * 插入拦截
+     *
      * @param metaObject
      */
     @Override
     public void insertFill(MetaObject metaObject) {
-        this.setFieldValByName("createTime",new Date(),metaObject);
-        this.setFieldValByName("updateTime",new Date(),metaObject);
+        this.setFieldValByName("createTime", new Date(), metaObject);
+        this.setFieldValByName("updateTime", new Date(), metaObject);
         AccountInfo accountInfo = AuthUserUtil.get();
-        if (Objects.nonNull(accountInfo)){
-            this.setFieldValByName("createUserId",new Date(),metaObject);
-            this.setFieldValByName("updateUserId",new Date(),metaObject);
+        if (Objects.nonNull(accountInfo)) {
+            this.setFieldValByName("createUserId", String.valueOf(accountInfo.getId()), metaObject);
+            this.setFieldValByName("updateUserId", String.valueOf(accountInfo.getId()), metaObject);
         }
 
     }
 
     /**
      * 更新数据时拦截
+     *
      * @param metaObject
      */
     @Override
     public void updateFill(MetaObject metaObject) {
-        this.setFieldValByName("updateTime",new Date(),metaObject);
+        this.setFieldValByName("updateTime", new Date(), metaObject);
         AccountInfo accountInfo = AuthUserUtil.get();
-        if (Objects.nonNull(accountInfo)){
-            this.setFieldValByName("updateUserId",new Date(),metaObject);
+        if (Objects.nonNull(accountInfo)) {
+            this.setFieldValByName("updateUserId",  String.valueOf(accountInfo.getId()), metaObject);
         }
     }
-
-
 }

+ 38 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/ext/CurrencyDto.java

@@ -0,0 +1,38 @@
+package com.fuint.common.dto.ext;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 货币表实体
+ *
+ * @Created by pzg
+ * CopyRight https://www.fuint.cn
+ */
+@Getter
+@Setter
+@TableName("mt_currency")
+@ApiModel(value = "currency表对象", description = "currency表对象")
+public class CurrencyDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("id")
+    @TableId(value = "ID", type = IdType.AUTO)
+    private Long id;
+
+
+    @ApiModelProperty("货币名称")
+    private String name;
+
+
+
+}

+ 6 - 2
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/CountryService.java

@@ -2,10 +2,13 @@ package com.fuint.common.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fuint.common.dto.ext.CountryDto;
+import com.fuint.common.vo.CountryVo;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.repository.model.MtCountry;
 import com.fuint.framework.exception.BusinessCheckException;
+import org.springframework.web.bind.annotation.RequestParam;
+
 import java.util.List;
 import java.util.Map;
 
@@ -47,11 +50,10 @@ public interface CountryService extends IService<MtCountry> {
      * 根据ID删除国家表
      *
      * @param id ID
-     * @param operator 操作人
      * @throws BusinessCheckException
      * @return
      */
-    void deleteCountry(Long id, String operator) throws BusinessCheckException;
+    boolean deleteCountry(Long id) throws BusinessCheckException;
 
     /**
      * 更新国家表
@@ -77,4 +79,6 @@ public interface CountryService extends IService<MtCountry> {
      * @return
      */
 	boolean saveCountry(CountryDto countryDto, Long accountInfoId) throws BusinessCheckException;
+
+    List<CountryVo> getCountryTree(String countryCode, String countryName);
 }

+ 9 - 47
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/CurrencyService.java

@@ -1,8 +1,12 @@
 package com.fuint.common.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fuint.common.dto.ext.CurrencyDto;
+import com.fuint.common.param.PageParam;
+import com.fuint.common.vo.CurrencyVo;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.framework.web.PageResult;
 import com.fuint.repository.model.MtCurrency;
 import com.fuint.framework.exception.BusinessCheckException;
 import java.util.List;
@@ -16,56 +20,14 @@ import java.util.Map;
  */
 public interface CurrencyService extends IService<MtCurrency> {
 
-    /**
-     * 分页查询列表
-     *
-     * @param paginationRequest
-     * @return
-     */
-    PaginationResponse<MtCurrency> queryCurrencyListByPagination(PaginationRequest paginationRequest) throws BusinessCheckException;
 
-    /**
-     * 添加货币表
-     *
-     * @param  mtCurrency
-     * @throws BusinessCheckException
-     * @return
-     */
-    MtCurrency addCurrency(MtCurrency mtCurrency) throws BusinessCheckException;
+    boolean addCurrency(CurrencyDto currencyDto);
 
-    /**
-     * 根据ID获取货币表信息
-     *
-     * @param id ID
-     * @throws BusinessCheckException
-     * @return
-     */
-    MtCurrency queryCurrencyById(Long id) throws BusinessCheckException;
+    boolean updateCurrency(CurrencyDto currencyDto);
 
-    /**
-     * 根据ID删除货币表
-     *
-     * @param id ID
-     * @param operator 操作人
-     * @throws BusinessCheckException
-     * @return
-     */
-    void deleteCurrency(Long id, String operator) throws BusinessCheckException;
+    PageResult<CurrencyVo> getCurrencyById(String name, PageParam pageParam);
 
-    /**
-     * 更新货币表
-     * @param  mtCurrency
-     * @throws BusinessCheckException
-     * @return
-     * */
-    MtCurrency updateCurrency(MtCurrency mtCurrency) throws BusinessCheckException;
+    boolean deleteCurrency(Integer id);
 
-    /**
-     * 根据条件搜索货币表
-     *
-     * @param params 查询参数
-     * @throws BusinessCheckException
-     * @return
-     * */
-    List<MtCurrency> queryCurrencyListByParams(Map<String, Object> params) throws BusinessCheckException;
+    List<CurrencyVo> allList(String name);
 }

+ 50 - 7
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CountryServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.dto.ext.CountryDto;
+import com.fuint.common.vo.CountryVo;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.exception.BusinessRuntimeException;
@@ -25,6 +26,7 @@ import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 国家表服务接口
@@ -99,19 +101,20 @@ public class CountryServiceImpl extends ServiceImpl<MtCountryMapper, MtCountry>
      * 根据ID删除国家表
      *
      * @param id 国家表ID
-     * @param operator 操作人
      * @return
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "删除国家表")
-    public void deleteCountry(Long id, String operator) {
-        MtCountry mtCountry = queryCountryById(id);
-        if (null == mtCountry) {
-            return;
+    public boolean deleteCountry(Long id) {
+        // 检查是否有子节点
+        int childCount = baseMapper.countChildrenById(id);
+        if (childCount > 0) {
+            // 存在子节点,不能删除
+            return false;
         }
-        mtCountry.setUpdateTime(new Date());
-        mtCountryMapper.updateById(mtCountry);
+        // 删除节点
+        return removeById(id);
     }
 
     /**
@@ -204,4 +207,44 @@ public class CountryServiceImpl extends ServiceImpl<MtCountryMapper, MtCountry>
         //保存数据
         return this.save(country);
     }
+
+    @Override
+    public List<CountryVo> getCountryTree(String countryCode, String countryName) {
+        //获取所有国家数据
+        List<MtCountry> countries = list(new LambdaQueryWrapper<MtCountry>()
+                .eq(StringUtils.isNotBlank(countryCode),MtCountry::getCountryCode,countryCode)
+                .eq(StringUtils.isNotBlank(countryName),MtCountry::getCountryName,countryName)); // 获取所有国家
+        return buildTree(countries).stream()
+                .map(this::convertToVO)
+                .collect(Collectors.toList());
+    }
+
+    private List<MtCountry> buildTree(List<MtCountry> countries) {
+        // 将所有国家根据 parentId 构建树形结构
+        return countries.stream()
+                .filter(country -> country.getParentId() == null)
+                .peek(parent -> parent.setChildren(getChildren(parent, countries)))
+                .collect(Collectors.toList());
+    }
+
+    private List<MtCountry> getChildren(MtCountry parent, List<MtCountry> countries) {
+      //递归查询子节点
+        return countries.stream()
+                .filter(country -> parent.getId().equals(country.getParentId()))
+                .peek(child -> child.setChildren(getChildren(child, countries)))
+                .collect(Collectors.toList());
+    }
+
+    private CountryVo convertToVO(MtCountry country) {
+        //封装到CountryVo
+        CountryVo vo = new CountryVo();
+        BeanUtils.copyProperties(country,vo);
+        //赋值子节点
+        if (country.getChildren() != null) {
+            vo.setChildren(country.getChildren().stream()
+                    .map(this::convertToVO)
+                    .collect(Collectors.toList()));
+        }
+        return vo;
+    }
 }

+ 54 - 99
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CurrencyServiceImpl.java

@@ -1,12 +1,18 @@
 package com.fuint.common.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fuint.common.dto.ext.CurrencyDto;
+import com.fuint.common.param.PageParam;
+import com.fuint.common.vo.CurrencyVo;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
+import com.fuint.framework.web.PageResult;
 import com.fuint.repository.model.MtCurrency;
 import com.fuint.common.service.CurrencyService;
 import com.fuint.common.enums.StatusEnum;
@@ -16,12 +22,14 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.github.pagehelper.Page;
+import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
 
 /**
  * 货币表服务接口
@@ -35,121 +43,68 @@ public class CurrencyServiceImpl extends ServiceImpl<MtCurrencyMapper, MtCurrenc
 
     private static final Logger logger = LoggerFactory.getLogger(CurrencyServiceImpl.class);
 
-    private MtCurrencyMapper mtCurrencyMapper;
 
-    /**
-     * 分页查询数据列表
-     *
-     * @param paginationRequest
-     * @return
-     */
     @Override
-    public PaginationResponse<MtCurrency> queryCurrencyListByPagination(PaginationRequest paginationRequest) {
-        Page<MtCurrency> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
-        LambdaQueryWrapper<MtCurrency> lambdaQueryWrapper = Wrappers.lambdaQuery();
-
-        lambdaQueryWrapper.orderByAsc(MtCurrency::getId);
-        List<MtCurrency> dataList = mtCurrencyMapper.selectList(lambdaQueryWrapper);
-
-        PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
-        PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
-        PaginationResponse<MtCurrency> paginationResponse = new PaginationResponse(pageImpl, MtCurrency.class);
-        paginationResponse.setTotalPages(pageHelper.getPages());
-        paginationResponse.setTotalElements(pageHelper.getTotal());
-        paginationResponse.setContent(dataList);
-
-        return paginationResponse;
+    public boolean addCurrency(CurrencyDto currencyDto) {
+        if (!isNameUnique(currencyDto.getName())) {
+            return false; // 货币名称已存在
+        }
+        MtCurrency mtCurrency = new MtCurrency();
+        mtCurrency.setId(currencyDto.getId());
+        mtCurrency.setName(currencyDto.getName());
+        mtCurrency.setDeleteFlag(0);
+        return save(mtCurrency);
     }
 
-    /**
-     * 添加货币表
-     *
-     * @param mtCurrency 货币表信息
-     * @return
-     */
     @Override
-    @OperationServiceLog(description = "新增货币表")
-    public MtCurrency addCurrency(MtCurrency mtCurrency) throws BusinessCheckException {
-
-        mtCurrency.setUpdateTime(new Date());
-        mtCurrency.setCreateTime(new Date());
-        Integer id = mtCurrencyMapper.insert(mtCurrency);
-        if (id > 0) {
-            return mtCurrency;
-        } else {
-            throw new BusinessCheckException("新增货币表数据失败");
+    public boolean updateCurrency(CurrencyDto currencyDto) {
+        MtCurrency existing = getById(currencyDto.getId());
+        if (existing == null) {
+            return false; // 货币不存在
+        }
+        if (!existing.getName().equals(currencyDto.getName()) && !isNameUnique(currencyDto.getName())) {
+            return false; // 货币名称已存在
         }
+        MtCurrency mtCurrency = new MtCurrency();
+        mtCurrency.setId(currencyDto.getId());
+        mtCurrency.setName(currencyDto.getName());
+        return updateById(mtCurrency);
     }
 
-    /**
-     * 根据ID获货币表取息
-     *
-     * @param id 货币表ID
-     * @return
-     */
     @Override
-    public MtCurrency queryCurrencyById(Long id) {
-        return mtCurrencyMapper.selectById(id);
+    public PageResult<CurrencyVo> getCurrencyById(String name, PageParam pageParam) {
+        IPage<MtCurrency> mtCurrencyIPage = this.baseMapper.selectPage(new Page<>(pageParam.getPage(), pageParam.getPageSize()), new LambdaQueryWrapper<MtCurrency>()
+                .select(MtCurrency::getId, MtCurrency::getName)
+                .like(StringUtils.isNotBlank(name),MtCurrency::getName, name));
+        List<CurrencyVo> currencyVos = mtCurrencyIPage.getRecords().stream().map(mtCurrency -> {
+            CurrencyVo currencyVo = new CurrencyVo();
+            BeanUtils.copyProperties(mtCurrency, currencyVo);
+            return currencyVo;
+        }).collect(Collectors.toList());
+        return PageResult.<CurrencyVo>builder().total(Math.toIntExact(mtCurrencyIPage.getTotal())).data(currencyVos).build();
     }
 
-    /**
-     * 根据ID删除货币表
-     *
-     * @param id 货币表ID
-     * @param operator 操作人
-     * @return
-     */
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    @OperationServiceLog(description = "删除货币表")
-    public void deleteCurrency(Long id, String operator) {
-        MtCurrency mtCurrency = queryCurrencyById(id);
-        if (null == mtCurrency) {
-            return;
-        }
-
-        mtCurrency.setUpdateTime(new Date());
-        mtCurrencyMapper.updateById(mtCurrency);
+    public boolean deleteCurrency(Integer id) {
+        return removeById(id);
     }
 
-    /**
-     * 修改货币表数据
-     *
-     * @param mtCurrency
-     * @throws BusinessCheckException
-     * @return
-     */
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    @OperationServiceLog(description = "更新货币表")
-    public MtCurrency updateCurrency(MtCurrency mtCurrency) throws BusinessCheckException {
-        mtCurrency = queryCurrencyById(mtCurrency.getId());
-        if (mtCurrency == null) {
-            throw new BusinessCheckException("该货币表状态异常");
-        }
-        mtCurrency.setUpdateTime(new Date());
-        mtCurrencyMapper.updateById(mtCurrency);
-        return mtCurrency;
+    public List<CurrencyVo> allList(String name) {
+        //获取货币列表,可根据名称模糊查询
+        List<MtCurrency> mtCurrencies = this.baseMapper.selectList(new LambdaQueryWrapper<MtCurrency>()
+                .select(MtCurrency::getId, MtCurrency::getName)
+                .likeRight(StringUtils.isNotBlank(name), MtCurrency::getName, name));
+        //将MtCurrency复制到CurrencyVo并返回
+	    return mtCurrencies.stream().map(mtCurrency -> {
+            CurrencyVo currencyVo = new CurrencyVo();
+            BeanUtils.copyProperties(mtCurrencies, currencyVo);
+            return currencyVo;
+        }).collect(Collectors.toList());
     }
 
-   /**
-    * 根据条件搜索货币表
-    *
-    * @param  params 查询参数
-    * @throws BusinessCheckException
-    * @return
-    * */
-    @Override
-    public List<MtCurrency> queryCurrencyListByParams(Map<String, Object> params) {
-        String status =  params.get("status") == null ? StatusEnum.ENABLED.getKey(): params.get("status").toString();
-        String storeId =  params.get("storeId") == null ? "" : params.get("storeId").toString();
-        String merchantId =  params.get("merchantId") == null ? "" : params.get("merchantId").toString();
-
-        LambdaQueryWrapper<MtCurrency> lambdaQueryWrapper = Wrappers.lambdaQuery();
-
 
-        lambdaQueryWrapper.orderByAsc(MtCurrency::getId);
-        List<MtCurrency> dataList = mtCurrencyMapper.selectList(lambdaQueryWrapper);
-        return dataList;
+    public boolean isNameUnique(String name) {
+        return this.baseMapper.countByNameAndProject(name) == 0;
     }
 }

+ 32 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/vo/CountryVo.java

@@ -0,0 +1,32 @@
+package com.fuint.common.vo;
+
+import lombok.Data;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class CountryVo {
+	private Long id;
+
+	private Long parentId;
+
+	private String englishName;
+
+	private String countryCode;
+
+	private String areaCode;
+
+	private String pinYin;
+
+	private String firstCode;
+
+	private String fileId;
+
+	private BigDecimal serviceChargeValue;
+
+	private String countryName;
+
+	private Integer serveState;
+
+	private List<CountryVo> children;
+}

+ 15 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/vo/CurrencyVo.java

@@ -0,0 +1,15 @@
+package com.fuint.common.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class CurrencyVo {
+	@ApiModelProperty("id")
+	private Long id;
+
+	@ApiModelProperty("货币名称")
+	private String name;
+}

+ 4 - 5
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendAccountController.java

@@ -212,7 +212,7 @@ public class BackendAccountController extends BaseController {
             return getFailureResult(1001, "请先登录");
         }
 
-        List<Integer> roleIds = (List) param.get("roleIds");
+        List<String> roleIds = (List) param.get("roleIds");
         String accountName = param.get("accountName").toString();
         String accountStatus = param.get("accountStatus").toString();
         String realName = param.get("realName").toString();
@@ -228,10 +228,9 @@ public class BackendAccountController extends BaseController {
 
         List<TDuty> duties = new ArrayList<>();
         if (roleIds.size() > 0) {
-            Integer[] roles = roleIds.toArray(new Integer[roleIds.size()]);
-            String[] ids = new String[roles.length];
-            for (int i = 0; i < roles.length; i++) {
-                ids[i] = roles[i].toString();
+            String[] ids = new String[roleIds.size()];
+            for (int i = 0; i < roleIds.size(); i++) {
+                ids[i] = roleIds.get(i).toString();
             }
             duties = tDutyService.findDatasByIds(ids);
             if (duties.size() < roleIds.size()) {

+ 13 - 11
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCountryController.java

@@ -5,6 +5,7 @@ import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.ext.CountryDto;
 import com.fuint.common.util.AuthUserUtil;
 import com.fuint.common.util.TokenUtil;
+import com.fuint.common.vo.CountryVo;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
 import com.fuint.common.Constants;
@@ -22,6 +23,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -44,15 +46,16 @@ public class BackendCountryController extends BaseController {
     /**
      * 国家表列表查询
      *
-     * @param  request HttpServletRequest对象
      * @return 国家表列表
      */
-    @ApiOperation(value = "国家表列表查询")
+    @ApiOperation(value = "国家表树形结构查询")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('country:list')")
-    public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
-        return getSuccessResult(null);
+    public ResponseObject list(@RequestParam(value = "countryCode",defaultValue = "") String countryCode,
+                               @RequestParam(value = "countryName",defaultValue = "") String countryName) throws BusinessCheckException {
+        List<CountryVo> countryVoList = countryService.getCountryTree(countryCode,countryName);
+        return getSuccessResult(countryVoList);
     }
 
     /**
@@ -94,18 +97,17 @@ public class BackendCountryController extends BaseController {
     }
 
     /**
-     * 获取国家表详情
+     * 删除国家表数据
      *
      * @param id
      * @return
      */
-    @ApiOperation(value = "获取国家表详情")
-    @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
+    @ApiOperation(value = "通过id删除国家表数据")
+    @DeleteMapping("/{id}")
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('country:list')")
-    public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
-
-
-        return getSuccessResult(null);
+    public ResponseObject deleteCountry(@PathVariable Long id) throws BusinessCheckException {
+        boolean success = countryService.deleteCountry(id);
+        return success ? getSuccessResult("删除成功"):getFailureResult(1002,"删除失败");
     }
 }

+ 44 - 111
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCurrencyController.java

@@ -1,8 +1,12 @@
 package com.fuint.module.backendApi.controller;
 
 import com.fuint.common.dto.AccountInfo;
+import com.fuint.common.dto.ext.CurrencyDto;
+import com.fuint.common.param.PageParam;
 import com.fuint.common.util.TokenUtil;
+import com.fuint.common.vo.CurrencyVo;
 import com.fuint.framework.web.BaseController;
+import com.fuint.framework.web.PageResult;
 import com.fuint.framework.web.ResponseObject;
 import com.fuint.common.Constants;
 import com.fuint.common.enums.StatusEnum;
@@ -19,6 +23,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -41,147 +46,75 @@ public class BackendCurrencyController extends BaseController {
     /**
      * 货币表列表查询
      *
-     * @param  request HttpServletRequest对象
      * @return 货币表列表
      */
     @ApiOperation(value = "货币表列表查询")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('currency:list')")
-    public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
-        Integer pageSize = request.getParameter("pageSize") == null ? Constants.PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
-        String title = request.getParameter("title");
-        String status = request.getParameter("status");
-        String searchStoreId = request.getParameter("storeId");
-
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        Long storeId;
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
-        } else {
-            storeId = accountInfo.getStoreId();
-        }
-
-        PaginationRequest paginationRequest = new PaginationRequest();
-        paginationRequest.setCurrentPage(page);
-        paginationRequest.setPageSize(pageSize);
-
-        Map<String, Object> params = new HashMap<>();
-        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
-            params.put("merchantId", accountInfo.getMerchantId());
-        }
-        if (StringUtil.isNotEmpty(title)) {
-            params.put("title", title);
-        }
-        if (StringUtil.isNotEmpty(status)) {
-            params.put("status", status);
-        }
-        if (StringUtil.isNotEmpty(searchStoreId)) {
-            params.put("storeId", searchStoreId);
-        }
-        if (storeId != null && storeId > 0) {
-            params.put("storeId", storeId);
-        }
-        paginationRequest.setSearchParams(params);
-        PaginationResponse<MtCurrency> paginationResponse = currencyService.queryCurrencyListByPagination(paginationRequest);
-
-        Map<String, Object> paramsStore = new HashMap<>();
-        paramsStore.put("status", StatusEnum.ENABLED.getKey());
-        if (accountInfo.getStoreId() != null && accountInfo.getStoreId() > 0) {
-            paramsStore.put("storeId", accountInfo.getStoreId().toString());
-        }
-        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
-            paramsStore.put("merchantId", accountInfo.getMerchantId());
-        }
-
-        Map<String, Object> result = new HashMap<>();
-        result.put("paginationResponse", paginationResponse);
-
-        return getSuccessResult(result);
+    public PageResult<CurrencyVo> list(@RequestParam(defaultValue = "") String name, PageParam pageParam) throws BusinessCheckException {
+        return currencyService.getCurrencyById(name,pageParam);
     }
 
     /**
-     * 更新货币表状态
+     * 更新货币数据
      *
-     * @return
+     * @return 结果
      */
-    @ApiOperation(value = "更新货币表状态")
-    @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
+    @ApiOperation(value = "更新货币数据")
+    @RequestMapping(value = "/updateCurrency", method = RequestMethod.POST)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('currency:edit')")
-    public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
-        Long id = params.get("id") == null ? 0 : Long.parseLong(params.get("id").toString());
-
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
-        }
-
-        MtCurrency mtCurrency = currencyService.queryCurrencyById(id);
-        if (mtCurrency == null) {
-            return getFailureResult(201);
-        }
-
-        String operator = accountInfo.getAccountName();
-
-        currencyService.updateCurrency(mtCurrency);
-
-        return getSuccessResult(true);
+    public ResponseObject updateStatus(@RequestBody CurrencyDto currencyDto) throws BusinessCheckException {
+        boolean success = currencyService.updateCurrency(currencyDto);
+        return success?getSuccessResult(true):getFailureResult(1002,"更新失败");
     }
 
     /**
      * 保存货币表
-     *
-     * @param request HttpServletRequest对象
-     * @return
+     * @param currencyDto 参数实体
+     * @return 结果
+     * @throws BusinessCheckException
      */
     @ApiOperation(value = "保存货币表")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('currency:add')")
-    public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        String id = params.get("id") == null ? "" : params.get("id").toString();
-        String status = params.get("status") == null ? "" : params.get("status").toString();
-        String storeId = params.get("storeId") == null ? "0" : params.get("storeId").toString();
-
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
-        }
-
-        MtCurrency info = new MtCurrency();
-
-
-        return getSuccessResult(true);
+    public ResponseObject saveHandler(@RequestBody CurrencyDto currencyDto) throws BusinessCheckException {
+        boolean success = currencyService.addCurrency(currencyDto);
+        return success?getSuccessResult(true):getFailureResult(1002,"保存失败");
     }
 
     /**
-     * 获取货币表详情
+     * 通过id删除货币数据
      *
-     * @param id
-     * @return
+     * @param id id
+     * @return 结果
      */
-    @ApiOperation(value = "获取货币表详情")
-    @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
+    @ApiOperation(value = "通过id删除货币数据")
+    @DeleteMapping("/{id}")
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('currency:list')")
-    public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
-        }
-
-        MtCurrency currencyInfo = currencyService.queryCurrencyById(Long.valueOf(id));
+    @PreAuthorize("@pms.hasPermission('currency:delete')")
+    public ResponseObject info(@PathVariable("id") Integer id) throws BusinessCheckException {
+        boolean success = currencyService.deleteCurrency(id);
+        return success?getSuccessResult(true):getFailureResult(1002,"删除失败");
+    }
 
-        Map<String, Object> result = new HashMap<>();
-        result.put("currencyInfo", currencyInfo);
 
+    /**
+     * 获取全部的货币列表
+     *
+     * @param name 货币名称
+     * @return 结果
+     */
+    @ApiOperation(value = "获取全部的货币列表")
+    @DeleteMapping("/allList")
+    @CrossOrigin
+    @PreAuthorize("@pms.hasPermission('currency:allList')")
+    public ResponseObject allList(@RequestParam(value = "name",defaultValue = "") String name) throws BusinessCheckException {
+        List<CurrencyVo> result = currencyService.allList(name);
         return getSuccessResult(result);
     }
+
+
 }

+ 3 - 3
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendDutyController.java

@@ -212,7 +212,7 @@ public class BackendDutyController extends BaseController {
     @PreAuthorize("@pms.hasPermission('system:role:edit')")
     public ResponseObject updateHandler(HttpServletRequest request, @RequestBody Map<String, Object> param) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
-        List<Integer> menuIds = (List) param.get("menuIds");
+        List<String> menuIds = (List) param.get("menuIds");
         String id = param.get("id").toString();
         String name = param.get("roleName").toString();
         String type = param.get("roleType").toString();
@@ -240,10 +240,10 @@ public class BackendDutyController extends BaseController {
 
         // 获取角色所分配的菜单
         List<TSource> sources = null;
-        if (menuIds.size() > 0) {
+        if (!menuIds.isEmpty()) {
             String[] sourceIds = new String[menuIds.size()];
             for (int i = 0; i < sourceIds.length; i++) {
-                 sourceIds[i] = menuIds.get(i).toString();
+                 sourceIds[i] = menuIds.get(i);
             }
             sources = tSourceService.findDatasByIds(sourceIds);
         }

+ 2 - 0
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtCountryMapper.java

@@ -13,4 +13,6 @@ import org.apache.ibatis.annotations.Param;
 public interface MtCountryMapper extends BaseMapper<MtCountry> {
 
 	int checkParentExist(@Param("parentId") Long parentId);
+
+	int countChildrenById(@Param("id") Long id);
 }

+ 3 - 1
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/mapper/MtCurrencyMapper.java

@@ -2,6 +2,7 @@ package com.fuint.repository.mapper;
 
 import com.fuint.repository.model.MtCurrency;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 货币表 Mapper 接口
@@ -11,4 +12,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface MtCurrencyMapper extends BaseMapper<MtCurrency> {
 
-}
+	int countByNameAndProject(@Param("name") String name);
+}

+ 6 - 0
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtCountry.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.*;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
@@ -81,4 +83,8 @@ public class MtCountry implements Serializable {
     @ApiModelProperty("修改用户id")
     private String updateUserId;
 
+    //用于树形结构
+    @TableField(exist = false)
+    private List<MtCountry> children;
+
 }

+ 7 - 3
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtCurrency.java

@@ -1,8 +1,7 @@
 package com.fuint.repository.model;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
+
 import java.io.Serializable;
 import java.util.Date;
 import io.swagger.annotations.ApiModel;
@@ -25,12 +24,15 @@ public class MtCurrency implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty("创建时间")
+    @TableField(fill = FieldFill.INSERT)
     private Date createTime;
 
     @ApiModelProperty("创建用户id")
+    @TableField(fill = FieldFill.INSERT)
     private String createUserId;
 
     @ApiModelProperty("是否删除 0否 1是")
+    @TableLogic
     private Integer deleteFlag;
 
     @ApiModelProperty("id")
@@ -44,9 +46,11 @@ public class MtCurrency implements Serializable {
     private String project;
 
     @ApiModelProperty("更新时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
     private Date updateTime;
 
     @ApiModelProperty("修改用户id")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
     private String updateUserId;
 
 }

+ 3 - 0
fuintBackend/fuint-repository/src/main/resources/mapper/MtCountryMapper.xml

@@ -4,4 +4,7 @@
     <select id="checkParentExist" resultType="java.lang.Integer">
         SELECT COUNT(1) FROM mt_country WHERE id = #{parentId} AND delete_flag = 0
     </select>
+    <select id="countChildrenById" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM mt_country WHERE parent_id = #{parentId}
+    </select>
 </mapper>

+ 4 - 1
fuintBackend/fuint-repository/src/main/resources/mapper/MtCurrencyMapper.xml

@@ -1,5 +1,8 @@
 <?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.fuint.repository.mapper.MtCurrencyMapper}">
+<mapper namespace="com.fuint.repository.mapper.MtCurrencyMapper">
 
+    <select id="countByNameAndProject" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM mt_currency WHERE NAME = #{name}
+    </select>
 </mapper>