diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardClientUserController.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardClientUserController.java new file mode 100644 index 00000000..5978cff9 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/controller/XhpcCardClientUserController.java @@ -0,0 +1,75 @@ +package com.xhpc.card.controller; + +import com.xhpc.card.domain.CardClientUser; +import com.xhpc.card.service.IXhpcCardClientUserService; +import com.xhpc.common.api.dto.XhpcChargingStationDto; +import com.xhpc.common.core.web.controller.BaseController; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.common.log.annotation.Log; +import com.xhpc.common.log.enums.BusinessType; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2022/3/21 10:32 + */ +@RestController +@RequestMapping("/cardClientUser") +@Api(value = "卡管理员信息", tags = "卡管理员信息") +public class XhpcCardClientUserController extends BaseController { + + @Autowired + private IXhpcCardClientUserService xhpcCardClientUserService; + + + @GetMapping("/list") + public TableDataInfo list(String userName, Integer usersLevel,Long operatorId,String tenantId) { + List> list = xhpcCardClientUserService.selectXhpcCardClientUserList(userName, usersLevel, operatorId, tenantId); + return getDataTable(list); + } + + + /** + * 添加 + * @param cardClientUser + * @return + */ + @Log(title = "添加", businessType = BusinessType.INSERT) + @PostMapping(value = "/addOrUpdateXhpcCardClientUser") + public AjaxResult addOrUpdateXhpcCardClientUser(@RequestBody CardClientUser cardClientUser) { + return xhpcCardClientUserService.addOrUpdateXhpcCardClientUser(cardClientUser); + } + + /** + * 获取运营商接口 + */ + @GetMapping("/getoperatorList") + public AjaxResult getoperatorList(String tenantId) { + return xhpcCardClientUserService.getoperatorList(tenantId); + } + + /** + * 获取运营商接口 + */ + @GetMapping("/getXhpcCardClientUserById") + public AjaxResult getXhpcCardClientUserById(Integer usersID) { + return AjaxResult.success(xhpcCardClientUserService.getXhpcCardClientUserById(usersID)); + } + + + /** + * 修改状态 + */ + @GetMapping("/getXhpcCardClientUserStatus") + public AjaxResult getXhpcCardClientUserStatus(Integer usersID,Integer status) { + return xhpcCardClientUserService.getXhpcCardClientUserStatus(usersID,status); + } + +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/CardClientUser.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/CardClientUser.java new file mode 100644 index 00000000..1b82686e --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/domain/CardClientUser.java @@ -0,0 +1,65 @@ +package com.xhpc.card.domain; + +import lombok.Data; + +/** + * @author yuyang + * @date 2022/3/21 10:02 + */ +@Data +public class CardClientUser { + + /** + * + */ + private Integer usersID; + /** + *命名规则:字母数字组合 + */ + private String usersName; + /** + *用户密码 + */ + private String usersPwd; + /** + *用户电话 + */ + private String usersPhone; + /** + *用户Email + */ + private String usersEmail; + /** + *用户地址 + */ + private String usersAdress; + /** + *用户级别 3.运营商管理员 4.平台管理员 + */ + private Integer usersLevel; + /** + *所属运营商id,对应xhpc_operator.operator_id + */ + private String usersCorp; + /** + *所属运营商前缀 + */ + private String corpNo; + /** + *所属运营商名称 + */ + private String corpName; + /** + *添加日期 + */ + private String usersTime; + /** + *租户id + */ + private String tenantId; + + /** + *逻辑删除字段(0,存在,1为删除) + */ + private Integer delFlag; +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/IXhpcCardClientUserMapper.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/IXhpcCardClientUserMapper.java new file mode 100644 index 00000000..23263128 --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/mapper/IXhpcCardClientUserMapper.java @@ -0,0 +1,44 @@ +package com.xhpc.card.mapper; + +import com.xhpc.card.domain.CardClientUser; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.domain.XhpcRateModel; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2022/3/21 9:59 + */ +public interface IXhpcCardClientUserMapper { + + List> selectXhpcCardClientUserList(@Param("userName") String userName, @Param("usersLevel")Integer usersLevel, @Param("operatorId")Long operatorId,@Param("tenantId") String tenantId,@Param("status")Integer status,@Param("logOperatorId")Long logOperatorId); + + + /** + * 添加费率模型 + */ + int insertXhpcCardClientUser(CardClientUser cardClientUser); + + /** + * 添加费率模型 + */ + int updateXhpcCardClientUser(CardClientUser cardClientUser); + + /** + * 获取运营商接口 + * @param tenantId + * @return + */ + List> getoperatorList(String tenantId); + + /** + * 列表 + * @param usersID 用户Id + * @return + */ + Map getXhpcCardClientUserById(@Param("type")Integer type,@Param("usersID") Integer usersID,@Param("usersName")String usersName); + +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardClientUserService.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardClientUserService.java new file mode 100644 index 00000000..e814cf0a --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/IXhpcCardClientUserService.java @@ -0,0 +1,55 @@ +package com.xhpc.card.service; + +import com.xhpc.card.domain.CardClientUser; +import com.xhpc.common.api.dto.XhpcChargingStationDto; +import com.xhpc.common.core.web.domain.AjaxResult; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2022/3/21 9:45 + */ +public interface IXhpcCardClientUserService { + + + /** + * 列表 + * @param userName 用户名称 + * @param usersLevel 用户级别 + * @param operatorId 运营商id + * @param tenantId 租户id + * @return + */ + List> selectXhpcCardClientUserList(String userName, Integer usersLevel,Long operatorId,String tenantId); + + /** + * 添加 + * @param cardClientUser + * @return + */ + AjaxResult addOrUpdateXhpcCardClientUser(CardClientUser cardClientUser); + + /** + * 获取运营商接口 + * @param tenantId 租户id + * @return + */ + AjaxResult getoperatorList(String tenantId); + + /** + * 详情 + * @param usersID 用户Id + * @return + */ + Map getXhpcCardClientUserById(Integer usersID); + + /** + * 获取运营商接口 + * @param tenantId 租户id + * @return + */ + AjaxResult getXhpcCardClientUserStatus(Integer usersID,Integer status); +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardClientUserServiceImpl.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardClientUserServiceImpl.java new file mode 100644 index 00000000..e541484e --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardClientUserServiceImpl.java @@ -0,0 +1,153 @@ +package com.xhpc.card.service.impl; + +import com.xhpc.card.domain.CardClientUser; +import com.xhpc.card.mapper.IXhpcCardClientUserMapper; +import com.xhpc.card.service.IXhpcCardClientUserService; +import com.xhpc.common.core.web.domain.AjaxResult; +import com.xhpc.common.core.web.service.BaseService; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; +import com.xhpc.system.api.domain.SysUser; +import com.xhpc.system.api.model.LoginUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.naming.ldap.PagedResultsControl; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author yuyang + * @date 2022/3/21 9:46 + */ +@Service +public class XhpcCardClientUserServiceImpl extends BaseService implements IXhpcCardClientUserService { + + @Autowired + private TokenService tokenService; + @Autowired + private IXhpcCardClientUserMapper xhpcCardClientUserMapper; + + @Override + public List> selectXhpcCardClientUserList(String userName, Integer usersLevel, Long operatorId, String tenantId) { + + LoginUser loginUser = tokenService.getLoginUser(); + String loginUserTenantId = loginUser.getTenantId(); + Long logUserId = loginUser.getUserid(); + SysUser sysUser = loginUser.getSysUser(); + List> list = new ArrayList<>(); + startPage(); + if (logUserId != UserTypeUtil.USER_ID) { + Long logOperatorId = sysUser.getOperatorId(); + if (UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())) { + //运营商看自己的场站 + list = xhpcCardClientUserMapper.selectXhpcCardClientUserList(userName,usersLevel,operatorId,tenantId,1,logOperatorId); + } else { + //查询赋值的场站 + list = xhpcCardClientUserMapper.selectXhpcCardClientUserList(userName,usersLevel,operatorId,tenantId,2,logOperatorId); + } + }else{ + list = xhpcCardClientUserMapper.selectXhpcCardClientUserList(userName,usersLevel,operatorId,tenantId,0,null); + } + return list; + } + + /** + * 添加 + * + * @param cardClientUser + * @return + */ + @Override + public AjaxResult addOrUpdateXhpcCardClientUser(CardClientUser cardClientUser) { + + if(cardClientUser.getUsersName() ==null || "".equals(cardClientUser.getUsersName())){ + return AjaxResult.error("用户名称为空"); + } + if(cardClientUser.getUsersID()==null){ + Map xhpcCardClientUserById = xhpcCardClientUserMapper.getXhpcCardClientUserById(1,null, cardClientUser.getUsersName()); + if(xhpcCardClientUserById !=null &&( false ==(boolean)xhpcCardClientUserById.get("delFlag") || "0".equals(xhpcCardClientUserById.get("delFlag").toString()))){ + return AjaxResult.error("用户名称已存在"); + } + }else{ + Map xhpcCardClientUserById = xhpcCardClientUserMapper.getXhpcCardClientUserById(1,cardClientUser.getUsersID(), cardClientUser.getUsersName()); + if(xhpcCardClientUserById !=null &&( false ==(boolean)xhpcCardClientUserById.get("delFlag") || "0".equals(xhpcCardClientUserById.get("delFlag").toString()))){ + return AjaxResult.error("用户名称已存在"); + } + } + if(cardClientUser.getUsersPwd() ==null || "".equals(cardClientUser.getUsersPwd())){ + return AjaxResult.error("用户密码为空"); + } + if(cardClientUser.getTenantId() ==null || "".equals(cardClientUser.getTenantId())){ + return AjaxResult.error("租户为空"); + } + if(cardClientUser.getUsersLevel() ==null){ + return AjaxResult.error("级别为空"); + }else{ +// if(cardClientUser.getUsersLevel() ==3){ +// if(cardClientUser.getCorpNo() ==null || "".equals(cardClientUser.getCorpNo())){ +// return AjaxResult.error("运营商为空"); +// } +// } + } + if(cardClientUser.getCorpNo() ==null || "".equals(cardClientUser.getCorpNo())){ + return AjaxResult.error("运营商为空"); + } + if(cardClientUser.getUsersID()==null){ + int i = xhpcCardClientUserMapper.insertXhpcCardClientUser(cardClientUser); + if(i==0){ + return AjaxResult.error("添加失败"); + } + }else{ + int i = xhpcCardClientUserMapper.updateXhpcCardClientUser(cardClientUser); + if(i==0){ + return AjaxResult.error("添加失败"); + } + } + + return AjaxResult.success(); + } + + /** + * 获取运营商接口 + * + * @param tenantId 租户id + * @return + */ + @Override + public AjaxResult getoperatorList(String tenantId) { + return AjaxResult.success(xhpcCardClientUserMapper.getoperatorList(tenantId)); + } + + /** + * 详情 + * + * @param usersID 用户Id + * @return + */ + @Override + public Map getXhpcCardClientUserById(Integer usersID) { + return xhpcCardClientUserMapper.getXhpcCardClientUserById(0,usersID,null); + } + + /** + * 获取运营商接口 + * + * @param usersID + * @param status + * @return + */ + @Override + public AjaxResult getXhpcCardClientUserStatus(Integer usersID, Integer status) { + CardClientUser cardClientUser =new CardClientUser(); + cardClientUser.setUsersID(usersID); + cardClientUser.setDelFlag(status); + int i = xhpcCardClientUserMapper.updateXhpcCardClientUser(cardClientUser); + if(i==0){ + return AjaxResult.error("状态改变失败"); + }else{ + return AjaxResult.error("状态改变成功"); + } + } +} diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java index d1d3e664..4602a736 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java @@ -605,7 +605,9 @@ public class XhpcCardServiceImpl implements IXhpcCardService { Integer operatorId = tIccardLog.getOperatorid(); XhpcOperator operator = xhpcOperatorMapper.selectByPrimaryKey(Long.valueOf(operatorId)); dataDTO.setOperatorName(operator.getName()); - dataDTO.setOperateTime(MyDateUtil.parseDateToStr(tIccardLog.getCreatetime())); + if(tIccardLog.getCreatetime() !=null){ + dataDTO.setOperateTime(MyDateUtil.parseDateToStr(tIccardLog.getCreatetime())); + } operateDevicesLogResponse.getData().add(dataDTO); } return R.ok(operateDevicesLogResponse); diff --git a/xhpc-modules/xhpc-card/src/main/resources/mapper/IXhpcCardClientUsersMapper.xml b/xhpc-modules/xhpc-card/src/main/resources/mapper/IXhpcCardClientUsersMapper.xml new file mode 100644 index 00000000..961d21ef --- /dev/null +++ b/xhpc-modules/xhpc-card/src/main/resources/mapper/IXhpcCardClientUsersMapper.xml @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + insert into t_iccard_client_users + + + usersName, + + + usersPwd, + + + usersPhone, + + + usersAdress, + + + usersLevel, + + + usersCorp, + + + corpNo, + + + corpName, + + + usersTime, + + + tenant_id + + + + + #{usersName}, + + + #{usersPwd}, + + + #{usersPhone}, + + + #{usersAdress}, + + + #{usersLevel}, + + + #{usersCorp}, + + + #{corpNo}, + + + #{corpNameand}, + + + #{usersTime}, + + + #{tenantId} + + + + + + + + + + update t_iccard_client_users + + + usersName= #{usersName}, + + + usersPwd= #{usersPwd}, + + + usersPhone= #{usersPhone}, + + + usersAdress=#{usersAdress}, + + + usersLevel=#{usersLevel}, + + + usersCorp=#{usersCorp}, + + + corpNo= #{corpNo}, + + + corpName= #{corpNameand}, + + + usersTime=#{usersTime}, + + + tenant_id= #{tenantId} + + + where usersID = #{usersID} + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardLogMapper.xml b/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardLogMapper.xml index 767e4a3e..c6ed722d 100644 --- a/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardLogMapper.xml +++ b/xhpc-modules/xhpc-card/src/main/resources/mapper/TIccardLogMapper.xml @@ -73,6 +73,7 @@ AND createTime <= #{logEndTime} + order by createTime desc limit #{currentPage},#{items}