|
|
@@ -4,16 +4,22 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.saas.base.Result;
|
|
|
import com.usoftchina.saas.commons.dto.DocReqDTO;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
|
|
|
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.mapper.CurrencyMapper;
|
|
|
import com.usoftchina.saas.document.service.CurrencyService;
|
|
|
+import com.usoftchina.saas.exception.BizException;
|
|
|
import com.usoftchina.saas.page.PageDefault;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -26,6 +32,8 @@ public class CurrencyController {
|
|
|
|
|
|
@Autowired
|
|
|
private CurrencyService currencyService;
|
|
|
+ @Autowired
|
|
|
+ private CurrencyMapper currencyMapper;
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
public Result getAll(@PageDefault(number = 1, size = 10) PageRequest pageRequest, ListReqDTO listReqDTO){
|
|
|
@@ -52,8 +60,24 @@ public class CurrencyController {
|
|
|
|
|
|
@PostMapping("/delete/{id}")
|
|
|
public Result delete(@PathVariable("id") Long id){
|
|
|
+ Currency currency = currencyService.findByPrimaryKey(id);
|
|
|
+ if(currency.getCr_standard()==1){
|
|
|
+ //本位币无法删除
|
|
|
+ throw new BizException(BizExceptionCode.BIZ_MAINCURRENCY_DELETE);
|
|
|
+ }
|
|
|
+ //校验是否可以删除币别
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("v_type","currency");
|
|
|
+ map.put("v_id",0);
|
|
|
+ map.put("v_code",currency.getCr_name());
|
|
|
+ map.put("v_companyid",BaseContextHolder.getCompanyId());
|
|
|
+ map.put("v_res","");
|
|
|
+ currencyMapper.check(map);
|
|
|
+ Object result = map.get("v_res");
|
|
|
+ if(!StringUtils.isEmpty(result)){
|
|
|
+ throw new BizException(-999999,result.toString());
|
|
|
+ }
|
|
|
currencyService.removeByPrimaryKey(id);
|
|
|
return Result.success();
|
|
|
}
|
|
|
-
|
|
|
}
|