Commit f07f41b4 by guojuxing

账号分组接口

parent 751cc287
package com.gic.auth.dao.mapper;
import com.gic.auth.entity.TabSysAccountGroup;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabSysAccountGroupMapper {
/**
* 根据主键删除
*
* @param accountGroupId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer accountGroupId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabSysAccountGroup record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabSysAccountGroup record);
/**
* 根据主键查询
*
* @param accountGroupId 主键
* @return 实体对象
*/
TabSysAccountGroup selectByPrimaryKey(Integer accountGroupId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabSysAccountGroup record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabSysAccountGroup record);
/**
* 最大排序值
* @Title: getMaxSortValueByEnterpriseId

* @Description:

 * @author guojuxing
* @param enterpriseId

* @return int


 */
int getMaxSortValueByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
/**
* 查询同名称个数,用于校验重复
* @Title: countByAccountGroupName

* @Description:

 * @author guojuxing
* @param enterpriseId
* @param accountGroupId
* @param accountGroupName

* @return int


 */
int countByAccountGroupName(@Param("enterpriseId") Integer enterpriseId,
@Param("accountGroupId") Integer accountGroupId, @Param("accountGroupName") String accountGroupName);
/**
* 查询列表
* @Title: listAccountGroupByEnterpriseId

* @Description:

 * @author guojuxing
* @param enterpriseId

* @return java.util.List<com.gic.auth.entity.TabSysAccountGroup>


 */
List<TabSysAccountGroup> listAccountGroupByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
}
\ No newline at end of file
package com.gic.auth.entity;
import java.util.Date;
/**
* tab_sys_account_group
*/
public class TabSysAccountGroup {
/**
* ID
*/
private Integer accountGroupId;
/**
* 账号名称
*/
private String accountGroupName;
/**
*
*/
private Integer enterpriseId;
/**
* 1:有效 0:无效
*/
private Integer status;
/**
* 排序
*/
private Integer sort;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
public Integer getAccountGroupId() {
return accountGroupId;
}
public void setAccountGroupId(Integer accountGroupId) {
this.accountGroupId = accountGroupId;
}
public String getAccountGroupName() {
return accountGroupName;
}
public void setAccountGroupName(String accountGroupName) {
this.accountGroupName = accountGroupName;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.auth.service;
import com.gic.auth.dto.AccountGroupDTO;
import com.gic.auth.entity.TabSysAccountGroup;
import java.util.List;
/**
* 账号分组
* @ClassName: AccountGroupService

* @Description: 

* @author guojuxing

* @date 2019/10/28 4:11 PM

*/
public interface AccountGroupService {
/**
* 账号分组新增
* @Title: save

* @Description:

 * @author guojuxing
* @param dto

* @return int


 */
int save(AccountGroupDTO dto);
/**
* 编辑
* @Title: update

* @Description:

 * @author guojuxing
* @param dto

* @return int


 */
int update(AccountGroupDTO dto);
/**
* 获取数据库最大排序值
* @Title: getMaxSortValueByEnterpriseId

* @Description:

 * @author guojuxing
* @param enterpriseId

* @return int


 */
int getMaxSortValueByEnterpriseId(Integer enterpriseId);
/**
* 校验名称是否重复
* @Title: isAccountGroupNameRepeat

* @Description:

 * @author guojuxing
* @param enterpriseId
* @param accountGroupId
* @param accountGroupName

* @return boolean


 */
boolean isAccountGroupNameRepeat(Integer enterpriseId, Integer accountGroupId, String accountGroupName);
/**
* 根据逐渐查询数据
* @Title: getById

* @Description:

 * @author guojuxing
* @param accountGroupId

* @return com.gic.auth.entity.TabSysAccountGroup


 */
TabSysAccountGroup getById(Integer accountGroupId);
/**
* 查询列表
* @Title: listAccountGroupByEnterpriseId

* @Description:

 * @author guojuxing
* @param enterpriseId

* @return java.util.List<com.gic.auth.entity.TabSysAccountGroup>


 */
List<TabSysAccountGroup> listAccountGroupByEnterpriseId(Integer enterpriseId);
/**
* 逻辑删除
* @Title: updateStatusByAccountGroupId

* @Description:

 * @author guojuxing
* @param accountGroupId

* @return int


 */
int updateStatusByAccountGroupId(Integer accountGroupId);
}
package com.gic.auth.service.impl;
import com.gic.auth.dao.mapper.TabSysAccountGroupMapper;
import com.gic.auth.dto.AccountGroupDTO;
import com.gic.auth.entity.TabSysAccountGroup;
import com.gic.auth.service.AccountGroupService;
import com.gic.commons.util.EntityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service("AccountGroupService")
public class AccountGroupServiceImpl implements AccountGroupService{
@Autowired
private TabSysAccountGroupMapper tabSysAccountGroupMapper;
@Override
public int save(AccountGroupDTO dto) {
dto.setStatus(1);
dto.setCreateTime(new Date());
dto.setUpdateTime(new Date());
TabSysAccountGroup record = EntityUtil.changeEntityNew(TabSysAccountGroup.class, dto);
return tabSysAccountGroupMapper.insert(record);
}
@Override
public int update(AccountGroupDTO dto) {
dto.setUpdateTime(new Date());
TabSysAccountGroup record = EntityUtil.changeEntityNew(TabSysAccountGroup.class, dto);
return tabSysAccountGroupMapper.updateByPrimaryKeySelective(record);
}
@Override
public int getMaxSortValueByEnterpriseId(Integer enterpriseId) {
return tabSysAccountGroupMapper.getMaxSortValueByEnterpriseId(enterpriseId);
}
@Override
public boolean isAccountGroupNameRepeat(Integer enterpriseId, Integer accountGroupId, String accountGroupName) {
int count = tabSysAccountGroupMapper.countByAccountGroupName(enterpriseId, accountGroupId, accountGroupName);
if (count > 0) {
return true;
}
return false;
}
@Override
public TabSysAccountGroup getById(Integer accountGroupId) {
return tabSysAccountGroupMapper.selectByPrimaryKey(accountGroupId);
}
@Override
public List<TabSysAccountGroup> listAccountGroupByEnterpriseId(Integer enterpriseId) {
return tabSysAccountGroupMapper.listAccountGroupByEnterpriseId(enterpriseId);
}
@Override
public int updateStatusByAccountGroupId(Integer accountGroupId) {
TabSysAccountGroup record = new TabSysAccountGroup();
record.setAccountGroupId(accountGroupId);
record.setStatus(0);
return tabSysAccountGroupMapper.updateByPrimaryKeySelective(record);
}
}
package com.gic.auth.service.outer.impl;
import com.gic.auth.entity.TabSysAccountGroup;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.error.ErrorCode;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.AccountGroupDTO;
import com.gic.auth.service.AccountGroupApiService;
import com.gic.auth.service.AccountGroupService;
import com.gic.enterprise.utils.valid.ValidParamsUtils;
import java.util.ArrayList;
import java.util.List;
@Service("AccountGroupApiService")
public class AccountGroupApiServiceImpl implements AccountGroupApiService{
@Autowired
private AccountGroupService accountGroupService;
@Override
public ServiceResponse<Integer> save(AccountGroupDTO dto) {
ServiceResponse paramValid = ValidParamsUtils.allCheckValidate(AccountGroupDTO.class, AccountGroupDTO.SaveValid.class);
if (!paramValid.isSuccess()) {
return paramValid;
}
if (accountGroupService.isAccountGroupNameRepeat(dto.getEnterpriseId(), null, dto.getAccountGroupName())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组名称不能重复");
}
//sort值设置
int maxSortValue = accountGroupService.getMaxSortValueByEnterpriseId(dto.getEnterpriseId());
dto.setSort(maxSortValue + 1);
return ServiceResponse.success(accountGroupService.save(dto));
}
@Override
public ServiceResponse<Integer> update(AccountGroupDTO dto) {
TabSysAccountGroup record = accountGroupService.getById(dto.getAccountGroupId());
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组id有误,查无数据");
}
ServiceResponse paramValid = ValidParamsUtils.allCheckValidate(AccountGroupDTO.class, AccountGroupDTO.EditValid.class);
if (!paramValid.isSuccess()) {
return paramValid;
}
if (accountGroupService.isAccountGroupNameRepeat(dto.getEnterpriseId(), dto.getAccountGroupId(), dto.getAccountGroupName())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组名称不能重复");
}
dto.setEnterpriseId(record.getEnterpriseId());
dto.setSort(record.getSort());
return ServiceResponse.success(accountGroupService.update(dto));
}
@Override
public ServiceResponse<List<AccountGroupDTO>> listAccountGroupByEnterpriseId(Integer enterpriseId) {
List<TabSysAccountGroup> list = accountGroupService.listAccountGroupByEnterpriseId(enterpriseId);
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(EntityUtil.changeEntityListNew(AccountGroupDTO.class, list));
}
return ServiceResponse.success(new ArrayList<>());
}
@Override
public ServiceResponse<Void> deleteByAccountGroupId(Integer accountGroupId) {
TabSysAccountGroup record = accountGroupService.getById(accountGroupId);
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组id有误,查无数据");
}
//逻辑删除分组
accountGroupService.updateStatusByAccountGroupId(accountGroupId);
//todo 删除组员分组关系数据
return ServiceResponse.success();
}
}
......@@ -43,4 +43,7 @@
<dubbo:reference interface="com.gic.store.service.StoreAuthorizationApiService" id="storeAuthorizationApiService" timeout="6000">
<dubbo:method name="authStore" async="true"/>
</dubbo:reference>
<!--账号分组-->
<dubbo:service interface="com.gic.auth.service.AccountGroupApiService" ref="accountGroupApiService" timeout="6000" />
<!--角色-->
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.auth.dao.mapper.TabSysAccountGroupMapper">
<resultMap id="BaseResultMap" type="com.gic.auth.entity.TabSysAccountGroup">
<id column="account_group_id" jdbcType="INTEGER" property="accountGroupId" />
<result column="account_group_name" jdbcType="VARCHAR" property="accountGroupName" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
account_group_id, account_group_name, enterprise_id, status, sort, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_account_group
where account_group_id = #{accountGroupId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_sys_account_group
where account_group_id = #{accountGroupId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.auth.entity.TabSysAccountGroup">
insert into tab_sys_account_group (account_group_id, account_group_name,
enterprise_id, status, sort,
create_time, update_time)
values (#{accountGroupId,jdbcType=INTEGER}, #{accountGroupName,jdbcType=VARCHAR},
#{enterpriseId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{sort,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.auth.entity.TabSysAccountGroup">
insert into tab_sys_account_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="accountGroupId != null">
account_group_id,
</if>
<if test="accountGroupName != null">
account_group_name,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="status != null">
status,
</if>
<if test="sort != null">
sort,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="accountGroupId != null">
#{accountGroupId,jdbcType=INTEGER},
</if>
<if test="accountGroupName != null">
#{accountGroupName,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.auth.entity.TabSysAccountGroup">
update tab_sys_account_group
<set>
<if test="accountGroupName != null">
account_group_name = #{accountGroupName,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where account_group_id = #{accountGroupId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.auth.entity.TabSysAccountGroup">
update tab_sys_account_group
set account_group_name = #{accountGroupName,jdbcType=VARCHAR},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
sort = #{sort,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where account_group_id = #{accountGroupId,jdbcType=INTEGER}
</update>
<select id="getMaxSortValueByEnterpriseId" resultType="int">
SELECT ifnull(max(sort), 0)
from tab_sys_account_group
where status = 1
and enterprise_id = #{enterpriseId}
</select>
<select id="countByAccountGroupName" resultType="int">
SELECT count(1)
from tab_sys_account_group
where status = 1
and enterprise_id = #{enterpriseId}
<if test="accountGroupId != null">
and account_group_id &lt;&gt; #{accountGroupId}
</if>
and account_group_name = #{accountGroupName}
</select>
<select id="listAccountGroupByEnterpriseId" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
from tab_sys_account_group
where status = 1
and enterprise_id = #{enterpriseId}
order by sort
</select>
</mapper>
\ No newline at end of file
......@@ -55,4 +55,6 @@
<!--受审项目-->
<dubbo:reference interface= "com.gic.enterprise.service.ProjectApiService" id="projectApiService" timeout="6000" />
<dubbo:reference interface="com.gic.goods.api.service.GoodsRightsSelectorApiService" id="goodsRightsSelectorApiService" timeout="60000" retries="0" />
<!--账号分组-->
<dubbo:reference interface="com.gic.auth.service.AccountGroupApiService" id="accountGroupApiService" timeout="6000" />
</beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment