异常处理框架
This commit is contained in:
parent
b4a60e00da
commit
a35259c1ef
|
|
@ -38,11 +38,13 @@ public class TaxAgentSaveCmd extends AbstractCommonCommand<Map<String, Object>>
|
|||
List<TaxAgent> list = mapper.listByName(Util.null2String(this.params.get("name")));
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
throw new SalaryRunTimeException("名称不允许重复");
|
||||
// apidatas.put("status",false);
|
||||
}
|
||||
|
||||
TaxAgent taxAgent = TaxAgent.convertToPO(params, (long) user.getUID());
|
||||
mapper.insert(taxAgent);
|
||||
|
||||
sqlSession.commit();
|
||||
} finally {
|
||||
sqlSession.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import weaver.conn.mybatis.MyBatisFactory;
|
|||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
public class TaxAgentUpdateCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.engine.salary.constant;
|
||||
|
||||
/**
|
||||
* @description: 默认的租户key
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 2/8/22 11:25 AM
|
||||
* @version:v1.0
|
||||
*/
|
||||
public class SalaryDefaultTenantConstant {
|
||||
|
||||
public static final String DEFAULT_TENANT_KEY = "all_teams";
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.engine.salary.constant;
|
||||
|
||||
/**
|
||||
* @description: 薪酬管理公式编辑器的常量
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 12/24/21 5:51 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
public class SalaryFormulaFieldConstant {
|
||||
|
||||
// 公式变量的所属模块
|
||||
public static final String MODULE = "hrmsalary";
|
||||
|
||||
// 公式中变量的fieldId的分隔符
|
||||
public static final String FIELD_ID_SEPARATOR = "_";
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.engine.salary.constant;
|
||||
|
||||
/**
|
||||
* @Description: 薪资项目常量
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2021/12/30 13:32
|
||||
*/
|
||||
public class SalaryItemConstant {
|
||||
|
||||
/**
|
||||
* 列表中薪资项目动态列后缀标识
|
||||
*/
|
||||
public static final String DYNAMIC_SUFFIX = "_salaryItem";
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.engine.salary.constant;
|
||||
|
||||
/**
|
||||
* @description: 薪资项目的值的字段类型
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 2/9/22 1:56 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
public class SalaryItemDataTypeConstant {
|
||||
|
||||
/**
|
||||
* 数字型
|
||||
*/
|
||||
public static final String TYPE_NUMBER = "number";
|
||||
|
||||
/**
|
||||
* 字符类型
|
||||
*/
|
||||
public static final String TYPE_STRING = "string";
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.engine.salary.constant;
|
||||
|
||||
/**
|
||||
* @Description: 工资单模板项目设置分组id
|
||||
* @Author: wangxiangzhong
|
||||
* @Date: 2022/2/21 22:19
|
||||
*/
|
||||
public class SalaryTemplateSalaryItemSetGroupConstant {
|
||||
|
||||
/**
|
||||
* 员工信息组id
|
||||
*/
|
||||
public static final String EMPLOYEE_INFO_GROUP_ID = String.valueOf(111111111111111111L);
|
||||
|
||||
/**
|
||||
* 无分类组id
|
||||
*/
|
||||
public static final String NO_TYPE_GROUP_ID = String.valueOf(222222222222222222L);
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.engine.salary.constant;
|
||||
|
||||
/**
|
||||
* @description: 个税税率表明细表的dataIndex
|
||||
* @author: xiajun
|
||||
* @modified By: xiajun
|
||||
* @date: Created in 1/17/22 1:58 PM
|
||||
* @version:v1.0
|
||||
*/
|
||||
public class TaxRateDataIndexConstant {
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
public static final String INDEX_NUM = "indexNum";
|
||||
|
||||
/**
|
||||
* 收入下限(不含)
|
||||
*/
|
||||
public static final String INCOME_LOWER_LIMIT = "incomeLowerLimit";
|
||||
|
||||
/**
|
||||
* 收入上限(含)
|
||||
*/
|
||||
public static final String INCOME_UPPER_LIMIT = "incomeUpperLimit";
|
||||
|
||||
/**
|
||||
* 免税固定值
|
||||
*/
|
||||
public static final String DUTY_FREE_VALUE = "dutyFreeValue";
|
||||
|
||||
/**
|
||||
* 免税比例
|
||||
*/
|
||||
public static final String DUTY_FREE_RATE = "dutyFreeRate";
|
||||
|
||||
/**
|
||||
* 应纳税所得额下限(不含)
|
||||
*/
|
||||
public static final String TAXABLE_INCOME_LOWER_LIMIT = "taxableIncomeLLimit";
|
||||
|
||||
/**
|
||||
* 应纳税所得额上限(含)
|
||||
*/
|
||||
public static final String TAXABLE_INCOME_UPPER_LIMIT = "taxableIncomeULimit";
|
||||
|
||||
/**
|
||||
* 税率
|
||||
*/
|
||||
public static final String TAX_RATE = "taxRate";
|
||||
|
||||
/**
|
||||
* 速算扣除数
|
||||
*/
|
||||
public static final String TAX_DEDUCTION = "taxDeduction";
|
||||
}
|
||||
|
|
@ -9,6 +9,8 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import static com.engine.salary.constant.SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
|
||||
|
||||
/**
|
||||
* 个税扣缴义务人表
|
||||
*/
|
||||
|
|
@ -51,17 +53,19 @@ public class TaxAgent {
|
|||
private Date updateTime;
|
||||
|
||||
|
||||
public static TaxAgent convertToPO(Map<String,Object> param, Long employeeId) {
|
||||
public static TaxAgent convertToPO(Map<String, Object> param, Long employeeId) {
|
||||
if (param == null) {
|
||||
return null;
|
||||
}
|
||||
return TaxAgent.builder()
|
||||
.id((long)param.get("id"))
|
||||
.name((String) param.get("name"))
|
||||
.description((String) param.get("description"))
|
||||
.id(param.get("id") == null ? null : (long) param.get("id"))
|
||||
.name(param.get("name") == null ? null : (String) param.get("name"))
|
||||
.description(param.get("description") == null ? null : (String) param.get("description"))
|
||||
.deleteType(0)
|
||||
.createTime(new Date())
|
||||
.updateTime(new Date())
|
||||
.creator(employeeId)
|
||||
.tenantKey(DEFAULT_TENANT_KEY)
|
||||
// .tenantKey(tenantKey)
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public interface TaxAgentMapper {
|
|||
*/
|
||||
int delete(TaxAgent taxAgent);
|
||||
|
||||
@Select("SELECT * FROM hrsa_tax_agent WHERE deleteType = 0 and name = #{name}")
|
||||
@Select("SELECT * FROM hrsa_tax_agent WHERE delete_type = 0 and name = #{name}")
|
||||
List<TaxAgent> listByName(String name);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.engine.salary.util;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.engine.core.exception.ECException;
|
||||
import com.engine.salary.exception.SalaryRunTimeException;
|
||||
import weaver.general.BaseBean;
|
||||
|
||||
|
|
@ -18,11 +19,16 @@ public class ResponseResult extends HashMap<String, Object> {
|
|||
/**
|
||||
* 统一返回方法
|
||||
*/
|
||||
public static String run(Function<Map<String, Object>,Map<String, Object>> f,Map<String, Object> m) {
|
||||
public static String run(Function<Map<String, Object>, Map<String, Object>> f, Map<String, Object> m) {
|
||||
try {
|
||||
return Ok(f.apply(m));
|
||||
} catch (SalaryRunTimeException e) {
|
||||
return Error(e.getMessage());
|
||||
} catch (ECException e) {
|
||||
BaseBean b = new BaseBean();
|
||||
b.writeLog(e);
|
||||
Throwable cause = e.getCause();
|
||||
return Error(cause.getMessage());
|
||||
} catch (Exception e) {
|
||||
BaseBean b = new BaseBean();
|
||||
b.writeLog(e);
|
||||
|
|
@ -36,7 +42,7 @@ public class ResponseResult extends HashMap<String, Object> {
|
|||
private static String Ok(Map<String, Object> map) {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
apidatas.put("status", true);
|
||||
apidatas.put("data",map);
|
||||
apidatas.put("data", map);
|
||||
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DemoController {
|
||||
|
||||
|
|
@ -49,6 +52,18 @@ public class DemoController {
|
|||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String getFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ResponseResult.run(getService(user)::save, ParamUtil.request2Map(request));
|
||||
return ResponseResult.run(getService(user)::save, getRequestParams(request,response));
|
||||
}
|
||||
|
||||
|
||||
protected Map<String,Object> getRequestParams(HttpServletRequest request, HttpServletResponse response){
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Enumeration<String> em = request.getParameterNames();
|
||||
while(em.hasMoreElements()){
|
||||
String paramname = em.nextElement();
|
||||
params.put(paramname, request.getParameter(paramname));
|
||||
}
|
||||
params.put("param_ip", request.getRemoteAddr());//加入ip
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TaxAgentController {
|
||||
|
||||
|
|
@ -52,7 +55,7 @@ public class TaxAgentController {
|
|||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String getFrom(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ResponseResult.run(getService(user)::save, ParamUtil.request2Map(request));
|
||||
return ResponseResult.run(getService(user)::save, getRequestParams(request,response));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,5 +69,16 @@ public class TaxAgentController {
|
|||
return ResponseResult.run(getService(user)::update, ParamUtil.request2Map(request));
|
||||
}
|
||||
|
||||
protected Map<String,Object> getRequestParams(HttpServletRequest request, HttpServletResponse response){
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Enumeration<String> em = request.getParameterNames();
|
||||
while(em.hasMoreElements()){
|
||||
String paramname = em.nextElement();
|
||||
params.put(paramname, request.getParameter(paramname));
|
||||
}
|
||||
params.put("param_ip", request.getRemoteAddr());//加入ip
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue