160 changed files with 380 additions and 8416 deletions
@ -0,0 +1,15 @@
|
||||
package com.zsw.erp.config; |
||||
|
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
@Configuration |
||||
public class MvcConfigurer implements WebMvcConfigurer { |
||||
|
||||
@Override |
||||
public void configurePathMatch(PathMatchConfigurer configurer) { |
||||
configurer.addPathPrefix("/admin-api/erp",aClass -> aClass.getPackage().getName().startsWith("com.zsw.erp")); |
||||
} |
||||
|
||||
} |
@ -1,152 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.datasource.entities.Account; |
||||
import com.zsw.erp.datasource.vo.AccountVo4InOutList; |
||||
import com.zsw.erp.service.account.AccountService; |
||||
import com.zsw.base.R; |
||||
import com.zsw.erp.utils.ErpInfo; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping(value = "/account") |
||||
@Api(tags = {"账户管理"}) |
||||
public class AccountController { |
||||
private Logger logger = LoggerFactory.getLogger(AccountController.class); |
||||
|
||||
@Resource |
||||
private AccountService accountService; |
||||
|
||||
/** |
||||
* 查找结算账户信息-下拉框 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/findBySelect") |
||||
@ApiOperation(value = "查找结算账户信息-下拉框") |
||||
public String findBySelect(HttpServletRequest request) throws Exception { |
||||
String res = null; |
||||
try { |
||||
List<Account> dataList = accountService.findBySelect(); |
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray(); |
||||
if (null != dataList) { |
||||
for (Account account : dataList) { |
||||
JSONObject item = new JSONObject(); |
||||
item.put("Id", account.getId()); |
||||
//结算账户名称
|
||||
item.put("AccountName", account.getName()); |
||||
dataArray.add(item); |
||||
} |
||||
} |
||||
res = dataArray.toJSONString(); |
||||
} catch(Exception e){ |
||||
e.printStackTrace(); |
||||
res = "获取数据失败"; |
||||
} |
||||
return res; |
||||
} |
||||
|
||||
/** |
||||
* 获取所有结算账户 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/getAccount") |
||||
@ApiOperation(value = "获取所有结算账户") |
||||
public R getAccount(HttpServletRequest request) throws Exception { |
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>(); |
||||
List<Account> accountList = accountService.getAccount(); |
||||
map.put("accountList", accountList); |
||||
return R.success(map); |
||||
} |
||||
|
||||
/** |
||||
* 账户流水信息 |
||||
* @param currentPage |
||||
* @param pageSize |
||||
* @param accountId |
||||
* @param initialAmount |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/findAccountInOutList") |
||||
@ApiOperation(value = "账户流水信息") |
||||
public R findAccountInOutList(@RequestParam("currentPage") Integer currentPage, |
||||
@RequestParam("pageSize") Integer pageSize, |
||||
@RequestParam("accountId") Long accountId, |
||||
@RequestParam("initialAmount") BigDecimal initialAmount, |
||||
HttpServletRequest request) throws Exception{ |
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>(); |
||||
List<AccountVo4InOutList> dataList = accountService.findAccountInOutList(accountId, (currentPage-1)*pageSize, pageSize); |
||||
int total = accountService.findAccountInOutListCount(accountId); |
||||
map.put("total", total); |
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray(); |
||||
if (null != dataList) { |
||||
for (AccountVo4InOutList aEx : dataList) { |
||||
String timeStr = aEx.getOperTime().toString(); |
||||
BigDecimal balance = accountService.getAccountSum(accountId, timeStr, "date").add(accountService.getAccountSumByHead(accountId, timeStr, "date")) |
||||
.add(accountService.getAccountSumByDetail(accountId, timeStr, "date")).add(accountService.getManyAccountSum(accountId, timeStr, "date")).add(initialAmount); |
||||
aEx.setBalance(balance); |
||||
aEx.setAccountId(accountId); |
||||
dataArray.add(aEx); |
||||
} |
||||
} |
||||
map.put("rows", dataArray); |
||||
return R.success(map); |
||||
} |
||||
|
||||
/** |
||||
* 更新默认账户 |
||||
* @param object |
||||
* @param request |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@PostMapping(value = "/updateIsDefault") |
||||
@ApiOperation(value = "更新默认账户") |
||||
public String updateIsDefault(@RequestBody JSONObject object, |
||||
HttpServletRequest request) throws Exception{ |
||||
Long accountId = object.getLong("id"); |
||||
Map<String, Object> objectMap = new HashMap<>(); |
||||
int res = accountService.updateIsDefault(accountId); |
||||
if(res > 0) { |
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); |
||||
} else { |
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 结算账户的统计 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/getStatistics") |
||||
@ApiOperation(value = "结算账户的统计") |
||||
public R getStatistics(@RequestParam("name") String name, |
||||
@RequestParam("serialNo") String serialNo, |
||||
HttpServletRequest request) throws Exception { |
||||
|
||||
Map<String, Object> map = accountService.getStatistics(name, serialNo); |
||||
return R.success(map); |
||||
} |
||||
} |
@ -1,241 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import cn.hutool.json.JSONArray; |
||||
import cn.hutool.json.JSONObject; |
||||
import com.google.common.collect.Lists; |
||||
import com.zsw.erp.datasource.entities.BtnDto; |
||||
import com.zsw.erp.datasource.entities.Function; |
||||
import com.zsw.erp.datasource.entities.UserBusiness; |
||||
import com.zsw.erp.service.functions.FunctionService; |
||||
import com.zsw.erp.service.userBusiness.UserBusinessService; |
||||
import com.zsw.base.R; |
||||
import com.zsw.erp.utils.Tools; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.dao.DataAccessException; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping(value = "/function") |
||||
@Api(tags = {"功能管理"}) |
||||
public class FunctionController { |
||||
private Logger logger = LoggerFactory.getLogger(FunctionController.class); |
||||
|
||||
@Resource |
||||
private FunctionService functionService; |
||||
|
||||
@Resource |
||||
private UserBusinessService userBusinessService; |
||||
|
||||
/** |
||||
* 根据父编号查询菜单 |
||||
* @param jsonObject |
||||
* @param request |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@PostMapping(value = "/findMenuByPNumber") |
||||
@ApiOperation(value = "根据父编号查询菜单") |
||||
public JSONArray findMenuByPNumber(@RequestBody JSONObject jsonObject, |
||||
HttpServletRequest request)throws Exception { |
||||
String pNumber = jsonObject.getStr("pNumber"); |
||||
Long userId = jsonObject.getLong("userId"); |
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray(); |
||||
try { |
||||
Long roleId = 0L; |
||||
List<Long> fc = Lists.newArrayList(); |
||||
UserBusiness role = userBusinessService.getBasicData(userId, "UserRole"); |
||||
roleId = role.getValue().get(0).longValue(); |
||||
//当前用户所拥有的功能列表,格式如:[1][2][5]
|
||||
// List<UserBusiness> funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions");
|
||||
// if(funList!=null && funList.size()>0){
|
||||
// fc = funList.get(0).getValue();
|
||||
// }
|
||||
// List<Function> dataList = functionService.getRoleFunction(pNumber);
|
||||
List<Function> dataList; |
||||
if (roleId == 1L){ |
||||
logger.info("当前是系统管理员,给予全部菜单和权限。"); |
||||
dataList = functionService.getRoleFunction(pNumber); |
||||
fc = functionService.getFunction().stream().map(Function::getId).collect(Collectors.toList()); |
||||
}else{ |
||||
dataList = functionService.getRoleFunction(pNumber); |
||||
UserBusiness fun = userBusinessService.getBasicData(roleId, "RoleFunctions"); |
||||
fc = fun.getValue().stream().map(Number::longValue).collect(Collectors.toList()); |
||||
} |
||||
|
||||
if (dataList.size() != 0) { |
||||
dataArray = getMenuByFunction(dataList, fc); |
||||
//增加首页菜单项
|
||||
JSONObject homeItem = new JSONObject(); |
||||
homeItem.set("id", 0); |
||||
homeItem.set("text", "首页"); |
||||
homeItem.set("icon", "home"); |
||||
homeItem.set("url", "/dashboard/analysis"); |
||||
homeItem.set("component", "/layouts/TabLayout"); |
||||
dataArray.add(0,homeItem); |
||||
} |
||||
} catch (DataAccessException e) { |
||||
logger.error(">>>>>>>>>>>>>>>>>>>查找异常", e); |
||||
} |
||||
return dataArray; |
||||
} |
||||
|
||||
public JSONArray getMenuByFunction(List<Function> dataList, List<Long> fc) throws Exception { |
||||
|
||||
dataList = dataList.stream() |
||||
.filter(function -> fc.contains(function.getId())) |
||||
.collect(Collectors.toList()); |
||||
|
||||
JSONArray dataArray = new JSONArray(); |
||||
for (Function function : dataList) { |
||||
JSONObject item = new JSONObject(); |
||||
List<Function> newList = functionService.getRoleFunction(function.getNumber()); |
||||
item.set("id", function.getId()); |
||||
item.set("text", function.getName()); |
||||
item.set("icon", function.getIcon()); |
||||
item.set("url", function.getUrl()); |
||||
item.set("component", function.getComponent()); |
||||
if (newList.size()>0) { |
||||
JSONArray childrenArr = getMenuByFunction(newList, fc); |
||||
if(childrenArr.size()>0) { |
||||
item.put("children", childrenArr); |
||||
dataArray.add(item); |
||||
} |
||||
} else { |
||||
if (fc.contains(function.getId())) { |
||||
dataArray.add(item); |
||||
} |
||||
} |
||||
} |
||||
return dataArray; |
||||
} |
||||
|
||||
/** |
||||
* 角色对应功能显示 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/findRoleFunction") |
||||
@ApiOperation(value = "角色对应功能显示") |
||||
public JSONArray findRoleFunction(@RequestParam("UBType") String type, @RequestParam("UBKeyId") Long keyId, |
||||
HttpServletRequest request)throws Exception { |
||||
JSONArray arr = new JSONArray(); |
||||
try { |
||||
List<Function> dataListFun = functionService.findRoleFunction("0"); |
||||
//开始拼接json数据
|
||||
JSONObject outer = new JSONObject(); |
||||
outer.set("id", 0); |
||||
outer.set("key", 0); |
||||
outer.set("value", 0); |
||||
outer.set("title", "功能列表"); |
||||
outer.set("attributes", "功能列表"); |
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray(); |
||||
if (null != dataListFun) { |
||||
//根据条件从列表里面移除"系统管理"
|
||||
List<Function> dataList = new ArrayList<>(); |
||||
for (Function fun : dataListFun) { |
||||
String token = request.getHeader("X-Access-Token"); |
||||
Long tenantId = Tools.getTenantIdByToken(token); |
||||
if (tenantId!=0L) { |
||||
if(!("系统管理").equals(fun.getName())) { |
||||
dataList.add(fun); |
||||
} |
||||
} else { |
||||
//超管
|
||||
dataList.add(fun); |
||||
} |
||||
} |
||||
dataArray = getFunctionList(dataList, type, keyId); |
||||
outer.set("children", dataArray); |
||||
} |
||||
arr.add(outer); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return arr; |
||||
} |
||||
|
||||
public JSONArray getFunctionList(List<Function> dataList, String type, Long keyId) throws Exception { |
||||
JSONArray dataArray = new JSONArray(); |
||||
//获取权限信息
|
||||
List<Long> ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId); |
||||
if (null != dataList) { |
||||
for (Function function : dataList) { |
||||
JSONObject item = new JSONObject(); |
||||
item.set("id", function.getId()); |
||||
item.set("key", function.getId()); |
||||
item.set("value", function.getId()); |
||||
item.set("title", function.getName()); |
||||
item.set("attributes", function.getName()); |
||||
List<Function> funList = functionService.findRoleFunction(function.getNumber()); |
||||
if(funList.size()>0) { |
||||
JSONArray funArr = getFunctionList(funList, type, keyId); |
||||
item.set("children", funArr); |
||||
} else { |
||||
if (ubValue == null){ |
||||
item.set("checked", false); |
||||
}else { |
||||
Boolean flag = ubValue.contains(function.getId()); |
||||
item.set("checked", flag); |
||||
} |
||||
} |
||||
dataArray.add(item); |
||||
} |
||||
} |
||||
return dataArray; |
||||
} |
||||
|
||||
/** |
||||
* 根据id列表查找功能信息 |
||||
* @param roleId |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/findRoleFunctionsById") |
||||
@ApiOperation(value = "根据id列表查找功能信息") |
||||
public R findByIds(@RequestParam("roleId") Long roleId, |
||||
HttpServletRequest request)throws Exception { |
||||
|
||||
UserBusiness ub = userBusinessService.getBasicData(roleId, "RoleFunctions"); |
||||
//按钮
|
||||
Map<Long,String> btnMap = new HashMap<>(); |
||||
List<BtnDto> btnStr = ub.getBtnStr(); |
||||
if(ObjectUtil.isNotEmpty(btnStr)) { |
||||
for(BtnDto obj: btnStr) { |
||||
if(obj.getFunId()!=null && obj.getBtnStr()!=null) { |
||||
btnMap.put(obj.getFunId(), obj.getBtnStr()); |
||||
} |
||||
} |
||||
} |
||||
//菜单
|
||||
List<Long> funIds = ub.getValue().stream().map(Number::longValue).collect(Collectors.toList()); |
||||
List<Function> dataList = functionService.findByIds(funIds); |
||||
JSONObject outer = new JSONObject(); |
||||
outer.set("total", dataList.size()); |
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray(); |
||||
if (ObjectUtil.isNotEmpty(dataList)) { |
||||
for (Function function : dataList) { |
||||
JSONObject item = new JSONObject(); |
||||
item.set("id", function.getId()); |
||||
item.set("name", function.getName()); |
||||
item.set("pushBtn", function.getPushBtn()); |
||||
item.set("btnStr", ObjectUtil.isEmpty(btnMap.get(function.getId()))?"":btnMap.get(function.getId())); |
||||
dataArray.add(item); |
||||
} |
||||
} |
||||
outer.set("rows", dataArray); |
||||
return R.success(outer); |
||||
} |
||||
} |
@ -1,14 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import com.zsw.base.R; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
public class IndexController { |
||||
|
||||
@RequestMapping("/") |
||||
public R<String> index(){ |
||||
return R.success("","欢迎访问回乡进销存系统"); |
||||
} |
||||
} |
@ -1,116 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.datasource.entities.PlatformConfig; |
||||
import com.zsw.erp.service.platformConfig.PlatformConfigService; |
||||
import com.zsw.erp.service.user.UserService; |
||||
import com.zsw.base.R; |
||||
import com.zsw.erp.utils.ErpInfo; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping(value = "/platformConfig") |
||||
@Api(tags = {"平台参数"}) |
||||
public class PlatformConfigController { |
||||
private Logger logger = LoggerFactory.getLogger(PlatformConfigController.class); |
||||
|
||||
@Value("${demonstrate.open}") |
||||
private boolean demonstrateOpen; |
||||
|
||||
@Resource |
||||
private PlatformConfigService platformConfigService; |
||||
|
||||
@Resource |
||||
private UserService userService; |
||||
|
||||
private static final String TEST_USER = "jsh"; |
||||
|
||||
/** |
||||
* 获取平台名称 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/getPlatform/name") |
||||
@ApiOperation(value = "获取平台名称") |
||||
public String getPlatformName(HttpServletRequest request)throws Exception { |
||||
String res; |
||||
try { |
||||
String platformKey = "platform_name"; |
||||
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey); |
||||
res = platformConfig.getPlatformValue(); |
||||
} catch(Exception e){ |
||||
e.printStackTrace(); |
||||
res = "ERP系统"; |
||||
} |
||||
return res; |
||||
} |
||||
|
||||
/** |
||||
* 获取官方网站地址 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/getPlatform/url") |
||||
@ApiOperation(value = "获取官方网站地址") |
||||
public String getPlatformUrl(HttpServletRequest request)throws Exception { |
||||
String res; |
||||
try { |
||||
String platformKey = "platform_url"; |
||||
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey); |
||||
res = platformConfig.getPlatformValue(); |
||||
} catch(Exception e){ |
||||
e.printStackTrace(); |
||||
res = "#"; |
||||
} |
||||
return res; |
||||
} |
||||
|
||||
/** |
||||
* 根据platformKey更新platformValue |
||||
* @param object |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/updatePlatformConfigByKey") |
||||
@ApiOperation(value = "根据platformKey更新platformValue") |
||||
public String updatePlatformConfigByKey(@RequestBody JSONObject object, |
||||
HttpServletRequest request)throws Exception { |
||||
Map<String, Object> objectMap = new HashMap<>(); |
||||
String platformKey = object.getString("platformKey"); |
||||
String platformValue = object.getString("platformValue"); |
||||
int res = platformConfigService.updatePlatformConfigByKey(platformKey, platformValue); |
||||
if(res > 0) { |
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); |
||||
} else { |
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 根据platformKey查询信息 |
||||
* @param platformKey |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/getPlatformConfigByKey") |
||||
@ApiOperation(value = "根据platformKey查询信息") |
||||
public R getPlatformConfigByKey(@RequestParam("platformKey") String platformKey, |
||||
HttpServletRequest request)throws Exception { |
||||
|
||||
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey); |
||||
return R.success(platformConfig); |
||||
} |
||||
} |
@ -1,71 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.datasource.entities.Role; |
||||
import com.zsw.erp.service.role.RoleService; |
||||
import com.zsw.erp.service.userBusiness.UserBusinessService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
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.servlet.http.HttpServletRequest; |
||||
import java.util.List; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping(value = "/role") |
||||
@Api(tags = {"角色管理"}) |
||||
public class RoleController { |
||||
private Logger logger = LoggerFactory.getLogger(RoleController.class); |
||||
|
||||
@Resource |
||||
private RoleService roleService; |
||||
|
||||
@Resource |
||||
private UserBusinessService userBusinessService; |
||||
|
||||
/** |
||||
* 角色对应应用显示 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/findUserRole") |
||||
@ApiOperation(value = "查询用户的角色") |
||||
public JSONArray findUserRole(@RequestParam("UBType") String type, @RequestParam("UBKeyId") Long keyId, |
||||
HttpServletRequest request)throws Exception { |
||||
JSONArray arr = new JSONArray(); |
||||
try { |
||||
//获取权限信息
|
||||
List<Long> ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId); |
||||
List<Role> dataList = roleService.findUserRole(); |
||||
if (null != dataList) { |
||||
for (Role role : dataList) { |
||||
JSONObject item = new JSONObject(); |
||||
item.put("id", role.getId()); |
||||
item.put("text", role.getName()); |
||||
Boolean flag = ubValue.contains(role.getId()); |
||||
if (flag) { |
||||
item.put("checked", true); |
||||
} |
||||
arr.add(item); |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return arr; |
||||
} |
||||
|
||||
@GetMapping(value = "/allList") |
||||
@ApiOperation(value = "查询全部角色列表") |
||||
public List<Role> allList(HttpServletRequest request)throws Exception { |
||||
return roleService.allList(); |
||||
} |
||||
} |
@ -1,57 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.service.tenant.TenantService; |
||||
import com.zsw.erp.utils.ErpInfo; |
||||
import com.zsw.erp.utils.ResponseCode; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson; |
||||
import static com.zsw.erp.utils.ResponseJsonUtil.success; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping(value = "/tenant") |
||||
@Api(tags = {"租户管理"}) |
||||
public class TenantController { |
||||
private Logger logger = LoggerFactory.getLogger(TenantController.class); |
||||
|
||||
@Resource |
||||
private TenantService tenantService; |
||||
|
||||
/** |
||||
* 批量设置状态-启用或者禁用 |
||||
* @param jsonObject |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/batchSetStatus") |
||||
@ApiOperation(value = "批量设置状态") |
||||
public String batchSetStatus(@RequestBody JSONObject jsonObject, |
||||
HttpServletRequest request)throws Exception { |
||||
Boolean status = jsonObject.getBoolean("status"); |
||||
String ids = jsonObject.getString("ids"); |
||||
Map<String, Object> objectMap = new HashMap<>(); |
||||
int res = tenantService.batchSetStatus(status, ids); |
||||
if(res > 0) { |
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); |
||||
} else { |
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); |
||||
} |
||||
} |
||||
|
||||
@GetMapping("/listAllTenant") |
||||
@ApiOperation("列举全部租户") |
||||
public ResponseCode listAllTenant() throws Exception { |
||||
return success(tenantService.getTenant()); |
||||
} |
||||
} |
@ -1,35 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import com.zsw.base.R; |
||||
import com.zsw.jwt.model.TenantAuthInfo; |
||||
import com.zsw.pos.authority.dto.auth.LoginParamDTO; |
||||
import com.zsw.pos.oauth.service.LoginService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.dubbo.config.annotation.DubboReference; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@Slf4j |
||||
@Validated |
||||
public class TestController { |
||||
|
||||
@DubboReference |
||||
private LoginService loginService; |
||||
|
||||
@GetMapping("/test/login") |
||||
public R test(@RequestParam String username, @RequestParam String password){ |
||||
|
||||
LoginParamDTO dto = new LoginParamDTO(); |
||||
dto.setAccount(username); |
||||
dto.setPassword(password); |
||||
dto.setGrantType("password"); |
||||
R<TenantAuthInfo> rs = loginService.grant(dto); |
||||
log.debug("login result : {}",rs.getData()); |
||||
return rs; |
||||
} |
||||
|
||||
} |
||||
|
@ -1,104 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.google.common.collect.Lists; |
||||
import com.zsw.erp.datasource.dto.BtnStrDto; |
||||
import com.zsw.erp.datasource.entities.UserBusiness; |
||||
import com.zsw.erp.service.user.UserService; |
||||
import com.zsw.erp.service.userBusiness.UserBusinessService; |
||||
import com.zsw.base.R; |
||||
import com.zsw.erp.utils.ErpInfo; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping(value = "/userBusiness") |
||||
@Api(tags = {"用户角色模块的关系"}) |
||||
public class UserBusinessController { |
||||
private Logger logger = LoggerFactory.getLogger(UserBusinessController.class); |
||||
|
||||
@Resource |
||||
private UserBusinessService userBusinessService; |
||||
@Resource |
||||
private UserService userService; |
||||
|
||||
/** |
||||
* 获取信息 |
||||
* @param keyId |
||||
* @param type |
||||
* @param request |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@GetMapping(value = "/getBasicData") |
||||
@ApiOperation(value = "获取信息") |
||||
public R getBasicData(@RequestParam(value = "KeyId") Long keyId, |
||||
@RequestParam(value = "Type") String type, |
||||
HttpServletRequest request)throws Exception { |
||||
|
||||
UserBusiness list = userBusinessService.getBasicData(keyId, type); |
||||
Map<String, List> mapData = new HashMap<String, List>(); |
||||
mapData.put("userBusinessList", Lists.newArrayList(list)); |
||||
return R.success(mapData); |
||||
} |
||||
|
||||
/** |
||||
* 校验存在 |
||||
* @param type |
||||
* @param keyId |
||||
* @param request |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@GetMapping(value = "/checkIsValueExist") |
||||
@ApiOperation(value = "校验存在") |
||||
public String checkIsValueExist(@RequestParam(value ="type", required = false) String type, |
||||
@RequestParam(value ="keyId", required = false) String keyId, |
||||
HttpServletRequest request)throws Exception { |
||||
Map<String, Object> objectMap = new HashMap<String, Object>(); |
||||
Long id = userBusinessService.checkIsValueExist(type, keyId); |
||||
if(id != null) { |
||||
objectMap.put("id", id); |
||||
} else { |
||||
objectMap.put("id", null); |
||||
} |
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); |
||||
} |
||||
|
||||
/** |
||||
* 更新角色的按钮权限 |
||||
* @param jsonObject |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/updateBtnStr") |
||||
@ApiOperation(value = "更新角色的按钮权限") |
||||
public R updateBtnStr(@RequestBody BtnStrDto dto, |
||||
HttpServletRequest request)throws Exception { |
||||
|
||||
String roleId = dto.getRoleId(); |
||||
// JSONArray btnStrArray = jsonObject.getJSONArray("btnStr");
|
||||
// List<BtnDto> btnStr = btnStrArray.toJavaList(BtnDto.class);
|
||||
String keyId = roleId; |
||||
String type = "RoleFunctions"; |
||||
int back = userBusinessService.updateBtnStr(keyId, type, dto.getBtnStr()); |
||||
if(back > 0) { |
||||
return R.success("成功"); |
||||
}else { |
||||
return R.fail("更新失败"); |
||||
} |
||||
} |
||||
} |
@ -1,483 +0,0 @@
|
||||
package com.zsw.erp.controller; |
||||
|
||||
import cn.hutool.core.date.*; |
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import cn.hutool.jwt.*; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.constants.BusinessConstants; |
||||
import com.zsw.erp.constants.ExceptionConstants; |
||||
import com.zsw.erp.datasource.entities.BtnDto; |
||||
import com.zsw.erp.datasource.dto.UserLoginDto; |
||||
import com.zsw.erp.datasource.entities.Tenant; |
||||
import com.zsw.erp.datasource.entities.User; |
||||
import com.zsw.erp.datasource.entities.UserEx; |
||||
import com.zsw.erp.datasource.vo.TreeNodeEx; |
||||
import com.zsw.erp.exception.BusinessParamCheckingException; |
||||
import com.zsw.erp.service.inventorySeason.InventorySeasonService; |
||||
import com.zsw.erp.service.log.LogService; |
||||
import com.zsw.erp.service.redis.RedisService; |
||||
import com.zsw.erp.service.tenant.TenantService; |
||||
import com.zsw.erp.service.user.UserService; |
||||
import com.zsw.base.R; |
||||
import com.zsw.erp.utils.*; |
||||
import com.zsw.jwt.model.AuthInfo; |
||||
import com.zsw.jwt.model.TenantAuthInfo; |
||||
import com.zsw.pos.authority.dto.auth.LoginParamDTO; |
||||
import com.zsw.pos.oauth.service.LoginService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.dubbo.config.annotation.DubboReference; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.time.LocalDateTime; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.time.temporal.ChronoUnit; |
||||
import java.util.*; |
||||
|
||||
import static com.zsw.erp.utils.ResponseJsonUtil.returnJson; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping(value = "/user") |
||||
@Api(tags = {"用户管理"}) |
||||
public class UserController { |
||||
private Logger logger = LoggerFactory.getLogger(UserController.class); |
||||
|
||||
@Value("${manage.roleId}") |
||||
private Integer manageRoleId; |
||||
|
||||
@Value("${demonstrate.open}") |
||||
private boolean demonstrateOpen; |
||||
|
||||
@Resource |
||||
private UserService userService; |
||||
|
||||
@Resource |
||||
private TenantService tenantService; |
||||
|
||||
@Resource |
||||
private LogService logService; |
||||
|
||||
@Resource |
||||
private RedisService redisService; |
||||
|
||||
@Resource |
||||
private InventorySeasonService inventorySeasonService; |
||||
|
||||
@DubboReference |
||||
private LoginService loginService; |
||||
|
||||
@Value("${tenant.userNumLimit}") |
||||
private Integer systemLimit; |
||||
|
||||
private static final String TEST_USER = "jsh"; |
||||
private static String SUCCESS = "操作成功"; |
||||
private static String ERROR = "操作失败"; |
||||
private static final String HTTP = "http://"; |
||||
private static final String CODE_OK = "200"; |
||||
private static final String BASE_CHECK_CODES = "qwertyuiplkjhgfdsazxcvbnmQWERTYUPLKJHGFDSAZXCVBNM1234567890"; |
||||
|
||||
@PostMapping(value = "/login") |
||||
@ApiOperation(value = "登录") |
||||
public R login(@RequestBody User userParam, |
||||
HttpServletRequest request)throws Exception { |
||||
logger.info("============用户登录 login 方法调用开始=============="); |
||||
String msgTip = ""; |
||||
User user=null; |
||||
|
||||
String loginName = userParam.getLoginName().trim(); |
||||
String password = userParam.getPassword().trim(); |
||||
|
||||
String posTenantCode = null; |
||||
JWTPayload payload = new JWTPayload(); |
||||
|
||||
// 登录zsw-admin
|
||||
LoginParamDTO dto = new LoginParamDTO(); |
||||
dto.setAccount(loginName); |
||||
dto.setPassword(password); |
||||
R<TenantAuthInfo> result = loginService.grant(dto); |
||||
logger.error("result:{}",result); |
||||
if (result.getIsSuccess()){ |
||||
// 检查系统里是否存在租户和账户 没有准备走注册流程
|
||||
posTenantCode = result.getData().getTenantCode(); |
||||
// 在这里带了太多的门店ID
|
||||
payload.setPayload("loginName",loginName); |
||||
payload.setPayload("tenantId",posTenantCode); |
||||
} |
||||
|
||||
//获取用户状态
|
||||
//int userStatus = -1;
|
||||
redisService.deleteObjectBySession(request,"userId"); |
||||
UserLoginDto loginDto = userService.validateUser(loginName, password); |
||||
|
||||
switch (loginDto.getUserStatus()) { |
||||
case ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST: |
||||
msgTip = "user is not exist"; |
||||
if (posTenantCode != null){ |
||||
// 用户不存在 但是用户不存在 可能报错。
|
||||
UserEx ex = new UserEx(); |
||||
ex.setLoginName(loginName); |
||||
ex.setPassword(password); |
||||
ex.setTenantId(Long.parseLong(posTenantCode)); |
||||
LocalDateTime time = LocalDateTimeUtil.offset(LocalDateTime.now(), 10, ChronoUnit.YEARS); |
||||
DateTimeFormatter formater = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN); |
||||
String t = time.format(formater); |
||||
ex.setExpireTime(t); |
||||
user = this.registerUser(ex,request); |
||||
payload.setPayload("userId",user.getId()); |
||||
payload.setPayload("loginName",loginName); |
||||
payload.setPayload("tenantId",posTenantCode); |
||||
msgTip = "user can login"; |
||||
} |
||||
break; |
||||
case ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR: |
||||
msgTip = "user password error"; |
||||
break; |
||||
case ExceptionCodeConstants.UserExceptionCode.BLACK_USER: |
||||
msgTip = "user is black"; |
||||
break; |
||||
case ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION: |
||||
msgTip = "access service error"; |
||||
break; |
||||
case ExceptionCodeConstants.UserExceptionCode.BLACK_TENANT: |
||||
msgTip = "tenant is black"; |
||||
break; |
||||
case ExceptionCodeConstants.UserExceptionCode.EXPIRE_TENANT: |
||||
msgTip = "tenant is expire"; |
||||
break; |
||||
case ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT: |
||||
msgTip = "user can login"; |
||||
user = loginDto.getUser(); |
||||
payload.setPayload("userId",user.getId()); |
||||
payload.setPayload("loginName",loginName); |
||||
payload.setPayload("tenantId",user.getTenantId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
// 1个月过期
|
||||
DateTime exAt = DateUtil.offset(new Date(), DateField.MONTH, 1); |
||||
payload.setExpiresAt(exAt); |
||||
String token = JWTUtil.createToken(payload.getClaimsJson(), "88888888".getBytes(StandardCharsets.UTF_8)); |
||||
|
||||
Map<String, Object> data = new HashMap<String, Object>(); |
||||
data.put("msgTip", msgTip); |
||||
if(user!=null){ |
||||
redisService.storageObjectBySession(token,"userId",user.getId()); |
||||
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
|
||||
if (roleType == null){ |
||||
logger.error("角色错误!"); |
||||
} |
||||
redisService.storageObjectBySession(token,"roleType",roleType); |
||||
redisService.storageObjectBySession(token,"clientIp", Tools.getLocalIp(request)); |
||||
logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(), |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
List<BtnDto> btnStrArr = userService.getBtnStrArrById(user.getId()); |
||||
data.put("token", token); |
||||
data.put("user", user); |
||||
LocalUser.setTenantId(user.getTenantId()); |
||||
LocalUser.setUserId(user.getId()); |
||||
data.put("season",inventorySeasonService.getNow()); |
||||
//用户的按钮权限
|
||||
if(!"admin".equals(user.getLoginName())){ |
||||
data.put("userBtn", btnStrArr); |
||||
} |
||||
data.put("roleType", roleType); |
||||
logger.info("===============用户登录 login 方法调用结束==============="); |
||||
return R.success(data); |
||||
}else{ |
||||
return R.fail("用户名或者密码错误"); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
@GetMapping(value = "/getUserSession") |
||||
@ApiOperation(value = "获取用户信息") |
||||
public R getSessionUser(HttpServletRequest request)throws Exception { |
||||
Map<String, Object> data = new HashMap<>(); |
||||
Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString()); |
||||
User user = userService.getUser(userId); |
||||
user.setPassword(null); |
||||
data.put("user", user); |
||||
return R.success(data); |
||||
} |
||||
|
||||
@GetMapping(value = "/logout") |
||||
@ApiOperation(value = "退出") |
||||
public R logout(HttpServletRequest request, HttpServletResponse response)throws Exception { |
||||
redisService.deleteObjectBySession(request,"userId"); |
||||
return R.success(); |
||||
} |
||||
|
||||
@PostMapping(value = "/resetPwd") |
||||
@ApiOperation(value = "重置密码") |
||||
public String resetPwd(@RequestBody JSONObject jsonObject, |
||||
HttpServletRequest request) throws Exception { |
||||
Map<String, Object> objectMap = new HashMap<>(); |
||||
Long id = jsonObject.getLong("id"); |
||||
String password = "123456"; |
||||
String md5Pwd = Tools.md5Encryp(password); |
||||
int update = userService.resetPwd(md5Pwd, id); |
||||
if(update > 0) { |
||||
return returnJson(objectMap, SUCCESS, ErpInfo.OK.code); |
||||
} else { |
||||
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code); |
||||
} |
||||
} |
||||
|
||||
@PutMapping(value = "/updatePwd") |
||||
@ApiOperation(value = "更新密码") |
||||
public String updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception { |
||||
Integer flag = 0; |
||||
Map<String, Object> objectMap = new HashMap<String, Object>(); |
||||
try { |
||||
String info = ""; |
||||
Long userId = jsonObject.getLong("userId"); |
||||
String oldpwd = jsonObject.getString("oldpassword"); |
||||
String password = jsonObject.getString("password"); |
||||
User user = userService.getUser(userId); |
||||
//必须和原始密码一致才可以更新密码
|
||||
if(demonstrateOpen && user.getLoginName().equals(TEST_USER)){ |
||||
flag = 3; //jsh用户不能修改密码
|
||||
info = "jsh用户不能修改密码"; |
||||
} else if (oldpwd.equalsIgnoreCase(user.getPassword())) { |
||||
user.setPassword(password); |
||||
flag = userService.updateUserByObj(user); //1-成功
|
||||
info = "修改成功"; |
||||
} else { |
||||
flag = 2; //原始密码输入错误
|
||||
info = "原始密码输入错误"; |
||||
} |
||||
objectMap.put("status", flag); |
||||
if(flag > 0) { |
||||
return returnJson(objectMap, info, ErpInfo.OK.code); |
||||
} else { |
||||
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code); |
||||
} |
||||
} catch (Exception e) { |
||||
logger.error(">>>>>>>>>>>>>修改用户ID为 : " + jsonObject.getLong("userId") + "密码信息失败", e); |
||||
flag = 3; |
||||
objectMap.put("status", flag); |
||||
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取全部用户数据列表 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/getAllList") |
||||
@ApiOperation(value = "获取全部用户数据列表") |
||||
public R getAllList(HttpServletRequest request)throws Exception { |
||||
|
||||
Map<String, Object> data = new HashMap<String, Object>(); |
||||
List<User> dataList = userService.getUser(); |
||||
if(dataList!=null) { |
||||
data.put("userList", dataList); |
||||
} |
||||
return R.success(data); |
||||
} |
||||
|
||||
/** |
||||
* 用户列表,用于用户下拉框 |
||||
* @param request |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@GetMapping(value = "/getUserList") |
||||
@ApiOperation(value = "用户列表") |
||||
public JSONArray getUserList(HttpServletRequest request)throws Exception { |
||||
JSONArray dataArray = new JSONArray(); |
||||
try { |
||||
List<User> dataList = userService.getUser(); |
||||
if (null != dataList) { |
||||
for (User user : dataList) { |
||||
JSONObject item = new JSONObject(); |
||||
item.put("id", user.getId()); |
||||
item.put("userName", user.getUsername()); |
||||
dataArray.add(item); |
||||
} |
||||
} |
||||
} catch(Exception e){ |
||||
e.printStackTrace(); |
||||
} |
||||
return dataArray; |
||||
} |
||||
|
||||
/** |
||||
* create by: cjl |
||||
* description: |
||||
* 新增用户及机构和用户关系 |
||||
* create time: 2019/3/8 16:06 |
||||
* @Param: beanJson |
||||
* @return java.lang.Object |
||||
*/ |
||||
@PostMapping("/addUser") |
||||
@ApiOperation(value = "新增用户") |
||||
@ResponseBody |
||||
public Object addUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{ |
||||
JSONObject result = ExceptionConstants.standardSuccess(); |
||||
// 系统的人数限制
|
||||
Object limit = redisService.getObjectFromSessionByKey(request, "userNumLimit"); |
||||
Long userNumLimit = ObjectUtil.isNotEmpty(limit) |
||||
? Long.parseLong(limit.toString()) |
||||
: systemLimit; |
||||
Long count = userService.countUser(null,null); |
||||
if(count>= userNumLimit) { |
||||
throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE, |
||||
ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG); |
||||
} else { |
||||
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class); |
||||
userService.addUserAndOrgUserRel(ue, request); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* create by: cjl |
||||
* description: |
||||
* 修改用户及机构和用户关系 |
||||
* create time: 2019/3/8 16:06 |
||||
* @Param: beanJson |
||||
* @return java.lang.Object |
||||
*/ |
||||
@PutMapping("/updateUser") |
||||
@ApiOperation(value = "修改用户") |
||||
@ResponseBody |
||||
public Object updateUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{ |
||||
JSONObject result = ExceptionConstants.standardSuccess(); |
||||
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class); |
||||
userService.updateUserAndOrgUserRel(ue, request); |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 注册用户 |
||||
* @param ue |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@PostMapping(value = "/registerUser") |
||||
@ApiOperation(value = "注册用户") |
||||
public UserEx registerUser(@RequestBody UserEx ue, |
||||
HttpServletRequest request)throws Exception{ |
||||
logger.error("用户注册开始..."); |
||||
JSONObject result = ExceptionConstants.standardSuccess(); |
||||
ue.setUsername(ue.getLoginName()); |
||||
userService.checkUserNameAndLoginName(ue); //检查用户名和登录名
|
||||
ue = userService.registerUser(ue,manageRoleId,request); |
||||
return ue; |
||||
} |
||||
|
||||
/** |
||||
* 获取机构用户树 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@RequestMapping("/getOrganizationUserTree") |
||||
@ApiOperation(value = "获取机构用户树") |
||||
public JSONArray getOrganizationUserTree()throws Exception{ |
||||
JSONArray arr=new JSONArray(); |
||||
List<TreeNodeEx> organizationUserTree= userService.getOrganizationUserTree(); |
||||
if(organizationUserTree!=null&&organizationUserTree.size()>0){ |
||||
for(TreeNodeEx node:organizationUserTree){ |
||||
String str=JSON.toJSONString(node); |
||||
JSONObject obj=JSON.parseObject(str); |
||||
arr.add(obj) ; |
||||
} |
||||
} |
||||
return arr; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前用户的角色类型 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping("/getRoleTypeByCurrentUser") |
||||
@ApiOperation(value = "获取当前用户的角色类型") |
||||
public R getRoleTypeByCurrentUser(HttpServletRequest request) { |
||||
|
||||
Map<String, Object> data = new HashMap<String, Object>(); |
||||
String roleType = redisService.getObjectFromSessionByKey(request,"roleType").toString(); |
||||
data.put("roleType", roleType); |
||||
return R.success(data); |
||||
} |
||||
|
||||
/** |
||||
* 获取随机校验码 |
||||
* @param response |
||||
* @param key |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/randomImage/{key}") |
||||
@ApiOperation(value = "获取随机校验码") |
||||
public R randomImage(HttpServletResponse response,@PathVariable String key) throws IOException { |
||||
|
||||
Map<String, Object> data = new HashMap<>(); |
||||
String codeNum = Tools.getCharAndNum(4); |
||||
String base64 = RandImageUtil.generate(codeNum); |
||||
data.put("codeNum", codeNum); |
||||
data.put("base64", base64); |
||||
return R.success(data); |
||||
} |
||||
|
||||
/** |
||||
* 批量设置状态-启用或者禁用 |
||||
* @param jsonObject |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/batchSetStatus") |
||||
@ApiOperation(value = "批量设置状态") |
||||
public String batchSetStatus(@RequestBody JSONObject jsonObject, |
||||
HttpServletRequest request)throws Exception { |
||||
Byte status = jsonObject.getByte("status"); |
||||
String ids = jsonObject.getString("ids"); |
||||
Map<String, Object> objectMap = new HashMap<>(); |
||||
int res = userService.batchSetStatus(status, ids); |
||||
if(res > 0) { |
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); |
||||
} else { |
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取当前用户的用户数量和租户信息 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@GetMapping(value = "/infoWithTenant") |
||||
@ApiOperation(value = "获取当前用户的用户数量和租户信息") |
||||
public R randomImage(HttpServletRequest request){ |
||||
|
||||
Map<String, Object> data = new HashMap<>(); |
||||
Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString()); |
||||
User user = userService.getUser(userId); |
||||
//获取当前用户数
|
||||
Long userCurrentNum = userService.countUser(null, null); |
||||
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId()); |
||||
data.put("type", tenant.getType()); //租户类型,0免费租户,1付费租户
|
||||
data.put("expireTime", Tools.parseDateToStr(tenant.getExpireTime())); |
||||
data.put("userCurrentNum", userCurrentNum); |
||||
data.put("userNumLimit", tenant.getUserNumLimit()); |
||||
return R.success(data); |
||||
} |
||||
} |
@ -1,20 +0,0 @@
|
||||
package com.zsw.erp.datasource.dto; |
||||
|
||||
import com.zsw.erp.datasource.entities.User; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
@Data |
||||
@Builder |
||||
public class UserLoginDto { |
||||
|
||||
private Integer userStatus; |
||||
|
||||
private User user; |
||||
|
||||
public static UserLoginDto buildStatus(Integer status){ |
||||
return UserLoginDto.builder().userStatus(status).build(); |
||||
} |
||||
} |
@ -1,76 +0,0 @@
|
||||
package com.zsw.erp.datasource.entities; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
||||
public class Role { |
||||
@TableId(type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
private String name; |
||||
|
||||
private String type; |
||||
|
||||
private String value; |
||||
|
||||
private String description; |
||||
|
||||
private Long tenantId; |
||||
|
||||
private String deleteFlag; |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name == null ? null : name.trim(); |
||||
} |
||||
|
||||
public String getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(String type) { |
||||
this.type = type == null ? null : type.trim(); |
||||
} |
||||
|
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public void setValue(String value) { |
||||
this.value = value == null ? null : value.trim(); |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public void setDescription(String description) { |
||||
this.description = description == null ? null : description.trim(); |
||||
} |
||||
|
||||
public Long getTenantId() { |
||||
return tenantId; |
||||
} |
||||
|
||||
public void setTenantId(Long tenantId) { |
||||
this.tenantId = tenantId; |
||||
} |
||||
|
||||
public String getDeleteFlag() { |
||||
return deleteFlag; |
||||
} |
||||
|
||||
public void setDeleteFlag(String deleteFlag) { |
||||
this.deleteFlag = deleteFlag == null ? null : deleteFlag.trim(); |
||||
} |
||||
} |
@ -1,669 +0,0 @@
|
||||
package com.zsw.erp.datasource.entities; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class RoleExample { |
||||
protected String orderByClause; |
||||
|
||||
protected boolean distinct; |
||||
|
||||
protected List<Criteria> oredCriteria; |
||||
|
||||
public RoleExample() { |
||||
oredCriteria = new ArrayList<>(); |
||||
} |
||||
|
||||
public void setOrderByClause(String orderByClause) { |
||||
this.orderByClause = orderByClause; |
||||
} |
||||
|
||||
public String getOrderByClause() { |
||||
return orderByClause; |
||||
} |
||||
|
||||
public void setDistinct(boolean distinct) { |
||||
this.distinct = distinct; |
||||
} |
||||
|
||||
public boolean isDistinct() { |
||||
return distinct; |
||||
} |
||||
|
||||
public List<Criteria> getOredCriteria() { |
||||
return oredCriteria; |
||||
} |
||||
|
||||
public void or(Criteria criteria) { |
||||
oredCriteria.add(criteria); |
||||
} |
||||
|
||||
public Criteria or() { |
||||
Criteria criteria = createCriteriaInternal(); |
||||
oredCriteria.add(criteria); |
||||
return criteria; |
||||
} |
||||
|
||||
public Criteria createCriteria() { |
||||
Criteria criteria = createCriteriaInternal(); |
||||
if (oredCriteria.size() == 0) { |
||||
oredCriteria.add(criteria); |
||||
} |
||||
return criteria; |
||||
} |
||||
|
||||
protected Criteria createCriteriaInternal() { |
||||
Criteria criteria = new Criteria(); |
||||
return criteria; |
||||
} |
||||
|
||||
public void clear() { |
||||
oredCriteria.clear(); |
||||
orderByClause = null; |
||||
distinct = false; |
||||
} |
||||
|
||||
protected abstract static class GeneratedCriteria { |
||||
protected List<Criterion> criteria; |
||||
|
||||
protected GeneratedCriteria() { |
||||
super(); |
||||
criteria = new ArrayList<>(); |
||||
} |
||||
|
||||
public boolean isValid() { |
||||
return criteria.size() > 0; |
||||
} |
||||
|
||||
public List<Criterion> getAllCriteria() { |
||||
return criteria; |
||||
} |
||||
|
||||
public List<Criterion> getCriteria() { |
||||
return criteria; |
||||
} |
||||
|
||||
protected void addCriterion(String condition) { |
||||
if (condition == null) { |
||||
throw new RuntimeException("Value for condition cannot be null"); |
||||
} |
||||
criteria.add(new Criterion(condition)); |
||||
} |
||||
|
||||
protected void addCriterion(String condition, Object value, String property) { |
||||
if (value == null) { |
||||
throw new RuntimeException("Value for " + property + " cannot be null"); |
||||
} |
||||
criteria.add(new Criterion(condition, value)); |
||||
} |
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) { |
||||
if (value1 == null || value2 == null) { |
||||
throw new RuntimeException("Between values for " + property + " cannot be null"); |
||||
} |
||||
criteria.add(new Criterion(condition, value1, value2)); |
||||
} |
||||
|
||||
public Criteria andIdIsNull() { |
||||
addCriterion("id is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdIsNotNull() { |
||||
addCriterion("id is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdEqualTo(Long value) { |
||||
addCriterion("id =", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdNotEqualTo(Long value) { |
||||
addCriterion("id <>", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdGreaterThan(Long value) { |
||||
addCriterion("id >", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Long value) { |
||||
addCriterion("id >=", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdLessThan(Long value) { |
||||
addCriterion("id <", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Long value) { |
||||
addCriterion("id <=", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdIn(List<Long> values) { |
||||
addCriterion("id in", values, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdNotIn(List<Long> values) { |
||||
addCriterion("id not in", values, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdBetween(Long value1, Long value2) { |
||||
addCriterion("id between", value1, value2, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdNotBetween(Long value1, Long value2) { |
||||
addCriterion("id not between", value1, value2, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameIsNull() { |
||||
addCriterion("name is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameIsNotNull() { |
||||
addCriterion("name is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameEqualTo(String value) { |
||||
addCriterion("name =", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameNotEqualTo(String value) { |
||||
addCriterion("name <>", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameGreaterThan(String value) { |
||||
addCriterion("name >", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) { |
||||
addCriterion("name >=", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameLessThan(String value) { |
||||
addCriterion("name <", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) { |
||||
addCriterion("name <=", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameLike(String value) { |
||||
addCriterion("name like", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameNotLike(String value) { |
||||
addCriterion("name not like", value, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameIn(List<String> values) { |
||||
addCriterion("name in", values, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameNotIn(List<String> values) { |
||||
addCriterion("name not in", values, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameBetween(String value1, String value2) { |
||||
addCriterion("name between", value1, value2, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) { |
||||
addCriterion("name not between", value1, value2, "name"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeIsNull() { |
||||
addCriterion("type is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeIsNotNull() { |
||||
addCriterion("type is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeEqualTo(String value) { |
||||
addCriterion("type =", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotEqualTo(String value) { |
||||
addCriterion("type <>", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeGreaterThan(String value) { |
||||
addCriterion("type >", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeGreaterThanOrEqualTo(String value) { |
||||
addCriterion("type >=", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeLessThan(String value) { |
||||
addCriterion("type <", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeLessThanOrEqualTo(String value) { |
||||
addCriterion("type <=", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeLike(String value) { |
||||
addCriterion("type like", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotLike(String value) { |
||||
addCriterion("type not like", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeIn(List<String> values) { |
||||
addCriterion("type in", values, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotIn(List<String> values) { |
||||
addCriterion("type not in", values, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeBetween(String value1, String value2) { |
||||
addCriterion("type between", value1, value2, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotBetween(String value1, String value2) { |
||||
addCriterion("type not between", value1, value2, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueIsNull() { |
||||
addCriterion("value is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueIsNotNull() { |
||||
addCriterion("value is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueEqualTo(String value) { |
||||
addCriterion("value =", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotEqualTo(String value) { |
||||
addCriterion("value <>", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueGreaterThan(String value) { |
||||
addCriterion("value >", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueGreaterThanOrEqualTo(String value) { |
||||
addCriterion("value >=", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueLessThan(String value) { |
||||
addCriterion("value <", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueLessThanOrEqualTo(String value) { |
||||
addCriterion("value <=", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueLike(String value) { |
||||
addCriterion("value like", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotLike(String value) { |
||||
addCriterion("value not like", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueIn(List<String> values) { |
||||
addCriterion("value in", values, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotIn(List<String> values) { |
||||
addCriterion("value not in", values, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueBetween(String value1, String value2) { |
||||
addCriterion("value between", value1, value2, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotBetween(String value1, String value2) { |
||||
addCriterion("value not between", value1, value2, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionIsNull() { |
||||
addCriterion("description is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionIsNotNull() { |
||||
addCriterion("description is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionEqualTo(String value) { |
||||
addCriterion("description =", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionNotEqualTo(String value) { |
||||
addCriterion("description <>", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionGreaterThan(String value) { |
||||
addCriterion("description >", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionGreaterThanOrEqualTo(String value) { |
||||
addCriterion("description >=", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionLessThan(String value) { |
||||
addCriterion("description <", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionLessThanOrEqualTo(String value) { |
||||
addCriterion("description <=", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionLike(String value) { |
||||
addCriterion("description like", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionNotLike(String value) { |
||||
addCriterion("description not like", value, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionIn(List<String> values) { |
||||
addCriterion("description in", values, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionNotIn(List<String> values) { |
||||
addCriterion("description not in", values, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionBetween(String value1, String value2) { |
||||
addCriterion("description between", value1, value2, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDescriptionNotBetween(String value1, String value2) { |
||||
addCriterion("description not between", value1, value2, "description"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdIsNull() { |
||||
addCriterion("tenant_id is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdIsNotNull() { |
||||
addCriterion("tenant_id is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdEqualTo(Long value) { |
||||
addCriterion("tenant_id =", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdNotEqualTo(Long value) { |
||||
addCriterion("tenant_id <>", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdGreaterThan(Long value) { |
||||
addCriterion("tenant_id >", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdGreaterThanOrEqualTo(Long value) { |
||||
addCriterion("tenant_id >=", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdLessThan(Long value) { |
||||
addCriterion("tenant_id <", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdLessThanOrEqualTo(Long value) { |
||||
addCriterion("tenant_id <=", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdIn(List<Long> values) { |
||||
addCriterion("tenant_id in", values, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdNotIn(List<Long> values) { |
||||
addCriterion("tenant_id not in", values, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdBetween(Long value1, Long value2) { |
||||
addCriterion("tenant_id between", value1, value2, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdNotBetween(Long value1, Long value2) { |
||||
addCriterion("tenant_id not between", value1, value2, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagIsNull() { |
||||
addCriterion("delete_flag is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagIsNotNull() { |
||||
addCriterion("delete_flag is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagEqualTo(String value) { |
||||
addCriterion("delete_flag =", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotEqualTo(String value) { |
||||
addCriterion("delete_flag <>", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagGreaterThan(String value) { |
||||
addCriterion("delete_flag >", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagGreaterThanOrEqualTo(String value) { |
||||
addCriterion("delete_flag >=", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagLessThan(String value) { |
||||
addCriterion("delete_flag <", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagLessThanOrEqualTo(String value) { |
||||
addCriterion("delete_flag <=", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagLike(String value) { |
||||
addCriterion("delete_flag like", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotLike(String value) { |
||||
addCriterion("delete_flag not like", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagIn(List<String> values) { |
||||
addCriterion("delete_flag in", values, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotIn(List<String> values) { |
||||
addCriterion("delete_flag not in", values, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagBetween(String value1, String value2) { |
||||
addCriterion("delete_flag between", value1, value2, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotBetween(String value1, String value2) { |
||||
addCriterion("delete_flag not between", value1, value2, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
} |
||||
|
||||
public static class Criteria extends GeneratedCriteria { |
||||
protected Criteria() { |
||||
super(); |
||||
} |
||||
} |
||||
|
||||
public static class Criterion { |
||||
private String condition; |
||||
|
||||
private Object value; |
||||
|
||||
private Object secondValue; |
||||
|
||||
private boolean noValue; |
||||
|
||||
private boolean singleValue; |
||||
|
||||
private boolean betweenValue; |
||||
|
||||
private boolean listValue; |
||||
|
||||
private String typeHandler; |
||||
|
||||
public String getCondition() { |
||||
return condition; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public Object getSecondValue() { |
||||
return secondValue; |
||||
} |
||||
|
||||
public boolean isNoValue() { |
||||
return noValue; |
||||
} |
||||
|
||||
public boolean isSingleValue() { |
||||
return singleValue; |
||||
} |
||||
|
||||
public boolean isBetweenValue() { |
||||
return betweenValue; |
||||
} |
||||
|
||||
public boolean isListValue() { |
||||
return listValue; |
||||
} |
||||
|
||||
public String getTypeHandler() { |
||||
return typeHandler; |
||||
} |
||||
|
||||
protected Criterion(String condition) { |
||||
super(); |
||||
this.condition = condition; |
||||
this.typeHandler = null; |
||||
this.noValue = true; |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) { |
||||
super(); |
||||
this.condition = condition; |
||||
this.value = value; |
||||
this.typeHandler = typeHandler; |
||||
if (value instanceof List<?>) { |
||||
this.listValue = true; |
||||
} else { |
||||
this.singleValue = true; |
||||
} |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value) { |
||||
this(condition, value, null); |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { |
||||
super(); |
||||
this.condition = condition; |
||||
this.value = value; |
||||
this.secondValue = secondValue; |
||||
this.typeHandler = typeHandler; |
||||
this.betweenValue = true; |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) { |
||||
this(condition, value, secondValue, null); |
||||
} |
||||
} |
||||
} |
@ -1,38 +0,0 @@
|
||||
package com.zsw.erp.datasource.entities; |
||||
|
||||
import lombok.Data; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
||||
@Data |
||||
public class User { |
||||
@TableId(type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
private String username; |
||||
|
||||
private String loginName; |
||||
|
||||
private String password; |
||||
|
||||
private String position; |
||||
|
||||
private String department; |
||||
|
||||
private String email; |
||||
|
||||
private String phonenum; |
||||
|
||||
private Byte ismanager; |
||||
|
||||
private Byte isystem; |
||||
|
||||
private Byte status; |
||||
|
||||
private String description; |
||||
|
||||
private String remark; |
||||
|
||||
private Long tenantId; |
||||
|
||||
} |
@ -1,33 +0,0 @@
|
||||
package com.zsw.erp.datasource.entities; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; |
||||
import com.zsw.erp.config.ArrayListTypeHandler; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
@TableName(autoResultMap = true) |
||||
public class UserBusiness implements Serializable { |
||||
@TableId(type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
private String type; |
||||
|
||||
private String keyId; |
||||
|
||||
@TableField(value = "`value`",typeHandler = JacksonTypeHandler.class) |
||||
private List<Number> value; |
||||
|
||||
@TableField(value = "`btn_str`",typeHandler = ArrayListTypeHandler.class) |
||||
private List<BtnDto> btnStr; |
||||
|
||||
private Long tenantId; |
||||
|
||||
private String deleteFlag; |
||||
|
||||
} |
@ -1,669 +0,0 @@
|
||||
package com.zsw.erp.datasource.entities; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class UserBusinessExample { |
||||
protected String orderByClause; |
||||
|
||||
protected boolean distinct; |
||||
|
||||
protected List<Criteria> oredCriteria; |
||||
|
||||
public UserBusinessExample() { |
||||
oredCriteria = new ArrayList<>(); |
||||
} |
||||
|
||||
public void setOrderByClause(String orderByClause) { |
||||
this.orderByClause = orderByClause; |
||||
} |
||||
|
||||
public String getOrderByClause() { |
||||
return orderByClause; |
||||
} |
||||
|
||||
public void setDistinct(boolean distinct) { |
||||
this.distinct = distinct; |
||||
} |
||||
|
||||
public boolean isDistinct() { |
||||
return distinct; |
||||
} |
||||
|
||||
public List<Criteria> getOredCriteria() { |
||||
return oredCriteria; |
||||
} |
||||
|
||||
public void or(Criteria criteria) { |
||||
oredCriteria.add(criteria); |
||||
} |
||||
|
||||
public Criteria or() { |
||||
Criteria criteria = createCriteriaInternal(); |
||||
oredCriteria.add(criteria); |
||||
return criteria; |
||||
} |
||||
|
||||
public Criteria createCriteria() { |
||||
Criteria criteria = createCriteriaInternal(); |
||||
if (oredCriteria.size() == 0) { |
||||
oredCriteria.add(criteria); |
||||
} |
||||
return criteria; |
||||
} |
||||
|
||||
protected Criteria createCriteriaInternal() { |
||||
Criteria criteria = new Criteria(); |
||||
return criteria; |
||||
} |
||||
|
||||
public void clear() { |
||||
oredCriteria.clear(); |
||||
orderByClause = null; |
||||
distinct = false; |
||||
} |
||||
|
||||
protected abstract static class GeneratedCriteria { |
||||
protected List<Criterion> criteria; |
||||
|
||||
protected GeneratedCriteria() { |
||||
super(); |
||||
criteria = new ArrayList<>(); |
||||
} |
||||
|
||||
public boolean isValid() { |
||||
return criteria.size() > 0; |
||||
} |
||||
|
||||
public List<Criterion> getAllCriteria() { |
||||
return criteria; |
||||
} |
||||
|
||||
public List<Criterion> getCriteria() { |
||||
return criteria; |
||||
} |
||||
|
||||
protected void addCriterion(String condition) { |
||||
if (condition == null) { |
||||
throw new RuntimeException("Value for condition cannot be null"); |
||||
} |
||||
criteria.add(new Criterion(condition)); |
||||
} |
||||
|
||||
protected void addCriterion(String condition, Object value, String property) { |
||||
if (value == null) { |
||||
throw new RuntimeException("Value for " + property + " cannot be null"); |
||||
} |
||||
criteria.add(new Criterion(condition, value)); |
||||
} |
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) { |
||||
if (value1 == null || value2 == null) { |
||||
throw new RuntimeException("Between values for " + property + " cannot be null"); |
||||
} |
||||
criteria.add(new Criterion(condition, value1, value2)); |
||||
} |
||||
|
||||
public Criteria andIdIsNull() { |
||||
addCriterion("id is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdIsNotNull() { |
||||
addCriterion("id is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdEqualTo(Long value) { |
||||
addCriterion("id =", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdNotEqualTo(Long value) { |
||||
addCriterion("id <>", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdGreaterThan(Long value) { |
||||
addCriterion("id >", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Long value) { |
||||
addCriterion("id >=", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdLessThan(Long value) { |
||||
addCriterion("id <", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Long value) { |
||||
addCriterion("id <=", value, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdIn(List<Long> values) { |
||||
addCriterion("id in", values, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdNotIn(List<Long> values) { |
||||
addCriterion("id not in", values, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdBetween(Long value1, Long value2) { |
||||
addCriterion("id between", value1, value2, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andIdNotBetween(Long value1, Long value2) { |
||||
addCriterion("id not between", value1, value2, "id"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeIsNull() { |
||||
addCriterion("type is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeIsNotNull() { |
||||
addCriterion("type is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeEqualTo(String value) { |
||||
addCriterion("type =", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotEqualTo(String value) { |
||||
addCriterion("type <>", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeGreaterThan(String value) { |
||||
addCriterion("type >", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeGreaterThanOrEqualTo(String value) { |
||||
addCriterion("type >=", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeLessThan(String value) { |
||||
addCriterion("type <", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeLessThanOrEqualTo(String value) { |
||||
addCriterion("type <=", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeLike(String value) { |
||||
addCriterion("type like", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotLike(String value) { |
||||
addCriterion("type not like", value, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeIn(List<String> values) { |
||||
addCriterion("type in", values, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotIn(List<String> values) { |
||||
addCriterion("type not in", values, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeBetween(String value1, String value2) { |
||||
addCriterion("type between", value1, value2, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTypeNotBetween(String value1, String value2) { |
||||
addCriterion("type not between", value1, value2, "type"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdIsNull() { |
||||
addCriterion("key_id is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdIsNotNull() { |
||||
addCriterion("key_id is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdEqualTo(String value) { |
||||
addCriterion("key_id =", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdNotEqualTo(String value) { |
||||
addCriterion("key_id <>", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdGreaterThan(String value) { |
||||
addCriterion("key_id >", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdGreaterThanOrEqualTo(String value) { |
||||
addCriterion("key_id >=", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdLessThan(String value) { |
||||
addCriterion("key_id <", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdLessThanOrEqualTo(String value) { |
||||
addCriterion("key_id <=", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdLike(String value) { |
||||
addCriterion("key_id like", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdNotLike(String value) { |
||||
addCriterion("key_id not like", value, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdIn(List<String> values) { |
||||
addCriterion("key_id in", values, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdNotIn(List<String> values) { |
||||
addCriterion("key_id not in", values, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdBetween(String value1, String value2) { |
||||
addCriterion("key_id between", value1, value2, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andKeyIdNotBetween(String value1, String value2) { |
||||
addCriterion("key_id not between", value1, value2, "keyId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueIsNull() { |
||||
addCriterion("value is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueIsNotNull() { |
||||
addCriterion("value is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueEqualTo(String value) { |
||||
addCriterion("value =", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotEqualTo(String value) { |
||||
addCriterion("value <>", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueGreaterThan(String value) { |
||||
addCriterion("value >", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueGreaterThanOrEqualTo(String value) { |
||||
addCriterion("value >=", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueLessThan(String value) { |
||||
addCriterion("value <", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueLessThanOrEqualTo(String value) { |
||||
addCriterion("value <=", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueLike(String value) { |
||||
addCriterion("value like", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotLike(String value) { |
||||
addCriterion("value not like", value, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueIn(List<String> values) { |
||||
addCriterion("value in", values, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotIn(List<String> values) { |
||||
addCriterion("value not in", values, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueBetween(String value1, String value2) { |
||||
addCriterion("value between", value1, value2, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andValueNotBetween(String value1, String value2) { |
||||
addCriterion("value not between", value1, value2, "value"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrIsNull() { |
||||
addCriterion("btn_str is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrIsNotNull() { |
||||
addCriterion("btn_str is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrEqualTo(String value) { |
||||
addCriterion("btn_str =", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrNotEqualTo(String value) { |
||||
addCriterion("btn_str <>", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrGreaterThan(String value) { |
||||
addCriterion("btn_str >", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrGreaterThanOrEqualTo(String value) { |
||||
addCriterion("btn_str >=", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrLessThan(String value) { |
||||
addCriterion("btn_str <", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrLessThanOrEqualTo(String value) { |
||||
addCriterion("btn_str <=", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrLike(String value) { |
||||
addCriterion("btn_str like", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrNotLike(String value) { |
||||
addCriterion("btn_str not like", value, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrIn(List<String> values) { |
||||
addCriterion("btn_str in", values, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrNotIn(List<String> values) { |
||||
addCriterion("btn_str not in", values, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrBetween(String value1, String value2) { |
||||
addCriterion("btn_str between", value1, value2, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andBtnStrNotBetween(String value1, String value2) { |
||||
addCriterion("btn_str not between", value1, value2, "btnStr"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdIsNull() { |
||||
addCriterion("tenant_id is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdIsNotNull() { |
||||
addCriterion("tenant_id is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdEqualTo(Long value) { |
||||
addCriterion("tenant_id =", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdNotEqualTo(Long value) { |
||||
addCriterion("tenant_id <>", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdGreaterThan(Long value) { |
||||
addCriterion("tenant_id >", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdGreaterThanOrEqualTo(Long value) { |
||||
addCriterion("tenant_id >=", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdLessThan(Long value) { |
||||
addCriterion("tenant_id <", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdLessThanOrEqualTo(Long value) { |
||||
addCriterion("tenant_id <=", value, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdIn(List<Long> values) { |
||||
addCriterion("tenant_id in", values, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdNotIn(List<Long> values) { |
||||
addCriterion("tenant_id not in", values, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdBetween(Long value1, Long value2) { |
||||
addCriterion("tenant_id between", value1, value2, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andTenantIdNotBetween(Long value1, Long value2) { |
||||
addCriterion("tenant_id not between", value1, value2, "tenantId"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagIsNull() { |
||||
addCriterion("delete_flag is null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagIsNotNull() { |
||||
addCriterion("delete_flag is not null"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagEqualTo(String value) { |
||||
addCriterion("delete_flag =", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotEqualTo(String value) { |
||||
addCriterion("delete_flag <>", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagGreaterThan(String value) { |
||||
addCriterion("delete_flag >", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagGreaterThanOrEqualTo(String value) { |
||||
addCriterion("delete_flag >=", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagLessThan(String value) { |
||||
addCriterion("delete_flag <", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagLessThanOrEqualTo(String value) { |
||||
addCriterion("delete_flag <=", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagLike(String value) { |
||||
addCriterion("delete_flag like", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotLike(String value) { |
||||
addCriterion("delete_flag not like", value, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagIn(List<String> values) { |
||||
addCriterion("delete_flag in", values, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotIn(List<String> values) { |
||||
addCriterion("delete_flag not in", values, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagBetween(String value1, String value2) { |
||||
addCriterion("delete_flag between", value1, value2, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
|
||||
public Criteria andDeleteFlagNotBetween(String value1, String value2) { |
||||
addCriterion("delete_flag not between", value1, value2, "deleteFlag"); |
||||
return (Criteria) this; |
||||
} |
||||
} |
||||
|
||||
public static class Criteria extends GeneratedCriteria { |
||||
protected Criteria() { |
||||
super(); |
||||
} |
||||
} |
||||
|
||||
public static class Criterion { |
||||
private String condition; |
||||
|
||||
private Object value; |
||||
|
||||
private Object secondValue; |
||||
|
||||
private boolean noValue; |
||||
|
||||
private boolean singleValue; |
||||
|
||||
private boolean betweenValue; |
||||
|
||||
private boolean listValue; |
||||
|
||||
private String typeHandler; |
||||
|
||||
public String getCondition() { |
||||
return condition; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public Object getSecondValue() { |
||||
return secondValue; |
||||
} |
||||
|
||||
public boolean isNoValue() { |
||||
return noValue; |
||||
} |
||||
|
||||
public boolean isSingleValue() { |
||||
return singleValue; |
||||
} |
||||
|
||||
public boolean isBetweenValue() { |
||||
return betweenValue; |
||||
} |
||||
|
||||
public boolean isListValue() { |
||||
return listValue; |
||||
} |
||||
|
||||
public String getTypeHandler() { |
||||
return typeHandler; |
||||
} |
||||
|
||||
protected Criterion(String condition) { |
||||
super(); |
||||
this.condition = condition; |
||||
this.typeHandler = null; |
||||
this.noValue = true; |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) { |
||||
super(); |
||||
this.condition = condition; |
||||
this.value = value; |
||||
this.typeHandler = typeHandler; |
||||
if (value instanceof List<?>) { |
||||
this.listValue = true; |
||||
} else { |
||||
this.singleValue = true; |
||||
} |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value) { |
||||
this(condition, value, null); |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { |
||||
super(); |
||||
this.condition = condition; |
||||
this.value = value; |
||||
this.secondValue = secondValue; |
||||
this.typeHandler = typeHandler; |
||||
this.betweenValue = true; |
||||
} |
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) { |
||||
this(condition, value, secondValue, null); |
||||
} |
||||
} |
||||
} |
@ -1,36 +0,0 @@
|
||||
package com.zsw.erp.datasource.entities; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* Description |
||||
* |
||||
* @Author: cjl |
||||
* @Date: 2019/3/8 15:12 |
||||
*/ |
||||
@Data |
||||
public class UserEx extends User{ |
||||
//机构简称
|
||||
private String orgAbr; |
||||
//机构id
|
||||
private Long orgaId; |
||||
//用户在部门中排序
|
||||
private String userBlngOrgaDsplSeq; |
||||
//机构用户关联关系id
|
||||
private Long orgaUserRelId; |
||||
|
||||
private Long roleId; |
||||
|
||||
private String roleName; |
||||
|
||||
private String userType; |
||||
|
||||
private Integer userNumLimit; |
||||
|
||||
private String expireTime; |
||||
|
||||
@TableField(exist = false) |
||||
private Long storeId; |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
||||
import com.zsw.erp.datasource.entities.Role; |
||||
import com.zsw.erp.datasource.entities.RoleExample; |
||||
import java.util.List; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
public interface RoleMapper { |
||||
long countByExample(RoleExample example); |
||||
|
||||
int deleteByExample(RoleExample example); |
||||
|
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
int insert(Role record); |
||||
|
||||
int insertSelective(Role record); |
||||
|
||||
List<Role> selectByExample(RoleExample example); |
||||
|
||||
@InterceptorIgnore |
||||
Role selectByPrimaryKey(Long id); |
||||
|
||||
int updateByExampleSelective(@Param("record") Role record, @Param("example") RoleExample example); |
||||
|
||||
int updateByExample(@Param("record") Role record, @Param("example") RoleExample example); |
||||
|
||||
int updateByPrimaryKeySelective(Role record); |
||||
|
||||
int updateByPrimaryKey(Role record); |
||||
} |
@ -1,20 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import com.zsw.erp.datasource.entities.Role; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
public interface RoleMapperEx { |
||||
|
||||
List<Role> selectByConditionRole( |
||||
@Param("name") String name, |
||||
@Param("offset") Integer offset, |
||||
@Param("rows") Integer rows); |
||||
|
||||
Long countsByRole( |
||||
@Param("name") String name); |
||||
|
||||
int batchDeleteRoleByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]); |
||||
} |
@ -1,32 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.zsw.erp.datasource.entities.Tenant; |
||||
import com.zsw.erp.datasource.entities.TenantExample; |
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
@Repository |
||||
public interface TenantMapper extends BaseMapper<Tenant> { |
||||
long countByExample(TenantExample example); |
||||
|
||||
int deleteByExample(TenantExample example); |
||||
|
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
List<Tenant> selectByExample(TenantExample example); |
||||
|
||||
@InterceptorIgnore(tenantLine = "true") |
||||
Tenant selectByPrimaryKey(Long id); |
||||
|
||||
int updateByExampleSelective(@Param("record") Tenant record, @Param("example") TenantExample example); |
||||
|
||||
int updateByExample(@Param("record") Tenant record, @Param("example") TenantExample example); |
||||
|
||||
int updateByPrimaryKeySelective(Tenant record); |
||||
|
||||
int updateByPrimaryKey(Tenant record); |
||||
} |
@ -1,21 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import com.zsw.erp.datasource.entities.TenantEx; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface TenantMapperEx { |
||||
|
||||
List<TenantEx> selectByConditionTenant( |
||||
@Param("loginName") String loginName, |
||||
@Param("type") String type, |
||||
@Param("enabled") String enabled, |
||||
@Param("offset") Integer offset, |
||||
@Param("rows") Integer rows); |
||||
|
||||
Long countsByTenant( |
||||
@Param("loginName") String loginName, |
||||
@Param("type") String type, |
||||
@Param("enabled") String enabled); |
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.zsw.erp.datasource.entities.UserBusiness; |
||||
import com.zsw.erp.datasource.entities.UserBusinessExample; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
@Repository |
||||
public interface UserBusinessMapper extends BaseMapper<UserBusiness> { |
||||
|
||||
} |
@ -1,17 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* Description |
||||
* |
||||
* @Author: qiankunpingtai |
||||
* @Date: 2019/3/29 15:09 |
||||
*/ |
||||
public interface UserBusinessMapperEx { |
||||
|
||||
int batchDeleteUserBusinessByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]); |
||||
|
||||
} |
@ -1,30 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.zsw.erp.datasource.entities.User; |
||||
import com.zsw.erp.datasource.entities.UserExample; |
||||
import java.util.List; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
@Repository |
||||
public interface UserMapper extends BaseMapper<User> { |
||||
long countByExample(UserExample example); |
||||
|
||||
int deleteByExample(UserExample example); |
||||
|
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
List<User> selectByExample(UserExample example); |
||||
|
||||
User selectByPrimaryKey(Long id); |
||||
|
||||
int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example); |
||||
|
||||
int updateByExample(@Param("record") User record, @Param("example") UserExample example); |
||||
|
||||
int updateByPrimaryKeySelective(User record); |
||||
|
||||
int updateByPrimaryKey(User record); |
||||
} |
@ -1,30 +0,0 @@
|
||||
package com.zsw.erp.datasource.mappers; |
||||
|
||||
import com.zsw.erp.datasource.entities.User; |
||||
import com.zsw.erp.datasource.entities.UserEx; |
||||
import com.zsw.erp.datasource.vo.TreeNodeEx; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface UserMapperEx { |
||||
|
||||
List<UserEx> selectByConditionUser( |
||||
@Param("userName") String userName, |
||||
@Param("loginName") String loginName, |
||||
@Param("offset") Integer offset, |
||||
@Param("rows") Integer rows); |
||||
|
||||
Long countsByUser( |
||||
@Param("userName") String userName, |
||||
@Param("loginName") String loginName); |
||||
|
||||
List<User> getUserListByUserNameOrLoginName(@Param("userName") String userName, |
||||
@Param("loginName") String loginName); |
||||
|
||||
int batDeleteOrUpdateUser(@Param("ids") String ids[], @Param("status") byte status); |
||||
|
||||
List<TreeNodeEx> getNodeTree(); |
||||
List<TreeNodeEx> getNextNodeTree(Map<String, Object> parameterMap); |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.zsw.erp.dto.bom; |
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.CpUser.vo.CpUserRespVO; |
||||
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO; |
||||
import com.zsw.erp.datasource.dto.BomDto; |
||||
import com.zsw.erp.datasource.entities.Bom; |
||||
import org.mapstruct.Mapper; |
||||
import org.mapstruct.factory.Mappers; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface BomConvert { |
||||
|
||||
BomConvert INSTANCE = Mappers.getMapper(BomConvert.class); |
||||
|
||||
List<BomDto> convertList2Dto(List<Bom> list); |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.zsw.erp.dto.depot; |
||||
|
||||
import com.zsw.erp.datasource.dto.DepotItemDto; |
||||
import com.zsw.erp.datasource.entities.DepotItem; |
||||
import com.zsw.erp.dto.bom.BomConvert; |
||||
import org.mapstruct.Mapper; |
||||
import org.mapstruct.factory.Mappers; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface DepotConvert { |
||||
|
||||
DepotConvert INSTANCE = Mappers.getMapper(DepotConvert.class); |
||||
|
||||
List<DepotItemDto> convertList(List<DepotItem> list); |
||||
|
||||
} |
@ -1,75 +0,0 @@
|
||||
package com.zsw.erp.service.account; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.service.ICommonQuery; |
||||
import com.zsw.erp.utils.Constants; |
||||
import com.zsw.erp.utils.QueryUtils; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service(value = "account_component") |
||||
@AccountResource |
||||
public class AccountComponent implements ICommonQuery { |
||||
|
||||
@Resource |
||||
private AccountService accountService; |
||||
|
||||
@Override |
||||
public Object selectOne(Long id) throws Exception { |
||||
return accountService.getAccount(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<?> select(Map<String, String> map)throws Exception { |
||||
return getAccountList(map); |
||||
} |
||||
|
||||
private List<?> getAccountList(Map<String, String> map) throws Exception{ |
||||
String search = map.get(Constants.SEARCH); |
||||
String name = StringUtil.getInfo(search, "name"); |
||||
String serialNo = StringUtil.getInfo(search, "serialNo"); |
||||
String remark = StringUtil.getInfo(search, "remark"); |
||||
String order = QueryUtils.order(map); |
||||
return accountService.select(name, serialNo, remark, QueryUtils.offset(map), QueryUtils.rows(map)); |
||||
} |
||||
|
||||
@Override |
||||
public Long counts(Map<String, String> map) throws Exception{ |
||||
String search = map.get(Constants.SEARCH); |
||||
String name = StringUtil.getInfo(search, "name"); |
||||
String serialNo = StringUtil.getInfo(search, "serialNo"); |
||||
String remark = StringUtil.getInfo(search, "remark"); |
||||
return accountService.countAccount(name, serialNo, remark); |
||||
} |
||||
|
||||
@Override |
||||
public int insert(JSONObject obj, HttpServletRequest request) throws Exception{ |
||||
return accountService.insertAccount(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return accountService.updateAccount(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int delete(Long id, HttpServletRequest request)throws Exception { |
||||
return accountService.deleteAccount(id, request); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception { |
||||
return accountService.batchDeleteAccount(ids, request); |
||||
} |
||||
|
||||
@Override |
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
return accountService.checkIsNameExist(id, name); |
||||
} |
||||
|
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.zsw.erp.service.account; |
||||
|
||||
import com.zsw.erp.service.ResourceInfo; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
|
||||
@ResourceInfo(value = "account") |
||||
@Inherited |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface AccountResource { |
||||
} |
@ -1,575 +0,0 @@
|
||||
package com.zsw.erp.service.account; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.constants.BusinessConstants; |
||||
import com.zsw.erp.constants.ExceptionConstants; |
||||
import com.zsw.erp.datasource.vo.AccountVo4InOutList; |
||||
import com.zsw.erp.datasource.vo.AccountVo4List; |
||||
import com.zsw.erp.exception.BusinessRunTimeException; |
||||
import com.zsw.erp.exception.BoomException; |
||||
import com.zsw.erp.service.log.LogService; |
||||
import com.zsw.erp.service.user.UserService; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import com.zsw.erp.utils.Tools; |
||||
import com.zsw.erp.datasource.entities.*; |
||||
import com.zsw.erp.datasource.mappers.*; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.dao.DataAccessException; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.text.DecimalFormat; |
||||
import java.util.*; |
||||
|
||||
@Service |
||||
public class AccountService { |
||||
private Logger logger = LoggerFactory.getLogger(AccountService.class); |
||||
|
||||
@Resource |
||||
private AccountMapper accountMapper; |
||||
|
||||
@Resource |
||||
private AccountMapperEx accountMapperEx; |
||||
|
||||
@Resource |
||||
private DepotHeadMapper depotHeadMapper; |
||||
@Resource |
||||
private DepotHeadMapperEx depotHeadMapperEx; |
||||
|
||||
@Resource |
||||
private AccountHeadMapper accountHeadMapper; |
||||
@Resource |
||||
private AccountHeadMapperEx accountHeadMapperEx; |
||||
|
||||
@Resource |
||||
private AccountItemMapper accountItemMapper; |
||||
@Resource |
||||
private AccountItemMapperEx accountItemMapperEx; |
||||
@Resource |
||||
private LogService logService; |
||||
@Resource |
||||
private UserService userService; |
||||
|
||||
public Account getAccount(long id) throws Exception{ |
||||
return accountMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
public List<Account> getAccountListByIds(String ids)throws Exception { |
||||
List<Long> idList = StringUtil.strToLongList(ids); |
||||
List<Account> list = new ArrayList<>(); |
||||
try{ |
||||
AccountExample example = new AccountExample(); |
||||
example.createCriteria().andIdIn(idList); |
||||
list = accountMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Account> getAccount() throws Exception{ |
||||
AccountExample example = new AccountExample(); |
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<Account> list=null; |
||||
try{ |
||||
list=accountMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Account> getAccountByParam(String name, String serialNo) { |
||||
List<Account> list=null; |
||||
try{ |
||||
list=accountMapperEx.getAccountByParam(name, serialNo); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) throws Exception{ |
||||
List<AccountVo4List> resList = new ArrayList<AccountVo4List>(); |
||||
List<AccountVo4List> list=null; |
||||
try{ |
||||
list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
String timeStr = Tools.getCurrentMonth(); |
||||
if (null != list && null !=timeStr) { |
||||
for (AccountVo4List al : list) { |
||||
DecimalFormat df = new DecimalFormat(".##"); |
||||
BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month").add(getAccountSumByHead(al.getId(), timeStr, "month")).add(getAccountSumByDetail(al.getId(), timeStr, "month")).add(getManyAccountSum(al.getId(), timeStr, "month")); |
||||
String thisMonthAmountFmt = "0"; |
||||
if ((thisMonthAmount.compareTo(BigDecimal.ZERO))!=0) { |
||||
thisMonthAmountFmt = df.format(thisMonthAmount); |
||||
} |
||||
al.setThisMonthAmount(thisMonthAmountFmt); //本月发生额
|
||||
BigDecimal currentAmount = getAccountSum(al.getId(), "", "month").add(getAccountSumByHead(al.getId(), "", "month")).add(getAccountSumByDetail(al.getId(), "", "month")).add(getManyAccountSum(al.getId(), "", "month")) .add(al.getInitialAmount()) ; |
||||
al.setCurrentAmount(currentAmount); |
||||
resList.add(al); |
||||
} |
||||
} |
||||
return resList; |
||||
} |
||||
|
||||
public Long countAccount(String name, String serialNo, String remark)throws Exception { |
||||
Long result=null; |
||||
try{ |
||||
result=accountMapperEx.countsByAccount(name, serialNo, remark); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int insertAccount(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
Account account = JSONObject.parseObject(obj.toJSONString(), Account.class); |
||||
if(account.getInitialAmount() == null) { |
||||
account.setInitialAmount(BigDecimal.ZERO); |
||||
} |
||||
account.setIsDefault(false); |
||||
int result=0; |
||||
try{ |
||||
result = accountMapper.insertSelective(account); |
||||
logService.insertLog("账户", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(account.getName()).toString(), request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int updateAccount(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
Account account = JSONObject.parseObject(obj.toJSONString(), Account.class); |
||||
int result=0; |
||||
try{ |
||||
result = accountMapper.updateByPrimaryKeySelective(account); |
||||
logService.insertLog("账户", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(account.getName()).toString(), request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int deleteAccount(Long id, HttpServletRequest request) throws Exception{ |
||||
return batchDeleteAccountByIds(id.toString()); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteAccount(String ids, HttpServletRequest request)throws Exception { |
||||
return batchDeleteAccountByIds(ids); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteAccountByIds(String ids) throws Exception{ |
||||
int result=0; |
||||
String [] idArray=ids.split(","); |
||||
//校验财务主表 jsh_accounthead
|
||||
List<AccountHead> accountHeadList=null; |
||||
try{ |
||||
accountHeadList = accountHeadMapperEx.getAccountHeadListByAccountIds(idArray); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
if(accountHeadList!=null&&accountHeadList.size()>0){ |
||||
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]", |
||||
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); |
||||
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, |
||||
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); |
||||
} |
||||
//校验财务子表 jsh_accountitem
|
||||
List<AccountItem> accountItemList=null; |
||||
try{ |
||||
accountItemList = accountItemMapperEx.getAccountItemListByAccountIds(idArray); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
if(accountItemList!=null&&accountItemList.size()>0){ |
||||
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]", |
||||
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); |
||||
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, |
||||
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); |
||||
} |
||||
//校验单据主表 jsh_depot_head
|
||||
List<DepotHead> depotHeadList =null; |
||||
try{ |
||||
depotHeadList = depotHeadMapperEx.getDepotHeadListByAccountIds(idArray); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
if(depotHeadList!=null&&depotHeadList.size()>0){ |
||||
logger.error("异常码[{}],异常提示[{}],参数,AccountIds[{}]", |
||||
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); |
||||
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE, |
||||
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG); |
||||
} |
||||
//记录日志
|
||||
StringBuffer sb = new StringBuffer(); |
||||
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE); |
||||
List<Account> list = getAccountListByIds(ids); |
||||
for(Account account: list){ |
||||
sb.append("[").append(account.getName()).append("]"); |
||||
} |
||||
logService.insertLog("账户", sb.toString(), |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
User userInfo=userService.getCurrentUser(); |
||||
//校验通过执行删除操作
|
||||
try{ |
||||
result = accountMapperEx.batchDeleteAccountByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
AccountExample example = new AccountExample(); |
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<Account> list=null; |
||||
try{ |
||||
list = accountMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list==null?0:list.size(); |
||||
} |
||||
|
||||
public List<Account> findBySelect()throws Exception { |
||||
AccountExample example = new AccountExample(); |
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
example.setOrderByClause("id desc"); |
||||
List<Account> list=null; |
||||
try{ |
||||
list = accountMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
/** |
||||
* 单个账户的金额求和-入库和出库 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
public BigDecimal getAccountSum(Long id, String timeStr, String type) throws Exception{ |
||||
BigDecimal accountSum = BigDecimal.ZERO; |
||||
try { |
||||
DepotHeadExample example = new DepotHeadExample(); |
||||
if (!timeStr.equals("")) { |
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null); |
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
if (type.equals("month")) { |
||||
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款") |
||||
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} else if (type.equals("date")) { |
||||
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款") |
||||
.andOperTimeLessThanOrEqualTo(mTime).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} |
||||
} else { |
||||
example.createCriteria().andAccountIdEqualTo(id).andPayTypeNotEqualTo("预付款") |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} |
||||
List<DepotHead> dataList=null; |
||||
try{ |
||||
dataList = depotHeadMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
if (dataList != null) { |
||||
for (DepotHead depotHead : dataList) { |
||||
if(depotHead.getChangeAmount()!=null) { |
||||
accountSum = accountSum .add(depotHead.getChangeAmount()) ; |
||||
} |
||||
} |
||||
} |
||||
} catch (DataAccessException e) { |
||||
logger.error(">>>>>>>>>查找进销存信息异常", e); |
||||
} |
||||
return accountSum; |
||||
} |
||||
|
||||
/** |
||||
* 单个账户的金额求和-收入、支出、转账的单据表头的合计 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
public BigDecimal getAccountSumByHead(Long id, String timeStr, String type) throws Exception{ |
||||
BigDecimal accountSum = BigDecimal.ZERO; |
||||
try { |
||||
AccountHeadExample example = new AccountHeadExample(); |
||||
if (!timeStr.equals("")) { |
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null); |
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
if (type.equals("month")) { |
||||
example.createCriteria().andAccountIdEqualTo(id) |
||||
.andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} else if (type.equals("date")) { |
||||
example.createCriteria().andAccountIdEqualTo(id) |
||||
.andBillTimeLessThanOrEqualTo(mTime) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} |
||||
} else { |
||||
example.createCriteria().andAccountIdEqualTo(id) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} |
||||
List<AccountHead> dataList=null; |
||||
try{ |
||||
dataList = accountHeadMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
if (dataList != null) { |
||||
for (AccountHead accountHead : dataList) { |
||||
if(accountHead.getChangeAmount()!=null) { |
||||
accountSum = accountSum.add(accountHead.getChangeAmount()); |
||||
} |
||||
} |
||||
} |
||||
} catch (DataAccessException e) { |
||||
logger.error(">>>>>>>>>查找进销存信息异常", e); |
||||
} |
||||
return accountSum; |
||||
} |
||||
|
||||
/** |
||||
* 单个账户的金额求和-收款、付款、转账、收预付款的单据明细的合计 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
public BigDecimal getAccountSumByDetail(Long id, String timeStr, String type)throws Exception { |
||||
BigDecimal accountSum =BigDecimal.ZERO ; |
||||
try { |
||||
AccountHeadExample example = new AccountHeadExample(); |
||||
if (!timeStr.equals("")) { |
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null); |
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
if (type.equals("month")) { |
||||
example.createCriteria().andBillTimeGreaterThanOrEqualTo(bTime).andBillTimeLessThanOrEqualTo(eTime) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} else if (type.equals("date")) { |
||||
example.createCriteria().andBillTimeLessThanOrEqualTo(mTime) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} |
||||
} |
||||
List<AccountHead> dataList=null; |
||||
try{ |
||||
dataList = accountHeadMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
if (dataList != null) { |
||||
String ids = ""; |
||||
for (AccountHead accountHead : dataList) { |
||||
ids = ids + accountHead.getId() + ","; |
||||
} |
||||
if (!ids.equals("")) { |
||||
ids = ids.substring(0, ids.length() - 1); |
||||
} |
||||
AccountItemExample exampleAi = new AccountItemExample(); |
||||
if (!ids.equals("")) { |
||||
List<Long> idList = StringUtil.strToLongList(ids); |
||||
exampleAi.createCriteria().andAccountIdEqualTo(id).andHeaderIdIn(idList) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi); |
||||
if (dataListOne != null) { |
||||
for (AccountItem accountItem : dataListOne) { |
||||
if(accountItem.getEachAmount()!=null) { |
||||
accountSum = accountSum.add(accountItem.getEachAmount()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} catch (DataAccessException e) { |
||||
logger.error(">>>>>>>>>查找进销存信息异常", e); |
||||
} catch (Exception e) { |
||||
logger.error(">>>>>>>>>异常信息:", e); |
||||
} |
||||
return accountSum; |
||||
} |
||||
|
||||
/** |
||||
* 单个账户的金额求和-多账户的明细合计 |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
public BigDecimal getManyAccountSum(Long id, String timeStr, String type)throws Exception { |
||||
BigDecimal accountSum = BigDecimal.ZERO; |
||||
try { |
||||
DepotHeadExample example = new DepotHeadExample(); |
||||
if (!timeStr.equals("")) { |
||||
Date bTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
Date eTime = StringUtil.getDateByString(Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME, null); |
||||
Date mTime = StringUtil.getDateByString(Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME, null); |
||||
if (type.equals("month")) { |
||||
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%") |
||||
.andOperTimeGreaterThanOrEqualTo(bTime).andOperTimeLessThanOrEqualTo(eTime) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} else if (type.equals("date")) { |
||||
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%") |
||||
.andOperTimeLessThanOrEqualTo(mTime) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} |
||||
} else { |
||||
example.createCriteria().andAccountIdListLike("%" +id.toString() + "%") |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
} |
||||
List<DepotHead> dataList=null; |
||||
try{ |
||||
dataList = depotHeadMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
if (dataList != null) { |
||||
for (DepotHead depotHead : dataList) { |
||||
String accountIdList = depotHead.getAccountIdList(); |
||||
String accountMoneyList = depotHead.getAccountMoneyList(); |
||||
if(StringUtil.isNotEmpty(accountIdList) && StringUtil.isNotEmpty(accountMoneyList)) { |
||||
accountIdList = accountIdList.replace("[", "").replace("]", "").replace("\"", ""); |
||||
accountMoneyList = accountMoneyList.replace("[", "").replace("]", "").replace("\"", ""); |
||||
String[] aList = accountIdList.split(","); |
||||
String[] amList = accountMoneyList.split(","); |
||||
for (int i = 0; i < aList.length; i++) { |
||||
if (aList[i].toString().equals(id.toString())) { |
||||
if(amList!=null && amList.length>0) { |
||||
accountSum = accountSum.add(new BigDecimal(amList[i])); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} catch (DataAccessException e) { |
||||
logger.error(">>>>>>>>>查找信息异常", e); |
||||
} |
||||
return accountSum; |
||||
} |
||||
|
||||
public List<AccountVo4InOutList> findAccountInOutList(Long accountId, Integer offset, Integer rows) throws Exception{ |
||||
List<AccountVo4InOutList> list=null; |
||||
try{ |
||||
list = accountMapperEx.findAccountInOutList(accountId, offset, rows); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public int findAccountInOutListCount(Long accountId) throws Exception{ |
||||
int result=0; |
||||
try{ |
||||
result = accountMapperEx.findAccountInOutListCount(accountId); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int updateIsDefault(Long accountId) throws Exception{ |
||||
int result=0; |
||||
try{ |
||||
//全部取消默认
|
||||
Account allAccount = new Account(); |
||||
allAccount.setIsDefault(false); |
||||
AccountExample allExample = new AccountExample(); |
||||
allExample.createCriteria(); |
||||
accountMapper.updateByExampleSelective(allAccount, allExample); |
||||
//给指定账户设为默认
|
||||
Account account = new Account(); |
||||
account.setIsDefault(true); |
||||
AccountExample example = new AccountExample(); |
||||
example.createCriteria().andIdEqualTo(accountId); |
||||
accountMapper.updateByExampleSelective(account, example); |
||||
logService.insertLog("账户",BusinessConstants.LOG_OPERATION_TYPE_EDIT+accountId, |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
result = 1; |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public Map<Long,String> getAccountMap() throws Exception { |
||||
List<Account> accountList = getAccount(); |
||||
Map<Long,String> accountMap = new HashMap<>(); |
||||
for(Account account : accountList){ |
||||
accountMap.put(account.getId(), account.getName()); |
||||
} |
||||
return accountMap; |
||||
} |
||||
|
||||
public String getAccountStrByIdAndMoney(Map<Long,String> accountMap, String accountIdList, String accountMoneyList){ |
||||
StringBuffer sb = new StringBuffer(); |
||||
List<Long> idList = StringUtil.strToLongList(accountIdList); |
||||
List<Long> moneyList = StringUtil.strToLongList(accountMoneyList); |
||||
for (int i = 0; i < idList.size(); i++) { |
||||
Long id = idList.get(i); |
||||
BigDecimal money = BigDecimal.valueOf(moneyList.get(i)).abs(); |
||||
sb.append(accountMap.get(id) + "(" + money + "元) "); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
public Map<String, Object> getStatistics(String name, String serialNo) { |
||||
Map<String, Object> map = new HashMap<>(); |
||||
try { |
||||
List<Account> list = getAccountByParam(name, serialNo); |
||||
String timeStr = Tools.getCurrentMonth(); |
||||
BigDecimal allMonthAmount = BigDecimal.ZERO; |
||||
BigDecimal allCurrentAmount = BigDecimal.ZERO; |
||||
if (null != list && null !=timeStr) { |
||||
for (Account a : list) { |
||||
BigDecimal monthAmount = getAccountSum(a.getId(), timeStr, "month").add(getAccountSumByHead(a.getId(), timeStr, "month")) |
||||
.add(getAccountSumByDetail(a.getId(), timeStr, "month")).add(getManyAccountSum(a.getId(), timeStr, "month")); |
||||
BigDecimal currentAmount = getAccountSum(a.getId(), "", "month").add(getAccountSumByHead(a.getId(), "", "month")) |
||||
.add(getAccountSumByDetail(a.getId(), "", "month")).add(getManyAccountSum(a.getId(), "", "month")).add(a.getInitialAmount()); |
||||
allMonthAmount = allMonthAmount.add(monthAmount); |
||||
allCurrentAmount = allCurrentAmount.add(currentAmount); |
||||
} |
||||
} |
||||
map.put("allCurrentAmount", priceFormat(allCurrentAmount)); //当前总金额
|
||||
map.put("allMonthAmount", priceFormat(allMonthAmount)); //本月发生额
|
||||
} catch (Exception e) { |
||||
BoomException.readFail(e); |
||||
} |
||||
return map; |
||||
} |
||||
|
||||
/** |
||||
* 价格格式化 |
||||
* @param price |
||||
* @return |
||||
*/ |
||||
private String priceFormat(BigDecimal price) { |
||||
String priceFmt = "0"; |
||||
DecimalFormat df = new DecimalFormat(".##"); |
||||
if ((price.compareTo(BigDecimal.ZERO))!=0) { |
||||
priceFmt = df.format(price); |
||||
} |
||||
return priceFmt; |
||||
} |
||||
} |
@ -1,73 +0,0 @@
|
||||
package com.zsw.erp.service.functions; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.service.ICommonQuery; |
||||
import com.zsw.erp.utils.Constants; |
||||
import com.zsw.erp.utils.QueryUtils; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service(value = "function_component") |
||||
@FunctionResource |
||||
public class FunctionComponent implements ICommonQuery { |
||||
|
||||
@Resource |
||||
private FunctionService functionService; |
||||
|
||||
@Override |
||||
public Object selectOne(Long id) throws Exception { |
||||
return functionService.getFunction(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<?> select(Map<String, String> map)throws Exception { |
||||
return getFunctionsList(map); |
||||
} |
||||
|
||||
private List<?> getFunctionsList(Map<String, String> map) throws Exception{ |
||||
String search = map.get(Constants.SEARCH); |
||||
String name = StringUtil.getInfo(search, "name"); |
||||
String type = StringUtil.getInfo(search, "type"); |
||||
String order = QueryUtils.order(map); |
||||
return functionService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map)); |
||||
} |
||||
|
||||
@Override |
||||
public Long counts(Map<String, String> map) throws Exception{ |
||||
String search = map.get(Constants.SEARCH); |
||||
String name = StringUtil.getInfo(search, "name"); |
||||
String type = StringUtil.getInfo(search, "type"); |
||||
return functionService.countFunction(name, type); |
||||
} |
||||
|
||||
@Override |
||||
public int insert(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return functionService.insertFunction(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return functionService.updateFunction(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int delete(Long id, HttpServletRequest request)throws Exception { |
||||
return functionService.deleteFunction(id, request); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception { |
||||
return functionService.batchDeleteFunction(ids, request); |
||||
} |
||||
|
||||
@Override |
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
return functionService.checkIsNameExist(id, name); |
||||
} |
||||
|
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.zsw.erp.service.functions; |
||||
|
||||
import com.zsw.erp.service.ResourceInfo; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
|
||||
@ResourceInfo(value = "function") |
||||
@Inherited |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface FunctionResource { |
||||
} |
@ -1,211 +0,0 @@
|
||||
package com.zsw.erp.service.functions; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.constants.BusinessConstants; |
||||
import com.zsw.erp.datasource.entities.Function; |
||||
import com.zsw.erp.datasource.entities.FunctionExample; |
||||
import com.zsw.erp.datasource.entities.User; |
||||
import com.zsw.erp.datasource.mappers.FunctionMapper; |
||||
import com.zsw.erp.datasource.mappers.FunctionMapperEx; |
||||
import com.zsw.erp.exception.BoomException; |
||||
import com.zsw.erp.service.log.LogService; |
||||
import com.zsw.erp.service.user.UserService; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class FunctionService { |
||||
private Logger logger = LoggerFactory.getLogger(FunctionService.class); |
||||
|
||||
@Resource |
||||
private FunctionMapper functionsMapper; |
||||
|
||||
@Resource |
||||
private FunctionMapperEx functionMapperEx; |
||||
@Resource |
||||
private UserService userService; |
||||
@Resource |
||||
private LogService logService; |
||||
|
||||
public Function getFunction(long id)throws Exception { |
||||
Function result=null; |
||||
try{ |
||||
result=functionsMapper.selectByPrimaryKey(id); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public List<Function> getFunctionListByIds(String ids)throws Exception { |
||||
List<Long> idList = StringUtil.strToLongList(ids); |
||||
List<Function> list = new ArrayList<>(); |
||||
try{ |
||||
FunctionExample example = new FunctionExample(); |
||||
example.createCriteria().andIdIn(idList); |
||||
list = functionsMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Function> getFunction()throws Exception { |
||||
FunctionExample example = new FunctionExample(); |
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<Function> list=null; |
||||
try{ |
||||
list=functionsMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Function> select(String name, String type, int offset, int rows)throws Exception { |
||||
List<Function> list=null; |
||||
try{ |
||||
list= functionMapperEx.selectByConditionFunction(name, type, offset, rows); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public Long countFunction(String name, String type)throws Exception { |
||||
Long result=null; |
||||
try{ |
||||
result= functionMapperEx.countsByFunction(name, type); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int insertFunction(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class); |
||||
int result=0; |
||||
try{ |
||||
result=functionsMapper.insert(functions); |
||||
logService.insertLog("功能", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(functions.getName()).toString(),request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int updateFunction(JSONObject obj, HttpServletRequest request) throws Exception{ |
||||
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class); |
||||
int result=0; |
||||
try{ |
||||
result=functionsMapper.updateByPrimaryKeySelective(functions); |
||||
logService.insertLog("功能", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int deleteFunction(Long id, HttpServletRequest request)throws Exception { |
||||
return batchDeleteFunctionByIds(id.toString()); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteFunction(String ids, HttpServletRequest request)throws Exception { |
||||
return batchDeleteFunctionByIds(ids); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteFunctionByIds(String ids)throws Exception { |
||||
StringBuffer sb = new StringBuffer(); |
||||
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE); |
||||
List<Function> list = getFunctionListByIds(ids); |
||||
for(Function functions: list){ |
||||
sb.append("[").append(functions.getName()).append("]"); |
||||
} |
||||
logService.insertLog("功能", sb.toString(), |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
User userInfo=userService.getCurrentUser(); |
||||
String [] idArray=ids.split(","); |
||||
int result=0; |
||||
try{ |
||||
result = functionMapperEx.batchDeleteFunctionByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
FunctionExample example = new FunctionExample(); |
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<Function> list=null; |
||||
try{ |
||||
list = functionsMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list==null?0:list.size(); |
||||
} |
||||
|
||||
// 菜单到下级菜单
|
||||
public List<Function> getRoleFunction(String pNumber)throws Exception { |
||||
FunctionExample example = new FunctionExample(); |
||||
example.createCriteria() |
||||
.andEnabledEqualTo(true) |
||||
.andParentNumberEqualTo(pNumber) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
example.setOrderByClause("Sort"); |
||||
List<Function> list=null; |
||||
try{ |
||||
list = functionsMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Function> findRoleFunction(String pnumber)throws Exception{ |
||||
FunctionExample example = new FunctionExample(); |
||||
example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pnumber) |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
example.setOrderByClause("Sort"); |
||||
List<Function> list=null; |
||||
try{ |
||||
list =functionsMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Function> findByIds(List<Long> functionsIds)throws Exception{ |
||||
FunctionExample example = new FunctionExample(); |
||||
example.createCriteria().andEnabledEqualTo(true).andIdIn(functionsIds).andPushBtnIsNotNull().andPushBtnNotEqualTo("") |
||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
example.setOrderByClause("Sort asc"); |
||||
List<Function> list=null; |
||||
try{ |
||||
list =functionsMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
} |
@ -1,70 +0,0 @@
|
||||
package com.zsw.erp.service.role; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.service.ICommonQuery; |
||||
import com.zsw.erp.utils.Constants; |
||||
import com.zsw.erp.utils.QueryUtils; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service(value = "role_component") |
||||
@RoleResource |
||||
public class RoleComponent implements ICommonQuery { |
||||
|
||||
@Resource |
||||
private RoleService roleService; |
||||
|
||||
@Override |
||||
public Object selectOne(Long id) throws Exception { |
||||
return roleService.getRole(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<?> select(Map<String, String> map)throws Exception { |
||||
return getRoleList(map); |
||||
} |
||||
|
||||
private List<?> getRoleList(Map<String, String> map) throws Exception{ |
||||
String search = map.get(Constants.SEARCH); |
||||
String name = StringUtil.getInfo(search, "name"); |
||||
return roleService.select(name, QueryUtils.offset(map), QueryUtils.rows(map)); |
||||
} |
||||
|
||||
@Override |
||||
public Long counts(Map<String, String> map) throws Exception{ |
||||
String search = map.get(Constants.SEARCH); |
||||
String name = StringUtil.getInfo(search, "name"); |
||||
return roleService.countRole(name); |
||||
} |
||||
|
||||
@Override |
||||
public int insert(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return roleService.insertRole(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return roleService.updateRole(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int delete(Long id, HttpServletRequest request)throws Exception { |
||||
return roleService.deleteRole(id, request); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception { |
||||
return roleService.batchDeleteRole(ids, request); |
||||
} |
||||
|
||||
@Override |
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
return roleService.checkIsNameExist(id, name); |
||||
} |
||||
|
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.zsw.erp.service.role; |
||||
|
||||
import com.zsw.erp.service.ResourceInfo; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
|
||||
@ResourceInfo(value = "role") |
||||
@Inherited |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface RoleResource { |
||||
} |
@ -1,184 +0,0 @@
|
||||
package com.zsw.erp.service.role; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.constants.BusinessConstants; |
||||
import com.zsw.erp.datasource.entities.Role; |
||||
import com.zsw.erp.datasource.entities.RoleExample; |
||||
import com.zsw.erp.datasource.entities.User; |
||||
import com.zsw.erp.datasource.mappers.RoleMapper; |
||||
import com.zsw.erp.datasource.mappers.RoleMapperEx; |
||||
import com.zsw.erp.exception.BoomException; |
||||
import com.zsw.erp.service.log.LogService; |
||||
import com.zsw.erp.service.user.UserService; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class RoleService { |
||||
private Logger logger = LoggerFactory.getLogger(RoleService.class); |
||||
@Resource |
||||
private RoleMapper roleMapper; |
||||
|
||||
@Resource |
||||
private RoleMapperEx roleMapperEx; |
||||
@Resource |
||||
private LogService logService; |
||||
@Resource |
||||
private UserService userService; |
||||
|
||||
public Role getRole(long id)throws Exception { |
||||
Role result=null; |
||||
try{ |
||||
result=roleMapper.selectByPrimaryKey(id); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public List<Role> getRoleListByIds(String ids)throws Exception { |
||||
List<Long> idList = StringUtil.strToLongList(ids); |
||||
List<Role> list = new ArrayList<>(); |
||||
try{ |
||||
RoleExample example = new RoleExample(); |
||||
example.createCriteria().andIdIn(idList); |
||||
list = roleMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Role> allList()throws Exception { |
||||
RoleExample example = new RoleExample(); |
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<Role> list=null; |
||||
try{ |
||||
list=roleMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<Role> select(String name, int offset, int rows)throws Exception { |
||||
List<Role> list=null; |
||||
try{ |
||||
list=roleMapperEx.selectByConditionRole(name, offset, rows); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public Long countRole(String name)throws Exception { |
||||
Long result=null; |
||||
try{ |
||||
result=roleMapperEx.countsByRole(name); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int insertRole(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
Role role = JSONObject.parseObject(obj.toJSONString(), Role.class); |
||||
int result=0; |
||||
try{ |
||||
result=roleMapper.insertSelective(role); |
||||
logService.insertLog("角色", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(role.getName()).toString(), request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int updateRole(JSONObject obj, HttpServletRequest request) throws Exception{ |
||||
Role role = JSONObject.parseObject(obj.toJSONString(), Role.class); |
||||
int result=0; |
||||
try{ |
||||
result=roleMapper.updateByPrimaryKeySelective(role); |
||||
logService.insertLog("角色", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(role.getName()).toString(), request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int deleteRole(Long id, HttpServletRequest request)throws Exception { |
||||
return batchDeleteRoleByIds(id.toString()); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteRole(String ids, HttpServletRequest request) throws Exception{ |
||||
return batchDeleteRoleByIds(ids); |
||||
} |
||||
|
||||
public int checkIsNameExist(Long id, String name) throws Exception{ |
||||
RoleExample example = new RoleExample(); |
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<Role> list =null; |
||||
try{ |
||||
list=roleMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list==null?0:list.size(); |
||||
} |
||||
|
||||
public List<Role> findUserRole()throws Exception{ |
||||
RoleExample example = new RoleExample(); |
||||
example.setOrderByClause("Id"); |
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); |
||||
List<Role> list=null; |
||||
try{ |
||||
list=roleMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
/** |
||||
* create by: qiankunpingtai |
||||
* 逻辑删除角色信息 |
||||
* create time: 2019/3/28 15:44 |
||||
* @Param: ids |
||||
* @return int |
||||
*/ |
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteRoleByIds(String ids) throws Exception{ |
||||
StringBuffer sb = new StringBuffer(); |
||||
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE); |
||||
List<Role> list = getRoleListByIds(ids); |
||||
for(Role role: list){ |
||||
sb.append("[").append(role.getName()).append("]"); |
||||
} |
||||
logService.insertLog("角色", sb.toString(), |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
User userInfo=userService.getCurrentUser(); |
||||
String [] idArray=ids.split(","); |
||||
int result=0; |
||||
try{ |
||||
result=roleMapperEx.batchDeleteRoleByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -1,78 +0,0 @@
|
||||
package com.zsw.erp.service.tenant; |
||||
|
||||
import cn.hutool.json.JSONUtil; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.datasource.entities.Tenant; |
||||
import com.zsw.erp.service.ICommonQuery; |
||||
import com.zsw.erp.utils.Constants; |
||||
import com.zsw.erp.utils.QueryUtils; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service(value = "tenant_component") |
||||
@TenantResource |
||||
public class TenantComponent implements ICommonQuery { |
||||
|
||||
@Resource |
||||
private TenantService tenantService; |
||||
|
||||
@Override |
||||
public Object selectOne(Long id) throws Exception { |
||||
return tenantService.getTenant(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<?> select(Map<String, String> map)throws Exception { |
||||
return getTenantList(map); |
||||
} |
||||
|
||||
private List<?> getTenantList(Map<String, String> map)throws Exception { |
||||
String search = map.get(Constants.SEARCH); |
||||
String loginName = StringUtil.getInfo(search, "loginName"); |
||||
String type = StringUtil.getInfo(search, "type"); |
||||
String enabled = StringUtil.getInfo(search, "enabled"); |
||||
return tenantService.select(loginName, type, enabled, QueryUtils.offset(map), QueryUtils.rows(map)); |
||||
} |
||||
|
||||
@Override |
||||
public Long counts(Map<String, String> map)throws Exception { |
||||
String search = map.get(Constants.SEARCH); |
||||
String loginName = StringUtil.getInfo(search, "loginName"); |
||||
String type = StringUtil.getInfo(search, "type"); |
||||
String enabled = StringUtil.getInfo(search, "enabled"); |
||||
return tenantService.countTenant(loginName, type, enabled); |
||||
} |
||||
|
||||
@Override |
||||
public int insert(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
Tenant tenant = JSONUtil.toBean(obj.toJSONString(), Tenant.class); |
||||
return tenantService.insertTenant(tenant, request); |
||||
} |
||||
|
||||
@Override |
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
Tenant tenant = JSONUtil.toBean(obj.toJSONString(), Tenant.class); |
||||
return tenantService.updateTenant(tenant, request); |
||||
} |
||||
|
||||
@Override |
||||
public int delete(Long id, HttpServletRequest request)throws Exception { |
||||
return tenantService.deleteTenant(id, request); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception { |
||||
return tenantService.batchDeleteTenant(ids, request); |
||||
} |
||||
|
||||
@Override |
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
return tenantService.checkIsNameExist(id, name); |
||||
} |
||||
|
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.zsw.erp.service.tenant; |
||||
|
||||
import com.zsw.erp.service.ResourceInfo; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
|
||||
@ResourceInfo(value = "tenant") |
||||
@Inherited |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface TenantResource { |
||||
} |
@ -1,182 +0,0 @@
|
||||
package com.zsw.erp.service.tenant; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.constants.BusinessConstants; |
||||
import com.zsw.erp.datasource.mappers.TenantMapper; |
||||
import com.zsw.erp.datasource.mappers.TenantMapperEx; |
||||
import com.zsw.erp.exception.BoomException; |
||||
import com.zsw.erp.service.log.LogService; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import com.zsw.erp.utils.Tools; |
||||
import com.zsw.erp.datasource.entities.Tenant; |
||||
import com.zsw.erp.datasource.entities.TenantEx; |
||||
import com.zsw.erp.datasource.entities.TenantExample; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Lazy; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
|
||||
@Service |
||||
public class TenantService { |
||||
private Logger logger = LoggerFactory.getLogger(TenantService.class); |
||||
|
||||
@Resource |
||||
private TenantMapper tenantMapper; |
||||
|
||||
@Resource |
||||
private TenantMapperEx tenantMapperEx; |
||||
|
||||
@Resource |
||||
@Lazy |
||||
private LogService logService; |
||||
|
||||
@Value("${tenant.userNumLimit}") |
||||
private Integer userNumLimit; |
||||
|
||||
@Value("${tenant.tryDayLimit}") |
||||
private Integer tryDayLimit; |
||||
|
||||
public Tenant getTenant(long id)throws Exception { |
||||
Tenant result=null; |
||||
try{ |
||||
result=tenantMapper.selectByPrimaryKey(id); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public List<Tenant> getTenant(){ |
||||
TenantExample example = new TenantExample(); |
||||
List<Tenant> list=null; |
||||
try{ |
||||
list=tenantMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public List<TenantEx> select(String loginName, String type, String enabled, int offset, int rows)throws Exception { |
||||
List<TenantEx> list= new ArrayList<>(); |
||||
try{ |
||||
list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, offset, rows); |
||||
if (null != list) { |
||||
for (TenantEx tenantEx : list) { |
||||
tenantEx.setCreateTimeStr(Tools.getCenternTime(tenantEx.getCreateTime())); |
||||
tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime())); |
||||
} |
||||
} |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public Long countTenant(String loginName, String type, String enabled)throws Exception { |
||||
Long result=null; |
||||
try{ |
||||
result=tenantMapperEx.countsByTenant(loginName, type, enabled); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int insertTenant(Tenant tenant, HttpServletRequest request)throws Exception { |
||||
tenant.setCreateTime(new Date()); |
||||
if(tenant.getUserNumLimit()==null) { |
||||
tenant.setUserNumLimit(userNumLimit); //默认用户限制数量
|
||||
} |
||||
if(tenant.getExpireTime()==null) { |
||||
tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
|
||||
} |
||||
return tenantMapper.insert(tenant); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int updateTenant(Tenant tenant, HttpServletRequest request)throws Exception { |
||||
return tenantMapper.updateById(tenant); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int deleteTenant(Long id, HttpServletRequest request)throws Exception { |
||||
int result=0; |
||||
try{ |
||||
result= tenantMapper.deleteByPrimaryKey(id); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteTenant(String ids, HttpServletRequest request)throws Exception { |
||||
List<Long> idList = StringUtil.strToLongList(ids); |
||||
TenantExample example = new TenantExample(); |
||||
example.createCriteria().andIdIn(idList); |
||||
int result=0; |
||||
try{ |
||||
result= tenantMapper.deleteByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
TenantExample example = new TenantExample(); |
||||
example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name); |
||||
List<Tenant> list=null; |
||||
try{ |
||||
list= tenantMapper.selectByExample(example); |
||||
}catch(Exception e){ |
||||
BoomException.readFail(e); |
||||
} |
||||
return list==null?0:list.size(); |
||||
} |
||||
|
||||
public Tenant getTenantByTenantId(long tenantId) { |
||||
Tenant tenant = new Tenant(); |
||||
TenantExample example = new TenantExample(); |
||||
example.createCriteria().andTenantIdEqualTo(tenantId); |
||||
List<Tenant> list = tenantMapper.selectByExample(example); |
||||
if(list.size()>0) { |
||||
tenant = list.get(0); |
||||
} |
||||
return tenant; |
||||
} |
||||
|
||||
public int batchSetStatus(Boolean status, String ids)throws Exception { |
||||
int result=0; |
||||
try{ |
||||
String statusStr =""; |
||||
if(status) { |
||||
statusStr ="批量启用"; |
||||
} else { |
||||
statusStr ="批量禁用"; |
||||
} |
||||
logService.insertLog("用户", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ids).append("-").append(statusStr).toString(), |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
List<Long> idList = StringUtil.strToLongList(ids); |
||||
Tenant tenant = new Tenant(); |
||||
tenant.setEnabled(status); |
||||
TenantExample example = new TenantExample(); |
||||
example.createCriteria().andIdIn(idList); |
||||
result = tenantMapper.updateByExampleSelective(tenant, example); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -1,73 +0,0 @@
|
||||
package com.zsw.erp.service.user; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.service.ICommonQuery; |
||||
import com.zsw.erp.utils.Constants; |
||||
import com.zsw.erp.utils.QueryUtils; |
||||
import com.zsw.erp.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
|
||||
@Service(value = "user_component") |
||||
@UserResource |
||||
public class UserComponent implements ICommonQuery { |
||||
|
||||
@Resource |
||||
private UserService userService; |
||||
|
||||
@Override |
||||
public Object selectOne(Long id) throws Exception { |
||||
return userService.getUser(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<?> select(Map<String, String> map)throws Exception { |
||||
return getUserList(map); |
||||
} |
||||
|
||||
private List<?> getUserList(Map<String, String> map)throws Exception { |
||||
String search = map.get(Constants.SEARCH); |
||||
String userName = StringUtil.getInfo(search, "userName"); |
||||
String loginName = StringUtil.getInfo(search, "loginName"); |
||||
String order = QueryUtils.order(map); |
||||
String filter = QueryUtils.filter(map); |
||||
return userService.select(userName, loginName, QueryUtils.offset(map), QueryUtils.rows(map)); |
||||
} |
||||
|
||||
@Override |
||||
public Long counts(Map<String, String> map)throws Exception { |
||||
String search = map.get(Constants.SEARCH); |
||||
String userName = StringUtil.getInfo(search, "userName"); |
||||
String loginName = StringUtil.getInfo(search, "loginName"); |
||||
return userService.countUser(userName, loginName); |
||||
} |
||||
|
||||
@Override |
||||
public int insert(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return userService.insertUser(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return userService.updateUser(obj, request); |
||||
} |
||||
|
||||
@Override |
||||
public int delete(Long id, HttpServletRequest request)throws Exception { |
||||
return userService.deleteUser(id, request); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception { |
||||
return userService.batchDeleteUser(ids, request); |
||||
} |
||||
|
||||
@Override |
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
return userService.checkIsNameExist(id, name); |
||||
} |
||||
|
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.zsw.erp.service.user; |
||||
|
||||
import com.zsw.erp.service.ResourceInfo; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
|
||||
@ResourceInfo(value = "user") |
||||
@Inherited |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface UserResource { |
||||
} |
@ -1,67 +0,0 @@
|
||||
package com.zsw.erp.service.userBusiness; |
||||
|
||||
import cn.hutool.json.JSONUtil; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.zsw.erp.constants.BusinessConstants; |
||||
import com.zsw.erp.datasource.entities.UserBusiness; |
||||
import com.zsw.erp.service.ICommonQuery; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service(value = "userBusiness_component") |
||||
@UserBusinessResource |
||||
public class UserBusinessComponent implements ICommonQuery { |
||||
|
||||
@Resource |
||||
private UserBusinessService userBusinessService; |
||||
|
||||
@Override |
||||
public Object selectOne(Long id) throws Exception { |
||||
return userBusinessService.getUserBusiness(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<?> select(Map<String, String> map)throws Exception { |
||||
return getUserBusinessList(map); |
||||
} |
||||
|
||||
private List<?> getUserBusinessList(Map<String, String> map)throws Exception { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public Long counts(Map<String, String> map)throws Exception { |
||||
return BusinessConstants.DEFAULT_LIST_NULL_NUMBER; |
||||
} |
||||
|
||||
@Override |
||||
public int insert(JSONObject obj, HttpServletRequest request) throws Exception { |
||||
return userBusinessService.insertUserBusiness(JSON.parseObject(obj.toJSONString(),UserBusiness.class), request); |
||||
} |
||||
|
||||
@Override |
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception { |
||||
return userBusinessService.updateUserBusiness(JSON.parseObject(obj.toJSONString(),UserBusiness.class), request); |
||||
} |
||||
|
||||
@Override |
||||
public int delete(Long id, HttpServletRequest request)throws Exception { |
||||
return userBusinessService.deleteUserBusiness(id, request); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception { |
||||
return userBusinessService.batchDeleteUserBusiness(ids, request); |
||||
} |
||||
|
||||
@Override |
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
return userBusinessService.checkIsNameExist(id, name); |
||||
} |
||||
|
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.zsw.erp.service.userBusiness; |
||||
|
||||
import com.zsw.erp.service.ResourceInfo; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
|
||||
@ResourceInfo(value = "userBusiness") |
||||
@Inherited |
||||
@Target(ElementType.TYPE) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
public @interface UserBusinessResource { |
||||
} |
@ -1,163 +0,0 @@
|
||||
package com.zsw.erp.service.userBusiness; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.google.common.collect.Lists; |
||||
import com.zsw.erp.constants.BusinessConstants; |
||||
import com.zsw.erp.datasource.entities.BtnDto; |
||||
import com.zsw.erp.datasource.mappers.UserBusinessMapper; |
||||
import com.zsw.erp.datasource.mappers.UserBusinessMapperEx; |
||||
import com.zsw.erp.exception.BoomException; |
||||
import com.zsw.erp.service.log.LogService; |
||||
import com.zsw.erp.service.user.UserService; |
||||
import com.zsw.erp.utils.Tools; |
||||
import com.zsw.erp.datasource.entities.User; |
||||
import com.zsw.erp.datasource.entities.UserBusiness; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.context.annotation.Lazy; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@Service |
||||
public class UserBusinessService { |
||||
private Logger logger = LoggerFactory.getLogger(UserBusinessService.class); |
||||
|
||||
@Resource |
||||
private UserBusinessMapper userBusinessMapper; |
||||
@Resource |
||||
private UserBusinessMapperEx userBusinessMapperEx; |
||||
@Resource |
||||
private LogService logService; |
||||
@Resource |
||||
@Lazy |
||||
private UserService userService; |
||||
|
||||
|
||||
public UserBusiness getUserBusiness(long id)throws Exception { |
||||
return userBusinessMapper.selectById(id); |
||||
} |
||||
|
||||
public List<UserBusiness> getUserBusiness(){ |
||||
return userBusinessMapper.selectList(Wrappers.<UserBusiness>lambdaQuery() |
||||
.eq(UserBusiness::getDeleteFlag,BusinessConstants.DELETE_FLAG_EXISTS)); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int insertUserBusiness(UserBusiness userBusiness, HttpServletRequest request) throws Exception { |
||||
int result=0; |
||||
try{ |
||||
String token = ""; |
||||
if(request!=null) { |
||||
token = request.getHeader("X-Access-Token"); |
||||
Long tenantId = Tools.getTenantIdByToken(token); |
||||
if(tenantId!=0L) { |
||||
userBusiness.setTenantId(tenantId); |
||||
} |
||||
} |
||||
result=userBusinessMapper.insert(userBusiness); |
||||
logService.insertLog("关联关系", BusinessConstants.LOG_OPERATION_TYPE_ADD, request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int updateUserBusiness(UserBusiness userBusiness, HttpServletRequest request) throws Exception { |
||||
int result=0; |
||||
try{ |
||||
result = userBusinessMapper.updateById(userBusiness); |
||||
logService.insertLog("关联关系", BusinessConstants.LOG_OPERATION_TYPE_EDIT, request); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int deleteUserBusiness(Long id, HttpServletRequest request)throws Exception { |
||||
return batchDeleteUserBusinessByIds(id.toString()); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteUserBusiness(String ids, HttpServletRequest request)throws Exception { |
||||
return batchDeleteUserBusinessByIds(ids); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int batchDeleteUserBusinessByIds(String ids) throws Exception{ |
||||
logService.insertLog("关联关系", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
User userInfo=userService.getCurrentUser(); |
||||
String [] idArray=ids.split(","); |
||||
int result=0; |
||||
try{ |
||||
result= userBusinessMapperEx.batchDeleteUserBusinessByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception { |
||||
return 1; |
||||
} |
||||
|
||||
public UserBusiness getBasicData(Long keyId, String type){ |
||||
return userBusinessMapper.selectOne(Wrappers.<UserBusiness>lambdaQuery() |
||||
.eq(UserBusiness::getType, type) |
||||
.eq(UserBusiness::getKeyId,keyId) |
||||
.eq(UserBusiness::getDeleteFlag, BusinessConstants.DELETE_FLAG_EXISTS)); |
||||
} |
||||
|
||||
public List<UserBusiness> getListBy(String keyId, String type){ |
||||
return userBusinessMapper.selectList(Wrappers.<UserBusiness>lambdaQuery() |
||||
.eq(UserBusiness::getKeyId,keyId) |
||||
.eq(UserBusiness::getType,type) |
||||
.eq(UserBusiness::getDeleteFlag,BusinessConstants.DELETE_FLAG_EXISTS)); |
||||
} |
||||
|
||||
public List<Long> getUBValueByTypeAndKeyId(String type, Long keyId) throws Exception { |
||||
List<Number> list = Lists.newArrayList(); |
||||
UserBusiness ubList = getBasicData(keyId, type); |
||||
if (ubList == null){ |
||||
return null; |
||||
} |
||||
return ubList.getValue().stream().map(Number::longValue).collect(Collectors.toList()); |
||||
} |
||||
|
||||
public Long checkIsValueExist(String type, String keyId)throws Exception { |
||||
UserBusiness business = userBusinessMapper.selectOne(Wrappers.<UserBusiness>lambdaQuery() |
||||
.eq(UserBusiness::getKeyId,keyId) |
||||
.eq(UserBusiness::getType,type) |
||||
.eq(UserBusiness::getDeleteFlag,BusinessConstants.DELETE_FLAG_EXISTS)); |
||||
return business==null ? null : business.getId(); |
||||
} |
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class) |
||||
public int updateBtnStr(String keyId, String type, List<BtnDto> btnStr) throws Exception{ |
||||
logService.insertLog("关联关系", |
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append("角色的按钮权限").toString(), |
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); |
||||
UserBusiness userBusiness = new UserBusiness(); |
||||
userBusiness.setBtnStr(btnStr); |
||||
int result=0; |
||||
try{ |
||||
result= userBusinessMapper.update(userBusiness, |
||||
Wrappers.<UserBusiness>lambdaUpdate() |
||||
.eq(UserBusiness::getType,type) |
||||
.eq(UserBusiness::getKeyId,keyId)); |
||||
}catch(Exception e){ |
||||
BoomException.writeFail(e); |
||||
} |
||||
return result; |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue