Commit 118b306a by 周海峰

分组

parent 0c051ab4
-- 添加分组菜单
INSERT INTO `platform_auth`.`platform_sys_menu` (`id`, `parentId`, `path`, `icon`, `title`, `name`, `leftMemu`,
`functionCode`, `isLock`, `sort`, `webtype`)
VALUES ('1482f54ad33a4266a3528cc2b7924a25', '7', '/platformapplicationsGroup', 'group', '应用分组',
'platformapplicationsGroup', 'true', 'platformapplicationsGroup', NULL, '1', NULL);
ALTER TABLE `platform_auth`.`platform_applications`
ADD COLUMN `group_code` varchar(20) NULL COMMENT '分组编码' AFTER `mailtype`;
\ No newline at end of file
......@@ -225,6 +225,11 @@
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build>
......@@ -234,20 +239,38 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--mybatis自动生成代码插件-->
<!-- <plugin>-->
<!-- <groupId>org.mybatis.generator</groupId>-->
<!-- <artifactId>mybatis-generator-maven-plugin</artifactId>-->
<!-- <version>1.3.6</version>-->
<!-- <configuration>-->
<!-- &lt;!&ndash; 是否覆盖,true表示会替换生成的JAVA文件,false则不覆盖 &ndash;&gt;-->
<!-- <overwrite>false</overwrite>-->
<!-- </configuration>-->
<!-- <dependencies>-->
<!-- &lt;!&ndash;mysql驱动包&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- <version>5.1.45</version>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </plugin>-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.6</version>
<version>1.3.2</version>
<configuration>
<!-- 是否覆盖,true表示会替换生成的JAVA文件,false则不覆盖 -->
<overwrite>false</overwrite>
<!-- mybatis用于生成代码的配置文件 -->
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<!--mysql驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
<version>8.0.15</version>
</dependency>
</dependencies>
</plugin>
......
......@@ -27,7 +27,6 @@ public class PlatformApplicationsController {
@PostMapping("/save")
public ResultJson saveApp(@RequestBody PlatformApplications platformApplications) throws Exception {
int count = platformApplicationsService.savaApp(platformApplications);
if(count>0){
return ResultJson.ok();
......
package com.metro.auth.platform.controller;
import com.metro.auth.platform.domain.ResultCode;
import com.metro.auth.platform.domain.ResultJson;
import com.metro.auth.platform.domain.auth.PlatformApplicationsGroup;
import com.metro.auth.platform.service.PlatformApplicationsGroupService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/applicationsGroup")
public class PlatformApplicationsGroupController {
@Resource
PlatformApplicationsGroupService platformApplicationsGroupService;
/**
* 分组列表
*
* @param platformApplicationsGroup
* @return resultJson
*/
@GetMapping("/list")
public ResultJson list(PlatformApplicationsGroup platformApplicationsGroup) {
List<PlatformApplicationsGroup> list = platformApplicationsGroupService.selectList(platformApplicationsGroup);
return ResultJson.ok(list);
}
@PostMapping("/add")
public ResultJson add(@RequestBody PlatformApplicationsGroup platformApplicationsGroup) {
int count = platformApplicationsGroupService.insert(platformApplicationsGroup);
if (count > 0) {
return ResultJson.ok();
} else {
return ResultJson.failure(ResultCode.RESPONSE_ERROR);
}
}
@PostMapping("/update")
public ResultJson update(@RequestBody PlatformApplicationsGroup platformApplicationsGroup) {
int count = platformApplicationsGroupService.updateByPrimaryKeySelective(platformApplicationsGroup);
if (count > 0) {
return ResultJson.ok();
} else {
return ResultJson.failure(ResultCode.RESPONSE_ERROR);
}
}
@PostMapping("/delete")
public ResultJson delete(@RequestBody PlatformApplicationsGroup platformApplicationsGroup) {
int count = platformApplicationsGroupService.deleteByPrimaryKey(platformApplicationsGroup.getId());
if (count > 0) {
return ResultJson.ok();
} else {
return ResultJson.failure(ResultCode.RESPONSE_ERROR);
}
}
}
......@@ -101,6 +101,15 @@ public class PlatformApplications implements Serializable {
private String mailtype;
private String groupCode;
public String getGroupCode() {
return groupCode;
}
public void setGroupCode(String groupCode) {
this.groupCode = groupCode;
}
public int getOpenmail() {
return openmail;
......
package com.metro.auth.platform.domain.auth;
import java.io.Serializable;
import java.util.Date;
public class PlatformApplicationsGroup implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications_group.id
*
* @mbggenerated
*/
private Integer id;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications_group.group_name
*
* @mbggenerated
*/
private String groupName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications_group.group_code
*
* @mbggenerated
*/
private String groupCode;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications_group.sort_index
*
* @mbggenerated
*/
private Integer sortIndex;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications_group.create_time
*
* @mbggenerated
*/
private Date createTime;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column platform_applications_group.update_by
*
* @mbggenerated
*/
private String updateBy;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
private static final long serialVersionUID = 1L;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications_group.id
*
* @return the value of platform_applications_group.id
*
* @mbggenerated
*/
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications_group.id
*
* @param id the value for platform_applications_group.id
*
* @mbggenerated
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications_group.group_name
*
* @return the value of platform_applications_group.group_name
*
* @mbggenerated
*/
public String getGroupName() {
return groupName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications_group.group_name
*
* @param groupName the value for platform_applications_group.group_name
*
* @mbggenerated
*/
public void setGroupName(String groupName) {
this.groupName = groupName;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications_group.group_code
*
* @return the value of platform_applications_group.group_code
*
* @mbggenerated
*/
public String getGroupCode() {
return groupCode;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications_group.group_code
*
* @param groupCode the value for platform_applications_group.group_code
*
* @mbggenerated
*/
public void setGroupCode(String groupCode) {
this.groupCode = groupCode;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications_group.sort_index
*
* @return the value of platform_applications_group.sort_index
*
* @mbggenerated
*/
public Integer getSortIndex() {
return sortIndex;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications_group.sort_index
*
* @param sortIndex the value for platform_applications_group.sort_index
*
* @mbggenerated
*/
public void setSortIndex(Integer sortIndex) {
this.sortIndex = sortIndex;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications_group.create_time
*
* @return the value of platform_applications_group.create_time
*
* @mbggenerated
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications_group.create_time
*
* @param createTime the value for platform_applications_group.create_time
*
* @mbggenerated
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column platform_applications_group.update_by
*
* @return the value of platform_applications_group.update_by
*
* @mbggenerated
*/
public String getUpdateBy() {
return updateBy;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column platform_applications_group.update_by
*
* @param updateBy the value for platform_applications_group.update_by
*
* @mbggenerated
*/
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
}
\ No newline at end of file
package com.metro.auth.platform.mapper;
import com.metro.auth.platform.domain.auth.PlatformApplicationsGroup;
import java.util.List;
public interface PlatformApplicationsGroupMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int insert(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int insertSelective(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
PlatformApplicationsGroup selectByPrimaryKey(Integer id);
List<PlatformApplicationsGroup> selectList(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int updateByPrimaryKeySelective(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int updateByPrimaryKey(PlatformApplicationsGroup record);
}
\ No newline at end of file
<?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.metro.auth.platform.mapper.PlatformApplicationsGroupMapper">
<resultMap id="BaseResultMap" type="com.metro.auth.platform.domain.auth.PlatformApplicationsGroup">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="group_name" property="groupName" jdbcType="VARCHAR"/>
<result column="group_code" property="groupCode" jdbcType="VARCHAR"/>
<result column="sort_index" property="sortIndex" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, group_name, group_code, sort_index, create_time, update_by
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List"/>
from platform_applications_group
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectList" resultMap="BaseResultMap"
parameterType="com.metro.auth.platform.domain.auth.PlatformApplicationsGroup">
select
<include refid="Base_Column_List"/>
from platform_applications_group
<where>
<if test="groupName!=null and groupName!=''">
and group_name = #{groupName}
</if>
<if test="groupCode!=null and groupCode!=''">
and group_code = #{groupCode}
</if>
</where>
order by sort_index asc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from platform_applications_group
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.metro.auth.platform.domain.auth.PlatformApplicationsGroup">
insert into platform_applications_group (id, group_name, group_code,
sort_index, create_time, update_by
)
values (#{id,jdbcType=INTEGER}, #{groupName,jdbcType=VARCHAR}, #{groupCode,jdbcType=VARCHAR},
#{sortIndex,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.metro.auth.platform.domain.auth.PlatformApplicationsGroup">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into platform_applications_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="groupName != null">
group_name,
</if>
<if test="groupCode != null">
group_code,
</if>
<if test="sortIndex != null">
sort_index,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="groupName != null">
#{groupName,jdbcType=VARCHAR},
</if>
<if test="groupCode != null">
#{groupCode,jdbcType=VARCHAR},
</if>
<if test="sortIndex != null">
#{sortIndex,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="com.metro.auth.platform.domain.auth.PlatformApplicationsGroup">
update platform_applications_group
<set>
<if test="groupName != null">
group_name = #{groupName,jdbcType=VARCHAR},
</if>
<if test="groupCode != null">
group_code = #{groupCode,jdbcType=VARCHAR},
</if>
<if test="sortIndex != null">
sort_index = #{sortIndex,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.metro.auth.platform.domain.auth.PlatformApplicationsGroup">
update platform_applications_group
set group_name = #{groupName,jdbcType=VARCHAR},
group_code = #{groupCode,jdbcType=VARCHAR},
sort_index = #{sortIndex,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
package com.metro.auth.platform.service;
import com.metro.auth.platform.domain.auth.PlatformApplicationsGroup;
import java.util.List;
public interface PlatformApplicationsGroupService {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int insert(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int insertSelective(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
PlatformApplicationsGroup selectByPrimaryKey(Integer id);
List<PlatformApplicationsGroup> selectList(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int updateByPrimaryKeySelective(PlatformApplicationsGroup record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table platform_applications_group
*
* @mbggenerated
*/
int updateByPrimaryKey(PlatformApplicationsGroup record);
}
package com.metro.auth.platform.service;
import com.metro.auth.platform.domain.auth.PlatformApplications;
import com.metro.auth.platform.domain.auth.PlatformApplicationsGroup;
import com.metro.auth.platform.mapper.PlatformApplicationsGroupMapper;
import com.metro.auth.platform.mapper.PlatformApplicationsMapper;
import com.metro.auth.platform.utils.DateUtil;
import com.metro.auth.platform.utils.StrUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class PlatformApplicationsGroupServiceImpl implements PlatformApplicationsGroupService {
@Resource
private PlatformApplicationsGroupMapper platformApplicationsGroupMapper;
@Resource
private PlatformApplicationsMapper platformApplicationsMapper;
@Override
public int deleteByPrimaryKey(Integer id) {
PlatformApplicationsGroup platformApplicationsGroup = selectByPrimaryKey(id);
List<PlatformApplications> platformApplicationsList = platformApplicationsMapper.getPlatformApplicationsList();
if (!CollectionUtils.isEmpty(platformApplicationsList) &&
platformApplicationsList.stream().anyMatch(app -> platformApplicationsGroup.getGroupCode().equals(app.getGroupCode()))) {
throw new RuntimeException("该分组下存在应用,不能删除!");
}
return platformApplicationsGroupMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(PlatformApplicationsGroup record) {
List<PlatformApplicationsGroup> platformApplicationsGroups = platformApplicationsGroupMapper.selectList(new PlatformApplicationsGroup());
String newGroupCode;
if (platformApplicationsGroups.isEmpty()) {
newGroupCode = "GRP001";
record.setSortIndex(1);
} else {
platformApplicationsGroups.sort((a, b) -> b.getGroupCode().compareTo(a.getGroupCode()));
String maxGroupCode = platformApplicationsGroups.get(0).getGroupCode();
int numericPart = Integer.parseInt(maxGroupCode.substring(3));
newGroupCode = "GRP" + StrUtil.padLeftZeros(numericPart + 1, 3);
record.setSortIndex(numericPart + 1);
}
record.setGroupCode(newGroupCode);
record.setCreateTime(new Date());
return platformApplicationsGroupMapper.insert(record);
}
@Override
public int insertSelective(PlatformApplicationsGroup record) {
return platformApplicationsGroupMapper.insertSelective(record);
}
@Override
public PlatformApplicationsGroup selectByPrimaryKey(Integer id) {
return platformApplicationsGroupMapper.selectByPrimaryKey(id);
}
@Override
public List<PlatformApplicationsGroup> selectList(PlatformApplicationsGroup record) {
return platformApplicationsGroupMapper.selectList(record);
}
@Override
public int updateByPrimaryKeySelective(PlatformApplicationsGroup record) {
return platformApplicationsGroupMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(PlatformApplicationsGroup record) {
return platformApplicationsGroupMapper.updateByPrimaryKey(record);
}
}
......@@ -149,6 +149,14 @@ public class StrUtil {
}
public static String padLeftZeros(int i, int i1) {
StringBuilder str = new StringBuilder(String.valueOf(i));
while (str.length() < i1) {
str.insert(0, "0");
}
return str.toString();
}
// public static void main(String[] args) {
// String str1 = "9,72";
// String str2 = "72,9";
......
......@@ -20,10 +20,10 @@
</commentGenerator>
<!-- 数据库连接,直接通过${}读取application.properties里的配置 -->
<jdbcConnection
driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://36.138.62.89:33063/platform-auth?useUnicode=true&amp;characterEncoding=UTF-8"
driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/platform_auth?serverTimezone=GMT&amp;nullCatalogMeansCurrent=true&amp;useUnicode=true&amp;characterEncoding=UTF-8"
userId="root"
password="!QAZ2wsx#EDC2022"/>
password="Aa123456"/>
<!-- 生成POJO对象,并将类放到com.songguoliang.springboot.entity包下 -->
<javaModelGenerator targetPackage="com.metro.auth.platform.domain.auth" targetProject="src/main/java"></javaModelGenerator>
......@@ -34,12 +34,10 @@
<javaClientGenerator targetPackage="com.metro.auth.platform.mapper" targetProject="src/main/java" type="XMLMAPPER"></javaClientGenerator>
<!-- table标签可以有多个,至少一个,tableName指定表名,可以使用_和%通配符 -->
<table tableName="history_today">
<!-- 是否只生成POJO对象 -->
<property name="modelOnly" value="false"/>
<!-- 数据库中表名有时我们都会带个前缀,而实体又不想带前缀,这个配置可以把实体的前缀去掉 -->
<domainObjectRenamingRule searchString="^Platform" replaceString="Platform"/>
<table tableName="platform_applications_group" domainObjectName="platformApplicationsGroup"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
<property name="useActualColumnNames" value="false"/>
</table>
</context>
</generatorConfiguration>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论