后勤平台 修改数据库连接 添加公司管理的增删改查 修改用户mapper 大小写问题
正在显示
10 个修改的文件
包含
356 行增加
和
12 行删除
@@ -47,9 +47,9 @@ spring: | @@ -47,9 +47,9 @@ spring: | ||
47 | #username=CGOETL | 47 | #username=CGOETL |
48 | #password=1q2w3e4r | 48 | #password=1q2w3e4r |
49 | #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 | 49 | #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 |
50 | - url: jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8 | ||
51 | - username: root | ||
52 | - password: | 50 | + url: jdbc:mysql://118.31.66.166:3306/HQPT_USER?useUnicode=true&characterEncoding=utf8 |
51 | + username: 110 | ||
52 | + password: QAHqCJf2kFYCLirM | ||
53 | driver-class-name: com.mysql.jdbc.Driver | 53 | driver-class-name: com.mysql.jdbc.Driver |
54 | max-idle: 10 | 54 | max-idle: 10 |
55 | max-wait: 10000 | 55 | max-wait: 10000 |
@@ -121,4 +121,4 @@ logging: | @@ -121,4 +121,4 @@ logging: | ||
121 | #日志配置,输出到文本, | 121 | #日志配置,输出到文本, |
122 | #Java Web Token 时效时间,单位秒 | 122 | #Java Web Token 时效时间,单位秒 |
123 | jwt: | 123 | jwt: |
124 | - max-alive: 300 | 124 | + max-alive: 30000 |
1 | +package com.tianbo.warehouse.controller; | ||
2 | + | ||
3 | +import com.github.pagehelper.PageInfo; | ||
4 | +import com.tianbo.warehouse.annotation.LogAnnotation; | ||
5 | +import com.tianbo.warehouse.controller.response.ResultJson; | ||
6 | +import com.tianbo.warehouse.model.Company; | ||
7 | +import com.tianbo.warehouse.service.CompanyService; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.web.bind.annotation.*; | ||
10 | + | ||
11 | +import javax.servlet.http.HttpServletRequest; | ||
12 | +import javax.servlet.http.HttpServletResponse; | ||
13 | +import javax.validation.Valid; | ||
14 | + | ||
15 | +@RestController | ||
16 | +@RequestMapping("/company") | ||
17 | +public class CompanyController { | ||
18 | + | ||
19 | + @Autowired | ||
20 | + CompanyService companyService; | ||
21 | + | ||
22 | + @GetMapping("/list") | ||
23 | + public PageInfo<Company> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1") | ||
24 | + int pageNum, | ||
25 | + @RequestParam(value = "pageSize",required = false,defaultValue = "5") | ||
26 | + int pageSize){ | ||
27 | + return companyService.findAll(pageNum,pageSize); | ||
28 | + | ||
29 | + } | ||
30 | + | ||
31 | + @LogAnnotation(moduleName = "公司管理",operate = "公司添加") | ||
32 | + @PostMapping("/add") | ||
33 | + public ResultJson add(@RequestBody Company company){ | ||
34 | + | ||
35 | + int i =companyService.insertSelective(company); | ||
36 | + | ||
37 | + ResultJson resultJson = new ResultJson(); | ||
38 | + if (1==i){ | ||
39 | + resultJson = new ResultJson("200","添加成功"); | ||
40 | + }else { | ||
41 | + resultJson = new ResultJson("500","insert faild"); | ||
42 | + } | ||
43 | + return resultJson; | ||
44 | + } | ||
45 | + | ||
46 | + @LogAnnotation(moduleName = "公司管理",operate = "公司修改") | ||
47 | + @PutMapping("/edit") | ||
48 | + @ResponseBody | ||
49 | + public ResultJson edit(@RequestBody @Valid Company company){ | ||
50 | + | ||
51 | + int i =companyService.updateByPrimaryKeySelective(company); | ||
52 | + | ||
53 | + ResultJson resultJson = new ResultJson(); | ||
54 | + if (1==i){ | ||
55 | + resultJson = new ResultJson("200","修改成功"); | ||
56 | + }else { | ||
57 | + resultJson = new ResultJson("500","insert faild"); | ||
58 | + } | ||
59 | + return resultJson; | ||
60 | + } | ||
61 | + | ||
62 | + @LogAnnotation(moduleName = "公司管理",operate = "公司删除") | ||
63 | + @DeleteMapping("/del") | ||
64 | + public ResultJson reomve(@RequestBody Company company, HttpServletRequest request, HttpServletResponse response){ | ||
65 | + | ||
66 | + int i =companyService.deleteByPrimaryKey(company.getCompanyId()); | ||
67 | + | ||
68 | + ResultJson resultJson = new ResultJson(); | ||
69 | + if (1==i){ | ||
70 | + resultJson = new ResultJson("200","修改成功"); | ||
71 | + }else { | ||
72 | + resultJson = new ResultJson("500","insert faild"); | ||
73 | + } | ||
74 | + return resultJson; | ||
75 | + } | ||
76 | + | ||
77 | + @LogAnnotation(moduleName = "公司管理",operate = "公司批量删除") | ||
78 | + @GetMapping("/batchremove") | ||
79 | + public ResultJson reomve(String ids, HttpServletRequest request, HttpServletResponse response){ | ||
80 | + | ||
81 | + ResultJson resultJson = new ResultJson(); | ||
82 | + | ||
83 | + if (companyService.deleteByPrimaryKey(ids)>0){ | ||
84 | + resultJson = new ResultJson("200","修改成功"); | ||
85 | + }else { | ||
86 | + resultJson = new ResultJson("500","insert faild"); | ||
87 | + } | ||
88 | + return resultJson; | ||
89 | + } | ||
90 | + | ||
91 | +} |
1 | +package com.tianbo.warehouse.dao; | ||
2 | + | ||
3 | +import com.tianbo.warehouse.model.Company; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +public interface CompanyMapper { | ||
8 | + int deleteByPrimaryKey(String companyId); | ||
9 | + | ||
10 | + int insert(Company record); | ||
11 | + | ||
12 | + int insertSelective(Company record); | ||
13 | + | ||
14 | + Company selectByPrimaryKey(String companyId); | ||
15 | + | ||
16 | + int updateByPrimaryKeySelective(Company record); | ||
17 | + | ||
18 | + int updateByPrimaryKey(Company record); | ||
19 | + | ||
20 | + List<Company> findAll(); | ||
21 | +} |
1 | +package com.tianbo.warehouse.model; | ||
2 | + | ||
3 | +import java.util.Date; | ||
4 | + | ||
5 | +public class Company { | ||
6 | + private String companyId; | ||
7 | + | ||
8 | + private String companyName; | ||
9 | + | ||
10 | + private String groupId; | ||
11 | + | ||
12 | + private Date creatTime; | ||
13 | + | ||
14 | + private String companyStatus; | ||
15 | + | ||
16 | + public String getCompanyId() { | ||
17 | + return companyId; | ||
18 | + } | ||
19 | + | ||
20 | + public void setCompanyId(String companyId) { | ||
21 | + this.companyId = companyId == null ? null : companyId.trim(); | ||
22 | + } | ||
23 | + | ||
24 | + public String getCompanyName() { | ||
25 | + return companyName; | ||
26 | + } | ||
27 | + | ||
28 | + public void setCompanyName(String companyName) { | ||
29 | + this.companyName = companyName == null ? null : companyName.trim(); | ||
30 | + } | ||
31 | + | ||
32 | + public String getGroupId() { | ||
33 | + return groupId; | ||
34 | + } | ||
35 | + | ||
36 | + public void setGroupId(String groupId) { | ||
37 | + this.groupId = groupId == null ? null : groupId.trim(); | ||
38 | + } | ||
39 | + | ||
40 | + public Date getCreatTime() { | ||
41 | + return creatTime; | ||
42 | + } | ||
43 | + | ||
44 | + public void setCreatTime(Date creatTime) { | ||
45 | + this.creatTime = creatTime; | ||
46 | + } | ||
47 | + | ||
48 | + public String getCompanyStatus() { | ||
49 | + return companyStatus; | ||
50 | + } | ||
51 | + | ||
52 | + public void setCompanyStatus(String companyStatus) { | ||
53 | + this.companyStatus = companyStatus == null ? null : companyStatus.trim(); | ||
54 | + } | ||
55 | +} |
1 | +package com.tianbo.warehouse.service; | ||
2 | + | ||
3 | +import com.github.pagehelper.PageInfo; | ||
4 | +import com.tianbo.warehouse.model.Company; | ||
5 | + | ||
6 | +public interface CompanyService { | ||
7 | + | ||
8 | + PageInfo<Company> findAll(int pageNum, int pageSize); | ||
9 | + | ||
10 | + int insertSelective(Company company); | ||
11 | + | ||
12 | + int updateByPrimaryKeySelective(Company company); | ||
13 | + | ||
14 | + int deleteByPrimaryKey(String companyId); | ||
15 | + | ||
16 | +} |
1 | +package com.tianbo.warehouse.service.imp; | ||
2 | + | ||
3 | +import com.github.pagehelper.Page; | ||
4 | +import com.github.pagehelper.PageHelper; | ||
5 | +import com.github.pagehelper.PageInfo; | ||
6 | +import com.tianbo.warehouse.dao.CompanyMapper; | ||
7 | +import com.tianbo.warehouse.model.Company; | ||
8 | +import com.tianbo.warehouse.service.CompanyService; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.stereotype.Service; | ||
11 | + | ||
12 | +import java.util.Date; | ||
13 | +import java.util.List; | ||
14 | +import java.util.UUID; | ||
15 | + | ||
16 | +@Service | ||
17 | +public class CompanyServiceImp implements CompanyService { | ||
18 | + | ||
19 | + @Autowired | ||
20 | + CompanyMapper companyMapper; | ||
21 | + | ||
22 | + @Override | ||
23 | + public PageInfo<Company> findAll(int pageNum, int pageSize) { | ||
24 | + Page<Company> page = PageHelper.startPage(pageNum,pageSize); | ||
25 | + List<Company> list = companyMapper.findAll(); | ||
26 | + PageInfo<Company> result = new PageInfo<>(list); | ||
27 | + return result; | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public int insertSelective(Company company) { | ||
32 | + company.setCompanyId(UUID.randomUUID().toString()); | ||
33 | + company.setCreatTime(new Date()); | ||
34 | + return companyMapper.insertSelective(company); | ||
35 | + } | ||
36 | + | ||
37 | + @Override | ||
38 | + public int updateByPrimaryKeySelective(Company company) { | ||
39 | + company.setCreatTime(new Date()); | ||
40 | + return companyMapper.updateByPrimaryKeySelective(company); | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public int deleteByPrimaryKey(String companyId) { | ||
45 | + if (companyId.contains(",")){ | ||
46 | + try { | ||
47 | + String[] split = companyId.split(","); | ||
48 | + for (int i=0; i<split.length; i++){ | ||
49 | + companyMapper.deleteByPrimaryKey(split[i]); | ||
50 | + } | ||
51 | + return 1; | ||
52 | + }catch (Exception e){ | ||
53 | + e.printStackTrace(); | ||
54 | + return 0; | ||
55 | + } | ||
56 | + }else { | ||
57 | + return companyMapper.deleteByPrimaryKey(companyId); | ||
58 | + } | ||
59 | + } | ||
60 | +} |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> | 4 | "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> |
5 | <generatorConfiguration> | 5 | <generatorConfiguration> |
6 | <!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包--> | 6 | <!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包--> |
7 | - <classPathEntry location="/Users/mrz/Downloads/mybatis-generator-core-1.3.2/lib/mysql-connector-java-5.1.25-bin.jar"/> | 7 | + <classPathEntry location="/Users/shenhailong/.m2/repository/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar"/> |
8 | <!--<classPathEntry location="/Users/mrz/Documents/maven/ojdbc6.jar"/>--> | 8 | <!--<classPathEntry location="/Users/mrz/Documents/maven/ojdbc6.jar"/>--> |
9 | <context id="DB2Tables" targetRuntime="MyBatis3"> | 9 | <context id="DB2Tables" targetRuntime="MyBatis3"> |
10 | <commentGenerator> | 10 | <commentGenerator> |
@@ -14,9 +14,9 @@ | @@ -14,9 +14,9 @@ | ||
14 | </commentGenerator> | 14 | </commentGenerator> |
15 | <!--数据库链接URL,用户名、密码 --> | 15 | <!--数据库链接URL,用户名、密码 --> |
16 | <jdbcConnection driverClass="com.mysql.jdbc.Driver" | 16 | <jdbcConnection driverClass="com.mysql.jdbc.Driver" |
17 | - connectionURL="jdbc:mysql://127.0.0.1:3307/statistics" | ||
18 | - userId="root" | ||
19 | - password=""> | 17 | + connectionURL="jdbc:mysql://118.31.66.166:3306/HQPT_USER" |
18 | + userId="110" | ||
19 | + password="QAHqCJf2kFYCLirM"> | ||
20 | </jdbcConnection> | 20 | </jdbcConnection> |
21 | <!--<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"--> | 21 | <!--<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"--> |
22 | <!--connectionURL="jdbc:oracle:thin:@10.50.3.68:1521:CGODW"--> | 22 | <!--connectionURL="jdbc:oracle:thin:@10.50.3.68:1521:CGODW"--> |
@@ -45,6 +45,6 @@ | @@ -45,6 +45,6 @@ | ||
45 | <property name="enableSubPackages" value="true"/> | 45 | <property name="enableSubPackages" value="true"/> |
46 | </javaClientGenerator> | 46 | </javaClientGenerator> |
47 | <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> | 47 | <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> |
48 | - <table tableName="attachment" domainObjectName="Attachment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> | 48 | + <table tableName="company" domainObjectName="company" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> |
49 | </context> | 49 | </context> |
50 | </generatorConfiguration> | 50 | </generatorConfiguration> |
src/main/resources/mapping/CompanyMapper.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.tianbo.warehouse.dao.CompanyMapper" > | ||
4 | + <resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.Company" > | ||
5 | + <id column="company_id" property="companyId" jdbcType="VARCHAR" /> | ||
6 | + <result column="company_name" property="companyName" jdbcType="VARCHAR" /> | ||
7 | + <result column="group_id" property="groupId" jdbcType="VARCHAR" /> | ||
8 | + <result column="creat_time" property="creatTime" jdbcType="TIMESTAMP" /> | ||
9 | + <result column="company_status" property="companyStatus" jdbcType="VARCHAR" /> | ||
10 | + </resultMap> | ||
11 | + <sql id="Base_Column_List" > | ||
12 | + company_id, company_name, group_id, creat_time, company_status | ||
13 | + </sql> | ||
14 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > | ||
15 | + select | ||
16 | + <include refid="Base_Column_List" /> | ||
17 | + from company | ||
18 | + where company_id = #{companyId,jdbcType=VARCHAR} | ||
19 | + </select> | ||
20 | + | ||
21 | + <select id="findAll" resultMap="BaseResultMap" > | ||
22 | + select | ||
23 | + <include refid="Base_Column_List" /> | ||
24 | + from company ORDER BY company_id | ||
25 | + </select> | ||
26 | + | ||
27 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > | ||
28 | + delete from company | ||
29 | + where company_id = #{companyId,jdbcType=VARCHAR} | ||
30 | + </delete> | ||
31 | + <insert id="insert" parameterType="com.tianbo.warehouse.model.Company" > | ||
32 | + insert into company (company_id, company_name, group_id, | ||
33 | + creat_time, company_status) | ||
34 | + values (#{companyId,jdbcType=VARCHAR}, #{companyName,jdbcType=VARCHAR}, #{groupId,jdbcType=VARCHAR}, | ||
35 | + #{creatTime,jdbcType=TIMESTAMP}, #{companyStatus,jdbcType=VARCHAR}) | ||
36 | + </insert> | ||
37 | + <insert id="insertSelective" parameterType="com.tianbo.warehouse.model.Company" > | ||
38 | + insert into company | ||
39 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
40 | + <if test="companyId != null" > | ||
41 | + company_id, | ||
42 | + </if> | ||
43 | + <if test="companyName != null" > | ||
44 | + company_name, | ||
45 | + </if> | ||
46 | + <if test="groupId != null" > | ||
47 | + group_id, | ||
48 | + </if> | ||
49 | + <if test="creatTime != null" > | ||
50 | + creat_time, | ||
51 | + </if> | ||
52 | + <if test="companyStatus != null" > | ||
53 | + company_status, | ||
54 | + </if> | ||
55 | + </trim> | ||
56 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
57 | + <if test="companyId != null" > | ||
58 | + #{companyId,jdbcType=VARCHAR}, | ||
59 | + </if> | ||
60 | + <if test="companyName != null" > | ||
61 | + #{companyName,jdbcType=VARCHAR}, | ||
62 | + </if> | ||
63 | + <if test="groupId != null" > | ||
64 | + #{groupId,jdbcType=VARCHAR}, | ||
65 | + </if> | ||
66 | + <if test="creatTime != null" > | ||
67 | + #{creatTime,jdbcType=TIMESTAMP}, | ||
68 | + </if> | ||
69 | + <if test="companyStatus != null" > | ||
70 | + #{companyStatus,jdbcType=VARCHAR}, | ||
71 | + </if> | ||
72 | + </trim> | ||
73 | + </insert> | ||
74 | + <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.Company" > | ||
75 | + update company | ||
76 | + <set > | ||
77 | + <if test="companyName != null" > | ||
78 | + company_name = #{companyName,jdbcType=VARCHAR}, | ||
79 | + </if> | ||
80 | + <if test="groupId != null" > | ||
81 | + group_id = #{groupId,jdbcType=VARCHAR}, | ||
82 | + </if> | ||
83 | + <if test="creatTime != null" > | ||
84 | + creat_time = #{creatTime,jdbcType=TIMESTAMP}, | ||
85 | + </if> | ||
86 | + <if test="companyStatus != null" > | ||
87 | + company_status = #{companyStatus,jdbcType=VARCHAR}, | ||
88 | + </if> | ||
89 | + </set> | ||
90 | + where company_id = #{companyId,jdbcType=VARCHAR} | ||
91 | + </update> | ||
92 | + <update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.Company" > | ||
93 | + update company | ||
94 | + set company_name = #{companyName,jdbcType=VARCHAR}, | ||
95 | + group_id = #{groupId,jdbcType=VARCHAR}, | ||
96 | + creat_time = #{creatTime,jdbcType=TIMESTAMP}, | ||
97 | + company_status = #{companyStatus,jdbcType=VARCHAR} | ||
98 | + where company_id = #{companyId,jdbcType=VARCHAR} | ||
99 | + </update> | ||
100 | + | ||
101 | +</mapper> |
@@ -35,8 +35,8 @@ | @@ -35,8 +35,8 @@ | ||
35 | FROM role R | 35 | FROM role R |
36 | LEFT JOIN role_permission RP ON R.role_id = RP.role_id | 36 | LEFT JOIN role_permission RP ON R.role_id = RP.role_id |
37 | LEFT JOIN permission P ON RP.permission_id = P.permission_id | 37 | LEFT JOIN permission P ON RP.permission_id = P.permission_id |
38 | - WHERE r.role_id=#{roleId,jdbcType=INTEGER} | ||
39 | - ORDER BY P.ismenu,P.name,p.permission_order DESC | 38 | + WHERE R.role_id=#{roleId,jdbcType=INTEGER} |
39 | + ORDER BY P.ismenu,P.name,P.permission_order DESC | ||
40 | </select> | 40 | </select> |
41 | <select id="getAllMenus" resultMap="BaseResultMap" > | 41 | <select id="getAllMenus" resultMap="BaseResultMap" > |
42 | SELECT | 42 | SELECT |
@@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
52 | <select id="selectAllUser" resultMap="SecurityResult" parameterType="com.tianbo.warehouse.model.USERS" > | 52 | <select id="selectAllUser" resultMap="SecurityResult" parameterType="com.tianbo.warehouse.model.USERS" > |
53 | select | 53 | select |
54 | <include refid="user_List" /> | 54 | <include refid="user_List" /> |
55 | - from USERS | 55 | + from users |
56 | WHERE 1=1 | 56 | WHERE 1=1 |
57 | <if test="username != null" > | 57 | <if test="username != null" > |
58 | and username = #{username,jdbcType=VARCHAR} | 58 | and username = #{username,jdbcType=VARCHAR} |
-
请 注册 或 登录 后发表评论