修复不能设置账户默认值的bug
This commit is contained in:
@@ -321,24 +321,21 @@
|
|||||||
function setDefault(accountID, isDefault) {
|
function setDefault(accountID, isDefault) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
url: "/account/updateAmountIsDefault.action",
|
url: "/account/updateAmountIsDefault",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
data: ({
|
data: ({
|
||||||
AccountID: accountID,
|
accountId: accountID,
|
||||||
IsDefault: isDefault
|
isDefault: isDefault
|
||||||
}),
|
}),
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (res == "true" && isDefault) {
|
if (res == "true" && isDefault) {
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//此处添加错误处理
|
//此处添加错误处理
|
||||||
error: function () {
|
error: function () {
|
||||||
$.messager.alert('删除提示', '删除结算账户异常,请稍后再试!', 'error');
|
$.messager.alert('提示', '设为默认账户异常,请稍后再试!', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,12 +6,10 @@ import com.jsh.erp.datasource.entities.Account;
|
|||||||
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
||||||
import com.jsh.erp.service.account.AccountService;
|
import com.jsh.erp.service.account.AccountService;
|
||||||
import com.jsh.erp.utils.BaseResponseInfo;
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import com.jsh.erp.utils.ErpInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -19,6 +17,8 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/account")
|
@RequestMapping(value = "/account")
|
||||||
public class AccountController {
|
public class AccountController {
|
||||||
@@ -121,4 +121,18 @@ public class AccountController {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/updateAmountIsDefault")
|
||||||
|
public String updateAmountIsDefault(@RequestParam("isDefault") Boolean isDefault,
|
||||||
|
@RequestParam("accountId") Long accountId,
|
||||||
|
HttpServletRequest request) {
|
||||||
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
|
int res = accountService.updateAmountIsDefault(isDefault, accountId);
|
||||||
|
if(res > 0) {
|
||||||
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else {
|
||||||
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ public class AccountService {
|
|||||||
|
|
||||||
public int insertAccount(String beanJson, HttpServletRequest request) {
|
public int insertAccount(String beanJson, HttpServletRequest request) {
|
||||||
Account account = JSONObject.parseObject(beanJson, Account.class);
|
Account account = JSONObject.parseObject(beanJson, Account.class);
|
||||||
|
if(account.getInitialamount() == null) {
|
||||||
|
account.setInitialamount(0d);
|
||||||
|
}
|
||||||
|
account.setIsdefault(false);
|
||||||
return accountMapper.insertSelective(account);
|
return accountMapper.insertSelective(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,4 +296,12 @@ public class AccountService {
|
|||||||
return accountMapper.findAccountInOutListCount(accountId);
|
return accountMapper.findAccountInOutListCount(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int updateAmountIsDefault(Boolean isDefault, Long accountId) {
|
||||||
|
Account account = new Account();
|
||||||
|
account.setIsdefault(isDefault);
|
||||||
|
AccountExample example = new AccountExample();
|
||||||
|
example.createCriteria().andIdEqualTo(accountId);
|
||||||
|
return accountMapper.updateByExampleSelective(account, example);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user